summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2007-12-29 02:43:51 +1100
committerDarren Tucker <dtucker@zip.com.au>2007-12-29 02:43:51 +1100
commit4abde771b73f3a54780ff3dedf59f57f94298870 (patch)
tree7973cf3fd2910dac0e8db591f690750d19fd4421
parent88b976f214e14da4ec29a7516d02c0141c8ef597 (diff)
- dtucker@cvs.openbsd.org 2007/12/27 14:22:08
[servconf.c canohost.c misc.c channels.c sshconnect.c misc.h ssh-keyscan.c sshd.c] Add a small helper function to consistently handle the EAI_SYSTEM error code of getaddrinfo. Prompted by vgiffin at apple com via bz #1417. ok markus@ stevesk@
-rw-r--r--ChangeLog8
-rw-r--r--canohost.c7
-rw-r--r--channels.c14
-rw-r--r--misc.c11
-rw-r--r--misc.h3
-rw-r--r--servconf.c4
-rw-r--r--ssh-keyscan.c4
-rw-r--r--sshconnect.c8
-rw-r--r--sshd.c5
9 files changed, 41 insertions, 23 deletions
diff --git a/ChangeLog b/ChangeLog
index 247f0e10c..5b8dec756 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,12 @@
4 [sftp.c] 4 [sftp.c]
5 unbreak lls command and add a regress test that would have caught the 5 unbreak lls command and add a regress test that would have caught the
6 breakage; spotted by mouring@ 6 breakage; spotted by mouring@
7 - dtucker@cvs.openbsd.org 2007/12/27 14:22:08
8 [servconf.c canohost.c misc.c channels.c sshconnect.c misc.h ssh-keyscan.c
9 sshd.c]
10 Add a small helper function to consistently handle the EAI_SYSTEM error
11 code of getaddrinfo. Prompted by vgiffin at apple com via bz #1417.
12 ok markus@ stevesk@
7 13
820071202 1420071202
9 - (dtucker) [configure.ac] Enable -fstack-protector-all on systems where 15 - (dtucker) [configure.ac] Enable -fstack-protector-all on systems where
@@ -3465,4 +3471,4 @@
3465 OpenServer 6 and add osr5bigcrypt support so when someone migrates 3471 OpenServer 6 and add osr5bigcrypt support so when someone migrates
3466 passwords between UnixWare and OpenServer they will still work. OK dtucker@ 3472 passwords between UnixWare and OpenServer they will still work. OK dtucker@
3467 3473
3468$Id: ChangeLog,v 1.4807 2007/12/28 15:40:43 dtucker Exp $ 3474$Id: ChangeLog,v 1.4808 2007/12/28 15:43:51 dtucker Exp $
diff --git a/canohost.c b/canohost.c
index 2345cc35c..8270500d3 100644
--- a/canohost.c
+++ b/canohost.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: canohost.c,v 1.61 2006/08/03 03:34:41 deraadt Exp $ */ 1/* $OpenBSD: canohost.c,v 1.62 2007/12/27 14:22:08 dtucker 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
@@ -32,6 +32,7 @@
32#include "packet.h" 32#include "packet.h"
33#include "log.h" 33#include "log.h"
34#include "canohost.h" 34#include "canohost.h"
35#include "misc.h"
35 36
36static void check_ip_options(int, char *); 37static void check_ip_options(int, char *);
37 38
@@ -271,7 +272,7 @@ get_socket_address(int sock, int remote, int flags)
271 if ((r = getnameinfo((struct sockaddr *)&addr, addrlen, ntop, 272 if ((r = getnameinfo((struct sockaddr *)&addr, addrlen, ntop,
272 sizeof(ntop), NULL, 0, flags)) != 0) { 273 sizeof(ntop), NULL, 0, flags)) != 0) {
273 error("get_socket_address: getnameinfo %d failed: %s", flags, 274 error("get_socket_address: getnameinfo %d failed: %s", flags,
274 r == EAI_SYSTEM ? strerror(errno) : gai_strerror(r)); 275 ssh_gai_strerror(r));
275 return NULL; 276 return NULL;
276 } 277 }
277 return xstrdup(ntop); 278 return xstrdup(ntop);
@@ -372,7 +373,7 @@ get_sock_port(int sock, int local)
372 if ((r = getnameinfo((struct sockaddr *)&from, fromlen, NULL, 0, 373 if ((r = getnameinfo((struct sockaddr *)&from, fromlen, NULL, 0,
373 strport, sizeof(strport), NI_NUMERICSERV)) != 0) 374 strport, sizeof(strport), NI_NUMERICSERV)) != 0)
374 fatal("get_sock_port: getnameinfo NI_NUMERICSERV failed: %s", 375 fatal("get_sock_port: getnameinfo NI_NUMERICSERV failed: %s",
375 r == EAI_SYSTEM ? strerror(errno) : gai_strerror(r)); 376 ssh_gai_strerror(r));
376 return atoi(strport); 377 return atoi(strport);
377} 378}
378 379
diff --git a/channels.c b/channels.c
index 2006353d4..25ebe1294 100644
--- a/channels.c
+++ b/channels.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: channels.c,v 1.270 2007/06/25 08:20:03 dtucker Exp $ */ 1/* $OpenBSD: channels.c,v 1.271 2007/12/27 14:22:08 dtucker 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
@@ -2409,10 +2409,11 @@ channel_setup_fwd_listener(int type, const char *listen_addr, u_short listen_por
2409 if (addr == NULL) { 2409 if (addr == NULL) {
2410 /* This really shouldn't happen */ 2410 /* This really shouldn't happen */
2411 packet_disconnect("getaddrinfo: fatal error: %s", 2411 packet_disconnect("getaddrinfo: fatal error: %s",
2412 gai_strerror(r)); 2412 ssh_gai_strerror(r));
2413 } else { 2413 } else {
2414 error("channel_setup_fwd_listener: " 2414 error("channel_setup_fwd_listener: "
2415 "getaddrinfo(%.64s): %s", addr, gai_strerror(r)); 2415 "getaddrinfo(%.64s): %s", addr,
2416 ssh_gai_strerror(r));
2416 } 2417 }
2417 return 0; 2418 return 0;
2418 } 2419 }
@@ -2732,7 +2733,7 @@ connect_to(const char *host, u_short port)
2732 snprintf(strport, sizeof strport, "%d", port); 2733 snprintf(strport, sizeof strport, "%d", port);
2733 if ((gaierr = getaddrinfo(host, strport, &hints, &aitop)) != 0) { 2734 if ((gaierr = getaddrinfo(host, strport, &hints, &aitop)) != 0) {
2734 error("connect_to %.100s: unknown host (%s)", host, 2735 error("connect_to %.100s: unknown host (%s)", host,
2735 gai_strerror(gaierr)); 2736 ssh_gai_strerror(gaierr));
2736 return -1; 2737 return -1;
2737 } 2738 }
2738 for (ai = aitop; ai; ai = ai->ai_next) { 2739 for (ai = aitop; ai; ai = ai->ai_next) {
@@ -2874,7 +2875,7 @@ x11_create_display_inet(int x11_display_offset, int x11_use_localhost,
2874 hints.ai_socktype = SOCK_STREAM; 2875 hints.ai_socktype = SOCK_STREAM;
2875 snprintf(strport, sizeof strport, "%d", port); 2876 snprintf(strport, sizeof strport, "%d", port);
2876 if ((gaierr = getaddrinfo(NULL, strport, &hints, &aitop)) != 0) { 2877 if ((gaierr = getaddrinfo(NULL, strport, &hints, &aitop)) != 0) {
2877 error("getaddrinfo: %.100s", gai_strerror(gaierr)); 2878 error("getaddrinfo: %.100s", ssh_gai_strerror(gaierr));
2878 return -1; 2879 return -1;
2879 } 2880 }
2880 for (ai = aitop; ai; ai = ai->ai_next) { 2881 for (ai = aitop; ai; ai = ai->ai_next) {
@@ -3047,7 +3048,8 @@ x11_connect_display(void)
3047 hints.ai_socktype = SOCK_STREAM; 3048 hints.ai_socktype = SOCK_STREAM;
3048 snprintf(strport, sizeof strport, "%u", 6000 + display_number); 3049 snprintf(strport, sizeof strport, "%u", 6000 + display_number);
3049 if ((gaierr = getaddrinfo(buf, strport, &hints, &aitop)) != 0) { 3050 if ((gaierr = getaddrinfo(buf, strport, &hints, &aitop)) != 0) {
3050 error("%.100s: unknown host. (%s)", buf, gai_strerror(gaierr)); 3051 error("%.100s: unknown host. (%s)", buf,
3052 ssh_gai_strerror(gaierr));
3051 return -1; 3053 return -1;
3052 } 3054 }
3053 for (ai = aitop; ai; ai = ai->ai_next) { 3055 for (ai = aitop; ai; ai = ai->ai_next) {
diff --git a/misc.c b/misc.c
index 625a34368..2ca0414d0 100644
--- a/misc.c
+++ b/misc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: misc.c,v 1.65 2006/11/23 01:35:11 ray Exp $ */ 1/* $OpenBSD: misc.c,v 1.66 2007/12/27 14:22:08 dtucker Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 * Copyright (c) 2005,2006 Damien Miller. All rights reserved. 4 * Copyright (c) 2005,2006 Damien Miller. All rights reserved.
@@ -42,6 +42,7 @@
42 42
43#include <errno.h> 43#include <errno.h>
44#include <fcntl.h> 44#include <fcntl.h>
45#include <netdb.h>
45#ifdef HAVE_PATHS_H 46#ifdef HAVE_PATHS_H
46# include <paths.h> 47# include <paths.h>
47#include <pwd.h> 48#include <pwd.h>
@@ -120,6 +121,14 @@ unset_nonblock(int fd)
120 return (0); 121 return (0);
121} 122}
122 123
124const char *
125ssh_gai_strerror(int gaierr)
126{
127 if (gaierr == EAI_SYSTEM)
128 return strerror(errno);
129 return gai_strerror(gaierr);
130}
131
123/* disable nagle on socket */ 132/* disable nagle on socket */
124void 133void
125set_nodelay(int fd) 134set_nodelay(int fd)
diff --git a/misc.h b/misc.h
index f175b4426..be05e806b 100644
--- a/misc.h
+++ b/misc.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: misc.h,v 1.36 2006/08/18 10:27:16 djm Exp $ */ 1/* $OpenBSD: misc.h,v 1.37 2007/12/27 14:22:08 dtucker Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -35,6 +35,7 @@ char *tohex(const void *, size_t);
35void sanitise_stdfd(void); 35void sanitise_stdfd(void);
36 36
37struct passwd *pwcopy(struct passwd *); 37struct passwd *pwcopy(struct passwd *);
38const char *ssh_gai_strerror(int);
38 39
39typedef struct arglist arglist; 40typedef struct arglist arglist;
40struct arglist { 41struct arglist {
diff --git a/servconf.c b/servconf.c
index 1a7545171..d4c01f7ff 100644
--- a/servconf.c
+++ b/servconf.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: servconf.c,v 1.172 2007/04/23 10:15:39 dtucker Exp $ */ 1/* $OpenBSD: servconf.c,v 1.173 2007/12/27 14:22:08 dtucker Exp $ */
2/* 2/*
3 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 3 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
4 * All rights reserved 4 * All rights reserved
@@ -458,7 +458,7 @@ add_one_listen_addr(ServerOptions *options, char *addr, u_short port)
458 if ((gaierr = getaddrinfo(addr, strport, &hints, &aitop)) != 0) 458 if ((gaierr = getaddrinfo(addr, strport, &hints, &aitop)) != 0)
459 fatal("bad addr or host: %s (%s)", 459 fatal("bad addr or host: %s (%s)",
460 addr ? addr : "<NULL>", 460 addr ? addr : "<NULL>",
461 gai_strerror(gaierr)); 461 ssh_gai_strerror(gaierr));
462 for (ai = aitop; ai->ai_next; ai = ai->ai_next) 462 for (ai = aitop; ai->ai_next; ai = ai->ai_next)
463 ; 463 ;
464 ai->ai_next = options->listen_addrs; 464 ai->ai_next = options->listen_addrs;
diff --git a/ssh-keyscan.c b/ssh-keyscan.c
index b19864007..43ebfee55 100644
--- a/ssh-keyscan.c
+++ b/ssh-keyscan.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-keyscan.c,v 1.74 2006/10/06 02:29:19 djm Exp $ */ 1/* $OpenBSD: ssh-keyscan.c,v 1.75 2007/12/27 14:22:08 dtucker Exp $ */
2/* 2/*
3 * Copyright 1995, 1996 by David Mazieres <dm@lcs.mit.edu>. 3 * Copyright 1995, 1996 by David Mazieres <dm@lcs.mit.edu>.
4 * 4 *
@@ -410,7 +410,7 @@ tcpconnect(char *host)
410 hints.ai_family = IPv4or6; 410 hints.ai_family = IPv4or6;
411 hints.ai_socktype = SOCK_STREAM; 411 hints.ai_socktype = SOCK_STREAM;
412 if ((gaierr = getaddrinfo(host, strport, &hints, &aitop)) != 0) 412 if ((gaierr = getaddrinfo(host, strport, &hints, &aitop)) != 0)
413 fatal("getaddrinfo %s: %s", host, gai_strerror(gaierr)); 413 fatal("getaddrinfo %s: %s", host, ssh_gai_strerror(gaierr));
414 for (ai = aitop; ai; ai = ai->ai_next) { 414 for (ai = aitop; ai; ai = ai->ai_next) {
415 s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); 415 s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
416 if (s < 0) { 416 if (s < 0) {
diff --git a/sshconnect.c b/sshconnect.c
index 933df39fa..a604c9724 100644
--- a/sshconnect.c
+++ b/sshconnect.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshconnect.c,v 1.202 2007/09/04 11:15:55 djm Exp $ */ 1/* $OpenBSD: sshconnect.c,v 1.203 2007/12/27 14:22:08 dtucker 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
@@ -224,7 +224,7 @@ ssh_create_socket(int privileged, struct addrinfo *ai)
224 gaierr = getaddrinfo(options.bind_address, "0", &hints, &res); 224 gaierr = getaddrinfo(options.bind_address, "0", &hints, &res);
225 if (gaierr) { 225 if (gaierr) {
226 error("getaddrinfo: %s: %s", options.bind_address, 226 error("getaddrinfo: %s: %s", options.bind_address,
227 gai_strerror(gaierr)); 227 ssh_gai_strerror(gaierr));
228 close(sock); 228 close(sock);
229 return -1; 229 return -1;
230 } 230 }
@@ -356,8 +356,8 @@ ssh_connect(const char *host, struct sockaddr_storage * hostaddr,
356 hints.ai_socktype = SOCK_STREAM; 356 hints.ai_socktype = SOCK_STREAM;
357 snprintf(strport, sizeof strport, "%u", port); 357 snprintf(strport, sizeof strport, "%u", port);
358 if ((gaierr = getaddrinfo(host, strport, &hints, &aitop)) != 0) 358 if ((gaierr = getaddrinfo(host, strport, &hints, &aitop)) != 0)
359 fatal("%s: %.100s: %s", __progname, host, 359 fatal("%s: Could not resolve hostname %.100s: %s", __progname,
360 gai_strerror(gaierr)); 360 host, ssh_gai_strerror(gaierr));
361 361
362 for (attempt = 0; attempt < connection_attempts; attempt++) { 362 for (attempt = 0; attempt < connection_attempts; attempt++) {
363 if (attempt > 0) { 363 if (attempt > 0) {
diff --git a/sshd.c b/sshd.c
index 04778ea99..399237889 100644
--- a/sshd.c
+++ b/sshd.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshd.c,v 1.351 2007/05/22 10:18:52 djm Exp $ */ 1/* $OpenBSD: sshd.c,v 1.352 2007/12/27 14:22:08 dtucker 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
@@ -953,8 +953,7 @@ server_listen(void)
953 ntop, sizeof(ntop), strport, sizeof(strport), 953 ntop, sizeof(ntop), strport, sizeof(strport),
954 NI_NUMERICHOST|NI_NUMERICSERV)) != 0) { 954 NI_NUMERICHOST|NI_NUMERICSERV)) != 0) {
955 error("getnameinfo failed: %.100s", 955 error("getnameinfo failed: %.100s",
956 (ret != EAI_SYSTEM) ? gai_strerror(ret) : 956 ssh_gai_strerror(ret));
957 strerror(errno));
958 continue; 957 continue;
959 } 958 }
960 /* Create socket for listening. */ 959 /* Create socket for listening. */