Apply Config fails with Unknown Error. Please Run: fwconsole reload --verbose

FreePBX 15.0.17.24 / Asterisk 16.15.1 / all modules up to date

As the subject line states, when I run Apply Config, the dialog says:
"Error! There was an error during reload: Unknown Error. Please Run: fwconsole reload --verbose

$ sudo fwconsole reload --verbose
Reload Started

In PJSip.class.php line 502:

[Exception]
Asterisk will crash if sip_server is blank!

Exception trace:
() at /var/www/html/admin/modules/core/functions.inc/drivers/PJSip.class.php:502
FreePBX\modules\Core\Drivers\PJSip->genConfig() at /var/www/html/admin/modules/core/Core.class.php:280
FreePBX\modules\Core->genConfig() at /var/www/html/admin/libraries/BMO/FileHooks.class.php:97
FreePBX\FileHooks->processNewHooks() at /var/www/html/admin/libraries/BMO/FileHooks.class.php:26
FreePBX\FileHooks->processFileHooks() at /var/www/html/admin/libraries/Console/Reload.class.php:335
FreePBX\Console\Command\Reload->reload() at /var/www/html/admin/libraries/Console/Reload.class.php:91
FreePBX\Console\Command\Reload->execute() at /var/www/html/admin/libraries/Composer/vendor/symfony/console/Command/Command.php:255
Symfony\Component\Console\Command\Command->run() at /var/www/html/admin/libraries/Composer/vendor/symfony/console/Application.php:960
Symfony\Component\Console\Application->doRunCommand() at /var/www/html/admin/libraries/Composer/vendor/symfony/console/Application.php:255
Symfony\Component\Console\Application->doRun() at /var/www/html/admin/libraries/Composer/vendor/symfony/console/Application.php:148
Symfony\Component\Console\Application->run() at /var/lib/asterisk/bin/fwconsole:163

reload [–json] [–dry-run] [–skip-registry-checks] [–dont-reload-asterisk]
$

I have tried running:

$ sudo yum update
$ sudo fwconsole ma upgradeall

and rebooting FreePBX, but the issue is the same.

Here is line 502 in /var/www/html/admin/modules/core/functions.inc/drivers/PJSip.class.php:502

501 if(empty($trunk[‘server_uri’]) && empty($trunk[‘sip_server’])) {
502 throw new \Exception(‘Asterisk will crash if sip_server is blank!’);
503 } else if(!empty($trunk[‘server_uri’])) {
504 $conf[‘pjsip.registration.conf’][$tn][‘server_uri’] = $trunk[‘server_uri’];
505 } else {
506 if (!empty($trunk[‘sip_server_port’])) {
507 $conf[‘pjsip.registration.conf’][$tn][‘server_uri’] = ‘sip:’.$trunk[‘sip_server’].‘:’.$trunk[‘sip_server_port’];
508 } else {
509 $conf[‘pjsip.registration.conf’][$tn][‘server_uri’] = ‘sip:’.$trunk[‘sip_server’];
510 }
511 }
512

I deleted two chan_pjsip trunks, ran Apply Config again, and this time it completed without an error.

When I log in to FreePBX, whether via the console or ssh, the following warnings are shown:

Last login: Tue Mar 23 15:19:43 2021
PHP Warning: include_once(/etc/freepbx.conf): failed to open stream: Permission denied in /var/lib/asterisk/bin/fwconsole on line 12
PHP Warning: include_once(): Failed opening ‘/etc/freepbx.conf’ for inclusion (include_path=‘.:/usr/share/pear:/usr/share/php’) in /var/lib/asterisk/bin/fwconsole on line 12
PHP Fatal error: Class ‘Symfony\Component\Console\Application’ not found in /var/www/html/admin/libraries/FWApplication.class.php on line 11
±-----------------------------------------------------------+
PHP Warning: include_once(/etc/freepbx.conf): failed to open stream: Permission denied in /var/lib/asterisk/bin/fwconsole on line 12
PHP Warning: include_once(): Failed opening ‘/etc/freepbx.conf’ for inclusion (include_path=‘.:/usr/share/pear:/usr/share/php’) in /var/lib/asterisk/bin/fwconsole on line 12
PHP Fatal error: Class ‘Symfony\Component\Console\Application’ not found in /var/www/html/admin/libraries/FWApplication.class.php on line 11
+

