version 1.3, 1999/09/29 06:15:00 |
version 1.4, 1999/09/29 21:14:16 |
|
|
|
|
parent_pid = getpid(); |
parent_pid = getpid(); |
|
|
sprintf(socket_name, SSH_AGENT_SOCKET, parent_pid); |
snprintf(socket_name, sizeof socket_name, SSH_AGENT_SOCKET, parent_pid); |
|
|
/* Fork, and have the parent execute the command. The child continues as |
/* Fork, and have the parent execute the command. The child continues as |
the authentication agent. */ |
the authentication agent. */ |
if (fork() != 0) |
if (fork() != 0) |
{ /* Parent - execute the given command. */ |
{ /* Parent - execute the given command. */ |
sprintf(buf, "SSH_AUTHENTICATION_SOCKET=%s", socket_name); |
snprintf(buf, sizeof buf, "SSH_AUTHENTICATION_SOCKET=%s", socket_name); |
putenv(buf); |
putenv(buf); |
execvp(av[1], av + 1); |
execvp(av[1], av + 1); |
perror(av[1]); |
perror(av[1]); |
|
|
} |
} |
memset(&sunaddr, 0, sizeof(sunaddr)); |
memset(&sunaddr, 0, sizeof(sunaddr)); |
sunaddr.sun_family = AF_UNIX; |
sunaddr.sun_family = AF_UNIX; |
strncpy(sunaddr.sun_path, socket_name, sizeof(sunaddr.sun_path)); |
strlcpy(sunaddr.sun_path, socket_name, sizeof(sunaddr.sun_path)); |
if (bind(sock, (struct sockaddr *)&sunaddr, AF_UNIX_SIZE(sunaddr)) < 0) |
if (bind(sock, (struct sockaddr *)&sunaddr, AF_UNIX_SIZE(sunaddr)) < 0) |
{ |
{ |
perror("bind"); |
perror("bind"); |
|
|
if (fork() != 0) |
if (fork() != 0) |
{ /* Parent - execute the given command. */ |
{ /* Parent - execute the given command. */ |
close(sockets[0]); |
close(sockets[0]); |
sprintf(buf, "SSH_AUTHENTICATION_FD=%d", sockets[1]); |
snprintf(buf, sizeof buf, "SSH_AUTHENTICATION_FD=%d", sockets[1]); |
putenv(buf); |
putenv(buf); |
execvp(av[1], av + 1); |
execvp(av[1], av + 1); |
perror(av[1]); |
perror(av[1]); |