mirror of
https://github.com/PowerShell/Win32-OpenSSH.git
synced 2025-07-23 22:15:37 +02:00
Code fixed for ssh-agent.exe and ssh-add.exe to work in Windows
ssh-agent.exe and ssh-add.exe code updated and fixed to work in Windows. For convenience of users, ssh-agent.exe starts a cmd shell with the "SSH_AUTH_SOCK" and "SSH_AGENT_PID" environment variables set. ssh-add.exe can be run immediately from the cmd shell. 'ssh-add -L" and "ssh-add id_rsa" and "ssh-add -d id_rsa" are 3 useful commands to list, add and delete keys from ssh-agent cache.
This commit is contained in:
parent
8f42a2f376
commit
fe136bc352
8
authfd.c
8
authfd.c
@ -114,6 +114,14 @@ ssh_get_authentication_socket(int *fdp)
|
|||||||
errno = oerrno;
|
errno = oerrno;
|
||||||
return SSH_ERR_SYSTEM_ERROR;
|
return SSH_ERR_SYSTEM_ERROR;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
if (
|
||||||
|
connect(sock, (struct sockaddr *)&sunaddr, sizeof(sunaddr)) < 0) {
|
||||||
|
oerrno = errno;
|
||||||
|
close(sock);
|
||||||
|
errno = oerrno;
|
||||||
|
return SSH_ERR_SYSTEM_ERROR;
|
||||||
|
}
|
||||||
#endif /* #ifndef WIN32_FIXME */
|
#endif /* #ifndef WIN32_FIXME */
|
||||||
|
|
||||||
if (fdp != NULL)
|
if (fdp != NULL)
|
||||||
|
@ -2013,9 +2013,10 @@ int cleanSelectThread(int thread_no)
|
|||||||
|
|
||||||
if(thread_data_set[thread_no] != NULL)
|
if(thread_data_set[thread_no] != NULL)
|
||||||
{
|
{
|
||||||
HeapFree(GetProcessHeap(), 0, thread_data_set[thread_no]);
|
thread_data_p ap = thread_data_set[thread_no];
|
||||||
|
thread_data_set[thread_no] = NULL;
|
||||||
thread_data_set[thread_no] = NULL;
|
HeapFree(GetProcessHeap(), 0, ap);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DBG_MSG("<- cleanSelectThread()...\n");
|
DBG_MSG("<- cleanSelectThread()...\n");
|
||||||
|
@ -520,6 +520,11 @@ 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);
|
||||||
|
@ -1734,7 +1734,9 @@ main(int ac, char **av)
|
|||||||
cleanup_exit(1);
|
cleanup_exit(1);
|
||||||
}
|
}
|
||||||
if (pid != 0) { /* Parent - execute the given command. */
|
if (pid != 0) { /* Parent - execute the given command. */
|
||||||
|
#ifndef WIN32_FIXME
|
||||||
close(sock);
|
close(sock);
|
||||||
|
#endif
|
||||||
snprintf(pidstrbuf, sizeof pidstrbuf, "%ld", (long)pid);
|
snprintf(pidstrbuf, sizeof pidstrbuf, "%ld", (long)pid);
|
||||||
if (ac == 0) {
|
if (ac == 0) {
|
||||||
#ifdef WIN32_FIXME
|
#ifdef WIN32_FIXME
|
||||||
@ -1748,6 +1750,11 @@ main(int ac, char **av)
|
|||||||
printf(format, SSH_AGENTPID_ENV_NAME, pidstrbuf,
|
printf(format, SSH_AGENTPID_ENV_NAME, pidstrbuf,
|
||||||
SSH_AGENTPID_ENV_NAME);
|
SSH_AGENTPID_ENV_NAME);
|
||||||
printf("echo Agent pid %ld;\n", (long)pid);
|
printf("echo Agent pid %ld;\n", (long)pid);
|
||||||
|
#ifdef WIN32_FIXME
|
||||||
|
SetEnvironmentVariable(SSH_AUTHSOCKET_ENV_NAME, socket_name);
|
||||||
|
SetEnvironmentVariable(SSH_AGENTPID_ENV_NAME, pidstrbuf);
|
||||||
|
system("start cmd");
|
||||||
|
#endif
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
if (setenv(SSH_AUTHSOCKET_ENV_NAME, socket_name, 1) == -1 ||
|
if (setenv(SSH_AUTHSOCKET_ENV_NAME, socket_name, 1) == -1 ||
|
||||||
|
Loading…
x
Reference in New Issue
Block a user