If I run fwconsole chown:

$ sudo fwconsole chown --verbose
Taking too long? Customize the chown command, See Sangoma Documentation
Setting Permissions

Setting base permissions
Done in 5 seconds
Setting specific permissions

Setting /home/asterisk to permissions of: 755

 [thousands of lines]
Setting /var/www/html/admin/modules/zulu/hooks user owner to: asterisk
Finished setting permissions
$

If I log out and then log back in, the same warnings appear.

How can these warnings be addressed?

ls -al /etc/freepbx.conf

$ ls -la /etc/freepbx.conf
-rw-rw----. 1 asterisk asterisk 337 Dec 25 19:02 /etc/freepbx.conf
$ sudo chmod 664 /etc/freepbx.conf
$ ls -la /etc/freepbx.conf
-rw-rw-r–. 1 asterisk asterisk 337 Dec 25 19:02 /etc/freepbx.conf
$ logout
Connection to 172.16.0.175 closed.

On the next login:

$ ssh -p XXXXXX [email protected]
Last login: Tue Mar 23 08:29:03 2021 from 172.16.0.XXX
UnexpectedValueException: The stream or file “/var/log/asterisk/freepbx.log” could not be opened: failed to open stream: Permission denied in file /var/www/html/admin/libraries/Composer/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 107
Stack trace:

  1. UnexpectedValueException->() /var/www/html/admin/libraries/Composer/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:107
  2. Monolog\Handler\StreamHandler->write() /var/www/html/admin/libraries/Composer/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php:39
  3. Monolog\Handler\AbstractProcessingHandler->handle() /var/www/html/admin/libraries/Composer/vendor/monolog/monolog/src/Monolog/Logger.php:344
  4. Monolog\Logger->addRecord() /var/www/html/admin/libraries/Composer/vendor/monolog/monolog/src/Monolog/Logger.php:637
  5. Monolog\Logger->info() /var/www/html/admin/libraries/BMO/Logger.class.php:155
  6. FreePBX\Logger->driverChannelLogWrite() /var/www/html/admin/libraries/BMO/Logger.class.php:106
  7. FreePBX\Logger->channelLogWrite() /var/www/html/admin/libraries/BMO/Logger.class.php:94
  8. FreePBX\Logger->logWrite() /var/www/html/admin/libraries/BMO/Logger.class.php:39
  9. FreePBX\Logger->log() /var/www/html/admin/libraries/utility.functions.php:77
  10. freepbx_log() /var/www/html/admin/libraries/modulefunctions.legacy.php:7
  11. _module_backtrace() /var/www/html/admin/libraries/modulefunctions.legacy.php:53
  12. module_getinfo() /var/www/html/admin/modules/cxpanel/functions.inc.php:71
  13. require_once() /var/www/html/admin/bootstrap.php:353
  14. require_once() /etc/freepbx.conf:11
  15. include_once() /var/lib/asterisk/bin/fwconsole:12
    ±-----------------------------------------------------------+
    ±-----------------------------------------------------------+

$ ls -l /var/log/asterisk/freepbx.log
-rw-rw-r-- 1 asterisk asterisk 58678077 Mar 23 13:13 /var/log/asterisk/freepbx.log
$ sudo chmod 666 /var/log/asterisk/freepbx.log
$ exit
$ ssh -p XXXX [email protected]
Last login: Tue Mar 23 13:12:21 2021 from 172.16.0.146


| | | ___ | ___ \ \ / /
| |
_ __ ___ ___ | |
/ /| |
/ / \ V /
| | | '__| / _ \ / _ | __/ | ___ \ /
| | | | | __/| __/| | | |
/ // /^\
_| || _| _|_| ___/ / /

