Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable Auto Config Backup feature (Feature #6951), add some tweaks for savemsg (Bug #6950) #234

Merged
merged 8 commits into from Dec 20, 2016
2 changes: 1 addition & 1 deletion 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
Expand Down
Expand Up @@ -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");
Expand All @@ -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.";
}
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -96,12 +122,8 @@ function configure_proxy() {
function test_connection($post) {
global $savemsg, $config, $g;

// Do nothing when booting
if (function_exists("platform_booting")) {
if (platform_booting()) {
return;
}
} elseif ($g['booting']) {
// Do nothing when booting or when not enabled
if (platform_booting() || !acb_enabled()) {
return;
}

Expand Down Expand Up @@ -150,12 +172,8 @@ function test_connection($post) {
function upload_config($reasonm = "") {
global $config, $g, $input_errors;

// Do nothing when booting
if (function_exists("platform_booting")) {
if (platform_booting()) {
return;
}
} elseif ($g['booting']) {
// Do nothing when booting or when not enabled
if (platform_booting() || !acb_enabled()) {
return;
}

Expand Down Expand Up @@ -284,4 +302,3 @@ function upload_config($reasonm = "") {
}
}
}

Expand Up @@ -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");
Expand Down Expand Up @@ -57,6 +57,12 @@
</tab>
</tabs>
<fields>
<field>
<fielddescr>Enable AutoConfigBackup</fielddescr>
<fieldname>enable_acb</fieldname>
<description>Check this to enable configuration backups to portal.pfsense.org</description>
<type>checkbox</type>
</field>
<field>
<fielddescr>Subscription Username</fielddescr>
<fieldname>username</fieldname>
Expand Down
Expand Up @@ -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();
Expand All @@ -47,7 +51,6 @@
*/
//upload_config($_REQUEST['reason']);

$savemsg = "Backup completed successfully.";
$donotshowheader = true;
}

Expand Down