diff -ur sysvinit-2.78.orig/src/last.c sysvinit-2.78/src/last.c --- sysvinit-2.78.orig/src/last.c Wed Nov 24 13:24:53 1999 +++ sysvinit-2.78/src/last.c Sat Sep 2 01:53:06 2000 @@ -36,6 +36,25 @@ #include #include "oldutmp.h" +/* + * Try to be smart about the location of the BTMP file + */ +#ifndef _PATH_BTMP +#define _PATH_BTMP "/var/log/btmp" +#define BTMP_FILE _PATH_BTMP +#endif + +#define TRANSFORM_UTMP_FILE_NAME(file_name) \ + ((strcmp (file_name, _PATH_WTMP) == 0 \ + && access ( _PATH_WTMP "x", F_OK) == 0) ? (_PATH_WTMP "x") : \ + ((strcmp (file_name, _PATH_BTMP) == 0 \ + && access ( _PATH_BTMP "x", F_OK) == 0) ? (_PATH_BTMP "x") : \ + ((strcmp (file_name, _PATH_WTMP "x") == 0 \ + && access (_PATH_WTMP "x", F_OK) != 0) ? _PATH_WTMP : \ + ((strcmp (file_name, _PATH_BTMP "x") == 0 \ + && access (_PATH_BTMP "x", F_OK) != 0) ? _PATH_BTMP : \ + file_name)))) + #ifndef SHUTDOWN_TIME # define SHUTDOWN_TIME 254 #endif @@ -233,27 +251,6 @@ #endif /* - * Try to be smart about the location of the BTMP file - */ -#ifndef BTMP_FILE -#define BTMP_FILE getbtmp() -char *getbtmp() -{ - static char btmp[128]; - char *p; - - strcpy(btmp, WTMP_FILE); - if ((p = strrchr(btmp, '/')) == NULL) - p = btmp; - else - p++; - *p = 0; - strcat(btmp, "btmp"); - return btmp; -} -#endif - -/* * Print a short date. */ char *showdate() @@ -344,6 +341,8 @@ utline[UT_LINESIZE - 1] = 0; if (strncmp(utline, "ftp", 3) == 0 && isdigit(utline[3])) utline[3] = 0; + if (strncmp(utline, "ftpd", 4) == 0 && isdigit(utline[4])) + utline[4] = 0; if (strncmp(utline, "uucp", 4) == 0 && isdigit(utline[4])) utline[4] = 0; @@ -531,10 +530,10 @@ * Which file do we want to read? */ if (strcmp(progname, "lastb") == 0) { - ufile = BTMP_FILE; + ufile = TRANSFORM_UTMP_FILE_NAME(BTMP_FILE); lastb = 1; } else - ufile = WTMP_FILE; + ufile = TRANSFORM_UTMP_FILE_NAME(WTMP_FILE); if (altufile) ufile = altufile; time(&lastdown); diff -ur sysvinit-2.78.orig/src/utmp.c sysvinit-2.78/src/utmp.c --- sysvinit-2.78.orig/src/utmp.c Wed Jun 9 13:11:33 1999 +++ sysvinit-2.78/src/utmp.c Sat Sep 2 01:30:44 2000 @@ -53,7 +53,9 @@ * this if we have updwtmp() so we can see if the * wtmp file is accessible. */ +#if !HAVE_UPDWTMP if ((fd = open(WTMP_FILE, O_WRONLY|O_APPEND)) < 0) return; +#endif #ifdef INIT_MAIN /* @@ -117,8 +119,10 @@ /* * Can't do much if UTMP_FILE is not present. */ +#if !HAVE_UPDWTMP if (access(UTMP_FILE, F_OK) < 0) return; +#endif #ifdef INIT_MAIN /*