From 553226e8e16639b00d61d81e0125330dbfb7eed8 Mon Sep 17 00:00:00 2001 From: suz Date: Fri, 19 Apr 2002 04:46:24 +0000 Subject: just merged cosmetic changes from KAME to ease sync between KAME and FreeBSD. (based on freebsd4-snap-20020128) Reviewed by: ume MFC after: 1 week --- usr.sbin/faithd/README | 2 +- usr.sbin/faithd/faithd.8 | 21 +++--- usr.sbin/faithd/faithd.c | 186 ++++++++++------------------------------------- usr.sbin/faithd/faithd.h | 4 +- usr.sbin/faithd/ftp.c | 16 ++-- usr.sbin/faithd/prefix.c | 6 +- usr.sbin/faithd/prefix.h | 2 +- usr.sbin/faithd/rsh.c | 10 +-- usr.sbin/faithd/tcp.c | 15 ++-- 9 files changed, 78 insertions(+), 184 deletions(-) (limited to 'usr.sbin/faithd') diff --git a/usr.sbin/faithd/README b/usr.sbin/faithd/README index 2ad0592..5bcc30d 100644 --- a/usr.sbin/faithd/README +++ b/usr.sbin/faithd/README @@ -1,7 +1,7 @@ Configuring FAITH IPv6-to-IPv4 TCP relay Kazu Yamamoto and Jun-ichiro itojun Hagino -$KAME: README,v 1.7 2001/04/25 11:25:19 itojun Exp $ +$KAME: README,v 1.8 2001/09/05 03:04:20 itojun Exp $ $FreeBSD$ Introduction diff --git a/usr.sbin/faithd/faithd.8 b/usr.sbin/faithd/faithd.8 index 702dbde..c4de0e0 100644 --- a/usr.sbin/faithd/faithd.8 +++ b/usr.sbin/faithd/faithd.8 @@ -1,4 +1,4 @@ -.\" $KAME: faithd.8,v 1.30 2001/05/24 20:47:56 itojun Exp $ +.\" $KAME: faithd.8,v 1.33 2001/09/05 03:04:20 itojun Exp $ .\" .\" Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. .\" All rights reserved. @@ -267,6 +267,9 @@ permit the connection. .Pp The directives are evaluated in sequence, and the first matching entry will be effective. +If there is no match +.Pq if we reach the end of the ruleset +the traffic will be denied. .Pp With inetd mode, traffic may be filtered by using access control functionality in @@ -297,15 +300,15 @@ as follows: If you would like to provide local telnet service via .Xr telnetd 8 on -.Pa /usr/local/v6/libexec/telnetd , +.Pa /usr/libexec/telnetd , use the following command line: .Bd -literal -offset -# faithd telnet /usr/local/v6/libexec/telnetd telnetd +# faithd telnet /usr/libexec/telnetd telnetd .Ed .Pp If you would like to pass extra arguments to the local daemon: .Bd -literal -offset -# faithd ftp /usr/local/v6/libexec/ftpd ftpd -l +# faithd ftp /usr/libexec/ftpd ftpd -l .Ed .Pp Here are some other examples. @@ -314,8 +317,8 @@ You may need to translate rsh/rlogin services. .Bd -literal -offset # faithd ssh -# faithd login /usr/local/v6/libexec/rlogin rlogind -# faithd shell /usr/local/v6/libexec/rshd rshd +# faithd login /usr/libexec/rlogin rlogind +# faithd shell /usr/libexec/rshd rshd .Ed .Pp However, you should be careful when translating rlogin or rsh @@ -377,9 +380,9 @@ on error. .%A Jun-ichiro itojun Hagino .%A Kazu Yamamoto .%T "An IPv6-to-IPv4 transport relay translator" -.%R internet draft -.%N draft-ietf-ngtrans-tcpudp-relay-04.txt -.%O work in progress material +.%B RFC3142 +.%O ftp://ftp.isi.edu/in-notes/rfc3142.txt +.%D June 2001 .Re .\" .Sh HISTORY diff --git a/usr.sbin/faithd/faithd.c b/usr.sbin/faithd/faithd.c index 2f02da1..09fac11 100644 --- a/usr.sbin/faithd/faithd.c +++ b/usr.sbin/faithd/faithd.c @@ -1,4 +1,4 @@ -/* $KAME: faithd.c,v 1.39 2001/04/25 11:20:42 itojun Exp $ */ +/* $KAME: faithd.c,v 1.46 2002/01/24 16:40:42 sumikawa Exp $ */ /* * Copyright (C) 1997 and 1998 WIDE Project. @@ -35,9 +35,8 @@ * User level translator from IPv6 to IPv4. * * Usage: faithd [ ...] - * e.g. faithd telnet /usr/local/v6/sbin/telnetd telnetd + * e.g. faithd telnet /usr/libexec/telnetd telnetd */ -#define HAVE_GETIFADDRS #include #include @@ -73,9 +72,7 @@ #include #include #include -#ifdef HAVE_GETIFADDRS #include -#endif #ifdef FAITH4 #include @@ -98,7 +95,7 @@ struct myaddrs { struct sockaddr *addr; }; struct myaddrs *myaddrs = NULL; -static char *service; +static const char *service; #ifdef USE_ROUTE static int sockfd = 0; #endif @@ -122,9 +119,6 @@ static void sig_terminate __P((int)); static void start_daemon __P((void)); static void exit_stderr __P((const char *, ...)) __attribute__((__format__(__printf__, 1, 2))); -#ifndef HAVE_GETIFADDRS -static unsigned int if_maxindex __P((void)); -#endif static void grab_myaddrs __P((void)); static void free_myaddrs __P((void)); static void update_myaddrs __P((void)); @@ -178,19 +172,19 @@ inetd_main(int argc, char **argv) sockfd = socket(PF_ROUTE, SOCK_RAW, PF_UNSPEC); if (sockfd < 0) { - exit_failure("socket(PF_ROUTE): %s", ERRSTR); + exit_failure("socket(PF_ROUTE): %s", strerror(errno)); /*NOTREACHED*/ } #endif melen = sizeof(me); if (getsockname(STDIN_FILENO, (struct sockaddr *)&me, &melen) < 0) { - exit_failure("getsockname: %s", ERRSTR); + exit_failure("getsockname: %s", strerror(errno)); /*NOTREACHED*/ } fromlen = sizeof(from); if (getpeername(STDIN_FILENO, (struct sockaddr *)&from, &fromlen) < 0) { - exit_failure("getpeername: %s", ERRSTR); + exit_failure("getpeername: %s", strerror(errno)); /*NOTREACHED*/ } if (getnameinfo((struct sockaddr *)&me, melen, NULL, 0, @@ -218,7 +212,7 @@ inetd_main(int argc, char **argv) error = setsockopt(STDIN_FILENO, SOL_SOCKET, SO_OOBINLINE, &on, sizeof(on)); if (error < 0) { - exit_failure("setsockopt(SO_OOBINLINE): %s", ERRSTR); + exit_failure("setsockopt(SO_OOBINLINE): %s", strerror(errno)); /*NOTREACHED*/ } @@ -325,17 +319,18 @@ daemon_main(int argc, char **argv) hints.ai_protocol = 0; error = getaddrinfo(NULL, service, &hints, &res); if (error) - exit_stderr("getaddrinfo: %s", gai_strerror(error)); + exit_failure("getaddrinfo: %s", gai_strerror(error)); s_wld = socket(res->ai_family, res->ai_socktype, res->ai_protocol); if (s_wld == -1) - exit_stderr("socket: %s", ERRSTR); + exit_failure("socket: %s", strerror(errno)); #ifdef IPV6_FAITH if (res->ai_family == AF_INET6) { error = setsockopt(s_wld, IPPROTO_IPV6, IPV6_FAITH, &on, sizeof(on)); if (error == -1) - exit_stderr("setsockopt(IPV6_FAITH): %s", ERRSTR); + exit_failure("setsockopt(IPV6_FAITH): %s", + strerror(errno)); } #endif #ifdef FAITH4 @@ -343,31 +338,32 @@ daemon_main(int argc, char **argv) if (res->ai_family == AF_INET) { error = setsockopt(s_wld, IPPROTO_IP, IP_FAITH, &on, sizeof(on)); if (error == -1) - exit_stderr("setsockopt(IP_FAITH): %s", ERRSTR); + exit_failure("setsockopt(IP_FAITH): %s", + strerror(errno)); } #endif #endif /* FAITH4 */ error = setsockopt(s_wld, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); if (error == -1) - exit_stderr("setsockopt(SO_REUSEADDR): %s", ERRSTR); + exit_failure("setsockopt(SO_REUSEADDR): %s", strerror(errno)); error = setsockopt(s_wld, SOL_SOCKET, SO_OOBINLINE, &on, sizeof(on)); if (error == -1) - exit_stderr("setsockopt(SO_OOBINLINE): %s", ERRSTR); + exit_failure("setsockopt(SO_OOBINLINE): %s", strerror(errno)); error = bind(s_wld, (struct sockaddr *)res->ai_addr, res->ai_addrlen); if (error == -1) - exit_stderr("bind: %s", ERRSTR); + exit_failure("bind: %s", strerror(errno)); error = listen(s_wld, 5); if (error == -1) - exit_stderr("listen: %s", ERRSTR); + exit_failure("listen: %s", strerror(errno)); #ifdef USE_ROUTE sockfd = socket(PF_ROUTE, SOCK_RAW, PF_UNSPEC); if (sockfd < 0) { - exit_stderr("socket(PF_ROUTE): %s", ERRSTR); + exit_failure("socket(PF_ROUTE): %s", strerror(errno)); /*NOTREACHED*/ } #endif @@ -419,7 +415,7 @@ again: if (error < 0) { if (errno == EINTR) goto again; - exit_failure("select: %s", ERRSTR); + exit_failure("select: %s", strerror(errno)); /*NOTREACHED*/ } @@ -433,7 +429,7 @@ again: s_src = accept(s_wld, (struct sockaddr *)&srcaddr, &len); if (s_src == -1) { - exit_failure("socket: %s", ERRSTR); + exit_failure("socket: %s", strerror(errno)); /*NOTREACHED*/ } @@ -462,9 +458,9 @@ play_child(int s_src, struct sockaddr *srcaddr) { struct sockaddr_storage dstaddr6; struct sockaddr_storage dstaddr4; - char src[MAXHOSTNAMELEN]; - char dst6[MAXHOSTNAMELEN]; - char dst4[MAXHOSTNAMELEN]; + char src[NI_MAXHOST]; + char dst6[NI_MAXHOST]; + char dst4[NI_MAXHOST]; int len = sizeof(dstaddr6); int s_dst, error, hport, nresvport, on = 1; struct timeval tv; @@ -480,7 +476,7 @@ play_child(int s_src, struct sockaddr *srcaddr) error = getsockname(s_src, (struct sockaddr *)&dstaddr6, &len); if (error == -1) { - exit_failure("getsockname: %s", ERRSTR); + exit_failure("getsockname: %s", strerror(errno)); /*NOTREACHED*/ } @@ -501,7 +497,8 @@ play_child(int s_src, struct sockaddr *srcaddr) dup2(0, 2); } execv(serverpath, serverarg); - syslog(LOG_ERR, "execv %s: %s", serverpath, ERRSTR); + syslog(LOG_ERR, "execv %s: %s", serverpath, + strerror(errno)); _exit(EXIT_FAILURE); } else { close(s_src); @@ -579,38 +576,38 @@ play_child(int s_src, struct sockaddr *srcaddr) break; } if (s_dst < 0) { - exit_failure("socket: %s", ERRSTR); + exit_failure("socket: %s", strerror(errno)); /*NOTREACHED*/ } if (conf->src.a.ss_family) { - if (bind(s_dst, (struct sockaddr *)&conf->src.a, + if (bind(s_dst, (const struct sockaddr *)&conf->src.a, conf->src.a.ss_len) < 0) { - exit_failure("bind: %s", ERRSTR); + exit_failure("bind: %s", strerror(errno)); /*NOTREACHED*/ } } error = setsockopt(s_dst, SOL_SOCKET, SO_OOBINLINE, &on, sizeof(on)); if (error < 0) { - exit_failure("setsockopt(SO_OOBINLINE): %s", ERRSTR); + exit_failure("setsockopt(SO_OOBINLINE): %s", strerror(errno)); /*NOTREACHED*/ } error = setsockopt(s_src, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)); if (error < 0) { - exit_failure("setsockopt(SO_SNDTIMEO): %s", ERRSTR); + exit_failure("setsockopt(SO_SNDTIMEO): %s", strerror(errno)); /*NOTREACHED*/ } error = setsockopt(s_dst, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)); if (error < 0) { - exit_failure("setsockopt(SO_SNDTIMEO): %s", ERRSTR); + exit_failure("setsockopt(SO_SNDTIMEO): %s", strerror(errno)); /*NOTREACHED*/ } error = connect(s_dst, sa4, sa4->sa_len); if (error < 0) { - exit_failure("connect: %s", ERRSTR); + exit_failure("connect: %s", strerror(errno)); /*NOTREACHED*/ } @@ -653,7 +650,7 @@ faith_prefix(struct sockaddr *dst) mib[3] = IPV6CTL_FAITH_PREFIX; size = sizeof(struct in6_addr); if (sysctl(mib, 4, &faith_prefix, &size, NULL, 0) < 0) { - exit_failure("sysctl: %s", ERRSTR); + exit_failure("sysctl: %s", strerror(errno)); /*NOTREACHED*/ } @@ -749,7 +746,8 @@ map4to6(struct sockaddr_in *dst4, struct sockaddr_in6 *dst6) hints.ai_protocol = 0; if ((ai_errno = getaddrinfo(host, serv, &hints, &res)) != 0) { - syslog(LOG_INFO, "%s %s: %s", host, serv, gai_strerror(ai_errno)); + syslog(LOG_INFO, "%s %s: %s", host, serv, + gai_strerror(ai_errno)); return 0; } @@ -787,7 +785,7 @@ start_daemon(void) #endif if (daemon(0, 0) == -1) - exit_stderr("daemon: %s", ERRSTR); + exit_stderr("daemon: %s", strerror(errno)); #ifdef SA_NOCLDWAIT memset(&sa, 0, sizeof(sa)); @@ -797,13 +795,13 @@ start_daemon(void) sigaction(SIGCHLD, &sa, (struct sigaction *)0); #else if (signal(SIGCHLD, sig_child) == SIG_ERR) { - exit_failure("signal CHLD: %s", ERRSTR); + exit_failure("signal CHLD: %s", strerror(errno)); /*NOTREACHED*/ } #endif if (signal(SIGTERM, sig_terminate) == SIG_ERR) { - exit_failure("signal TERM: %s", ERRSTR); + exit_failure("signal TERM: %s", strerror(errno)); /*NOTREACHED*/ } } @@ -848,27 +846,9 @@ exit_success(const char *fmt, ...) } #ifdef USE_ROUTE -#ifndef HAVE_GETIFADDRS -static unsigned int -if_maxindex() -{ - struct if_nameindex *p, *p0; - unsigned int max = 0; - - p0 = if_nameindex(); - for (p = p0; p && p->if_index && p->if_name; p++) { - if (max < p->if_index) - max = p->if_index; - } - if_freenameindex(p0); - return max; -} -#endif - static void grab_myaddrs() { -#ifdef HAVE_GETIFADDRS struct ifaddrs *ifap, *ifa; struct myaddrs *p; struct sockaddr_in6 *sin6; @@ -920,94 +900,6 @@ grab_myaddrs() } freeifaddrs(ifap); -#else - int s; - unsigned int maxif; - struct ifreq *iflist; - struct ifconf ifconf; - struct ifreq *ifr, *ifrp, *ifr_end; - struct myaddrs *p; - struct sockaddr_in6 *sin6; - size_t siz; - char ifrbuf[sizeof(struct ifreq) + 1024]; - - maxif = if_maxindex() + 1; - iflist = (struct ifreq *)malloc(maxif * BUFSIZ); /* XXX */ - if (!iflist) { - exit_failure("not enough core"); - /*NOTREACHED*/ - } - - if ((s = socket(PF_INET, SOCK_DGRAM, 0)) < 0) { - exit_failure("socket(SOCK_DGRAM)"); - /*NOTREACHED*/ - } - memset(&ifconf, 0, sizeof(ifconf)); - ifconf.ifc_req = iflist; - ifconf.ifc_len = maxif * BUFSIZ; /* XXX */ - if (ioctl(s, SIOCGIFCONF, &ifconf) < 0) { - exit_failure("ioctl(SIOCGIFCONF)"); - /*NOTREACHED*/ - } - close(s); - - /* Look for this interface in the list */ - ifr_end = (struct ifreq *) (ifconf.ifc_buf + ifconf.ifc_len); - for (ifrp = ifconf.ifc_req; - ifrp < ifr_end; - ifrp = (struct ifreq *)((char *)ifrp + siz)) { - memcpy(ifrbuf, ifrp, sizeof(*ifrp)); - ifr = (struct ifreq *)ifrbuf; - siz = ifr->ifr_addr.sa_len; - if (siz < sizeof(ifr->ifr_addr)) - siz = sizeof(ifr->ifr_addr); - siz += (sizeof(*ifrp) - sizeof(ifr->ifr_addr)); - if (siz > sizeof(ifrbuf)) { - /* ifr too big */ - break; - } - memcpy(ifrbuf, ifrp, siz); - - switch (ifr->ifr_addr.sa_family) { - case AF_INET: - case AF_INET6: - p = (struct myaddrs *)malloc(sizeof(struct myaddrs) - + ifr->ifr_addr.sa_len); - if (!p) { - exit_failure("not enough core"); - /*NOTREACHED*/ - } - memcpy(p + 1, &ifr->ifr_addr, ifr->ifr_addr.sa_len); - p->next = myaddrs; - p->addr = (struct sockaddr *)(p + 1); -#ifdef __KAME__ - if (ifr->ifr_addr.sa_family == AF_INET6) { - sin6 = (struct sockaddr_in6 *)p->addr; - if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr) - || IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr)) { - sin6->sin6_scope_id = - ntohs(*(u_int16_t *)&sin6->sin6_addr.s6_addr[2]); - sin6->sin6_addr.s6_addr[2] = 0; - sin6->sin6_addr.s6_addr[3] = 0; - } - } -#endif - myaddrs = p; - if (dflag) { - char hbuf[NI_MAXHOST]; - getnameinfo(p->addr, p->addr->sa_len, - hbuf, sizeof(hbuf), NULL, 0, - NI_NUMERICHOST); - syslog(LOG_INFO, "my interface: %s %s", hbuf, ifr->ifr_name); - } - break; - default: - break; - } - } - - free(iflist); -#endif } static void diff --git a/usr.sbin/faithd/faithd.h b/usr.sbin/faithd/faithd.h index 8a5021b..0efb2b8 100644 --- a/usr.sbin/faithd/faithd.h +++ b/usr.sbin/faithd/faithd.h @@ -1,4 +1,4 @@ -/* $KAME: faithd.h,v 1.6 2000/10/05 22:20:37 itojun Exp $ */ +/* $KAME: faithd.h,v 1.8 2001/09/05 03:04:21 itojun Exp $ */ /* * Copyright (C) 1997 and 1998 WIDE Project. @@ -69,6 +69,4 @@ extern void exit_failure __P((const char *, ...)) #define UC(b) (((int)b)&0xff) -#define ERRSTR strerror(errno) - #define FAITH_TIMEOUT (30 * 60) /*second*/ diff --git a/usr.sbin/faithd/ftp.c b/usr.sbin/faithd/ftp.c index 851409f..e086de6 100644 --- a/usr.sbin/faithd/ftp.c +++ b/usr.sbin/faithd/ftp.c @@ -1,4 +1,4 @@ -/* $KAME: ftp.c,v 1.10 2000/09/14 00:23:39 itojun Exp $ */ +/* $KAME: ftp.c,v 1.11 2001/07/02 14:36:49 itojun Exp $ */ /* * Copyright (C) 1997 and 1998 WIDE Project. @@ -103,7 +103,7 @@ ftp_relay(int ctl6, int ctl4) error = select(256, &readfds, NULL, NULL, &tv); if (error == -1) - exit_failure("select: %s", ERRSTR); + exit_failure("select: %s", strerror(errno)); else if (error == 0) exit_failure("connection timeout"); @@ -200,7 +200,7 @@ ftp_relay(int ctl6, int ctl4) } bad: - exit_failure(ERRSTR); + exit_failure("%s", strerror(errno)); } static int @@ -330,7 +330,7 @@ ftp_copy(int src, int dst) } bad: - exit_failure(ERRSTR); + exit_failure("%s", strerror(errno)); /*NOTREACHED*/ return 0; /* to make gcc happy */ } @@ -504,7 +504,7 @@ passivefail: error = setsockopt(wport6, IPPROTO_IPV6, IPV6_FAITH, &on, sizeof(on)); if (error == -1) - exit_failure("setsockopt(IPV6_FAITH): %s", ERRSTR); + exit_failure("setsockopt(IPV6_FAITH): %s", strerror(errno)); } #endif error = bind(wport6, (struct sockaddr *)sin6, sin6->sin6_len); @@ -626,7 +626,7 @@ passivefail2: error = setsockopt(wport6, IPPROTO_IP, IP_FAITH, &on, sizeof(on)); if (error == -1) - exit_error("setsockopt(IP_FAITH): %s", ERRSTR); + exit_error("setsockopt(IP_FAITH): %s", strerror(errno)); } #endif error = bind(wport6, (struct sockaddr *)sin, sin->sin_len); @@ -685,7 +685,7 @@ passivefail2: } bad: - exit_failure(ERRSTR); + exit_failure("%s", strerror(errno)); /*NOTREACHED*/ return 0; /* to make gcc happy */ } @@ -1119,7 +1119,7 @@ portfail: } bad: - exit_failure(ERRSTR); + exit_failure("%s", strerror(errno)); /*NOTREACHED*/ return 0; /* to make gcc happy */ } diff --git a/usr.sbin/faithd/prefix.c b/usr.sbin/faithd/prefix.c index 739ae56..a13c640 100644 --- a/usr.sbin/faithd/prefix.c +++ b/usr.sbin/faithd/prefix.c @@ -1,4 +1,4 @@ -/* $KAME: prefix.c,v 1.8 2000/11/24 06:16:56 itojun Exp $ */ +/* $KAME: prefix.c,v 1.9 2001/07/02 14:36:49 itojun Exp $ */ /* $FreeBSD$ */ /* @@ -136,8 +136,8 @@ prefix_string(prefix) static char buf[NI_MAXHOST + 20]; char hbuf[NI_MAXHOST]; - if (getnameinfo((struct sockaddr *)&prefix->a, prefix->a.ss_len, hbuf, - sizeof(hbuf), NULL, 0, niflags)) + if (getnameinfo((const struct sockaddr *)&prefix->a, prefix->a.ss_len, + hbuf, sizeof(hbuf), NULL, 0, niflags)) return NULL; snprintf(buf, sizeof(buf), "%s/%d", hbuf, prefix->l); return buf; diff --git a/usr.sbin/faithd/prefix.h b/usr.sbin/faithd/prefix.h index 3ef56e3..2a29639 100644 --- a/usr.sbin/faithd/prefix.h +++ b/usr.sbin/faithd/prefix.h @@ -1,4 +1,4 @@ -/* $KAME: prefix.h,v 1.3 2000/11/19 11:45:38 itojun Exp $ */ +/* $KAME: prefix.h,v 1.4 2001/09/05 03:04:21 itojun Exp $ */ /* $FreeBSD$ */ /* diff --git a/usr.sbin/faithd/rsh.c b/usr.sbin/faithd/rsh.c index 4e11d76..ab8e623e 100644 --- a/usr.sbin/faithd/rsh.c +++ b/usr.sbin/faithd/rsh.c @@ -1,4 +1,4 @@ -/* $KAME: rsh.c,v 1.5 2001/02/15 17:28:04 itojun Exp $ */ +/* $KAME: rsh.c,v 1.7 2001/09/05 01:10:30 itojun Exp $ */ /* * Copyright (C) 1997 and 1998 WIDE Project. @@ -69,7 +69,7 @@ rsh_relay(int s_src, int s_dst) tv.tv_usec = 0; error = select(256, &readfds, NULL, NULL, &tv); if (error == -1) - exit_failure("select %d: %s", s_src, ERRSTR); + exit_failure("select %d: %s", s_src, strerror(errno)); else if (error == 0) exit_failure("connection timeout"); @@ -102,7 +102,7 @@ relay(int src, int dst) switch (n) { case -1: - exit_failure(ERRSTR); + exit_failure("%s", strerror(errno)); case 0: if (s_rcv == src) { /* half close */ @@ -180,7 +180,7 @@ rsh_dual_relay(int s_src, int s_dst) error = select(256, &readfds, NULL, NULL, &tv); if (error == -1) - exit_failure("select 4 sockets: %s", ERRSTR); + exit_failure("select 4 sockets: %s", strerror(errno)); else if (error == 0) exit_failure("connection timeout"); @@ -208,5 +208,5 @@ rsh_dual_relay(int s_src, int s_dst) /* NOTREACHED */ bad: - exit_failure(ERRSTR); + exit_failure("%s", strerror(errno)); } diff --git a/usr.sbin/faithd/tcp.c b/usr.sbin/faithd/tcp.c index c754dfc..68a2f51 100644 --- a/usr.sbin/faithd/tcp.c +++ b/usr.sbin/faithd/tcp.c @@ -1,4 +1,4 @@ -/* $KAME: tcp.c,v 1.5 2000/09/29 03:48:31 sakane Exp $ */ +/* $KAME: tcp.c,v 1.8 2001/11/21 07:40:22 itojun Exp $ */ /* * Copyright (C) 1997 and 1998 WIDE Project. @@ -60,7 +60,7 @@ static fd_set readfds, writefds, exceptfds; static char atmark_buf[2]; static pid_t cpid = (pid_t)0; static pid_t ppid = (pid_t)0; -static time_t child_lastactive = (time_t)0; +volatile time_t child_lastactive = (time_t)0; static time_t parent_lastactive = (time_t)0; static void sig_ctimeout __P((int)); @@ -179,7 +179,7 @@ send_data(int s_rcv, int s_snd, const char *service, int direction) return; retry_or_err: if (errno != EAGAIN) - exit_failure("writing relay data failed: %s", ERRSTR); + exit_failure("writing relay data failed: %s", strerror(errno)); FD_SET(s_snd, &writefds); } @@ -210,7 +210,7 @@ relay(int s_rcv, int s_snd, const char *service, int direction) if (error == -1) { if (errno == EINTR) continue; - exit_failure("select: %s", ERRSTR); + exit_failure("select: %s", strerror(errno)); } else if (error == 0) { readfds = oreadfds; writefds = owritefds; @@ -237,7 +237,7 @@ relay(int s_rcv, int s_snd, const char *service, int direction) goto oob_read_retry; exit_failure("reading oob data failed" ": %s", - ERRSTR); + strerror(errno)); } } } @@ -251,7 +251,7 @@ relay(int s_rcv, int s_snd, const char *service, int direction) if (errno == EINTR) goto relaydata_read_retry; exit_failure("reading relay data failed: %s", - ERRSTR); + strerror(errno)); /* NOTREACHED */ case 0: /* to close opposite-direction relay process */ @@ -282,7 +282,8 @@ tcp_relay(int s_src, int s_dst, const char *service) cpid = fork(); switch (cpid) { case -1: - exit_failure("tcp_relay: can't fork grand child: %s", ERRSTR); + exit_failure("tcp_relay: can't fork grand child: %s", + strerror(errno)); /* NOTREACHED */ case 0: /* child process: relay going traffic */ -- cgit v1.1