+2002-03-05 Ken Raeburn <raeburn@mit.edu>
+
+ * 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 <raeburn@mit.edu>
* fieldbits.h: Deleted.
}
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;
{
#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) {
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),
}
(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';