diff options
Diffstat (limited to 'crypto/heimdal/appl/login')
-rw-r--r-- | crypto/heimdal/appl/login/ChangeLog | 5 | ||||
-rw-r--r-- | crypto/heimdal/appl/login/Makefile.in | 16 | ||||
-rw-r--r-- | crypto/heimdal/appl/login/login.c | 4 | ||||
-rw-r--r-- | crypto/heimdal/appl/login/login_protos.h | 6 | ||||
-rw-r--r-- | crypto/heimdal/appl/login/osfc2.c | 4 | ||||
-rw-r--r-- | crypto/heimdal/appl/login/utmp_login.c | 48 | ||||
-rw-r--r-- | crypto/heimdal/appl/login/utmpx_login.c | 4 |
7 files changed, 74 insertions, 13 deletions
diff --git a/crypto/heimdal/appl/login/ChangeLog b/crypto/heimdal/appl/login/ChangeLog index fc9f7554..15d01be 100644 --- a/crypto/heimdal/appl/login/ChangeLog +++ b/crypto/heimdal/appl/login/ChangeLog @@ -1,3 +1,8 @@ +2001-02-08 Assar Westerlund <assar@sics.se> + + * utmp_login.c, utmpx_login.c: try to write a useful string as + host in utmp, using the same algoritm as telnetd + 2001-01-29 Assar Westerlund <assar@sics.se> * login.c: remove some krb5_free_context that might happen at diff --git a/crypto/heimdal/appl/login/Makefile.in b/crypto/heimdal/appl/login/Makefile.in index ba353de..64f94b3 100644 --- a/crypto/heimdal/appl/login/Makefile.in +++ b/crypto/heimdal/appl/login/Makefile.in @@ -1,6 +1,7 @@ -# Makefile.in generated automatically by automake 1.4a from Makefile.am +# Makefile.in generated automatically by automake 1.4b from Makefile.am -# Copyright (C) 1994, 1995-9, 2000 Free Software Foundation, Inc. +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000 +# Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -119,7 +120,7 @@ install_sh = @install_sh@ # $Id: Makefile.am.common,v 1.3 1999/04/01 14:58:43 joda Exp $ -# $Id: Makefile.am.common,v 1.23 2000/12/05 09:11:09 joda Exp $ +# $Id: Makefile.am.common,v 1.26 2001/05/21 13:27:48 joda Exp $ AUTOMAKE_OPTIONS = foreign no-dependencies @@ -185,6 +186,8 @@ NROFF_MAN = groff -mandoc -Tascii @KRB5_TRUE@ $(top_builddir)/lib/asn1/libasn1.la @KRB5_TRUE@LIB_gssapi = @KRB5_TRUE@$(top_builddir)/lib/gssapi/libgssapi.la +@DCE_TRUE@LIB_kdfs = @DCE_TRUE@$(top_builddir)/lib/kdfs/libkdfs.la + CHECK_LOCAL = $(PROGRAMS) bin_PROGRAMS = login @@ -260,7 +263,7 @@ OBJECTS = $(am_login_OBJECTS) all: all-redirect .SUFFIXES: -.SUFFIXES: .1 .3 .5 .8 .c .cat1 .cat3 .cat5 .cat8 .et .h .lo .o .obj .x +.SUFFIXES: .et .h .1 .3 .5 .8 .cat1 .cat3 .cat5 .cat8 .x .c .lo .o .obj $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) $(top_srcdir)/Makefile.am.common $(top_srcdir)/cf/Makefile.am.common cd $(top_srcdir) && $(AUTOMAKE) --foreign appl/login/Makefile @@ -352,6 +355,11 @@ TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ || etags $(ETAGS_ARGS) $$tags $$unique $(LISP) +GTAGS: + here=`CDPATH=: && cd $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $$here + mostlyclean-tags: clean-tags: diff --git a/crypto/heimdal/appl/login/login.c b/crypto/heimdal/appl/login/login.c index 2ada921..7cd405b 100644 --- a/crypto/heimdal/appl/login/login.c +++ b/crypto/heimdal/appl/login/login.c @@ -39,7 +39,7 @@ #include <sys/capability.h> #endif -RCSID("$Id: login.c,v 1.46 2001/01/29 02:18:03 assar Exp $"); +RCSID("$Id: login.c,v 1.47 2001/02/20 01:44:45 assar Exp $"); static int login_timeout = 60; @@ -650,7 +650,7 @@ main(int argc, char **argv) int ask = 1; struct sigaction sa; - set_progname(argv[0]); + setprogname(argv[0]); #ifdef KRB5 { diff --git a/crypto/heimdal/appl/login/login_protos.h b/crypto/heimdal/appl/login/login_protos.h index e19a598..4bb8207 100644 --- a/crypto/heimdal/appl/login/login_protos.h +++ b/crypto/heimdal/appl/login/login_protos.h @@ -64,6 +64,12 @@ read_string __P(( int echo)); void +shrink_hostname __P(( + const char *hostname, + char *dst, + size_t dst_sz)); + +void stty_default __P((void)); void diff --git a/crypto/heimdal/appl/login/osfc2.c b/crypto/heimdal/appl/login/osfc2.c index 5d4d087..056484c 100644 --- a/crypto/heimdal/appl/login/osfc2.c +++ b/crypto/heimdal/appl/login/osfc2.c @@ -32,7 +32,7 @@ */ #include "login_locl.h" -RCSID("$Id: osfc2.c,v 1.3 1999/12/02 17:04:56 joda Exp $"); +RCSID("$Id: osfc2.c,v 1.4 2001/02/20 01:44:46 assar Exp $"); int do_osfc2_magic(uid_t uid) @@ -42,7 +42,7 @@ do_osfc2_magic(uid_t uid) char *argv[2]; /* fake */ - argv[0] = (char*)__progname; + argv[0] = (char*)getprogname(); argv[1] = NULL; set_auth_parameters(1, argv); diff --git a/crypto/heimdal/appl/login/utmp_login.c b/crypto/heimdal/appl/login/utmp_login.c index b584326b..0be6cdb 100644 --- a/crypto/heimdal/appl/login/utmp_login.c +++ b/crypto/heimdal/appl/login/utmp_login.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 1996, 1997, 1999 Kungliga Tekniska Högskolan + * Copyright (c) 1995 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -33,7 +33,49 @@ #include "login_locl.h" -RCSID("$Id: utmp_login.c,v 1.17 1999/12/02 17:04:56 joda Exp $"); +RCSID("$Id: utmp_login.c,v 1.18 2001/02/08 16:08:26 assar Exp $"); + +/* try to put something useful from hostname into dst, dst_sz: + * full name, first component or address */ + +void +shrink_hostname (const char *hostname, + char *dst, size_t dst_sz) +{ + char local_hostname[MaxHostNameLen]; + char *ld, *hd; + int ret; + struct addrinfo *ai; + + if (strlen(hostname) < dst_sz) { + strlcpy (dst, hostname, dst_sz); + return; + } + gethostname (local_hostname, sizeof(local_hostname)); + hd = strchr (hostname, '.'); + ld = strchr (local_hostname, '.'); + if (hd != NULL && ld != NULL && strcmp(hd, ld) == 0 + && hd - hostname < dst_sz) { + strlcpy (dst, hostname, dst_sz); + dst[hd - hostname] = '\0'; + return; + } + + ret = getaddrinfo (hostname, NULL, NULL, &ai); + if (ret) { + strncpy (dst, hostname, dst_sz); + return; + } + ret = getnameinfo (ai->ai_addr, ai->ai_addrlen, + dst, dst_sz, + NULL, 0, + NI_NUMERICHOST); + freeaddrinfo (ai); + if (ret) { + strncpy (dst, hostname, dst_sz); + return; + } +} void prepare_utmp (struct utmp *utmp, char *tty, @@ -60,7 +102,7 @@ prepare_utmp (struct utmp *utmp, char *tty, # endif # ifdef HAVE_STRUCT_UTMP_UT_HOST - strncpy(utmp->ut_host, hostname, sizeof(utmp->ut_host)); + shrink_hostname (hostname, utmp->ut_host, sizeof(utmp->ut_host)); # endif # ifdef HAVE_STRUCT_UTMP_UT_TYPE diff --git a/crypto/heimdal/appl/login/utmpx_login.c b/crypto/heimdal/appl/login/utmpx_login.c index 745d64c..46d7f15 100644 --- a/crypto/heimdal/appl/login/utmpx_login.c +++ b/crypto/heimdal/appl/login/utmpx_login.c @@ -2,7 +2,7 @@ #include "login_locl.h" -RCSID("$Id: utmpx_login.c,v 1.24 1999/08/04 17:03:15 assar Exp $"); +RCSID("$Id: utmpx_login.c,v 1.25 2001/02/08 16:08:47 assar Exp $"); /* utmpx_login - update utmp and wtmp after login */ @@ -21,7 +21,7 @@ utmpx_update(struct utmpx *ut, char *line, const char *user, const char *host) strncpy(ut->ut_id, make_id(clean_tty), sizeof(ut->ut_id)); #endif strncpy(ut->ut_user, user, sizeof(ut->ut_user)); - strncpy(ut->ut_host, host, sizeof(ut->ut_host)); + shrink_hostname (host, ut->ut_host, sizeof(ut->ut_host)); #ifdef HAVE_STRUCT_UTMPX_UT_SYSLEN ut->ut_syslen = strlen(host) + 1; if (ut->ut_syslen > sizeof(ut->ut_host)) |