Yesterday I tried to make changes to one of my connections and pressed the “orange” button. No changes saved because the asterisk config files in /etc/asterisk were not updated. After many hours I’m stuck with the following observations:
When I run “retrieve_conf --debug” I get the following error messages:
[DEBUG-retrieve_conf] (devel-debug) Writing extensions_additional.conf
PHP Warning: fopen(/extensions_additional.conf): failed to open stream: Permission denied in /var/lib/asterisk/bin/retrieve_conf on line 502
[DEBUG-retrieve_conf] (devel-debug) generateConf from queues_conf->queues_additional.conf
[DEBUG-retrieve_conf] (devel-debug) Writing queues_additional.conf
PHP Warning: fopen(/queues_additional.conf): failed to open stream: Permission denied in /var/lib/asterisk/bin/retrieve_conf on line 502
[DEBUG-retrieve_conf] (devel-debug) generateConf from queues_conf->queues_general_additional.conf
[DEBUG-retrieve_conf] (devel-debug) Writing queues_general_additional.conf
PHP Warning: fopen(/queues_general_additional.conf): failed to open stream: Permission denied in /var/lib/asterisk/bin/retrieve_conf on line 502
The problem seems to be that $asterisk_conf[‘astetcdir’] on line 502 returns an empty string. This results in the asterisk user tries to write to the Linux root directory. Since the asterisk user doesn’t have access to / permission denied is thrown. (By doing a su from the asterisk user, the files are written to /)
My question to the group is why is this suddenly happening? Is it my upgrade to CentoOS 5.3? Is it the upgrade of FreePBX to 2.5.1.5? I’m running PIAF 1.4 with all the latest scripts and fixes.
Anyone have a suggestion to what I can do to fix this problem with the empty string returned from $asterisk_conf[‘astetcdir’]?
Before the update to CentOS 5.3 and FreePBX 2.5.1.5 my system was working without problems. However my most recent change to my setup was May 19 and so I cannot pinpoint exactly when this broke.
Good suggestion and I suspect that there is something like this that has been changed with the CentOS 5.3 upgrade. What is strange is that the following code in retrieve_conf is returning null:
$asterisk_conf_file = $amp_conf["ASTETCDIR"]."/asterisk.conf";
outn(sprintf(_("Parsing %s .."), $asterisk_conf_file));
$asterisk_conf = parse_asterisk_conf($asterisk_conf_file);
if (count($asterisk_conf) == 0) {
fatal(_("asterisk.conf parsing failure"),sprintf(_("no entries found in %s"), $asterisk_conf_file));
}
out(_("OK"));
out(sprintf(_("The asterisk etc dir %s .."), $asterisk_conf['astetcdir']));
You can see that I’ve added an extra debugging statement. It return an empty string after the parse. This is why all subsequent functions depending upon this value is failing. The output from the run of retrieve_conf is:
[asterisk@frigg bin]$ retrieve_conf --debug
Checking for PEAR DB..OK
Checking for PEAR Console::Getopt..OK
[DEBUG-preDB] Debug mode enabled
Checking for /etc/amportal.conf ..OK
Bootstrapping /etc/amportal.conf ..OK
Parsing /etc/amportal.conf ..OK
Parsing /etc/asterisk/asterisk.conf ..OK
The asterisk etc dir ..
Connecting to database..OK
Connecting to Asterisk manager interface..OK
If the above is not what you see, then I suggest that you recreate your amportal.conf. Verify that amportal.conf is set to asterisk both as owner and group.
// Now that we parsed asterisk.conf, we need to make sure $amp_conf is consistent
// so just set it to what we found, since this is what asterisk will use anyhow.
//
foreach ($convert as $ast_conf_key => $amp_conf_key) {
if (isset($conf[$ast_conf_key])) {
$amp_conf[$amp_conf_key] = $conf[$ast_conf_key];
}
}
I don’t think you found a bug. This is the first time ever I have heard of this error and I think that there is something wrong with your setup.
Check your php version and your php.ini file.
What I do know is that on May 19 the system worked as intended. After that time the regular updates have been run i.e. yum, PIAF fixes and download of new FreePBX modules. Other than that, no changes.
After I made the change to the code and fixed the return statement, the parse_asterisk_conf function returns the parsed asterisk.conf file where all the identifiers are in lower case and my system works again. Without it returns the amportal.conf file.
When I look at the logic in the function, this makes sense as well. One explanation could be that previously the string match function used in retrieve_conf didn’t differentiate between uppercase and lower case. That would explain it.
My system is now working and I’ll be happy to share with you more details that can help explain what’s going on here.
the parse_asterisk_conf in functions.inc.php returns $conf, not $amp_conf. Have a look at SVN and do a log of that file, that should not have been touched for ‘ever.’ (Do an ‘svn blame’ and you can see when that line may have been last changed.
Either you or something outside of FreePBX changed that, or for some reason Tom changed it in one of his PIAF update scripts. I can’t imagine Tom would do that for any reason, but since his scripts are compiled and can’t be viewed, there is no way to know other than asking him (probably over in the PIAF forum).
Thank you for the information. Before this problem FreePBX was a “black box” to me, so no, I would not know how to change the return statement in question. It was your guys excellent support that allowed me to dive into the problem and determine what was wrong.
I’m waiting for an account on the PIAF forum and I will post this thread there to get some more clarity. I checked the FreePBX source code and it correctly returns $conf, so the change must have been induced somewhere else.
I hope your account gets activated quickly so you can pursue this with them. They have been known to be slow at times to get an account activated but bare with them, it will happen.
I too am getting the the parse_asterisk_conf() call error, except in my case it originates out of using the CALLBACK function.
[aroot@freePBX1 etc]# /var/lib/asterisk/bin/callback
Checking for PEAR Console::Getopt..OK
Reading /etc/amportal.conf..OK
PHP Fatal error: Call to undefined function parse_asterisk_conf() in /var/www/html/admin/common/php-asmanager.php on line 33
[aroot@freePBX1 etc]#
I too was working for quite a while and more recently noticed the failure. I noticed it because I was testing everything after taking the bump up to 2.6.0.beta2.0. I too did accept the yum updates from a week or so a go.
There definitely is a problem lurking in this region of the scripts base.
can you please start a new thread on your issue wrt to callback and that error on the beta forum so that we can have a look and pursue it. If appropriate, please file a bug report also.