|
Lines 83-103
decode_reply(u_char type)
Link Here
|
| 83 |
return SSH_ERR_INVALID_FORMAT; |
83 |
return SSH_ERR_INVALID_FORMAT; |
| 84 |
} |
84 |
} |
| 85 |
|
85 |
|
| 86 |
/* Returns the number of the authentication fd, or -1 if there is none. */ |
86 |
static int |
| 87 |
int |
87 |
get_authentication_socket(const char *authsocket, int *fdp) |
| 88 |
ssh_get_authentication_socket(int *fdp) |
|
|
| 89 |
{ |
88 |
{ |
| 90 |
const char *authsocket; |
|
|
| 91 |
int sock, oerrno; |
89 |
int sock, oerrno; |
| 92 |
struct sockaddr_un sunaddr; |
90 |
struct sockaddr_un sunaddr; |
| 93 |
|
91 |
|
| 94 |
if (fdp != NULL) |
|
|
| 95 |
*fdp = -1; |
| 96 |
|
| 97 |
authsocket = getenv(SSH_AUTHSOCKET_ENV_NAME); |
| 98 |
if (!authsocket) |
| 99 |
return SSH_ERR_AGENT_NOT_PRESENT; |
| 100 |
|
| 101 |
memset(&sunaddr, 0, sizeof(sunaddr)); |
92 |
memset(&sunaddr, 0, sizeof(sunaddr)); |
| 102 |
sunaddr.sun_family = AF_UNIX; |
93 |
sunaddr.sun_family = AF_UNIX; |
| 103 |
strlcpy(sunaddr.sun_path, authsocket, sizeof(sunaddr.sun_path)); |
94 |
strlcpy(sunaddr.sun_path, authsocket, sizeof(sunaddr.sun_path)); |
|
Lines 117-123
ssh_get_authentication_socket(int *fdp)
Link Here
|
| 117 |
*fdp = sock; |
108 |
*fdp = sock; |
| 118 |
else |
109 |
else |
| 119 |
close(sock); |
110 |
close(sock); |
| 120 |
return 0; |
111 |
return SSH_ERR_SUCCESS; |
|
|
112 |
} |
| 113 |
|
| 114 |
/* Returns the number of the authentication fd, or -1 if there is none. */ |
| 115 |
int |
| 116 |
ssh_get_authentication_socket(int *fdp) |
| 117 |
{ |
| 118 |
const char *authsocketlist; |
| 119 |
const char *authsocket; |
| 120 |
int rc; |
| 121 |
|
| 122 |
if (fdp != NULL) |
| 123 |
*fdp = -1; |
| 124 |
|
| 125 |
authsocketlist = getenv(SSH_AUTHSOCKET_ENV_NAME); |
| 126 |
if (!authsocketlist) |
| 127 |
return SSH_ERR_AGENT_NOT_PRESENT; |
| 128 |
|
| 129 |
authsocket = strtok((char *)authsocketlist, ":"); |
| 130 |
|
| 131 |
do { |
| 132 |
rc = get_authentication_socket(authsocket, fdp); |
| 133 |
authsocket = strtok(NULL, ":"); |
| 134 |
} while (rc != SSH_ERR_SUCCESS && authsocket != NULL); |
| 135 |
|
| 136 |
return rc; |
| 121 |
} |
137 |
} |
| 122 |
|
138 |
|
| 123 |
/* Communicate with agent: send request and read reply */ |
139 |
/* Communicate with agent: send request and read reply */ |