summaryrefslogtreecommitdiffstats
path: root/src/etc/inc/services.inc
diff options
context:
space:
mode:
authorjim-p <jimp@pfsense.org>2017-01-20 13:58:22 -0500
committerjim-p <jimp@pfsense.org>2017-01-20 14:13:24 -0500
commitb2bb49709d6d1cb845f2c7caf40bebe375ecb2d7 (patch)
tree461858060af6e75b86c1b0e3a933960ae579c508 /src/etc/inc/services.inc
parentdf1dcfa5478ecce39a952af8a01534285431bb3f (diff)
downloadpfsense-b2bb49709d6d1cb845f2c7caf40bebe375ecb2d7.zip
pfsense-b2bb49709d6d1cb845f2c7caf40bebe375ecb2d7.tar.gz
Add a parameter to install_cron_job to stop it from performing its own write_config. Adjust base system calls to match. Ticket #7146
Packages may still need the old behavior but need tested individually. Once all function calls are confirmed to work without the write, the write_config parameter and call can be removed from this function for good.
Diffstat (limited to 'src/etc/inc/services.inc')
-rw-r--r--src/etc/inc/services.inc17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/etc/inc/services.inc b/src/etc/inc/services.inc
index 8831e07..036b594 100644
--- a/src/etc/inc/services.inc
+++ b/src/etc/inc/services.inc
@@ -2817,11 +2817,12 @@ function upnp_start() {
}
}
-function install_cron_job($command, $active = false, $minute = "0", $hour = "*", $monthday = "*", $month = "*", $weekday = "*", $who = "root") {
+function install_cron_job($command, $active = false, $minute = "0", $hour = "*", $monthday = "*", $month = "*", $weekday = "*", $who = "root", $write_config = true) {
global $config, $g;
$is_installed = false;
$cron_changed = true;
+ $change_message = "";
if (!is_array($config['cron'])) {
$config['cron'] = array();
@@ -2850,24 +2851,30 @@ function install_cron_job($command, $active = false, $minute = "0", $hour = "*",
$cron_item['command'] = $command;
if (!$is_installed) {
$config['cron']['item'][] = $cron_item;
- write_config(sprintf(gettext("Installed cron job for %s"), $command));
+ $change_message = "Installed cron job for %s";
} else {
if ($config['cron']['item'][$x] == $cron_item) {
$cron_changed = false;
- log_error(sprintf(gettext("Checked cron job for %s, no change needed"), $command));
} else {
$config['cron']['item'][$x] = $cron_item;
- write_config(sprintf(gettext("Updated cron job for %s"), $command));
+ $change_message = "Updated cron job for %s";
}
}
} else {
if ($is_installed == true) {
unset($config['cron']['item'][$x]);
- write_config(sprintf(gettext("Removed cron job for %s"), $command));
+ $change_message = "Removed cron job for %s";
}
}
if ($cron_changed) {
+ /* Optionally write the configuration if this function made changes.
+ * Performing a write_config() in this way can have unintended side effects. See #7146
+ * Base system instances of this function do not need to write, packages may.
+ */
+ if ($write_config) {
+ write_config(sprintf(gettext($change_message), $command));
+ }
configure_cron();
}
}
OpenPOWER on IntegriCloud