From 03cc931a9b9c80b8cb12935fe5375a2ae9345007 Mon Sep 17 00:00:00 2001 From: Stephan Maximilian Huber Date: Wed, 1 May 2019 13:47:01 +0200 Subject: [PATCH 1/3] Show a warning if local users' keyagent does not have a key when running copySSHKeys --- src/Method/DockerMethod.php | 21 ++++++++++++++------- src/ShellProvider/LocalShellProvider.php | 8 +++++--- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/Method/DockerMethod.php b/src/Method/DockerMethod.php index 187ff549..8aabba88 100644 --- a/src/Method/DockerMethod.php +++ b/src/Method/DockerMethod.php @@ -305,13 +305,20 @@ private function copySSHKeys(HostConfig $hostconfig, TaskContextInterface $conte if (empty($files['/root/.ssh/authorized_keys'])) { $file = tempnam("/tmp", "phabalicious"); - $result = $shell->run(sprintf('#!ssh-add -L > %s', $file)); - - $files['/root/.ssh/authorized_keys'] = [ - 'source' => $file, - 'permissions' => '600', - ]; - $temp_files[] = $file; + try { + $result = $shell->run(sprintf('#!ssh-add -L > %s', $file)); + + $files['/root/.ssh/authorized_keys'] = [ + 'source' => $file, + 'permissions' => '600', + ]; + $temp_files[] = $file; + } catch (FailedShellCommandException $e) { + $context->io()->warning(sprintf( + 'Could not add public key to authorized_keys-file: %s', + $e->getMessage() + )); + } } if (count($files) > 0) { diff --git a/src/ShellProvider/LocalShellProvider.php b/src/ShellProvider/LocalShellProvider.php index db8d2ba0..5bf32664 100644 --- a/src/ShellProvider/LocalShellProvider.php +++ b/src/ShellProvider/LocalShellProvider.php @@ -4,6 +4,7 @@ use Phabalicious\Configuration\ConfigurationService; use Phabalicious\Configuration\HostConfig; +use Phabalicious\Exception\FailedShellCommandException; use Phabalicious\Method\TaskContextInterface; use Phabalicious\Utilities\SetAndRestoreObjProperty; use Phabalicious\Validation\ValidationErrorBagInterface; @@ -77,7 +78,7 @@ public function createShellProcess(array $command = [], array $options = []): Pr /** * Setup local shell. * - * @throws \Exception + * @throws \RuntimeException */ public function setup() { @@ -86,7 +87,7 @@ public function setup() } if (empty($this->hostConfig)) { - throw new \Exception('No host-config set for local shell provider'); + throw new \RuntimeException('No host-config set for local shell provider'); } $shell_executable = $this->hostConfig['shellExecutable']; @@ -125,7 +126,8 @@ public function setup() * @param bool $capture_output * @param bool $throw_exception_on_error * @return CommandResult - * @throws \Exception + * @throws FailedShellCommandException + * @throws \RuntimeException */ public function run(string $command, $capture_output = false, $throw_exception_on_error = true): CommandResult { From 11edd896f92e6ef8684779e475a8443045158658 Mon Sep 17 00:00:00 2001 From: Stephan Maximilian Huber Date: Wed, 1 May 2019 13:50:48 +0200 Subject: [PATCH 2/3] Update changelog --- Changelog.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Changelog.md b/Changelog.md index a405135c..3f0d8802 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,7 +1,15 @@ # Changelog +## 3.0.7 / 2019-05-01 + +### Fixed + + * Show a warning if local users' keyagent does not have a key when running `docker copySSHKeys` + ## 3.0.6 / 2019-04-25 +### Fixed + * rename setting `dockerAuthorizedKeyFile` to `dockerAuthorizedKeysFile`, keep the old one for backwards compatibility * if no dockerAuthorizedKeysFile is set, use the public-keys of the ssh-agent instead * Cd into siteFolder before restoring a db-dump. (Fixes #48) From e45bc5ef154bf48c9c259e8f00a2d9a0ee9de06b Mon Sep 17 00:00:00 2001 From: Stephan Maximilian Huber Date: Wed, 1 May 2019 13:51:20 +0200 Subject: [PATCH 3/3] Bump version number --- src/Utilities/Utilities.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Utilities/Utilities.php b/src/Utilities/Utilities.php index ffec17f5..4f124e83 100644 --- a/src/Utilities/Utilities.php +++ b/src/Utilities/Utilities.php @@ -5,7 +5,7 @@ class Utilities { - const FALLBACK_VERSION = '3.0.6'; + const FALLBACK_VERSION = '3.0.7'; public static function mergeData(array $data, array $override_data): array {