Skip to content

Commit 9f4873e

Browse files
Merge pull request #372 from veebkolm
Set parameters for gpg encryption
2 parents 891c407 + 7492c22 commit 9f4873e

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/Backup/Crypter/Gpg.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function setup(array $options = [])
5555

5656
$this->pathToGpg = Util\Arr::getValue($options, 'pathToOpenSSL', '');
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/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
*

0 commit comments

Comments
 (0)