Nextcloud password: allow to set a separeate pw and allow no encryption (#2545)

This commit is contained in:
Fabian Franz BSc 2018-07-15 11:27:04 +02:00 committed by Franco Fichtner
parent fdc52df6d5
commit 15534011f0
2 changed files with 17 additions and 4 deletions

View File

@ -74,6 +74,13 @@ class Nextcloud extends Base implements IBackupProvider
"help" => gettext("The app password which has been generated for you"),
"value" => null
),
array(
"name" => "password_encryption",
"type" => "password",
"label" => gettext("Encryption Password (Optional)"),
"help" => gettext("A password to encrypt your configuration"),
"value" => null
),
array(
"name" => "backupdir",
"type" => "text",
@ -128,13 +135,16 @@ class Nextcloud extends Base implements IBackupProvider
$username = (string)$nextcloud->user;
$password = (string)$nextcloud->password;
$backupdir = (string)$nextcloud->backupdir;
$crypto_password = (string)$nextcloud->password_encryption;
$hostname = $config->system->hostname . '.' .$config->system->domain;
$configname = 'config-' . $hostname . '-' . date("Y-m-d_H:i:s") . '.xml';
// backup source data to local strings (plain/encrypted)
$confdata = file_get_contents('/conf/config.xml');
$confdata_enc = chunk_split(
$this->encrypt($confdata, (string)$nextcloud->password)
);
if (!empty($crypto_password)) {
$confdata = chunk_split(
$this->encrypt($confdata, $crypto_password)
);
}
try {
$directories = $this->listFiles($url, $username, $password, '/');
if (!in_array("/$backupdir/", $directories)) {
@ -146,7 +156,7 @@ class Nextcloud extends Base implements IBackupProvider
$password,
$backupdir,
$configname,
$confdata_enc
$confdata
);
// do not list directories
return array_filter(

View File

@ -41,6 +41,9 @@
</check001>
</Constraints>
</password>
<password_encryption type="TextField">
<Required>N</Required>
</password_encryption>
<backupdir type="TextField">
<Required>Y</Required>
<mask>/[a-z0-9\-]+/i</mask>