This commit is contained in:
manojampalam 2016-04-17 19:35:50 -07:00
parent 988295d28a
commit 9c90948102
2 changed files with 14 additions and 6 deletions

View File

@ -95,6 +95,15 @@ ssh_get_authentication_socket(int *fdp)
*fdp = -1;
#ifdef WIN32_FIXME
#define SSH_AGENT_ROOT "SYSTEM\\CurrentControlSet\\Control\\SSH\\agent"
HKEY agent_root = 0;
DWORD agent_pid = 0, tmp_size = 4, pipe_server_pid = 0xff;
RegOpenKeyEx(HKEY_LOCAL_MACHINE, SSH_AGENT_ROOT, 0, KEY_QUERY_VALUE, &agent_root);
if (agent_root) {
RegQueryValueEx(agent_root, "ProcessId", 0, NULL, &agent_pid, &tmp_size);
RegCloseKey(agent_root);
}
HANDLE h = CreateFile(
"\\\\.\\pipe\\ssh-agent", // pipe name
GENERIC_READ | // read and write access
@ -105,10 +114,14 @@ ssh_get_authentication_socket(int *fdp)
FILE_FLAG_OVERLAPPED, // attributes
NULL); // no template file
if (h == INVALID_HANDLE_VALUE) {
debug("cannot open auth socket\n");
return SSH_ERR_AGENT_NOT_PRESENT;
}
if (!GetNamedPipeServerProcessId(h, &pipe_server_pid) || (agent_pid != pipe_server_pid)) {
return SSH_ERR_AGENT_COMMUNICATION;
}
sock = w32_allocate_fd_for_handle(h, FALSE);
#else

View File

@ -518,11 +518,6 @@ main(int argc, char **argv)
fprintf(stderr, "Could not open a connection to your "
"authentication agent.\n");
exit(2);
#ifdef WIN32_FIXME
case SSH_ERR_SYSTEM_ERROR:
fprintf(stderr, "Error connecting to agent: ssh-agent.exe may not be running\n");
exit(2);
#endif
default:
fprintf(stderr, "Error connecting to agent: %s\n", ssh_err(r));
exit(2);