diff options
author | assar <assar@FreeBSD.org> | 2001-06-21 02:12:07 +0000 |
---|---|---|
committer | assar <assar@FreeBSD.org> | 2001-06-21 02:12:07 +0000 |
commit | 0c8fa354358381b3f1b92598e7f1b46f8cf744cc (patch) | |
tree | ed28ffb73cc0ae48a9892dab3f10b09bc36436d5 /crypto/heimdal/appl/telnet/telnetd/telnetd.c | |
parent | 06c859ecf534f468a52f24a3eb14409d73a4907c (diff) | |
download | FreeBSD-src-0c8fa354358381b3f1b92598e7f1b46f8cf744cc.zip FreeBSD-src-0c8fa354358381b3f1b92598e7f1b46f8cf744cc.tar.gz |
import of heimdal 0.3f
Diffstat (limited to 'crypto/heimdal/appl/telnet/telnetd/telnetd.c')
-rw-r--r-- | crypto/heimdal/appl/telnet/telnetd/telnetd.c | 65 |
1 files changed, 34 insertions, 31 deletions
diff --git a/crypto/heimdal/appl/telnet/telnetd/telnetd.c b/crypto/heimdal/appl/telnet/telnetd/telnetd.c index b788574..af63ce1 100644 --- a/crypto/heimdal/appl/telnet/telnetd/telnetd.c +++ b/crypto/heimdal/appl/telnet/telnetd/telnetd.c @@ -33,7 +33,7 @@ #include "telnetd.h" -RCSID("$Id: telnetd.c,v 1.63 2000/10/08 13:32:28 assar Exp $"); +RCSID("$Id: telnetd.c,v 1.64 2001/02/08 16:06:27 assar Exp $"); #ifdef _SC_CRAY_SECURE_SYS #include <sys/sysv.h> @@ -289,9 +289,14 @@ main(int argc, char **argv) #endif break; - case 'u': - utmp_len = atoi(optarg); + case 'u': { + char *eptr; + + utmp_len = strtol(optarg, &eptr, 0); + if (optarg == eptr) + fprintf(stderr, "telnetd: unknown utmp len (%s)\n", optarg); break; + } case 'U': registerd_host_only = 1; @@ -490,7 +495,6 @@ int getterminaltype(char *name, size_t name_sz) { int retval = -1; - void _gettermname(); settimer(baseline); #ifdef AUTHENTICATION @@ -629,7 +633,7 @@ getterminaltype(char *name, size_t name_sz) } /* end of getterminaltype */ void -_gettermname() +_gettermname(void) { /* * If the client turned off the option, @@ -653,9 +657,9 @@ terminaltypeok(char *s) } -char *hostname; char host_name[MaxHostNameLen]; char remote_host_name[MaxHostNameLen]; +char remote_utmp_name[MaxHostNameLen]; /* * Get a pty, scan input lines. @@ -663,12 +667,10 @@ char remote_host_name[MaxHostNameLen]; static void doit(struct sockaddr *who, int who_len) { - char *host = NULL; int level; int ptynum; char user_name[256]; int error; - char host_addr[256]; /* * Find an available pty to use. @@ -693,43 +695,42 @@ doit(struct sockaddr *who, int who_len) } #endif /* _SC_CRAY_SECURE_SYS */ - error = getnameinfo_verified (who, who_len, host_addr, sizeof(host_addr), + error = getnameinfo_verified (who, who_len, + remote_host_name, + sizeof(remote_host_name), NULL, 0, registerd_host_only ? NI_NAMEREQD : 0); if (error) fatal(net, "Couldn't resolve your address into a host name.\r\n\ Please contact your net administrator"); - /* - * We must make a copy because Kerberos is probably going - * to also do a gethost* and overwrite the static data... - */ - strlcpy(remote_host_name, host_addr, sizeof(remote_host_name)); - host = remote_host_name; - - /* XXX - should be k_gethostname? */ gethostname(host_name, sizeof (host_name)); - hostname = host_name; + + strlcpy (remote_utmp_name, remote_host_name, sizeof(remote_utmp_name)); /* Only trim if too long (and possible) */ - if (strlen(remote_host_name) > abs(utmp_len)) { + if (strlen(remote_utmp_name) > utmp_len) { char *domain = strchr(host_name, '.'); - char *p = strchr(remote_host_name, '.'); - if (domain && p && (strcmp(p, domain) == 0)) - *p = 0; /* remove domain part */ + char *p = strchr(remote_utmp_name, '.'); + if (domain != NULL && p != NULL && (strcmp(p, domain) == 0)) + *p = '\0'; /* remove domain part */ } - /* * If hostname still doesn't fit utmp, use ipaddr. */ - if (strlen(remote_host_name) > abs(utmp_len)) - strlcpy(remote_host_name, - host_addr, - sizeof(remote_host_name)); + if (strlen(remote_utmp_name) > utmp_len) { + error = getnameinfo (who, who_len, + remote_utmp_name, + sizeof(remote_utmp_name), + NULL, 0, + NI_NUMERICHOST); + if (error) + fatal(net, "Couldn't get numeric address\r\n"); + } #ifdef AUTHENTICATION - auth_encrypt_init(hostname, host, "TELNETD", 1); + auth_encrypt_init(host_name, remote_host_name, "TELNETD", 1); #endif init_env(); @@ -750,7 +751,8 @@ Please contact your net administrator"); #endif /* _SC_CRAY_SECURE_SYS */ /* begin server processing */ - my_telnet(net, ourpty, host, level, user_name); + my_telnet(net, ourpty, remote_host_name, remote_utmp_name, + level, user_name); /*NOTREACHED*/ } /* end of doit */ @@ -777,7 +779,8 @@ show_issue(void) * hand data to telnet receiver finite state machine. */ void -my_telnet(int f, int p, char *host, int level, char *autoname) +my_telnet(int f, int p, const char *host, const char *utmp_host, + int level, char *autoname) { int on = 1; char *he; @@ -960,7 +963,7 @@ my_telnet(int f, int p, char *host, int level, char *autoname) indefinitely */ if(!startslave_called && (!encrypt_delay() || timeout > time(NULL))){ startslave_called = 1; - startslave(host, level, autoname); + startslave(host, utmp_host, level, autoname); } if (ncc < 0 && pcc < 0) |