diff -ur utempter-0.5.2.orig/utempter.c utempter-0.5.2/utempter.c --- utempter-0.5.2.orig/utempter.c Thu Apr 8 18:19:36 1999 +++ utempter-0.5.2/utempter.c Fri May 5 04:19:51 2000 @@ -88,6 +88,8 @@ int i; struct stat sb; char * id; + int fd; + struct lastlog ll; if (argc < 3) usage(); @@ -115,6 +117,7 @@ host = NULL; } + memset(&ll, 0, sizeof(ll)); memset(&utx, 0, sizeof(utx)); if (add) utx.ut_type = USER_PROCESS; @@ -130,6 +133,7 @@ checkDevice(device); strncpy(utx.ut_line, device + 5, sizeof(utx.ut_line)); + strncpy(ll.ll_line, device + 5, sizeof(ll.ll_line)); pw = getpwuid(getuid()); if (!pw) { @@ -139,8 +143,10 @@ strncpy(utx.ut_user, pw->pw_name, sizeof(utx.ut_user)); - if (host) + if (host) { strncpy(utx.ut_host, host, sizeof(utx.ut_host)); + strncpy(ll.ll_host, host, sizeof(ll.ll_host)); + } if (!strncmp("pts/", utx.ut_line, 4)) { id = utx.ut_line + 3; @@ -152,9 +158,16 @@ strncpy(utx.ut_id, id, sizeof(utx.ut_id)); gettimeofday(&utx.ut_tv, NULL); + ll.ll_time = time(NULL); pututxline(&utx); updwtmpx(_PATH_WTMP, &utx); + + if ((fd = open(_PATH_LASTLOG, O_RDWR)) != -1) { + lseek(fd, (off_t) ((long)pw->pw_uid * sizeof(ll)), SEEK_SET); + write(fd, &ll, sizeof(ll)); + close(fd); + } return 0; }