From 0bdc6f0c71f80e479c8771e94945e5c579a8963d Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sat, 17 Dec 2016 14:05:28 +0100 Subject: [PATCH 1/8] Disable Auto Config Backup without uninstalling (Feature #6951) --- .../files/usr/local/pkg/autoconfigbackup.inc | 35 +++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/sysutils/pfSense-pkg-AutoConfigBackup/files/usr/local/pkg/autoconfigbackup.inc b/sysutils/pfSense-pkg-AutoConfigBackup/files/usr/local/pkg/autoconfigbackup.inc index 983ebf0cc6bf..9bd9598d2e82 100644 --- a/sysutils/pfSense-pkg-AutoConfigBackup/files/usr/local/pkg/autoconfigbackup.inc +++ b/sysutils/pfSense-pkg-AutoConfigBackup/files/usr/local/pkg/autoconfigbackup.inc @@ -26,10 +26,31 @@ require_once("notices.inc"); unlink_if_exists("/usr/local/pkg/parse_config/parse_config_upload.inc"); unlink_if_exists("/usr/local/pkg/parse_config/parse_config_upload.php"); +/* Check whether ACB is enabled */ +function acb_enabled() { + global $config; + $acb_enabled = false; + + if (is_array($config['installedpackages']['autoconfigbackup']['config'])) { + if ($config['installedpackages']['autoconfigbackup']['config'][0]['enable_acb'] == "on") { + $acb_enabled = true; + } + } + return $acb_enabled; +} + // Ensures patches match function acb_custom_php_validation_command($post, &$input_errors) { global $_POST, $savemsg, $config; + // Do nothing when ACB is disabled in configuration + // This also makes it possible to delete the credentials from config.xml + if (!acb_enabled()) { + // We do not need to store this value. + unset($_POST['testconnection']); + return; + } + if (!$post['username']) { $input_errors[] = "Username is required."; } @@ -62,6 +83,11 @@ function acb_custom_php_validation_command($post, &$input_errors) { } function acb_custom_php_resync_config_command() { + // Do nothing when ACB is disabled in configuration + if (!acb_enabled()) { + return; + } + if (is_file("/cf/conf/lastpfSbackup.txt")) { conf_mount_rw(); unlink("/cf/conf/lastpfSbackup.txt"); @@ -96,13 +122,15 @@ function configure_proxy() { function test_connection($post) { global $savemsg, $config, $g; - // Do nothing when booting + // Do nothing when booting or when not enabled if (function_exists("platform_booting")) { if (platform_booting()) { return; } } elseif ($g['booting']) { return; + } elseif (!acb_enabled()) { + return; } // Seperator used during client / server communications @@ -150,13 +178,15 @@ function test_connection($post) { function upload_config($reasonm = "") { global $config, $g, $input_errors; - // Do nothing when booting + // Do nothing when booting or when not enabled if (function_exists("platform_booting")) { if (platform_booting()) { return; } } elseif ($g['booting']) { return; + } elseif (!acb_enabled()) { + return; } /* @@ -284,4 +314,3 @@ function upload_config($reasonm = "") { } } } - From 2dccd9a3e0d2808013234407e71200848f29f854 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sat, 17 Dec 2016 14:13:35 +0100 Subject: [PATCH 2/8] Disable Auto Config Backup without uninstalling (Feature #6951) --- .../files/usr/local/pkg/autoconfigbackup.xml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sysutils/pfSense-pkg-AutoConfigBackup/files/usr/local/pkg/autoconfigbackup.xml b/sysutils/pfSense-pkg-AutoConfigBackup/files/usr/local/pkg/autoconfigbackup.xml index 0c0723844232..55489e0bb790 100644 --- a/sysutils/pfSense-pkg-AutoConfigBackup/files/usr/local/pkg/autoconfigbackup.xml +++ b/sysutils/pfSense-pkg-AutoConfigBackup/files/usr/local/pkg/autoconfigbackup.xml @@ -8,7 +8,7 @@ * autoconfigbackup.xml * * part of pfSense (https://www.pfsense.org) - * Copyright (c) 2008-2015 Rubicon Communications, LLC (Netgate) + * Copyright (c) 2008-2016 Rubicon Communications, LLC (Netgate) * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -57,6 +57,12 @@ + + Enable AutoConfigBackup + enable_acb + Check this to enable configuration backups to portal.pfsense.org + checkbox + Subscription Username username From 5da52be16983abeaa098b40fd4e4854f06e7e30d Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sat, 17 Dec 2016 14:14:01 +0100 Subject: [PATCH 3/8] Bump port version --- sysutils/pfSense-pkg-AutoConfigBackup/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysutils/pfSense-pkg-AutoConfigBackup/Makefile b/sysutils/pfSense-pkg-AutoConfigBackup/Makefile index 84f5aea6cc86..e40b89e947f7 100644 --- a/sysutils/pfSense-pkg-AutoConfigBackup/Makefile +++ b/sysutils/pfSense-pkg-AutoConfigBackup/Makefile @@ -1,7 +1,7 @@ # $FreeBSD$ PORTNAME= pfSense-pkg-AutoConfigBackup -PORTVERSION= 1.45 +PORTVERSION= 1.46 CATEGORIES= sysutils MASTER_SITES= # empty DISTFILES= # empty From 82f98fb3bf577c225213307704222b17ea7f7815 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sat, 17 Dec 2016 15:30:33 +0100 Subject: [PATCH 4/8] Remove potentially misleading "success" message (Bug #6950) Remove useless stuff. There is nothing to check here for success, except possibly write_config() result, but that's not the point of this feature at all. --- .../files/usr/local/www/autoconfigbackup_backup.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/sysutils/pfSense-pkg-AutoConfigBackup/files/usr/local/www/autoconfigbackup_backup.php b/sysutils/pfSense-pkg-AutoConfigBackup/files/usr/local/www/autoconfigbackup_backup.php index 8c9dc9366a0a..5bddc8388049 100644 --- a/sysutils/pfSense-pkg-AutoConfigBackup/files/usr/local/www/autoconfigbackup_backup.php +++ b/sysutils/pfSense-pkg-AutoConfigBackup/files/usr/local/www/autoconfigbackup_backup.php @@ -47,7 +47,6 @@ */ //upload_config($_REQUEST['reason']); - $savemsg = "Backup completed successfully."; $donotshowheader = true; } @@ -57,9 +56,6 @@ if ($input_errors) { print_input_errors($input_errors); } -if ($savemsg) { - print_info_box($savemsg, 'success'); -} $tab_array = array(); $tab_array[] = array("Settings", false, "/pkg_edit.php?xml=autoconfigbackup.xml&id=0"); From c6bb85219e82573874c68568487dc1a0e9f4a0ac Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sat, 17 Dec 2016 16:00:07 +0100 Subject: [PATCH 5/8] Re-add the savemsg infobox with some checking at least We need some feedback for the users that the thing did something - it takes considerable time to finish and not providing any result is just badly confusing. Instead of always claiming success, at least check whether write_config() worked. --- .../files/usr/local/www/autoconfigbackup_backup.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sysutils/pfSense-pkg-AutoConfigBackup/files/usr/local/www/autoconfigbackup_backup.php b/sysutils/pfSense-pkg-AutoConfigBackup/files/usr/local/www/autoconfigbackup_backup.php index 5bddc8388049..5437b990b0f3 100644 --- a/sysutils/pfSense-pkg-AutoConfigBackup/files/usr/local/www/autoconfigbackup_backup.php +++ b/sysutils/pfSense-pkg-AutoConfigBackup/files/usr/local/www/autoconfigbackup_backup.php @@ -32,9 +32,13 @@ touch("/tmp/acb_nooverwrite"); } if ($_REQUEST['reason']) { - write_config($_REQUEST['reason']); + if (write_config($_REQUEST['reason'])) { + $savemsg = "Backup completed successfully."; + } + } elseif (write_config("Backup invoked via Auto Config Backup.")) { + $savemsg = "Backup completed successfully."; } else { - write_config("Backup invoked via Auto Config Backup."); + $savemsg = "Backup not completed - write_config() failed."; } $config = parse_config(true); conf_mount_rw(); @@ -56,6 +60,9 @@ if ($input_errors) { print_input_errors($input_errors); } +if ($savemsg) { + print_info_box($savemsg, 'success'); +} $tab_array = array(); $tab_array[] = array("Settings", false, "/pkg_edit.php?xml=autoconfigbackup.xml&id=0"); From 2c0f450506c12fd395869eec8d9747c664b9a13c Mon Sep 17 00:00:00 2001 From: doktornotor Date: Mon, 19 Dec 2016 17:07:44 +0100 Subject: [PATCH 6/8] Remove unneeded pre-2.2 compatibility checks and simplify --- .../files/usr/local/pkg/autoconfigbackup.inc | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/sysutils/pfSense-pkg-AutoConfigBackup/files/usr/local/pkg/autoconfigbackup.inc b/sysutils/pfSense-pkg-AutoConfigBackup/files/usr/local/pkg/autoconfigbackup.inc index 9bd9598d2e82..febcc4758d77 100644 --- a/sysutils/pfSense-pkg-AutoConfigBackup/files/usr/local/pkg/autoconfigbackup.inc +++ b/sysutils/pfSense-pkg-AutoConfigBackup/files/usr/local/pkg/autoconfigbackup.inc @@ -3,7 +3,7 @@ * autoconfigbackup.inc * * part of pfSense (https://www.pfsense.org) - * Copyright (c) 2008-2015 Rubicon Communications, LLC (Netgate) + * Copyright (c) 2008-2016 Rubicon Communications, LLC (Netgate) * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -123,13 +123,7 @@ function test_connection($post) { global $savemsg, $config, $g; // Do nothing when booting or when not enabled - if (function_exists("platform_booting")) { - if (platform_booting()) { - return; - } - } elseif ($g['booting']) { - return; - } elseif (!acb_enabled()) { + if (platform_booting() || !acb_enabled()) { return; } @@ -179,13 +173,7 @@ function upload_config($reasonm = "") { global $config, $g, $input_errors; // Do nothing when booting or when not enabled - if (function_exists("platform_booting")) { - if (platform_booting()) { - return; - } - } elseif ($g['booting']) { - return; - } elseif (!acb_enabled()) { + if (platform_booting() || !acb_enabled()) { return; } From fe5c2fb55030b8ef6dae40d8c6624410d654c391 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Mon, 19 Dec 2016 18:45:48 +0100 Subject: [PATCH 7/8] Change to select instead to have explicit values for enabled/disabled --- .../files/usr/local/pkg/autoconfigbackup.xml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sysutils/pfSense-pkg-AutoConfigBackup/files/usr/local/pkg/autoconfigbackup.xml b/sysutils/pfSense-pkg-AutoConfigBackup/files/usr/local/pkg/autoconfigbackup.xml index 55489e0bb790..b4bf79096d32 100644 --- a/sysutils/pfSense-pkg-AutoConfigBackup/files/usr/local/pkg/autoconfigbackup.xml +++ b/sysutils/pfSense-pkg-AutoConfigBackup/files/usr/local/pkg/autoconfigbackup.xml @@ -60,8 +60,13 @@ Enable AutoConfigBackup enable_acb - Check this to enable configuration backups to portal.pfsense.org - checkbox + Enable/disable configuration backups to portal.pfsense.org + select + enabled + + + + Subscription Username From fb00e44f71b998bf169b95d70950a6ba4f73c0ad Mon Sep 17 00:00:00 2001 From: doktornotor Date: Mon, 19 Dec 2016 18:49:13 +0100 Subject: [PATCH 8/8] Consider the package to be enabled If not explicitly disabled --- .../files/usr/local/pkg/autoconfigbackup.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysutils/pfSense-pkg-AutoConfigBackup/files/usr/local/pkg/autoconfigbackup.inc b/sysutils/pfSense-pkg-AutoConfigBackup/files/usr/local/pkg/autoconfigbackup.inc index febcc4758d77..8c489386b203 100644 --- a/sysutils/pfSense-pkg-AutoConfigBackup/files/usr/local/pkg/autoconfigbackup.inc +++ b/sysutils/pfSense-pkg-AutoConfigBackup/files/usr/local/pkg/autoconfigbackup.inc @@ -32,7 +32,7 @@ function acb_enabled() { $acb_enabled = false; if (is_array($config['installedpackages']['autoconfigbackup']['config'])) { - if ($config['installedpackages']['autoconfigbackup']['config'][0]['enable_acb'] == "on") { + if ($config['installedpackages']['autoconfigbackup']['config'][0]['enable_acb'] != "disabled") { $acb_enabled = true; } }