mirror of
https://github.com/PowerShell/Win32-OpenSSH.git
synced 2025-07-05 05:04:47 +02:00
4-17 C2
This commit is contained in:
parent
988295d28a
commit
9c90948102
15
authfd.c
15
authfd.c
@ -95,6 +95,15 @@ ssh_get_authentication_socket(int *fdp)
|
|||||||
*fdp = -1;
|
*fdp = -1;
|
||||||
|
|
||||||
#ifdef WIN32_FIXME
|
#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(
|
HANDLE h = CreateFile(
|
||||||
"\\\\.\\pipe\\ssh-agent", // pipe name
|
"\\\\.\\pipe\\ssh-agent", // pipe name
|
||||||
GENERIC_READ | // read and write access
|
GENERIC_READ | // read and write access
|
||||||
@ -105,10 +114,14 @@ ssh_get_authentication_socket(int *fdp)
|
|||||||
FILE_FLAG_OVERLAPPED, // attributes
|
FILE_FLAG_OVERLAPPED, // attributes
|
||||||
NULL); // no template file
|
NULL); // no template file
|
||||||
if (h == INVALID_HANDLE_VALUE) {
|
if (h == INVALID_HANDLE_VALUE) {
|
||||||
debug("cannot open auth socket\n");
|
|
||||||
return SSH_ERR_AGENT_NOT_PRESENT;
|
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);
|
sock = w32_allocate_fd_for_handle(h, FALSE);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
@ -518,11 +518,6 @@ main(int argc, char **argv)
|
|||||||
fprintf(stderr, "Could not open a connection to your "
|
fprintf(stderr, "Could not open a connection to your "
|
||||||
"authentication agent.\n");
|
"authentication agent.\n");
|
||||||
exit(2);
|
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:
|
default:
|
||||||
fprintf(stderr, "Error connecting to agent: %s\n", ssh_err(r));
|
fprintf(stderr, "Error connecting to agent: %s\n", ssh_err(r));
|
||||||
exit(2);
|
exit(2);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user