diff options
author | Colin Watson <cjwatson@debian.org> | 2019-10-09 22:59:48 +0100 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2019-10-09 22:59:48 +0100 |
commit | 4213eec74e74de6310c27a40c3e9759a08a73996 (patch) | |
tree | e97a6dcafc6763aea7c804e4e113c2750cb1400d /authfd.c | |
parent | 102062f825fb26a74295a1c089c00c4c4c76b68a (diff) | |
parent | cdf1d0a9f5d18535e0a18ff34860e81a6d83aa5c (diff) |
Import openssh_8.1p1.orig.tar.gz
Diffstat (limited to 'authfd.c')
-rw-r--r-- | authfd.c | 36 |
1 files changed, 32 insertions, 4 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: authfd.c,v 1.113 2018/12/27 23:02:11 djm Exp $ */ | 1 | /* $OpenBSD: authfd.c,v 1.117 2019/09/03 08:29:15 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -101,12 +101,12 @@ ssh_get_authentication_socket(int *fdp) | |||
101 | sunaddr.sun_family = AF_UNIX; | 101 | sunaddr.sun_family = AF_UNIX; |
102 | strlcpy(sunaddr.sun_path, authsocket, sizeof(sunaddr.sun_path)); | 102 | strlcpy(sunaddr.sun_path, authsocket, sizeof(sunaddr.sun_path)); |
103 | 103 | ||
104 | if ((sock = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) | 104 | if ((sock = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) |
105 | return SSH_ERR_SYSTEM_ERROR; | 105 | return SSH_ERR_SYSTEM_ERROR; |
106 | 106 | ||
107 | /* close on exec */ | 107 | /* close on exec */ |
108 | if (fcntl(sock, F_SETFD, FD_CLOEXEC) == -1 || | 108 | if (fcntl(sock, F_SETFD, FD_CLOEXEC) == -1 || |
109 | connect(sock, (struct sockaddr *)&sunaddr, sizeof(sunaddr)) < 0) { | 109 | connect(sock, (struct sockaddr *)&sunaddr, sizeof(sunaddr)) == -1) { |
110 | oerrno = errno; | 110 | oerrno = errno; |
111 | close(sock); | 111 | close(sock); |
112 | errno = oerrno; | 112 | errno = oerrno; |
@@ -312,10 +312,38 @@ ssh_free_identitylist(struct ssh_identitylist *idl) | |||
312 | if (idl->comments != NULL) | 312 | if (idl->comments != NULL) |
313 | free(idl->comments[i]); | 313 | free(idl->comments[i]); |
314 | } | 314 | } |
315 | free(idl->keys); | ||
316 | free(idl->comments); | ||
315 | free(idl); | 317 | free(idl); |
316 | } | 318 | } |
317 | 319 | ||
318 | /* | 320 | /* |
321 | * Check if the ssh agent has a given key. | ||
322 | * Returns 0 if found, or a negative SSH_ERR_* error code on failure. | ||
323 | */ | ||
324 | int | ||
325 | ssh_agent_has_key(int sock, struct sshkey *key) | ||
326 | { | ||
327 | int r, ret = SSH_ERR_KEY_NOT_FOUND; | ||
328 | size_t i; | ||
329 | struct ssh_identitylist *idlist = NULL; | ||
330 | |||
331 | if ((r = ssh_fetch_identitylist(sock, &idlist)) < 0) { | ||
332 | return r; | ||
333 | } | ||
334 | |||
335 | for (i = 0; i < idlist->nkeys; i++) { | ||
336 | if (sshkey_equal_public(idlist->keys[i], key)) { | ||
337 | ret = 0; | ||
338 | break; | ||
339 | } | ||
340 | } | ||
341 | |||
342 | ssh_free_identitylist(idlist); | ||
343 | return ret; | ||
344 | } | ||
345 | |||
346 | /* | ||
319 | * Sends a challenge (typically from a server via ssh(1)) to the agent, | 347 | * Sends a challenge (typically from a server via ssh(1)) to the agent, |
320 | * and waits for a response from the agent. | 348 | * and waits for a response from the agent. |
321 | * Returns true (non-zero) if the agent gave the correct answer, zero | 349 | * Returns true (non-zero) if the agent gave the correct answer, zero |
@@ -423,7 +451,7 @@ encode_constraints(struct sshbuf *m, u_int life, u_int confirm, u_int maxsign) | |||
423 | * This call is intended only for use by ssh-add(1) and like applications. | 451 | * This call is intended only for use by ssh-add(1) and like applications. |
424 | */ | 452 | */ |
425 | int | 453 | int |
426 | ssh_add_identity_constrained(int sock, const struct sshkey *key, | 454 | ssh_add_identity_constrained(int sock, struct sshkey *key, |
427 | const char *comment, u_int life, u_int confirm, u_int maxsign) | 455 | const char *comment, u_int life, u_int confirm, u_int maxsign) |
428 | { | 456 | { |
429 | struct sshbuf *msg; | 457 | struct sshbuf *msg; |