diff --git a/etc/inc/config.inc b/etc/inc/config.inc index a6e871abc3..c8853fa064 100644 --- a/etc/inc/config.inc +++ b/etc/inc/config.inc @@ -478,7 +478,7 @@ function conf_mount_ro() { return; /* firmare upgrade in progress */ - if(file_exists($g['varrun_path'] . "/firmware.lock")) + if (is_subsystem_dirty('firmwarelock')) return; /* do not umount if generating ssh keys */ @@ -1298,4 +1298,4 @@ function set_device_perms() { if($g['booting']) echo "."; $config = parse_config(); -?> \ No newline at end of file +?> diff --git a/etc/inc/util.inc b/etc/inc/util.inc index 2f757287be..21af5f5850 100644 --- a/etc/inc/util.inc +++ b/etc/inc/util.inc @@ -77,6 +77,31 @@ function killbyname($procname) { mwexec("/usr/bin/killall " . escapeshellarg($procname)); } +function is_subsystem_dirty($subsystem = "") { + global $g; + + if ($subsystem == "") + return false; + + if (file_exists("{$g['varrun_path']}/{$subsystem}.dirty")) + return true; + + return false; +} + +function mark_subsystem_dirty($subsystem = "") { + global $g; + + if (!file_put_contents("{$g['varrun_path']}/{$subsystem}.dirty", "DIRTY")) + log_error("WARNING: Could not mark subsystem: {$subsytem} dirty"); +} + +function clear_subsystem_dirty($subsystem = "") { + global $g; + + @unlink("{$g['varrun_path']}/{$subsystem}.dirty"); +} + function config_lock() { log_error("config_lock() is depricated please use lock()."); return; @@ -992,4 +1017,4 @@ function isAjax() { } -?> \ No newline at end of file +?> diff --git a/etc/rc.firmware b/etc/rc.firmware index 7d313839f6..f9e817d898 100755 --- a/etc/rc.firmware +++ b/etc/rc.firmware @@ -117,7 +117,7 @@ enable) echo "" > /cf/upgrade_log.txt ;; auto) - touch /var/run/firmware.lock + touch /var/run/firmwarelock.dirty backup_chflags remove_chflags /etc/rc.firmware_auto @@ -140,7 +140,7 @@ pfSenseNanoBSDupgrade) exit 1 fi - touch /var/run/firmware.lock + touch /var/run/firmwarelock.dirty echo "NanoBSD Firmware upgrade in progress..." >> /cf/upgrade_log.txt 2>&1 echo "NanoBSD Firmware upgrade in progress..." | wall @@ -216,7 +216,7 @@ pfSenseNanoBSDupgrade) /sbin/fsck_ffs -y /dev/$COMPLETE_PATH >> /cf/upgrade_log.txt 2>&1 if [ $? != 0 ]; then file_notice "UpgradeFailure" "{\$g['product_name']} upgrade has failed. Your system has been left in a usable state." - rm /var/run/firmware.lock + rm /var/run/firmwarelock.dirty /etc/rc.conf_mount_ro exit 1 fi @@ -248,7 +248,7 @@ pfSenseNanoBSDupgrade) if [ $? != 0 ]; then echo "Something went wrong when trying to update the fstab entry. Aborting upgrade." file_notice "UpgradeFailure" "Something went wrong when trying to update the fstab entry. Aborting upgrade." - rm /var/run/firmware.lock + rm /var/run/firmwarelock.dirty umount /tmp/$GLABEL_SLICE /etc/rc.conf_mount_ro exit 1 @@ -290,7 +290,7 @@ pfSenseNanoBSDupgrade) echo "/sbin/sysctl kern.geom.debugflags=0" >> /cf/upgrade_log.txt /sbin/sysctl kern.geom.debugflags=0 >> /cf/upgrade_log.txt 2>&1 - rm -f /var/run/firmware.lock + rm -f /var/run/firmwarelock.dirty sh /etc/rc.reboot ;; @@ -311,7 +311,7 @@ pfSenseupgrade) echo "NanoBSD upgrade starting" >> /cf/upgrade_log.txt echo "" >> /cf/upgrade_log.txt - touch /var/run/firmware.lock + touch /var/run/firmwarelock.dirty touch /cf/upgrade_log.txt echo "" >> /cf/upgrade_log.txt @@ -388,7 +388,7 @@ pfSenseupgrade) /etc/rc.conf_mount_ro # release the firmware lock - rm -f /var/run/firmware.lock + rm -f /var/run/firmwarelock.dirty /bin/sync # If the archive has unpacked a file called @@ -403,7 +403,7 @@ pfSenseupgrade) ;; delta_update) - touch /var/run/firmware.lock + touch /var/run/firmwarelock.dirty backup_chflags remove_chflags binary_update $IMG diff --git a/etc/rc.initial.firmware_update b/etc/rc.initial.firmware_update index ec8aad59b6..cdbaa9b6cc 100755 --- a/etc/rc.initial.firmware_update +++ b/etc/rc.initial.firmware_update @@ -2,18 +2,15 @@ \ No newline at end of file +?> diff --git a/usr/local/www/firewall_aliases.php b/usr/local/www/firewall_aliases.php index c0701f63b5..76c473eb81 100755 --- a/usr/local/www/firewall_aliases.php +++ b/usr/local/www/firewall_aliases.php @@ -61,10 +61,8 @@ if ($_POST) { $savemsg = get_std_save_message($retval); else $savemsg = $retval; - if ($retval == 0) { - if (file_exists($d_aliasesdirty_path)) - unlink($d_aliasesdirty_path); - } + if ($retval == 0) + clear_subsystem_dirty('aliases'); } } @@ -141,7 +139,7 @@ if ($_GET['act'] == "del") { unset($a_aliases[$_GET['id']]); write_config(); filter_configure(); - touch($d_aliasesdirty_path); + mark_subsystem_dirty('aliases'); header("Location: firewall_aliases.php"); exit; } @@ -157,7 +155,7 @@ include("head.inc");