only use pageant as agent if it's runing - fixes #2935, fixes #2936

This commit is contained in:
Eugene Pankov
2020-08-26 10:54:49 +02:00
parent 4346030459
commit 179acc1382

View File

@@ -18,6 +18,10 @@ import { SSHTabComponent } from '../components/sshTab.component'
const WINDOWS_OPENSSH_AGENT_PIPE = '\\\\.\\pipe\\openssh-ssh-agent' const WINDOWS_OPENSSH_AGENT_PIPE = '\\\\.\\pipe\\openssh-ssh-agent'
try {
var windowsProcessTreeNative = require('windows-process-tree/build/Release/windows_process_tree.node') // eslint-disable-line @typescript-eslint/no-var-requires, no-var
} catch { }
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class SSHService { export class SSHService {
private logger: Logger private logger: Logger
@@ -193,8 +197,15 @@ export class SSHService {
if (await fs.exists(WINDOWS_OPENSSH_AGENT_PIPE)) { if (await fs.exists(WINDOWS_OPENSSH_AGENT_PIPE)) {
agent = WINDOWS_OPENSSH_AGENT_PIPE agent = WINDOWS_OPENSSH_AGENT_PIPE
} else { } else {
const pageantRunning = new Promise<boolean>(resolve => {
windowsProcessTreeNative.getProcessList(list => { // eslint-disable-line block-scoped-var
resolve(list.some(x => x.name === 'pageant.exe'))
}, 0)
})
if (pageantRunning) {
agent = 'pageant' agent = 'pageant'
} }
}
} else { } else {
agent = process.env.SSH_AUTH_SOCK as string agent = process.env.SSH_AUTH_SOCK as string
} }