Page MenuHomePhabricator

D7697.id17381.diff

D7697.id17381.diff

diff --git a/src/applications/drydock/blueprint/DrydockPreallocatedHostBlueprintImplementation.php b/src/applications/drydock/blueprint/DrydockPreallocatedHostBlueprintImplementation.php
--- a/src/applications/drydock/blueprint/DrydockPreallocatedHostBlueprintImplementation.php
+++ b/src/applications/drydock/blueprint/DrydockPreallocatedHostBlueprintImplementation.php
@@ -42,7 +42,7 @@
$v_platform = $resource->getAttribute('platform');
$v_host = $resource->getAttribute('host');
$v_port = $resource->getAttribute('port');
- $v_user = $resource->getAttribute('user');
+ $v_credentials = $resource->getAttribute('credential');
$v_path = $resource->getAttribute('path');
if (empty($v_platform)) {
throw new Exception("Missing 'platform' attribute on resource.");
@@ -53,8 +53,8 @@
if (empty($v_port)) {
throw new Exception("Missing 'port' attribute on resource.");
}
- if (empty($v_user)) {
- throw new Exception("Missing 'user' attribute on resource.");
+ if (empty($v_credentials)) {
+ throw new Exception("Missing 'credential' attribute on resource.");
}
if (empty($v_path)) {
throw new Exception("Missing 'path' attribute on resource.");
@@ -111,8 +111,7 @@
->setConfiguration(array(
'host' => $resource->getAttribute('host'),
'port' => $resource->getAttribute('port'),
- 'user' => $resource->getAttribute('user'),
- 'ssh-keyfile' => $resource->getAttribute('ssh-keyfile'),
+ 'credential' => $resource->getAttribute('credential'),
'platform' => $resource->getAttribute('platform')));
}
diff --git a/src/applications/drydock/interface/command/DrydockSSHCommandInterface.php b/src/applications/drydock/interface/command/DrydockSSHCommandInterface.php
--- a/src/applications/drydock/interface/command/DrydockSSHCommandInterface.php
+++ b/src/applications/drydock/interface/command/DrydockSSHCommandInterface.php
@@ -22,23 +22,31 @@
// NOTE: The "-t -t" is for psuedo-tty allocation so we can "sudo" on some
// systems, but maybe more trouble than it's worth?
- $keyfile = $this->getConfig('ssh-keyfile');
- if (!empty($keyfile)) {
- return new ExecFuture(
- 'ssh -t -t -o StrictHostKeyChecking=no -p %s -i %s %s@%s -- %s',
- $this->getConfig('port'),
- $this->getConfig('ssh-keyfile'),
- $this->getConfig('user'),
- $this->getConfig('host'),
- $full_command);
- } else {
- return new ExecFuture(
- 'ssh -t -t -o StrictHostKeyChecking=no -p %s %s@%s -- %s',
- $this->getConfig('port'),
- $this->getConfig('user'),
- $this->getConfig('host'),
- $full_command);
+ $credential = id(new PassphraseCredentialQuery())
+ ->setViewer(PhabricatorUser::getOmnipotentUser())
+ ->withIDs(array($this->getConfig('credential')))
+ ->needSecrets(true)
+ ->executeOne();
+
+ // FIXME: We can't use text-based SSH files here because the TempFile goes
+ // out of scope after this function ends and thus the file gets removed
+ // before it can be used.
+ if ($credential->getCredentialType() !==
+ PassphraseCredentialTypeSSHPrivateKeyFile::CREDENTIAL_TYPE) {
+ throw new Exception("Only private key file credentials are supported.");
}
+
+ $ssh_key = PassphraseSSHKey::loadFromPHID(
+ $credential->getPHID(),
+ PhabricatorUser::getOmnipotentUser());
+
+ return new ExecFuture(
+ 'ssh -t -t -o StrictHostKeyChecking=no -p %s -i %s %s@%s -- %s',
+ $this->getConfig('port'),
+ $ssh_key->getKeyfileEnvelope()->openEnvelope(),
+ $credential->getUsername(),
+ $this->getConfig('host'),
+ $full_command);
}
}

File Metadata

Mime Type
text/x-diff
Storage Engine
amazon-s3
Storage Format
Raw Data
Storage Handle
phabricator/g6/yc/rygmf564uplwqr5s
Default Alt Text
D7697.id17381.diff (3 KB)

Event Timeline