--- sysvinit-2.88dsf/src/last.c.wiget 2010-02-19 16:51:36.000000000 +0100 +++ sysvinit-2.88dsf/src/last.c 2011-12-03 22:48:11.526513957 +0100 @@ -45,6 +45,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 @@ -247,27 +266,6 @@ int uread(FILE *fp, struct utmp *u, int #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() @@ -384,6 +382,8 @@ int list(struct utmp *p, time_t t, int w strncat(utline, p->ut_line, UT_LINESIZE); 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; @@ -666,10 +666,10 @@ int main(int argc, char **argv) * 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); --- sysvinit-2.88dsf/src/utmp.c.wiget 2009-11-24 11:03:19.000000000 +0100 +++ sysvinit-2.88dsf/src/utmp.c 2011-12-03 22:49:25.353492892 +0100 @@ -76,7 +76,9 @@ char *line) /* Which line is this */ * 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 /* @@ -160,8 +162,10 @@ char *oldline) /* Line of old utmp ent /* * Can't do much if UTMP_FILE is not present or not writable. */ +#if !HAVE_UPDWTMP if (access(UTMP_FILE, W_OK) < 0) return; +#endif #ifdef INIT_MAIN /*