Commit a156c466 authored by Ad Schellevis's avatar Ad Schellevis

reformat tag line of encrypted backup

parent a453bfe8
...@@ -447,7 +447,8 @@ function backup_to_google_drive() { ...@@ -447,7 +447,8 @@ function backup_to_google_drive() {
$client->login($config->system->remotebackup->GDriveEmail->__toString(), $config->system->remotebackup->GDriveP12key->__toString() ); $client->login($config->system->remotebackup->GDriveEmail->__toString(), $config->system->remotebackup->GDriveP12key->__toString() );
// backup source data to local strings (plain/encrypted) // backup source data to local strings (plain/encrypted)
$confdata = file_get_contents('/conf/config.xml') ; $confdata = file_get_contents('/conf/config.xml') ;
$confdata_enc = encrypt_data($confdata, $config->system->remotebackup->GDrivePassword->__toString()) ; $confdata_enc = encrypt_data($confdata, $config->system->remotebackup->GDrivePassword->__toString()) ;
tagfile_reformat($confdata_enc, $confdata_enc, "config.xml");
// read filelist (config-*.xml) and cleanup old files // read filelist (config-*.xml) and cleanup old files
......
...@@ -291,7 +291,6 @@ if ($_POST) { ...@@ -291,7 +291,6 @@ if ($_POST) {
if ($_POST['decrypt']) { if ($_POST['decrypt']) {
if (!tagfile_deformat($data, $data, "config.xml")) { if (!tagfile_deformat($data, $data, "config.xml")) {
$input_errors[] = gettext("The uploaded file does not appear to contain an encrypted OPNsense configuration."); $input_errors[] = gettext("The uploaded file does not appear to contain an encrypted OPNsense configuration.");
return 1;
} }
$data = decrypt_data($data, $_POST['decrypt_password']); $data = decrypt_data($data, $_POST['decrypt_password']);
} }
...@@ -321,7 +320,7 @@ if ($_POST) { ...@@ -321,7 +320,7 @@ if ($_POST) {
} }
} }
} else { } else {
if(true) { if(!$input_errors) {
/* restore the entire configuration */ /* restore the entire configuration */
$filename = $_FILES['conffile']['tmp_name']; $filename = $_FILES['conffile']['tmp_name'];
file_put_contents($filename, $data); file_put_contents($filename, $data);
...@@ -505,20 +504,20 @@ if ($_POST) { ...@@ -505,20 +504,20 @@ if ($_POST) {
unset($config['system']['remotebackup']['GDriveP12key']); unset($config['system']['remotebackup']['GDriveP12key']);
} }
write_config(); write_config();
// test / perform backup // test / perform backup
try { try {
$filesInBackup = backup_to_google_drive() ; $filesInBackup = backup_to_google_drive() ;
} catch (Exception $e) { } catch (Exception $e) {
$filesInBackup = array() ; $filesInBackup = array() ;
} }
if (count($filesInBackup) == 0) { if (count($filesInBackup) == 0) {
$input_errors[] = gettext("Google Drive communication failure"); $input_errors[] = gettext("Google Drive communication failure");
} else { } else {
$input_messages = gettext("Backup succesfull, current filelist:"); $input_messages = gettext("Backup succesfull, current filelist:");
foreach ($filesInBackup as $filename => $file) { foreach ($filesInBackup as $filename => $file) {
$input_messages = $input_messages . "<br>" . $filename ; $input_messages = $input_messages . "<br>" . $filename ;
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment