Calling stop_packages from system_reboot_cleanup in system.inc



  • When I shutdown the following comes out on the console when stopping services and packages:

    pfSense is rebooting now.
     Stopping package blinkled...done.
     Stopping package pfBlocker...done.
     Stopping rc.backup_dhcpleases.sh...done.
     Stopping rc.backup_rrd.sh...done.
     Stopping rc.update_bogons.sh...done.
    Syntax error: Bad fd number
    

    I am ignoring "Bad fd number" for now - it seems an intractable problem with popen() and pclose().
    The code in pkg-utils.inc function stop_packages really intends to call rc*.sh files in the dir defined by the definition in service-utils.inc:
    $rcfileprefix = "/usr/local/etc/rc.d/";
    But it is actually calling ones it finds in "/etc" - which appears to be it's default dir at the time.
    $rcfileprefix is not getting defined globally in this context. system.inc only does a require_once inside the system_reboot_cleanup routine. That only makes a local scope definition of $rcfileprefix.
    The way that stop_packages is called from /etc/rc.stop_packages works. The require_once is in the very top, in a global context where the definition gets made globally by default.
    This global variable business is quite mixed up - pkg-utils.inc has 3 times:
    require_once("service-utils.inc");
    One way to fix this is to add to the top of service-utils.inc:
    global $rcfileprefix;
    Then the definition straight after will always be global. Everything that uses it would have to also declare it global.
    But I suspect that it would be better to sort out the whole relationship between use of require_once in different places and use of global variables.




Locked