From: Ken Raeburn Date: Wed, 6 Dec 2000 09:46:49 +0000 (+0000) Subject: make pty_make_sane_hostname take sockaddr* arg instead of sockaddr_in* X-Git-Tag: krb5-1.3-alpha1~1739 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=80bbdfbc60404dd2edcd7c4512fd3bcd17073d00;p=krb5.git make pty_make_sane_hostname take sockaddr* arg instead of sockaddr_in* git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@12883 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/appl/bsd/ChangeLog b/src/appl/bsd/ChangeLog index 71130f23d..05c91afb1 100644 --- a/src/appl/bsd/ChangeLog +++ b/src/appl/bsd/ChangeLog @@ -1,3 +1,9 @@ +2000-12-06 Ken Raeburn + + * krlogind.c (doit): Cast first argument to pty_make_sane_hostname + to sockaddr pointer. + * krshd.c (doit): Likewise. + 2000-11-01 Ezra Peisach * configure.in: Update to autoconf 2 macro names: diff --git a/src/appl/bsd/krlogind.c b/src/appl/bsd/krlogind.c index b3102bd18..88446b3b3 100644 --- a/src/appl/bsd/krlogind.c +++ b/src/appl/bsd/krlogind.c @@ -812,7 +812,7 @@ void doit(f, fromp) setenv("TERM",term, 1); } - retval = pty_make_sane_hostname(fromp, maxhostlen, + retval = pty_make_sane_hostname((struct sockaddr *) fromp, maxhostlen, stripdomain, always_ip, &rhost_sane); if (retval) diff --git a/src/appl/bsd/krshd.c b/src/appl/bsd/krshd.c index cb745e307..b2b490902 100644 --- a/src/appl/bsd/krshd.c +++ b/src/appl/bsd/krshd.c @@ -778,7 +778,7 @@ void doit(f, fromp) hostname[0] = '\0'; #ifdef KERBEROS - status = pty_make_sane_hostname(fromp, maxhostlen, + status = pty_make_sane_hostname((struct sockaddr *) fromp, maxhostlen, stripdomain, always_ip, &sane_host); if (status) { error("failed make_sane_hostname: %s\n", error_message(status)); diff --git a/src/appl/gssftp/ftpd/ChangeLog b/src/appl/gssftp/ftpd/ChangeLog index 1273af0df..94ea81743 100644 --- a/src/appl/gssftp/ftpd/ChangeLog +++ b/src/appl/gssftp/ftpd/ChangeLog @@ -1,3 +1,8 @@ +2000-12-06 Ken Raeburn + + * ftpd.c (dolog): Cast first argument to pty_make_sane_hostname to + sockaddr pointer. + 2000-10-16 Ezra Peisach * ftpd.c (reply): For gssapi connection, do not include NULL in diff --git a/src/appl/gssftp/ftpd/ftpd.c b/src/appl/gssftp/ftpd/ftpd.c index 680c1844e..eefd3cb2a 100644 --- a/src/appl/gssftp/ftpd/ftpd.c +++ b/src/appl/gssftp/ftpd/ftpd.c @@ -1980,7 +1980,7 @@ dolog(sin) remotehost[0] = '\0'; strncpy(rhost_addra, inet_ntoa(sin->sin_addr), sizeof (rhost_addra)); rhost_addra[sizeof (rhost_addra) - 1] = '\0'; - retval = pty_make_sane_hostname(sin, maxhostlen, + retval = pty_make_sane_hostname((struct sockaddr *) sin, maxhostlen, stripdomain, always_ip, &rhost_sane); if (retval) { fprintf(stderr, "make_sane_hostname: %s\n", diff --git a/src/appl/telnet/telnetd/ChangeLog b/src/appl/telnet/telnetd/ChangeLog index f409ed411..c815eb0c4 100644 --- a/src/appl/telnet/telnetd/ChangeLog +++ b/src/appl/telnet/telnetd/ChangeLog @@ -1,3 +1,8 @@ +2000-12-06 Ken Raeburn + + * telnetd.c (doit): Cast pty_make_sane_hostname first argument to + sockaddr pointer. + 2000-11-01 Ezra Peisach * configure.in: Use AC_CHECK_HEADER and AC_CHECK_FUNC instead of diff --git a/src/appl/telnet/telnetd/telnetd.c b/src/appl/telnet/telnetd/telnetd.c index f103488cb..9a3dd3b7b 100644 --- a/src/appl/telnet/telnetd/telnetd.c +++ b/src/appl/telnet/telnetd/telnetd.c @@ -987,7 +987,7 @@ pty_init(); } #endif /* _SC_CRAY_SECURE_SYS */ - retval = pty_make_sane_hostname(who, maxhostlen, + retval = pty_make_sane_hostname((struct sockaddr *) who, maxhostlen, stripdomain, always_ip, &rhost_sane); if (retval) { diff --git a/src/util/pty/ChangeLog b/src/util/pty/ChangeLog index a6e1b80f8..a7db011b0 100644 --- a/src/util/pty/ChangeLog +++ b/src/util/pty/ChangeLog @@ -1,3 +1,9 @@ +2000-12-06 Ken Raeburn + + * sane_hostname.c (pty_make_sane_hostname, do_ntoa): Pass address + as sockaddr pointer. + * libpty.h (pty_make_sane_hostname): Update prototype. + 2000-11-01 Ezra Peisach * configure.in: Quote macro use inside AC_CHECK_LIB. Change diff --git a/src/util/pty/libpty.h b/src/util/pty/libpty.h index 5fccf016d..5e1200bf5 100644 --- a/src/util/pty/libpty.h +++ b/src/util/pty/libpty.h @@ -49,7 +49,7 @@ long pty_cleanup(char *slave, int pid, int update_utmp); struct sockaddr_in; #endif -long pty_make_sane_hostname(struct sockaddr_in *, int, int, int, char **); +long pty_make_sane_hostname(struct sockaddr *, int, int, int, char **); #else /*__STDC__*/ long pty_init(); long pty_getpty(); diff --git a/src/util/pty/sane_hostname.c b/src/util/pty/sane_hostname.c index 43814df53..23955c06d 100644 --- a/src/util/pty/sane_hostname.c +++ b/src/util/pty/sane_hostname.c @@ -2,7 +2,7 @@ * pty_make_sane_hostname: Make a sane hostname from an IP address. * This returns allocated memory! * - * Copyright 1999 by the Massachusetts Institute of Technology. + * Copyright 1999,2000 by the Massachusetts Institute of Technology. * * Permission to use, copy, modify, and distribute this software and * its documentation for any purpose and without fee is hereby @@ -25,17 +25,21 @@ #include static long -do_ntoa(struct sockaddr_in *addr, +do_ntoa(struct sockaddr *addr, size_t hostlen, char **out) { - strncpy(*out, inet_ntoa(addr->sin_addr), hostlen); + if (addr->sa_family == AF_INET) + strncpy(*out, inet_ntoa(((struct sockaddr_in *)addr)->sin_addr), + hostlen); + else + strncpy(*out, "??", hostlen); (*out)[hostlen - 1] = '\0'; return 0; } long -pty_make_sane_hostname(struct sockaddr_in *addr, +pty_make_sane_hostname(struct sockaddr *addr, int maxlen, int strip_ldomain, int always_ipaddr, @@ -69,8 +73,11 @@ pty_make_sane_hostname(struct sockaddr_in *addr, if (always_ipaddr) { return do_ntoa(addr, ut_host_len, out); } - hp = gethostbyaddr((char *)&addr->sin_addr, sizeof (struct in_addr), - addr->sin_family); + if (addr->sa_family == AF_INET) + hp = gethostbyaddr((char *)&((struct sockaddr_in *)addr)->sin_addr, + sizeof (struct in_addr), addr->sa_family); + else + hp = NULL; if (hp == NULL) { return do_ntoa(addr, ut_host_len, out); }