opennetadmin / ona

OpenNetAdmin IP Address Management (IPAM) system
opennetadmin.com
GNU General Public License v2.0
141 stars 35 forks source link

Can't create CNAME record #178

Closed heppel closed 12 months ago

heppel commented 1 year ago

Hi,

when trying to create a CNAME record, I get a misleading error message about not having filled in all required fields. Actually there is a PHP-Error on the server, as recorded by Apache2:

PHP Fatal error: Uncaught ValueError: strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) in /opt/ona/www/include/functions_general.inc.php:1074\nStack trace:\n#0 /opt/ona/www/include/functions_general.inc.php(1074): strpos()\n#1 /opt/ona/www/include/functions_gui.inc.php(506): ip_complete()\n#2 /opt/ona/www/include/functions_gui.inc.php(622): get_ip_suggestions()\n#3 /opt/ona/www/include/xajax_suggest/suggest.inc.php(32): suggest_qsearch()\n#4 /opt/ona/www/include/xajax/xajax_core/plugin_layer/support/xajaxUserFunction.inc.php(237): suggest()\n#5 /opt/ona/www/include/xajax/xajax_core/plugin_layer/xajaxFunctionPlugin.inc.php(228): xajaxUserFunction->call()\n#6 /opt/ona/www/include/xajax/xajax_core/xajaxPluginManager.inc.php(277): xajaxFunctionPlugin->processRequest()\n#7 /opt/ona/www/include/xajax/xajax_core/xajax.inc.php(603): xajaxPluginManager->processRequest()\n#8 /opt/ona/www/include/xajax_setup.inc.php(49): xajax->processRequest()\n#9 /opt/ona/www/index.php(50): require_once('...')\n#10 {main}\n thrown in /opt/ona/www/include/functions_general.inc.php on line 1074, referer: http://ona.intern.mydomain.example/ona/?work_space=display_host&host=30

Server is running on Debian 12, PHP 8.2.7, OpenNetAdmin - v19.0.1 plus cherry-picked fix for #176

Is this a PHP8 vs. PHP7 issue?

mattpascoe commented 1 year ago

Looks like I need to set up a newer version of php on my dev environment. I am using php v8.1.x and it seems there is no issue on that version.

This particular part of the code is not exactly written well so I'm not surprised it is starting to have issue with newer php versions. I'll see if I can get a newer version of php set up and get this code cleaned up. Thanks for letting me know!

heppel commented 1 year ago

Hi Matt,

this issue affects not just CNAMEs, but also (at least) MX and TXT records.

Is there a time frame for a fix? My workaround with footer files is tiresome. I appreciate your efforts but I start to think about switching to a different IPAM system. Downgrading my PHP version is not an option.

mattpascoe commented 12 months ago

@heppel Sorry for my delay in getting back to you on this. Well I have done what I can to try and recreate this and have not yet had the issue.

I have installed php 8.2.10 on ubuntu as well as php 8.2.7 on debian12 (via default docker container images). I am able to add CNAMES, MX and TXT records with no issues.

I'm not sure which method you use to install/upgrade ONA but I would maybe refresh your installation to see if something is possibly missing? I usually install my systems via a direct git clone which allows for easy updates as well as to see a comparison of local files with the core repo.

For reference.. my line 1074 of the functions_general.inc.php file looks like this:

    if ((strlen($ip) >= 3) and (@strpos($ip, ':',3) !== false)) {
heppel commented 12 months ago

Well, I'm using the official version from the "master" branch. The line you are citing is from the "develop" branch. It's different in the "master" branch.

Are you saying, that I should switch to the "develop" branch?

mattpascoe commented 12 months ago

Well this is just downright embarrassing. I clearly lost track timeframes. I looked at my develop branch and thought that my changes were already released in 19.0.1. CLEARLY they were not.

I have released a proper update (19.0.2) that should include the fixes to address your issue. Sorry for the extreme waste of time and frustration.

heppel commented 12 months ago

Thank you.It's working now since upgrading to 19.0.2.