Skip to content

Commit

Permalink
Nextcloud password: allow to set a separeate pw and allow no encrypti…
Browse files Browse the repository at this point in the history
…on (#2545)
  • Loading branch information
fabianfrz authored and fichtner committed Jul 15, 2018
1 parent fdc52df commit 1553401
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/opnsense/mvc/app/library/OPNsense/Backup/Nextcloud.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ public function getConfigurationFields()
"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",
Expand Down Expand Up @@ -128,13 +135,16 @@ function backup()
$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)) {
Expand All @@ -146,7 +156,7 @@ function backup()
$password,
$backupdir,
$configname,
$confdata_enc
$confdata
);
// do not list directories
return array_filter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit 1553401

Please sign in to comment.