Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14765760
D10328.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D10328.diff
View Options
diff --git a/src/applications/passphrase/keys/PassphraseSSHKey.php b/src/applications/passphrase/keys/PassphraseSSHKey.php
--- a/src/applications/passphrase/keys/PassphraseSSHKey.php
+++ b/src/applications/passphrase/keys/PassphraseSSHKey.php
@@ -17,16 +17,21 @@
$file_type = PassphraseCredentialTypeSSHPrivateKeyFile::CREDENTIAL_TYPE;
if ($credential->getCredentialType() != $file_type) {
- // If the credential does not store a file, write the key txt out to a
+ // If the credential does not store a file, write the key text out to a
// temporary file so we can pass it to `ssh`.
if (!$this->keyFile) {
- $temporary_file = new TempFile('passphrase-ssh-key');
+ $secret = $credential->getSecret();
+ if (!$secret) {
+ throw new Exception(
+ pht(
+ 'Attempting to use a credential ("%s") but the credential '.
+ 'secret has been destroyed!',
+ $credential->getMonogram()));
+ }
+ $temporary_file = new TempFile('passphrase-ssh-key');
Filesystem::changePermissions($temporary_file, 0600);
-
- Filesystem::writeFile(
- $temporary_file,
- $credential->getSecret()->openEnvelope());
+ Filesystem::writeFile($temporary_file, $secret->openEnvelope());
$this->keyFile = $temporary_file;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jan 24, 3:50 PM (17 h, 22 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7041437
Default Alt Text
D10328.diff (1 KB)
Attached To
Mode
D10328: Don't leave temporary files around when trying to use credentials with destroyed secrets
Attached
Detach File
Event Timeline
Log In to Comment