1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-20 05:42:40 +01:00

Check to make sure credential is not null in SSH command interface

Summary: This adds a check to make sure the credential exists when loading it in the Drydock SSH interface.  This effectively turns a fatal error (calling a method on a non-object) into a catchable exception.

Test Plan: Had a badly configured resource, saw the exception appear instead of daemon fataling.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11530
This commit is contained in:
James Rhodes 2015-01-28 23:40:34 +00:00
parent 6e723c5c5a
commit 82f506f175

View file

@ -16,6 +16,12 @@ final class DrydockSSHCommandInterface extends DrydockCommandInterface {
->needSecrets(true) ->needSecrets(true)
->executeOne(); ->executeOne();
if ($credential === null) {
throw new Exception(pht(
'There is no credential with ID %d.',
$this->getConfig('credential')));
}
if ($credential->getProvidesType() !== if ($credential->getProvidesType() !==
PassphraseCredentialTypeSSHPrivateKey::PROVIDES_TYPE) { PassphraseCredentialTypeSSHPrivateKey::PROVIDES_TYPE) {
throw new Exception('Only private key credentials are supported.'); throw new Exception('Only private key credentials are supported.');