Don't prompt for passphrase when 'agent' is set

pull/13/head
Kelvin Schoofs 7 years ago
parent b0bfa4010b
commit 13560218ec

@ -153,7 +153,7 @@ export class Manager implements vscode.FileSystemProvider, vscode.TreeDataProvid
session.username = process.env.USERNAME; session.username = process.env.USERNAME;
if (!session.username) return reject(new Error(`No username specified in the session (nor is using the system username enabled)`)); if (!session.username) return reject(new Error(`No username specified in the session (nor is using the system username enabled)`));
} }
if (session.publickeyfile) { if (!config.agent && session.publickeyfile) {
try { try {
const key = await toPromise<Buffer>(cb => readFile(session.publickeyfile, cb)); const key = await toPromise<Buffer>(cb => readFile(session.publickeyfile, cb));
config.privateKey = key; config.privateKey = key;
@ -171,12 +171,20 @@ export class Manager implements vscode.FileSystemProvider, vscode.TreeDataProvid
}); });
} }
if ((config.passphrase as any) === true) { if ((config.passphrase as any) === true) {
config.passphrase = await vscode.window.showInputBox({ if (config.privateKey) {
password: true, config.passphrase = await vscode.window.showInputBox({
ignoreFocusOut: true, password: true,
placeHolder: 'Passphrase', ignoreFocusOut: true,
prompt: 'Passphrase for the provided public/private key', placeHolder: 'Passphrase',
}); prompt: 'Passphrase for the provided public/private key',
});
} else {
const answer = await vscode.window.showWarningMessage(`The field 'passphrase' was set to true, but no key was provided`, 'Configure', 'Ignore');
if (answer === 'Configure') {
this.commandConfigure(name);
return reject(null);
}
}
} }
const client = new Client(); const client = new Client();
client.on('ready', () => { client.on('ready', () => {
@ -207,6 +215,11 @@ export class Manager implements vscode.FileSystemProvider, vscode.TreeDataProvid
reject(e); reject(e);
} }
}).catch((e) => { }).catch((e) => {
if (!e) {
delete this.creatingFileSystems[name];
this.commandConfigDisconnect(name);
throw e;
}
vscode.window.showErrorMessage(`Error while connecting to SSH FS ${name}:\n${e.message}`, 'Retry', 'Configure', 'Ignore').then((chosen) => { vscode.window.showErrorMessage(`Error while connecting to SSH FS ${name}:\n${e.message}`, 'Retry', 'Configure', 'Ignore').then((chosen) => {
delete this.creatingFileSystems[name]; delete this.creatingFileSystems[name];
if (chosen === 'Retry') { if (chosen === 'Retry') {

Loading…
Cancel
Save