Skip to content

Commit 9bfc18f

Browse files
Merge branch 'main' into 6.0
2 parents 63fb5f7 + cc3087d commit 9bfc18f

File tree

17 files changed

+99
-32
lines changed

17 files changed

+99
-32
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
},
5555
"require-dev": {
5656
"sebastianfeldmann/git": "^3.2",
57-
"sebastianfeldmann/ftp": "^0.9",
57+
"sebastianfeldmann/ftp": "^0.9.2",
5858
"guzzlehttp/guzzle": "^5.3.4|^6.5.8|^7.5.0",
5959
"aws/aws-sdk-php": "^3.10",
6060
"kunalvarma05/dropbox-php-sdk": "^0.4",
@@ -68,7 +68,7 @@
6868
"phpmailer/phpmailer": "^6.0"
6969
},
7070
"suggest": {
71-
"sebastianfeldmann/ftp": "Require ^0.9 to sync to an FTP server",
71+
"sebastianfeldmann/ftp": "Require ^0.9.2 to sync to an FTP server",
7272
"guzzlehttp/guzzle": "Require ^5.3.3|^6.2.1 to write logs to Telegram",
7373
"aws/aws-sdk-php": "Require '^3.10' to sync to Amazon S3",
7474
"kunalvarma05/dropbox-php-sdk": "Require '^0.2' to sync to Dropbox",

doc/config/sync/ftp.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"user": "user.name",
66
"password": "mySecret",
77
"path": "someDir/someSubDir",
8-
"passive": "false"
8+
"passive": "false",
9+
"secure": "false"
910
}
1011
}
1112

doc/config/sync/ftp.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,7 @@
1414

1515
<!-- optional, default=false -->
1616
<option name="passive" value="true" />
17+
18+
<!-- optional, default=false -->
19+
<option name="secure" value="true" />
1720
</sync>

src/Backup/Crypter/Gpg.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ public function setup(array $options = [])
5353
throw new Exception('gpg expects \'user\'');
5454
}
5555

56-
$this->pathToGpg = Util\Arr::getValue($options, 'pathToOpenSSL', '');
56+
$this->pathToGpg = Util\Arr::getValue($options, 'pathToGPG', '');
5757
$this->keepUncrypted = Util\Str::toBoolean(Util\Arr::getValue($options, 'keepUncrypted', ''), false);
58-
$this->user = $this->toAbsolutePath(Util\Arr::getValue($options, 'user', ''));
58+
$this->user = Util\Arr::getValue($options, 'user', '');
5959
}
6060

6161
/**

src/Backup/Crypter/OpenSSL.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ class OpenSSL extends Abstraction implements Simulator, Restorable
4848
*/
4949
private $password;
5050

51+
/**
52+
* Use password-based key derivation
53+
*
54+
* @var bool
55+
*/
56+
private bool $keyDerivation;
57+
5158
/**
5259
* Keep the not encrypted file
5360
*
@@ -157,6 +164,7 @@ public function setup(array $options = [])
157164
$this->certFile = $this->toAbsolutePath(Util\Arr::getValue($options, 'certFile', ''));
158165
$this->algorithm = Util\Arr::getValue($options, 'algorithm', '');
159166
$this->password = Util\Arr::getValue($options, 'password', '');
167+
$this->keyDerivation = Util\Str::toBoolean(Util\Arr::getValue($options, 'keyDerivation', ''), false);
160168
}
161169

162170
/**
@@ -242,6 +250,7 @@ private function createOpenSSL(Target $target): Executable\OpenSSL
242250
$executable->useSSLCert($this->certFile);
243251
} else {
244252
$executable->usePassword($this->password)
253+
->usePasswordBasedKeyDerivation($this->keyDerivation)
245254
->encodeBase64(true);
246255
}
247256
$executable->useAlgorithm($this->algorithm);

src/Backup/File/OpenStack.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class OpenStack extends Remote
3333
public function __construct($container, $object)
3434
{
3535
$this->container = $container;
36-
$this->filename = basename($object->name);
36+
$this->filename = empty($object->name) ? '' : basename($object->name);
3737
$this->pathname = $object->name;
3838
$this->size = (int) $object->contentLength;
3939
$this->lastModified = $object->lastModified->getTimestamp();

src/Backup/Sync/Ftp.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ class Ftp extends Xtp
3737
*/
3838
protected $passive;
3939

