]> git.pld-linux.org Git - packages/SysVinit.git/blame - sysvinit-wtmp.patch
- does not require logrotate; rel 19
[packages/SysVinit.git] / sysvinit-wtmp.patch
CommitLineData
68db8b21
JR
1diff -ur sysvinit-2.78.orig/src/last.c sysvinit-2.78/src/last.c
2--- sysvinit-2.78.orig/src/last.c Wed Nov 24 13:24:53 1999
3+++ sysvinit-2.78/src/last.c Sat Sep 2 01:53:06 2000
4@@ -36,6 +36,25 @@
5 #include <arpa/inet.h>
6 #include "oldutmp.h"
7
8+/*
9+ * Try to be smart about the location of the BTMP file
10+ */
11+#ifndef _PATH_BTMP
12+#define _PATH_BTMP "/var/log/btmp"
13+#define BTMP_FILE _PATH_BTMP
14+#endif
15+
16+#define TRANSFORM_UTMP_FILE_NAME(file_name) \
17+ ((strcmp (file_name, _PATH_WTMP) == 0 \
18+ && access ( _PATH_WTMP "x", F_OK) == 0) ? (_PATH_WTMP "x") : \
19+ ((strcmp (file_name, _PATH_BTMP) == 0 \
20+ && access ( _PATH_BTMP "x", F_OK) == 0) ? (_PATH_BTMP "x") : \
21+ ((strcmp (file_name, _PATH_WTMP "x") == 0 \
22+ && access (_PATH_WTMP "x", F_OK) != 0) ? _PATH_WTMP : \
23+ ((strcmp (file_name, _PATH_BTMP "x") == 0 \
24+ && access (_PATH_BTMP "x", F_OK) != 0) ? _PATH_BTMP : \
25+ file_name))))
26+
27 #ifndef SHUTDOWN_TIME
28 # define SHUTDOWN_TIME 254
29 #endif
30@@ -233,27 +251,6 @@
31 #endif
32
33 /*
34- * Try to be smart about the location of the BTMP file
35- */
36-#ifndef BTMP_FILE
37-#define BTMP_FILE getbtmp()
38-char *getbtmp()
39-{
40- static char btmp[128];
41- char *p;
42-
43- strcpy(btmp, WTMP_FILE);
44- if ((p = strrchr(btmp, '/')) == NULL)
45- p = btmp;
46- else
47- p++;
48- *p = 0;
49- strcat(btmp, "btmp");
50- return btmp;
51-}
52-#endif
53-
54-/*
55 * Print a short date.
56 */
57 char *showdate()
58@@ -344,6 +341,8 @@
59 utline[UT_LINESIZE - 1] = 0;
60 if (strncmp(utline, "ftp", 3) == 0 && isdigit(utline[3]))
61 utline[3] = 0;
62+ if (strncmp(utline, "ftpd", 4) == 0 && isdigit(utline[4]))
63+ utline[4] = 0;
64 if (strncmp(utline, "uucp", 4) == 0 && isdigit(utline[4]))
65 utline[4] = 0;
66
67@@ -531,10 +530,10 @@
68 * Which file do we want to read?
69 */
70 if (strcmp(progname, "lastb") == 0) {
71- ufile = BTMP_FILE;
72+ ufile = TRANSFORM_UTMP_FILE_NAME(BTMP_FILE);
73 lastb = 1;
74 } else
75- ufile = WTMP_FILE;
76+ ufile = TRANSFORM_UTMP_FILE_NAME(WTMP_FILE);
77 if (altufile)
78 ufile = altufile;
79 time(&lastdown);
80diff -ur sysvinit-2.78.orig/src/utmp.c sysvinit-2.78/src/utmp.c
81--- sysvinit-2.78.orig/src/utmp.c Wed Jun 9 13:11:33 1999
82+++ sysvinit-2.78/src/utmp.c Sat Sep 2 01:30:44 2000
83@@ -53,7 +53,9 @@
84 * this if we have updwtmp() so we can see if the
85 * wtmp file is accessible.
86 */
87+#if !HAVE_UPDWTMP
88 if ((fd = open(WTMP_FILE, O_WRONLY|O_APPEND)) < 0) return;
89+#endif
90
91 #ifdef INIT_MAIN
92 /*
93@@ -117,8 +119,10 @@
94 /*
95 * Can't do much if UTMP_FILE is not present.
96 */
97+#if !HAVE_UPDWTMP
98 if (access(UTMP_FILE, F_OK) < 0)
99 return;
100+#endif
101
102 #ifdef INIT_MAIN
103 /*
This page took 0.0399389999999999 seconds and 4 git commands to generate.