NOTICE! You have 1 notifications! Please log into the UI to see them!
Current Network Configuration
±----------±------------------±-------------------------+
| Interface | MAC Address | IP Addresses |
±----------±------------------±-------------------------+
| eth0 | 08:00:27:97:2F:36 | 172.16.0.175 |
| | | fe80::a00:27ff:fe97:2f36 |
±----------±------------------±-------------------------+

Please note most tasks should be handled through the GUI.
You can access the GUI by typing one of the above IPs in to your web browser.
For support please visit:
Training & Support | FreePBX - Let Freedom Ring

±-----------------------------------------------------------+
±-----------------------------------------------------------+
$

Well, that looks better.
(If I remember correctly, I’ve done this once or twice before. Let’s see how long it will last.)

Run as root

@jfinstrom Thanks for your reply.

You say “run as root.” I’ve been a UNIX system admin for (too) many years, and as a matter of policy I’ve learned to try to avoid running things as root unless absolutely necessary. If you check the commands that were run above, everything was run as sudo.

Can you explain why you recommend running these commands as root instead of sudo, and why running on CentOS would be any different than on other UNIX or Linux systems?

Absolutely no changes were made to the OS, nor were any permissions changed by me (and I’m the only one authorized to use this computer). However I see when I logged in again today, the problem re-surfaced:

$ ssh -p XXXX [email protected]
Last login: Wed Mar 24 12:41:35 2021 from 172.16.0.146
PHP Warning: include_once(/etc/freepbx.conf): failed to open stream: Permission denied in /var/lib/asterisk/bin/fwconsole on line 12
PHP Warning: include_once(): Failed opening ‘/etc/freepbx.conf’ for inclusion (include_path=‘.:/usr/share/pear:/usr/share/php’) in /var/lib/asterisk/bin/fwconsole on line 12
PHP Fatal error: Class ‘Symfony\Component\Console\Application’ not found in /var/www/html/admin/libraries/FWApplication.class.php on line 11
±-----------------------------------------------------------+
PHP Warning: include_once(/etc/freepbx.conf): failed to open stream: Permission denied in /var/lib/asterisk/bin/fwconsole on line 12
PHP Warning: include_once(): Failed opening ‘/etc/freepbx.conf’ for inclusion (include_path=‘.:/usr/share/pear:/usr/share/php’) in /var/lib/asterisk/bin/fwconsole on line 12
PHP Fatal error: Class ‘Symfony\Component\Console\Application’ not found in /var/www/html/admin/libraries/FWApplication.class.php on line 11
±-----------------------------------------------------------+
$

Anyone have advice?

fwconsole has to be run as root. If you don’t it won’t work. Fearing root is a very debian thing to do. I’ve been in and out of systems for 20 years as root and almost nobody has died. Seriously though it is just how it works.

1 Like

I don’t know where the sudo dogma originates, but I’ve had to fix more systems from “sudo” admins than those logged in as root.

If you don’t trust yourself at the root prompt, you probably shouldn’t trust youself with sudo either.

Too many folks just start automatically prefixing commands and might as well be logged in as root.

1 Like

If you insist on using sudo, do sudo -i to get the same environment as root, the relevant sudoer has effectively logged in as a root login without knowing root’s password, without an argument, sudo -i starts a root login $SHELL (from root’s environment).

This works even on RH based systems :slight_smile:

@jerrm I don’t want to start a flame war here, but I can tell you where the “sudo dogma” originates, at least from my point of view. It’s in response to the “cowboy root” dogma, where someone less qualified than they think (sometimes “the boss”) demands the root password and proceeds to log in every single time as root. (Cue rolling eyes and groans from the rest of the technical staff.) I’ve seen this happen a few times, and is one reason all UNIX-like systems I’ve worked on, Solaris, HP-UX, Linux, FreeBSD, SCO UNIX, macOS, and dozens more, are designed to limit the use of root with the sudo command, or even better, prevent someone from logging in directly as the root user.

I have no problem if someone with proper skills wants to log in or "su - " as root. But log in, do your work, and don’t forget to log out.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.