40+
/**
41+
* If set to `true` connection is made via FTPS (explicit SSL).
42+
*
43+
* @var bool
44+
*/
45+
protected $secure;
46+
4047
/**
4148
* Setup the Ftp sync
4249
*
@@ -56,6 +63,7 @@ public function setup(array $config)
5663
parent::setup($config);
5764

5865
$this->passive = Util\Str::toBoolean(Util\Arr::getValue($config, 'passive', ''), false);
66+
$this->secure = Util\Str::toBoolean(Util\Arr::getValue($config, 'secure', ''), false);
5967
$this->setUpCleanable($config);
6068
}
6169

@@ -113,7 +121,7 @@ protected function createClient()
113121
{
114122
if (!$this->ftpClient) {
115123
$login = $this->user . ($this->password ? ':' . $this->password : '');
116-
$this->ftpClient = new Client('ftp://' . $login . '@' . $this->host, $this->passive);
124+
$this->ftpClient = new Client('ftp://' . $login . '@' . $this->host, $this->passive, $this->secure);
117125
}
118126
return $this->ftpClient;
119127
}

src/Cli/Executable/Gpg.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,26 @@ protected function createCommandLine(): CommandLine
139139
$cmd = new Cmd($this->binary);
140140

141141
$process->addCommand($cmd);
142+
$this->setOptions($cmd);
142143

143144
$this->addDeleteCommand($process);
144145

145146
return $process;
146147
}
147148

149+
/**
150+
* Set the gpg command line options
151+
*
152+
* @param \SebastianFeldmann\Cli\Command\Executable $cmd
153+
*/
154+
protected function setOptions(Cmd $cmd): void
155+
{
156+
$cmd->addOption('--' . ($this->action === 'e' ? 'encrypt' : 'decrypt'));
157+
$cmd->addOption('-r', $this->user, ' ');
158+
$cmd->addOption('-o', $this->targetFile, ' ');
159+
$cmd->addArgument($this->sourceFile);
160+
}
161+
148162
/**
149163
* Add the 'rm' command to remove the uncrypted file
150164
*

src/Cli/Executable/OpenSSL.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ class OpenSSL extends Abstraction implements Executable
6868
*/
6969
private $password;
7070

71+
/**
72+
* Use password-based key derivation
73+
*
74+
* @var bool
75+
*/
76+
private $passwordBasedKeyDerivation;
77+
7178
/**
7279
* Algorithm to use
7380
*
@@ -237,6 +244,12 @@ public function usePassword(string $password): OpenSSL
237244
return $this;
238245
}
239246

247+
public function usePasswordBasedKeyDerivation(bool $bool): OpenSSL
248+
{
249+
$this->passwordBasedKeyDerivation = $bool;
250+
return $this;
251+
}
252+
240253
/**
241254
* Set algorithm to use
242255
*
@@ -359,6 +372,7 @@ protected function setPasswordOptions(Cmd $cmd): void
359372
$cmd->addOptionIfNotEmpty('-a', $this->base64, false);
360373
$cmd->addOption('-' . $this->algorithm);
361374
$cmd->addOption('-pass', $password, ' ');
375+
$cmd->addOptionIfNotEmpty('-pbkdf2', $this->passwordBasedKeyDerivation, false);
362376
$cmd->addOption('-in', $this->sourceFile, ' ');
363377
$cmd->addOption('-out', $this->targetFile, ' ');
364378
}

src/Cli/Executable/Xtrabackup8.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public function createCommandLine() : CommandLine
175175
$cmdDump->addOption('--databases', implode(' ', $this->databases));
176176
}
177177

178-
$cmdDump->addArgument($this->dumpDir);
178+
$cmdDump->addOption('--target-dir', $this->dumpDir);
179179

180180
return $process;
181181
}

0 commit comments

Comments
 (0)