diff options
-rw-r--r-- | libexec/identd/identd.c | 27 | ||||
-rw-r--r-- | libexec/identd/identd.h | 5 | ||||
-rw-r--r-- | libexec/identd/parse.c | 30 |
3 files changed, 42 insertions, 20 deletions
diff --git a/libexec/identd/identd.c b/libexec/identd/identd.c index fd6fce83c3a..befb10e31bb 100644 --- a/libexec/identd/identd.c +++ b/libexec/identd/identd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: identd.c,v 1.18 2001/04/15 23:48:15 hugh Exp $ */ +/* $OpenBSD: identd.c,v 1.19 2001/08/08 07:02:42 deraadt Exp $ */ /* * This program is in the public domain and may be used freely by anyone @@ -76,7 +76,7 @@ usage() * Return the name of the connecting host, or the IP number as a string. */ char * -gethost(addr) +gethost4_addr(addr) struct in_addr *addr; { struct hostent *hp; @@ -87,6 +87,27 @@ gethost(addr) return inet_ntoa(*addr); } +char * +gethost(ss) + struct sockaddr_storage *ss; +{ + if (ss->ss_family == AF_INET6) + return (gethost6((struct sockaddr_in6 *)ss)); + return (gethost4((struct sockaddr_in *)ss)); +} + +char * +gethost4(sin) + struct sockaddr_in *sin; +{ + struct hostent *hp; + + hp = gethostbyaddr((char *)&sin->sin_addr, sizeof(struct in_addr), AF_INET); + if (hp) + return hp->h_name; + return inet_ntoa(sin->sin_addr); +} + /* * Return the name of the connecting host, or the IP number as a string. */ @@ -432,7 +453,7 @@ main(argc, argv) #else openlog("identd", LOG_PID); #endif - syslog(LOG_INFO, "Connection from %s", gethost(&faddr)); + syslog(LOG_INFO, "Connection from %s", gethost(&sa)); } /* * Get local internet address diff --git a/libexec/identd/identd.h b/libexec/identd/identd.h index a0f0e2f9ee8..45093c544df 100644 --- a/libexec/identd/identd.h +++ b/libexec/identd/identd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: identd.h,v 1.8 2001/04/15 23:48:16 hugh Exp $*/ +/* $OpenBSD: identd.h,v 1.9 2001/08/08 07:02:42 deraadt Exp $*/ /* ** @@ -41,7 +41,8 @@ extern int fport; int parse __P((int, struct in_addr *, struct in_addr *)); int parse6 __P((int, struct sockaddr_in6 *, struct sockaddr_in6 *)); -char *gethost __P((struct in_addr *)); +char *gethost4 __P((struct sockaddr_in *)); +char *gethost4_addr __P((struct in_addr *)); char *gethost6 __P((struct sockaddr_in6 *)); int k_getuid __P((struct in_addr *, int, struct in_addr *, int, uid_t *)); int k_getuid6 __P((struct sockaddr_in6 *, int, struct sockaddr_in6 *, diff --git a/libexec/identd/parse.c b/libexec/identd/parse.c index 21e89c5493c..bbb714ad9d4 100644 --- a/libexec/identd/parse.c +++ b/libexec/identd/parse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.c,v 1.25 2001/08/08 06:46:09 deraadt Exp $ */ +/* $OpenBSD: parse.c,v 1.26 2001/08/08 07:02:42 deraadt Exp $ */ /* * This program is in the public domain and may be used freely by anyone @@ -202,7 +202,7 @@ parse(fd, laddr, faddr) if (debug_flag && syslog_flag) syslog(LOG_DEBUG, "In function parse(), from %s to %s", - gethost(faddr), gethost(laddr)); + gethost4_addr(faddr), gethost4_addr(laddr)); if (debug_flag && syslog_flag) syslog(LOG_DEBUG, " Before read from remote host"); @@ -215,11 +215,11 @@ parse(fd, laddr, faddr) if (syslog_flag) syslog(LOG_NOTICE, n ? "read from %s: %m" : "read from %s: EOF", - gethost(faddr)); + gethost4_addr(faddr)); n = snprintf(buf, sizeof(buf), "%d , %d : ERROR : UNKNOWN-ERROR\r\n", lport, fport); if (timed_write(fd, buf, n, IO_TIMEOUT) != n && syslog_flag) { - syslog(LOG_NOTICE, "write to %s: %m", gethost(faddr)); + syslog(LOG_NOTICE, "write to %s: %m", gethost4_addr(faddr)); return 1; } return 0; @@ -240,18 +240,18 @@ parse(fd, laddr, faddr) if (syslog_flag) syslog(LOG_NOTICE, "scanf: invalid-port(s): %d , %d from %s", - lport, fport, gethost(faddr)); + lport, fport, gethost4_addr(faddr)); n = snprintf(buf, sizeof(buf), "%d , %d : ERROR : %s\r\n", lport, fport, unknown_flag ? "UNKNOWN-ERROR" : "INVALID-PORT"); if (timed_write(fd, buf, n, IO_TIMEOUT) != n && syslog_flag) { - syslog(LOG_NOTICE, "write to %s: %m", gethost(faddr)); + syslog(LOG_NOTICE, "write to %s: %m", gethost4_addr(faddr)); return 1; } return 0; } if (syslog_flag && verbose_flag) syslog(LOG_NOTICE, "request for (%d,%d) from %s", - lport, fport, gethost(faddr)); + lport, fport, gethost4_addr(faddr)); if (debug_flag && syslog_flag) syslog(LOG_DEBUG, " After fscanf(), before k_getuid()"); @@ -268,7 +268,7 @@ parse(fd, laddr, faddr) n = snprintf(buf, sizeof(buf), "%d , %d : ERROR : %s\r\n", lport, fport, unknown_flag ? "UNKNOWN-ERROR" : "NO-USER"); if (timed_write(fd, buf, n, IO_TIMEOUT) != n && syslog_flag) { - syslog(LOG_NOTICE, "write to %s: %m", gethost(faddr)); + syslog(LOG_NOTICE, "write to %s: %m", gethost4_addr(faddr)); return 1; } return 0; @@ -286,7 +286,7 @@ parse(fd, laddr, faddr) "%d , %d : USERID : %s%s%s :%d\r\n", lport, fport, opsys_name, charset_sep, charset_name, uid); if (timed_write(fd, buf, n, IO_TIMEOUT) != n && syslog_flag) { - syslog(LOG_NOTICE, "write to %s: %m", gethost(faddr)); + syslog(LOG_NOTICE, "write to %s: %m", gethost4_addr(faddr)); return 1; } return 0; @@ -300,11 +300,11 @@ parse(fd, laddr, faddr) if (syslog_flag && verbose_flag) syslog(LOG_NOTICE, "user %s requested HIDDEN-USER for host %s: %d, %d", - pw->pw_name, gethost(faddr), lport, fport); + pw->pw_name, gethost4_addr(faddr), lport, fport); n = snprintf(buf, sizeof(buf), "%d , %d : ERROR : HIDDEN-USER\r\n", lport, fport); if (timed_write(fd, buf, n, IO_TIMEOUT) != n && syslog_flag) { - syslog(LOG_NOTICE, "write to %s: %m", gethost(faddr)); + syslog(LOG_NOTICE, "write to %s: %m", gethost4_addr(faddr)); return 1; } return 0; @@ -317,7 +317,7 @@ parse(fd, laddr, faddr) "%d , %d : USERID : %s%s%s :%s\r\n", lport, fport, opsys_name, charset_sep, charset_name, token); if (timed_write(fd, buf, n, IO_TIMEOUT) != n && syslog_flag) { - syslog(LOG_NOTICE, "write to %s: %m", gethost(faddr)); + syslog(LOG_NOTICE, "write to %s: %m", gethost4_addr(faddr)); return 1; } return 0; @@ -331,7 +331,7 @@ parse(fd, laddr, faddr) "%d , %d : USERID : %s%s%s :%s\r\n", lport, fport, opsys_name, charset_sep, charset_name, token); if (timed_write(fd, buf, n, IO_TIMEOUT) != n && syslog_flag) { - syslog(LOG_NOTICE, "write to %s: %m", gethost(faddr)); + syslog(LOG_NOTICE, "write to %s: %m", gethost4_addr(faddr)); return 1; } return 0; @@ -342,7 +342,7 @@ parse(fd, laddr, faddr) "%d , %d : USERID : %s%s%s :%d\r\n", lport, fport, opsys_name, charset_sep, charset_name, uid); if (timed_write(fd, buf, n, IO_TIMEOUT) != n && syslog_flag) { - syslog(LOG_NOTICE, "write to %s: %m", gethost(faddr)); + syslog(LOG_NOTICE, "write to %s: %m", gethost4_addr(faddr)); return 1; } return 0; @@ -350,7 +350,7 @@ parse(fd, laddr, faddr) n = snprintf(buf, sizeof(buf), "%d , %d : USERID : %s%s%s :%s\r\n", lport, fport, opsys_name, charset_sep, charset_name, pw->pw_name); if (timed_write(fd, buf, n, IO_TIMEOUT) != n && syslog_flag) { - syslog(LOG_NOTICE, "write to %s: %m", gethost(faddr)); + syslog(LOG_NOTICE, "write to %s: %m", gethost4_addr(faddr)); return 1; } return 0; |