diff options
Diffstat (limited to 'libexec')
-rw-r--r-- | libexec/fingerd/fingerd.c | 14 | ||||
-rw-r--r-- | libexec/ftpd/ftpd.c | 12 | ||||
-rw-r--r-- | libexec/rexecd/rexecd.c | 10 | ||||
-rw-r--r-- | libexec/rlogind/rlogind.c | 29 | ||||
-rw-r--r-- | libexec/rshd/rshd.c | 56 | ||||
-rw-r--r-- | libexec/telnetd/telnetd.c | 47 | ||||
-rw-r--r-- | libexec/tftpd/Makefile | 4 | ||||
-rw-r--r-- | libexec/tftpd/tftpd.c | 25 | ||||
-rw-r--r-- | libexec/uucpd/uucpd.c | 24 |
9 files changed, 51 insertions, 170 deletions
diff --git a/libexec/fingerd/fingerd.c b/libexec/fingerd/fingerd.c index 5626a21d486b..088077cdae08 100644 --- a/libexec/fingerd/fingerd.c +++ b/libexec/fingerd/fingerd.c @@ -42,10 +42,10 @@ static const char copyright[] = static char sccsid[] = "@(#)fingerd.c 8.1 (Berkeley) 6/4/93"; #endif static const char rcsid[] = - "$Id: fingerd.c,v 1.10 1997/11/20 07:26:04 charnier Exp $"; + "$Id: fingerd.c,v 1.11 1998/05/15 03:23:28 jb Exp $"; #endif /* not lint */ -#include <sys/types.h> +#include <sys/param.h> #include <sys/socket.h> #include <netinet/in.h> #include <netinet/tcp.h> @@ -70,11 +70,11 @@ main(argc, argv) register FILE *fp; register int ch; register char *lp; - struct hostent *hp; struct sockaddr_in sin; int p[2], logging, secure, sval; #define ENTRIES 50 char **ap, *av[ENTRIES + 1], **comp, line[1024], *prog; + char rhost[MAXHOSTNAMELEN + 1]; prog = _PATH_FINGER; logging = secure = 0; @@ -130,12 +130,8 @@ main(argc, argv) sval = sizeof(sin); if (getpeername(0, (struct sockaddr *)&sin, &sval) < 0) logerr("getpeername: %s", strerror(errno)); - if (hp = gethostbyaddr((char *)&sin.sin_addr.s_addr, - sizeof(sin.sin_addr.s_addr), AF_INET)) - lp = hp->h_name; - else - lp = inet_ntoa(sin.sin_addr); - syslog(LOG_NOTICE, "query from %s: `%s'", lp, t); + realhostname(rhost, sizeof rhost - 1, &sin.sin_addr); + syslog(LOG_NOTICE, "query from %s: `%s'", rhost, t); } comp = &av[1]; diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c index e844fe9fb1ac..3012fab74667 100644 --- a/libexec/ftpd/ftpd.c +++ b/libexec/ftpd/ftpd.c @@ -44,7 +44,7 @@ static char copyright[] = static char sccsid[] = "@(#)ftpd.c 8.4 (Berkeley) 4/16/94"; #endif static const char rcsid[] = - "$Id: ftpd.c,v 1.51 1998/06/03 11:33:44 jb Exp $"; + "$Id: ftpd.c,v 1.52 1998/10/13 20:42:01 des Exp $"; #endif /* not lint */ /* @@ -166,7 +166,7 @@ static struct ftphost { } *thishost, *firsthost; #endif -char remotehost[MAXHOSTNAMELEN]; +char remotehost[MAXHOSTNAMELEN + 1]; char *ident = NULL; static char ttyline[20]; @@ -1896,14 +1896,8 @@ static void dolog(sin) struct sockaddr_in *sin; { - struct hostent *hp = gethostbyaddr((char *)&sin->sin_addr, - sizeof(struct in_addr), AF_INET); + realhostname(remotehost, sizeof remotehost - 1, &sin->sin_addr); - if (hp) - (void) strncpy(remotehost, hp->h_name, sizeof(remotehost)); - else - (void) strncpy(remotehost, inet_ntoa(sin->sin_addr), - sizeof(remotehost)); #ifdef SETPROCTITLE #ifdef VIRTUAL_HOSTING if (thishost != firsthost) diff --git a/libexec/rexecd/rexecd.c b/libexec/rexecd/rexecd.c index ac7dca9b18fb..740368f323dd 100644 --- a/libexec/rexecd/rexecd.c +++ b/libexec/rexecd/rexecd.c @@ -42,7 +42,7 @@ static const char copyright[] = static char sccsid[] = "@(#)rexecd.c 8.1 (Berkeley) 6/4/93"; #endif static const char rcsid[] = - "$Id$"; + "$Id: rexecd.c,v 1.15 1997/11/26 07:29:04 charnier Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -55,6 +55,7 @@ static const char rcsid[] = #include <err.h> #include <netdb.h> +#include <libutil.h> #include <paths.h> #include <pwd.h> #include <signal.h> @@ -72,7 +73,7 @@ char path[sizeof(_PATH_DEFPATH) + sizeof("PATH=")] = "PATH="; char *envinit[] = {homedir, shell, path, username, 0}; char **environ; -char *remote; +char remote[MAXHOSTNAMELEN + 1]; struct sockaddr_in asin = { AF_INET }; @@ -103,10 +104,7 @@ main(argc, argv) if (getpeername(0, (struct sockaddr *)&from, &fromlen) < 0) err(1, "getpeername"); - hp = gethostbyaddr((char *) &from.sin_addr, sizeof(from.sin_addr), - from.sin_family); - remote = inet_ntoa(from.sin_addr); - remote = (hp != NULL) ? hp->h_name : inet_ntoa(from.sin_addr); + realhostname(remote, sizeof remote - 1, &from.sin_addr); doit(0, &from); return(0); diff --git a/libexec/rlogind/rlogind.c b/libexec/rlogind/rlogind.c index 64cf70fa68c7..a7cdba54a6cd 100644 --- a/libexec/rlogind/rlogind.c +++ b/libexec/rlogind/rlogind.c @@ -42,7 +42,7 @@ static const char copyright[] = static const char sccsid[] = "@(#)rlogind.c 8.1 (Berkeley) 6/4/93"; #endif static const char rcsid[] = - "$Id: rlogind.c,v 1.19 1997/11/25 07:17:15 charnier Exp $"; + "$Id: rlogind.c,v 1.20 1998/12/16 07:20:44 peter Exp $"; #endif /* not lint */ /* @@ -211,7 +211,6 @@ doit(f, fromp) { int master, pid, on = 1; int authenticated = 0; - register struct hostent *hp; char hostname[2 * MAXHOSTNAMELEN + 1]; char c; @@ -227,31 +226,7 @@ doit(f, fromp) alarm(0); fromp->sin_port = ntohs((u_short)fromp->sin_port); - hp = gethostbyaddr((char *)&fromp->sin_addr, sizeof(struct in_addr), - fromp->sin_family); - if (hp) { - strncpy(hostname, hp->h_name, sizeof(hostname) - 1); - hostname[sizeof(hostname) - 1] = '\0'; - hp = gethostbyname(hostname); - if (hp == NULL) { - strncpy(hostname, inet_ntoa(fromp->sin_addr), - sizeof(hostname) - 1); - } else for (; ; hp->h_addr_list++) { - if (hp->h_addr_list[0] == NULL) { - /* End of list - ditch it */ - strncpy(hostname, inet_ntoa(fromp->sin_addr), - sizeof(hostname) - 1); - break; - } - if (!bcmp(hp->h_addr_list[0], - (caddr_t)&fromp->sin_addr, - sizeof(fromp->sin_addr))) - break; /* OK! */ - } - } else { - strncpy(hostname, inet_ntoa(fromp->sin_addr), - sizeof(hostname) - 1); - } + realhostname(hostname, sizeof hostname - 1, &fromp->sin_addr); hostname[sizeof(hostname) - 1] = '\0'; #ifdef KERBEROS diff --git a/libexec/rshd/rshd.c b/libexec/rshd/rshd.c index cd2f57c36a1f..5ed7437bb495 100644 --- a/libexec/rshd/rshd.c +++ b/libexec/rshd/rshd.c @@ -42,7 +42,7 @@ static const char copyright[] = static const char sccsid[] = "@(#)rshd.c 8.2 (Berkeley) 4/6/94"; #endif static const char rcsid[] = - "$Id: rshd.c,v 1.22 1998/12/01 23:27:24 dg Exp $"; + "$Id: rshd.c,v 1.23 1998/12/16 07:20:45 peter Exp $"; #endif /* not lint */ /* @@ -67,6 +67,7 @@ static const char rcsid[] = #include <errno.h> #include <fcntl.h> +#include <libutil.h> #include <paths.h> #include <pwd.h> #include <signal.h> @@ -207,13 +208,12 @@ doit(fromp) struct sockaddr_in *fromp; { extern char *__rcmd_errstr; /* syslog hook from libc/net/rcmd.c. */ - struct hostent *hp; struct passwd *pwd; u_short port; fd_set ready, readfrom; int cc, nfd, pv[2], pid, s; int one = 1; - char *hostname, *errorstr; + char *errorstr; char *cp, sig, buf[BUFSIZ]; char cmdbuf[NCARGS+1], locuser[16], remuser[16]; char fromhost[2 * MAXHOSTNAMELEN + 1]; @@ -350,36 +350,8 @@ doit(fromp) errorstr = NULL; strncpy(fromhost, inet_ntoa(fromp->sin_addr), sizeof(fromhost) - 1); - hostname = fromhost; - hp = gethostbyaddr((char *)&fromp->sin_addr, sizeof (struct in_addr), - fromp->sin_family); - if (hp) { - /* - * OK, it looks like a DNS name is attached.. Lets see if - * it looks like we can use it. If it doesn't check out, - * ditch it and use the IP address for logging instead. - * Note that iruserok() does it's own hostname checking!! - */ - strncpy(fromhost, hp->h_name, sizeof(fromhost) - 1); - fromhost[sizeof(fromhost) - 1] = 0; - hp = gethostbyname(fromhost); - if (hp == NULL) { - strncpy(fromhost, inet_ntoa(fromp->sin_addr), - sizeof(fromhost) - 1); - } else for (; ; hp->h_addr_list++) { - if (hp->h_addr_list[0] == NULL) { - /* End of list - ditch it */ - strncpy(fromhost, inet_ntoa(fromp->sin_addr), - sizeof(fromhost) - 1); - break; - } - if (!bcmp(hp->h_addr_list[0], - (caddr_t)&fromp->sin_addr, - sizeof(fromp->sin_addr))) - break; /* OK! */ - } - } - fromhost[sizeof(fromhost) - 1] = 0; + realhostname(fromhost, sizeof fromhost - 1, &fromp->sin_addr); + fromhost[sizeof(fromhost) - 1] = '\0'; #ifdef KERBEROS if (use_kerberos) { @@ -426,7 +398,7 @@ doit(fromp) if (pwd == NULL) { syslog(LOG_INFO|LOG_AUTH, "%s@%s as %s: unknown login. cmd='%.80s'", - remuser, hostname, locuser, cmdbuf); + remuser, fromhost, locuser, cmdbuf); if (errorstr == NULL) errorstr = "Login incorrect.\n"; goto fail; @@ -440,7 +412,7 @@ doit(fromp) login_getcapbool(lc, "requirehome", !!pwd->pw_uid)) { syslog(LOG_INFO|LOG_AUTH, "%s@%s as %s: no home directory. cmd='%.80s'", - remuser, hostname, locuser, cmdbuf); + remuser, fromhost, locuser, cmdbuf); error("No remote home directory.\n"); exit(0); } @@ -449,7 +421,7 @@ doit(fromp) #ifdef notdef syslog(LOG_INFO|LOG_AUTH, "%s@%s as %s: no home directory. cmd='%.80s'", - remuser, hostname, locuser, cmdbuf); + remuser, fromhost, locuser, cmdbuf); error("No remote directory.\n"); exit(1); #endif @@ -479,16 +451,16 @@ doit(fromp) if (__rcmd_errstr) syslog(LOG_INFO|LOG_AUTH, "%s@%s as %s: permission denied (%s). cmd='%.80s'", - remuser, hostname, locuser, __rcmd_errstr, + remuser, fromhost, locuser, __rcmd_errstr, cmdbuf); else syslog(LOG_INFO|LOG_AUTH, "%s@%s as %s: permission denied. cmd='%.80s'", - remuser, hostname, locuser, cmdbuf); + remuser, fromhost, locuser, cmdbuf); fail: if (errorstr == NULL) errorstr = "Login incorrect.\n"; - error(errorstr, hostname); + error(errorstr, fromhost); exit(1); } @@ -506,7 +478,7 @@ fail: if (!auth_hostok(lc, fromhost, remote_ip)) { syslog(LOG_INFO|LOG_AUTH, "%s@%s as %s: permission denied (%s). cmd='%.80s'", - remuser, hostname, locuser, __rcmd_errstr, + remuser, fromhost, locuser, __rcmd_errstr, cmdbuf); error("Login incorrect.\n"); exit(1); @@ -729,11 +701,11 @@ fail: syslog(LOG_INFO|LOG_AUTH, "Kerberos shell from %s.%s@%s on %s as %s, cmd='%.80s'", kdata->pname, kdata->pinst, kdata->prealm, - hostname, locuser, cmdbuf); + fromhost, locuser, cmdbuf); else #endif syslog(LOG_INFO|LOG_AUTH, "%s@%s as %s: cmd='%.80s'", - remuser, hostname, locuser, cmdbuf); + remuser, fromhost, locuser, cmdbuf); } execl(pwd->pw_shell, cp, "-c", cmdbuf, 0); perror(pwd->pw_shell); diff --git a/libexec/telnetd/telnetd.c b/libexec/telnetd/telnetd.c index c825eab64575..8baaaf49328b 100644 --- a/libexec/telnetd/telnetd.c +++ b/libexec/telnetd/telnetd.c @@ -42,7 +42,7 @@ static const char copyright[] = static char sccsid[] = "@(#)telnetd.c 8.2 (Berkeley) 12/15/93"; #endif static const char rcsid[] = - "$Id: telnetd.c,v 1.15 1998/12/16 06:04:29 peter Exp $"; + "$Id: telnetd.c,v 1.16 1999/04/06 00:29:41 brian Exp $"; #endif /* not lint */ #include "telnetd.h" @@ -61,6 +61,8 @@ static const char rcsid[] = #include <arpa/inet.h> #include <sys/mman.h> +#include <libutil.h> +#include <utmp.h> #if defined(_SC_CRAY_SECURE_SYS) #include <sys/sysv.h> @@ -756,7 +758,7 @@ terminaltypeok(s) char *hostname; char host_name[MAXHOSTNAMELEN]; -char remote_host_name[MAXHOSTNAMELEN]; +char remote_hostname[UT_HOSTSIZE + 1]; extern void telnet P((int, int, char *)); @@ -769,8 +771,6 @@ char user_name[256]; doit(who) struct sockaddr_in *who; { - char *host = NULL; - struct hostent *hp; int ptynum; /* @@ -813,47 +813,16 @@ doit(who) #endif /* _SC_CRAY_SECURE_SYS */ /* get name of connected client */ - hp = gethostbyaddr((char *)&who->sin_addr, sizeof (struct in_addr), - who->sin_family); - - if (hp == NULL && registerd_host_only) { + if (realhostname(remote_hostname, sizeof remote_hostname - 1, + &who->sin_addr) == HOSTNAME_INVALIDADDR && registerd_host_only) fatal(net, "Couldn't resolve your address into a host name.\r\n\ Please contact your net administrator"); - } else if (hp && - (strlen(hp->h_name) <= ((utmp_len < 0) ? -utmp_len : utmp_len))) { - strncpy(remote_host_name, hp->h_name, - sizeof(remote_host_name)-1); - hp = gethostbyname(remote_host_name); - if (hp == NULL) - host = inet_ntoa(who->sin_addr); - else for (; ; hp->h_addr_list++) { - if (hp->h_addr_list[0] == NULL) { - /* End of list - ditch it */ - host = inet_ntoa(who->sin_addr); - break; - } - if (!bcmp(hp->h_addr_list[0], (caddr_t)&who->sin_addr, - sizeof(who->sin_addr))) { - host = hp->h_name; - break; /* OK! */ - } - } - } else { - host = inet_ntoa(who->sin_addr); - } - /* - * We must make a copy because Kerberos is probably going - * to also do a gethost* and overwrite the static data... - */ - strncpy(remote_host_name, host, sizeof(remote_host_name)-1); - remote_host_name[sizeof(remote_host_name)-1] = 0; - host = remote_host_name; (void) gethostname(host_name, sizeof (host_name)); hostname = host_name; #if defined(AUTHENTICATION) - auth_encrypt_init(hostname, host, "TELNETD", 1); + auth_encrypt_init(hostname, remote_hostname, "TELNETD", 1); #endif init_env(); @@ -873,7 +842,7 @@ doit(who) } #endif /* _SC_CRAY_SECURE_SYS */ - telnet(net, pty, host); /* begin server process */ + telnet(net, pty, remote_hostname); /* begin server process */ /*NOTREACHED*/ } /* end of doit */ diff --git a/libexec/tftpd/Makefile b/libexec/tftpd/Makefile index b7c600c41955..301a0d736ae6 100644 --- a/libexec/tftpd/Makefile +++ b/libexec/tftpd/Makefile @@ -1,8 +1,10 @@ # @(#)Makefile 8.1 (Berkeley) 6/4/93 -# $Id$ +# $Id: Makefile,v 1.5 1997/02/22 14:22:35 peter Exp $ PROG= tftpd SRCS= tftpd.c tftpsubs.c +DPADD= ${LIBUTIL} +LDADD= -lutil MAN8= tftpd.8 CFLAGS+=-I${.CURDIR}/../../usr.bin/tftp .PATH: ${.CURDIR}/../../usr.bin/tftp diff --git a/libexec/tftpd/tftpd.c b/libexec/tftpd/tftpd.c index d0499c9b19ce..f1f8a9a78098 100644 --- a/libexec/tftpd/tftpd.c +++ b/libexec/tftpd/tftpd.c @@ -42,7 +42,7 @@ static const char copyright[] = static char sccsid[] = "@(#)tftpd.c 8.1 (Berkeley) 6/4/93"; #endif static const char rcsid[] = - "$Id: tftpd.c,v 1.11 1998/04/12 11:15:54 phk Exp $"; + "$Id: tftpd.c,v 1.12 1998/10/30 16:17:39 dg Exp $"; #endif /* not lint */ /* @@ -65,6 +65,7 @@ static const char rcsid[] = #include <ctype.h> #include <errno.h> #include <fcntl.h> +#include <libutil.h> #include <netdb.h> #include <pwd.h> #include <setjmp.h> @@ -108,7 +109,6 @@ static int logging; static char *errtomsg __P((int)); static void nak __P((int)); -static char *verifyhost __P((struct sockaddr_in *)); int main(argc, argv) @@ -325,8 +325,11 @@ again: } ecode = (*pf->f_validate)(&filename, tp->th_opcode); if (logging) { - syslog(LOG_INFO, "%s: %s request for %s: %s", - verifyhost(&from), + char host[MAXHOSTNAMELEN + 1]; + + realhostname(host, sizeof host - 1, &from.sin_addr); + host[sizeof host - 1] = '\0'; + syslog(LOG_INFO, "%s: %s request for %s: %s", host, tp->th_opcode == WRQ ? "write" : "read", filename, errtomsg(ecode)); } @@ -670,17 +673,3 @@ nak(error) if (send(peer, buf, length, 0) != length) syslog(LOG_ERR, "nak: %m"); } - -static char * -verifyhost(fromp) - struct sockaddr_in *fromp; -{ - struct hostent *hp; - - hp = gethostbyaddr((char *)&fromp->sin_addr, sizeof (fromp->sin_addr), - fromp->sin_family); - if (hp) - return hp->h_name; - else - return inet_ntoa(fromp->sin_addr); -} diff --git a/libexec/uucpd/uucpd.c b/libexec/uucpd/uucpd.c index 59a69320b022..e15c05b3bea2 100644 --- a/libexec/uucpd/uucpd.c +++ b/libexec/uucpd/uucpd.c @@ -45,7 +45,7 @@ static const char copyright[] = static char sccsid[] = "@(#)uucpd.c 8.1 (Berkeley) 6/4/93"; #endif static const char rcsid[] = - "$Id: uucpd.c,v 1.15 1998/06/30 15:19:51 bde Exp $"; + "$Id: uucpd.c,v 1.16 1999/03/30 10:23:35 joerg Exp $"; #endif /* not lint */ /* @@ -121,16 +121,8 @@ void main(int argc, char **argv) void badlogin(char *name, struct sockaddr_in *sin) { char remotehost[MAXHOSTNAMELEN]; - struct hostent *hp = gethostbyaddr((char *)&sin->sin_addr, - sizeof (struct in_addr), AF_INET); - - if (hp) { - strncpy(remotehost, hp->h_name, sizeof (remotehost)); - endhostent(); - } else - strncpy(remotehost, inet_ntoa(sin->sin_addr), - sizeof (remotehost)); + realhostname(remotehost, sizeof remotehost - 1, &sin->sin_addr); remotehost[sizeof remotehost - 1] = '\0'; syslog(LOG_NOTICE, "LOGIN FAILURE FROM %s", remotehost); @@ -251,19 +243,13 @@ void dologout(void) void dologin(struct passwd *pw, struct sockaddr_in *sin) { char line[32]; - char remotehost[MAXHOSTNAMELEN]; + char remotehost[UT_HOSTSIZE + 1]; int f; time_t cur_time; - struct hostent *hp = gethostbyaddr((char *)&sin->sin_addr, - sizeof (struct in_addr), AF_INET); - if (hp) { - strncpy(remotehost, hp->h_name, sizeof (remotehost)); - endhostent(); - } else - strncpy(remotehost, inet_ntoa(sin->sin_addr), - sizeof (remotehost)); + realhostname(remotehost, sizeof remotehost - 1, &sin->sin_addr); remotehost[sizeof remotehost - 1] = '\0'; + /* hack, but must be unique and no tty line */ sprintf(line, "uucp%ld", (long)getpid()); time(&cur_time); |