diff --git a/src/etc/config.xml.sample b/src/etc/config.xml.sample
index 03da7a8b7..c34c2aa91 100644
--- a/src/etc/config.xml.sample
+++ b/src/etc/config.xml.sample
@@ -227,6 +227,7 @@
monthly
+ 60
diff --git a/src/etc/inc/config.lib.inc b/src/etc/inc/config.lib.inc
index c1fc765fb..d65fefe06 100644
--- a/src/etc/inc/config.lib.inc
+++ b/src/etc/inc/config.lib.inc
@@ -288,7 +288,8 @@ function cleanup_backups()
if (isset($config['system']['backupcount']) && is_numeric($config['system']['backupcount']) && ($config['system']['backupcount'] >= 0)) {
$revisions = intval($config['system']['backupcount']);
} else {
- $revisions = 30;
+ /* XXX this value used to be left out of the config */
+ $revisions = 60;
}
$cnf = OPNsense\Core\Config::getInstance();
diff --git a/src/etc/inc/upgrade_config.inc b/src/etc/inc/upgrade_config.inc
index c66d049d1..bac5f8ad9 100644
--- a/src/etc/inc/upgrade_config.inc
+++ b/src/etc/inc/upgrade_config.inc
@@ -3432,4 +3432,8 @@ function upgrade_111_to_112()
}
}
}
+
+ if (!isset($config['system']['backupcount'])) {
+ $config['system']['backupcount'] = 60;
+ }
}
diff --git a/src/www/diag_confbak.php b/src/www/diag_confbak.php
index 213fc4d57..635e9fbb2 100644
--- a/src/www/diag_confbak.php
+++ b/src/www/diag_confbak.php
@@ -33,6 +33,12 @@ require_once("guiconfig.inc");
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$cnf = OPNsense\Core\Config::getInstance();
$confvers = $cnf->getBackups(true);
+ if (isset($config['system']['backupcount'])) {
+ $pconfig['backupcount'] = $config['system']['backupcount'];
+ } else {
+ # XXX fallback value for older configs
+ $pconfig['backupcount'] = 60;
+ }
if (!empty($_GET['getcfg'])) {
foreach ($confvers as $filename => $revision) {
if ($revision['time'] == $_GET['getcfg']) {
@@ -79,16 +85,24 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
}
}
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
+ $input_errors = array();
+ $pconfig = $_POST;
+
+ if (!empty($pconfig['save'])) {
+ if (!isset($pconfig['backupcount']) || !is_numeric($pconfig['backupcount']) || $pconfig['backupcount'] < 0) {
+ $input_errors[] = gettext('Backup count must be greater or equal to zero.');
+ }
+ if (count($input_errors) == 0) {
+ $config['system']['backupcount'] = $pconfig['backupcount'];
+ write_config(gettext('Changed backup revision count.'));
+ $savemsg = get_std_save_message();
+ }
+ }
+
$cnf = OPNsense\Core\Config::getInstance();
$confvers = $cnf->getBackups(true);
- if (!empty($_POST['save'])) {
- if (is_numeric($_POST['backupcount']) && ($_POST['backupcount'] >= 0)) {
- $config['system']['backupcount'] = $_POST['backupcount'];
- } elseif (isset($config['system']['backupcount'])) {
- unset($config['system']['backupcount']);
- }
- write_config(gettext('Changed backup revision count.'));
- } elseif (!empty($_POST['act']) && $_POST['act'] == "revert") {
+
+ if (!empty($_POST['act']) && $_POST['act'] == "revert") {
foreach ($confvers as $filename => $revision) {
if (isset($revision['time']) && $revision['time'] == $_POST['time']) {
if (config_restore($filename) == 0) {
@@ -113,14 +127,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
}
}
}
-
}
-
include("head.inc");
?>
-