summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorjim-p <jimp@pfsense.org>2017-02-17 13:25:50 -0500
committerjim-p <jimp@pfsense.org>2017-02-17 13:25:50 -0500
commit3057a2ba467c5a4bcda3a004f876a43758d6e129 (patch)
treed4e1e5cc91684ba1c63a8df44be338921a640d29 /src
parent4e2d287c890e1fb6d93759b14f08c1cd0f810e08 (diff)
downloadpfsense-3057a2ba467c5a4bcda3a004f876a43758d6e129.zip
pfsense-3057a2ba467c5a4bcda3a004f876a43758d6e129.tar.gz
Fix handling of 0 for Backup Count. Fixes #7273
Diffstat (limited to 'src')
-rw-r--r--src/etc/inc/config.lib.inc1
-rw-r--r--src/usr/local/www/diag_confbak.php26
2 files changed, 19 insertions, 8 deletions
diff --git a/src/etc/inc/config.lib.inc b/src/etc/inc/config.lib.inc
index a05d35c..21aeb11 100644
--- a/src/etc/inc/config.lib.inc
+++ b/src/etc/inc/config.lib.inc
@@ -750,6 +750,7 @@ function cleanup_backupcache($lock = false) {
}
if (is_int($revisions) and (count($tocache) > $revisions)) {
$toslice = array_slice(array_keys($tocache), 0, $revisions);
+ $newcache = array();
foreach ($toslice as $sliced) {
$newcache[$sliced] = $tocache[$sliced];
}
diff --git a/src/usr/local/www/diag_confbak.php b/src/usr/local/www/diag_confbak.php
index 5c3e3c9..faed2ef 100644
--- a/src/usr/local/www/diag_confbak.php
+++ b/src/usr/local/www/diag_confbak.php
@@ -30,15 +30,20 @@
require_once("guiconfig.inc");
if (isset($_POST['backupcount'])) {
- if (is_numericint($_POST['backupcount'])) {
- $config['system']['backupcount'] = $_POST['backupcount'];
- $changedescr = $config['system']['backupcount'];
- } else {
- unset($config['system']['backupcount']);
- $changedescr = gettext("(platform default)");
+ if (!empty($_POST['backupcount']) && (!is_numericint($_POST['backupcount']) || ($_POST['backupcount'] < 0))) {
+ $input_errors[] = gettext("Invalid Backup Count specified");
}
- write_config(sprintf(gettext("Changed backup revision count to %s"), $changedescr));
+ if (!$input_errors) {
+ if (is_numericint($_POST['backupcount'])) {
+ $config['system']['backupcount'] = $_POST['backupcount'];
+ $changedescr = $config['system']['backupcount'];
+ } elseif (empty($_POST['backupcount'])) {
+ unset($config['system']['backupcount']);
+ $changedescr = gettext("(platform default)");
+ }
+ write_config(sprintf(gettext("Changed backup revision count to %s"), $changedescr));
+ }
}
$confvers = unserialize(file_get_contents($g['cf_conf_path'] . '/backup/backup.cache'));
@@ -97,6 +102,10 @@ $pgtitle = array(gettext("Diagnostics"), htmlspecialchars(gettext("Backup & Rest
$pglinks = array("", "diag_backup.php", "@self");
include("head.inc");
+if ($input_errors) {
+ print_input_errors($input_errors);
+}
+
if ($savemsg) {
print_info_box($savemsg, 'success');
}
@@ -154,7 +163,8 @@ $section->addInput(new Form_Input(
'backupcount',
'Backup Count',
'number',
- $config['system']['backupcount']
+ $config['system']['backupcount'],
+ ['min' => '0']
))->setHelp('Maximum number of old configurations to keep in the cache, 0 for no backups, or leave blank for the default value (%s for the current platform).', $g['default_config_backup_count']);
$space = exec("/usr/bin/du -sh /conf/backup | /usr/bin/awk '{print $1;}'");
OpenPOWER on IntegriCloud