Bugzilla – Attachment 1423 Details for
Bug 1417
Better error message when hostname resolution fails.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Add helper function to handle EAI_SYSTEM
openbsd-ssh-gaistrerror.patch (text/plain), 6.28 KB, created by
Darren Tucker
on 2007-12-28 02:14:28 AEDT
(
hide
)
Description:
Add helper function to handle EAI_SYSTEM
Filename:
MIME Type:
Creator:
Darren Tucker
Created:
2007-12-28 02:14:28 AEDT
Size:
6.28 KB
patch
obsolete
>Index: canohost.c >=================================================================== >RCS file: /cvs/src/usr.bin/ssh/canohost.c,v >Retrieving revision 1.61 >server -u -p -r1.61 canohost.c >--- canohost.c 23 Dec 2007 13:57:26 1.61 >+++ canohost.c 23 Dec 2007 13:56:46 >@@ -229,7 +229,7 @@ get_socket_address(int sock, int remote, int flags) > if ((r = getnameinfo((struct sockaddr *)&addr, addrlen, ntop, > sizeof(ntop), NULL, 0, flags)) != 0) { > error("get_socket_address: getnameinfo %d failed: %s", flags, >- r == EAI_SYSTEM ? strerror(errno) : gai_strerror(r)); >+ get_gai_strerror(r)); > return NULL; > } > return xstrdup(ntop); >@@ -325,7 +325,7 @@ get_sock_port(int sock, int local) > if ((r = getnameinfo((struct sockaddr *)&from, fromlen, NULL, 0, > strport, sizeof(strport), NI_NUMERICSERV)) != 0) > fatal("get_sock_port: getnameinfo NI_NUMERICSERV failed: %s", >- r == EAI_SYSTEM ? strerror(errno) : gai_strerror(r)); >+ get_gai_strerror(r)); > return atoi(strport); > } > >@@ -367,4 +367,12 @@ int > get_local_port(void) > { > return get_port(1); >+} >+ >+const char * >+get_gai_strerror(int gaierr) >+{ >+ if (gaierr == EAI_SYSTEM) >+ return strerror(errno); >+ return gai_strerror(gaierr); > } >Index: canohost.h >=================================================================== >RCS file: /cvs/src/usr.bin/ssh/canohost.h,v >Retrieving revision 1.9 >server -u -p -r1.9 canohost.h >--- canohost.h 23 Dec 2007 13:57:26 1.9 >+++ canohost.h 23 Dec 2007 13:56:46 >@@ -23,3 +23,4 @@ char *get_local_name(int); > > int get_remote_port(void); > int get_local_port(void); >+const char *get_gai_strerror(int); >Index: channels.c >=================================================================== >RCS file: /cvs/src/usr.bin/ssh/channels.c,v >Retrieving revision 1.270 >server -u -p -r1.270 channels.c >--- channels.c 23 Dec 2007 13:57:26 1.270 >+++ channels.c 23 Dec 2007 13:57:03 >@@ -2392,10 +2392,11 @@ channel_setup_fwd_listener(int type, const char *liste > if (addr == NULL) { > /* This really shouldn't happen */ > packet_disconnect("getaddrinfo: fatal error: %s", >- gai_strerror(r)); >+ get_gai_strerror(r)); > } else { > error("channel_setup_fwd_listener: " >- "getaddrinfo(%.64s): %s", addr, gai_strerror(r)); >+ "getaddrinfo(%.64s): %s", addr, >+ get_gai_strerror(r)); > } > return 0; > } >@@ -2709,7 +2710,7 @@ connect_to(const char *host, u_short port) > snprintf(strport, sizeof strport, "%d", port); > if ((gaierr = getaddrinfo(host, strport, &hints, &aitop)) != 0) { > error("connect_to %.100s: unknown host (%s)", host, >- gai_strerror(gaierr)); >+ get_gai_strerror(gaierr)); > return -1; > } > for (ai = aitop; ai; ai = ai->ai_next) { >@@ -2851,7 +2852,7 @@ x11_create_display_inet(int x11_display_offset, int x1 > hints.ai_socktype = SOCK_STREAM; > snprintf(strport, sizeof strport, "%d", port); > if ((gaierr = getaddrinfo(NULL, strport, &hints, &aitop)) != 0) { >- error("getaddrinfo: %.100s", gai_strerror(gaierr)); >+ error("getaddrinfo: %.100s", get_gai_strerror(gaierr)); > return -1; > } > for (ai = aitop; ai; ai = ai->ai_next) { >@@ -3002,7 +3003,8 @@ x11_connect_display(void) > hints.ai_socktype = SOCK_STREAM; > snprintf(strport, sizeof strport, "%u", 6000 + display_number); > if ((gaierr = getaddrinfo(buf, strport, &hints, &aitop)) != 0) { >- error("%.100s: unknown host. (%s)", buf, gai_strerror(gaierr)); >+ error("%.100s: unknown host. (%s)", buf, >+ get_gai_strerror(gaierr)); > return -1; > } > for (ai = aitop; ai; ai = ai->ai_next) { >Index: servconf.c >=================================================================== >RCS file: /cvs/src/usr.bin/ssh/servconf.c,v >Retrieving revision 1.172 >server -u -p -r1.172 servconf.c >--- servconf.c 23 Dec 2007 13:57:26 1.172 >+++ servconf.c 23 Dec 2007 13:57:12 >@@ -421,7 +421,7 @@ add_one_listen_addr(ServerOptions *options, char *addr > if ((gaierr = getaddrinfo(addr, strport, &hints, &aitop)) != 0) > fatal("bad addr or host: %s (%s)", > addr ? addr : "<NULL>", >- gai_strerror(gaierr)); >+ get_gai_strerror(gaierr)); > for (ai = aitop; ai->ai_next; ai = ai->ai_next) > ; > ai->ai_next = options->listen_addrs; >Index: ssh-keyscan.c >=================================================================== >RCS file: /cvs/src/usr.bin/ssh/ssh-keyscan.c,v >Retrieving revision 1.74 >server -u -p -r1.74 ssh-keyscan.c >--- ssh-keyscan.c 23 Dec 2007 13:57:26 1.74 >+++ ssh-keyscan.c 23 Dec 2007 13:57:13 >@@ -395,7 +395,7 @@ tcpconnect(char *host) > hints.ai_family = IPv4or6; > hints.ai_socktype = SOCK_STREAM; > if ((gaierr = getaddrinfo(host, strport, &hints, &aitop)) != 0) >- fatal("getaddrinfo %s: %s", host, gai_strerror(gaierr)); >+ fatal("getaddrinfo %s: %s", host, get_gai_strerror(gaierr)); > for (ai = aitop; ai; ai = ai->ai_next) { > s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); > if (s < 0) { >Index: sshconnect.c >=================================================================== >RCS file: /cvs/src/usr.bin/ssh/sshconnect.c,v >Retrieving revision 1.202 >server -u -p -r1.202 sshconnect.c >--- sshconnect.c 23 Dec 2007 13:57:26 1.202 >+++ sshconnect.c 23 Dec 2007 13:57:17 >@@ -211,7 +211,7 @@ ssh_create_socket(int privileged, struct addrinfo *ai) > gaierr = getaddrinfo(options.bind_address, "0", &hints, &res); > if (gaierr) { > error("getaddrinfo: %s: %s", options.bind_address, >- gai_strerror(gaierr)); >+ get_gai_strerror(gaierr)); > close(sock); > return -1; > } >@@ -344,7 +344,7 @@ ssh_connect(const char *host, struct sockaddr_storage > snprintf(strport, sizeof strport, "%u", port); > if ((gaierr = getaddrinfo(host, strport, &hints, &aitop)) != 0) > fatal("%s: %.100s: %s", __progname, host, >- gai_strerror(gaierr)); >+ get_gai_strerror(gaierr)); > > for (attempt = 0; attempt < connection_attempts; attempt++) { > if (attempt > 0) { >Index: sshd.c >=================================================================== >RCS file: /cvs/src/usr.bin/ssh/sshd.c,v >Retrieving revision 1.351 >server -u -p -r1.351 sshd.c >--- sshd.c 23 Dec 2007 13:57:26 1.351 >+++ sshd.c 23 Dec 2007 13:57:25 >@@ -928,8 +928,7 @@ server_listen(void) > ntop, sizeof(ntop), strport, sizeof(strport), > NI_NUMERICHOST|NI_NUMERICSERV)) != 0) { > error("getnameinfo failed: %.100s", >- (ret != EAI_SYSTEM) ? gai_strerror(ret) : >- strerror(errno)); >+ get_gai_strerror(ret)); > continue; > } > /* Create socket for listening. */
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 1417
:
1413
| 1423