From: Ken Raeburn Date: Thu, 7 Mar 2002 00:28:22 +0000 (+0000) Subject: changes from 1.2.4 branch X-Git-Tag: krb5-1.3-alpha1~856 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=8869534b9428770c39fc048608c74d32f6cec476;p=krb5.git changes from 1.2.4 branch * loginpaths.h [_PATH_DEFPATH]: Undefine LPATH and RPATH unconditionally before redefining them. * login.c (main): If the supplied name is longer than the utmp buffer, don't bother trying it as a username. (dolastlog): Don't assume lastlog.ll_time is a time_t. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@14234 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/appl/bsd/ChangeLog b/src/appl/bsd/ChangeLog index b99e79047..985823c51 100644 --- a/src/appl/bsd/ChangeLog +++ b/src/appl/bsd/ChangeLog @@ -1,3 +1,12 @@ +2002-03-05 Ken Raeburn + + * loginpaths.h [_PATH_DEFPATH]: Undefine LPATH and RPATH + unconditionally before redefining them. + + * login.c (main): If the supplied name is longer than the utmp + buffer, don't bother trying it as a username. + (dolastlog): Don't assume lastlog.ll_time is a time_t. + 2002-02-27 Ken Raeburn * fieldbits.h: Deleted. diff --git a/src/appl/bsd/login.c b/src/appl/bsd/login.c index 6ee629dd3..dee36247a 100644 --- a/src/appl/bsd/login.c +++ b/src/appl/bsd/login.c @@ -1186,8 +1186,13 @@ int main(argc, argv) } argc -= optind; argv += optind; - if (*argv) - username = *argv; + /* Throw away too-long names, they can't be usernames. */ + if (*argv) { + if (strlen (*argv) <= UT_NAMESIZE) + username = *argv; + else + fprintf (stderr, "login name '%s' too long\n", *argv); + } #if !defined(POSIX_TERMIOS) && defined(TIOCLSET) ioctlval = 0; @@ -2142,6 +2147,7 @@ void dolastlog(hostname, quiet, tty) { #if defined(HAVE_LASTLOG_H) || (defined(BSD) && (BSD >= 199103)) struct lastlog ll; + time_t lltime; int fd; if ((fd = open(LASTLOG, O_RDWR, 0)) >= 0) { @@ -2150,7 +2156,9 @@ void dolastlog(hostname, quiet, tty) if ((read(fd, (char *)&ll, sizeof(ll)) == sizeof(ll)) && (ll.ll_time != 0)) { - printf("Last login: %.*s ", 24-5, (char *)ctime(&ll.ll_time)); + /* .ll_time may not be a time_t. */ + lltime = ll.ll_time; + printf("Last login: %.*s ", 24-5, (char *)ctime(&lltime)); if (*ll.ll_host != '\0') printf("from %.*s\n", (int) sizeof(ll.ll_host), @@ -2160,7 +2168,8 @@ void dolastlog(hostname, quiet, tty) } (void)lseek(fd, (off_t)pwd->pw_uid * sizeof(ll), SEEK_SET); } - (void) time(&ll.ll_time); + (void) time(&lltime); + ll.ll_time = lltime; (void) strncpy(ll.ll_line, tty, sizeof(ll.ll_line)); ll.ll_line[sizeof(ll.ll_line) - 1] = '\0'; diff --git a/src/appl/bsd/loginpaths.h b/src/appl/bsd/loginpaths.h index 95c868829..0f2580bb9 100644 --- a/src/appl/bsd/loginpaths.h +++ b/src/appl/bsd/loginpaths.h @@ -96,13 +96,9 @@ #endif #ifdef _PATH_DEFPATH -#ifdef LPATH #undef LPATH -#endif #define LPATH _PATH_DEFPATH -#ifdef RPATH #undef RPATH -#endif #define RPATH _PATH_DEFPATH #endif