]> git.pld-linux.org Git - packages/SysVinit.git/blob - sysvinit-wtmp.patch
- updated to 3.04
[packages/SysVinit.git] / sysvinit-wtmp.patch
1 --- sysvinit-2.88dsf/src/last.c.wiget   2010-02-19 16:51:36.000000000 +0100
2 +++ sysvinit-2.88dsf/src/last.c 2011-12-03 22:48:11.526513957 +0100
3 @@ -45,6 +45,25 @@
4  #include <arpa/inet.h>
5  #include "oldutmp.h"
6  
7 +/*
8 + *     Try to be smart about the location of the BTMP file
9 + */
10 +#ifndef _PATH_BTMP
11 +#define _PATH_BTMP "/var/log/btmp"
12 +#define BTMP_FILE _PATH_BTMP
13 +#endif
14 +
15 +#define TRANSFORM_UTMP_FILE_NAME(file_name) \
16 +        ((strcmp (file_name, _PATH_WTMP) == 0 \
17 +          && access ( _PATH_WTMP "x", F_OK) == 0) ? (_PATH_WTMP "x") : \
18 +         ((strcmp (file_name, _PATH_BTMP) == 0 \
19 +           && access ( _PATH_BTMP "x", F_OK) == 0) ? (_PATH_BTMP "x") : \
20 +           ((strcmp (file_name, _PATH_WTMP "x") == 0 \
21 +             && access (_PATH_WTMP "x", F_OK) != 0) ? _PATH_WTMP : \
22 +            ((strcmp (file_name, _PATH_BTMP "x") == 0 \
23 +              && access (_PATH_BTMP "x", F_OK) != 0) ? _PATH_BTMP : \
24 +             file_name))))
25 +
26  #ifndef SHUTDOWN_TIME
27  #  define SHUTDOWN_TIME 254
28  #endif
29 @@ -247,27 +266,6 @@ int uread(FILE *fp, struct utmp *u, int
30  #endif
31  
32  /*
33 - *     Try to be smart about the location of the BTMP file
34 - */
35 -#ifndef BTMP_FILE
36 -#define BTMP_FILE getbtmp()
37 -char *getbtmp()
38 -{
39 -       static char btmp[128];
40 -       char *p;
41 -
42 -       strcpy(btmp, WTMP_FILE);
43 -       if ((p = strrchr(btmp, '/')) == NULL)
44 -               p = btmp;
45 -       else
46 -               p++;
47 -       *p = 0;
48 -       strcat(btmp, "btmp");
49 -       return btmp;
50 -}
51 -#endif
52 -
53 -/*
54   *     Print a short date.
55   */
56  char *showdate()
57 @@ -384,6 +382,8 @@ int list(struct utmp *p, time_t t, int w
58         strncat(utline, p->ut_line, UT_LINESIZE);
59         if (strncmp(utline, "ftp", 3) == 0 && isdigit(utline[3]))
60                 utline[3] = 0;
61 +       if (strncmp(utline, "ftpd", 4) == 0 && isdigit(utline[4]))
62 +               utline[4] = 0;
63         if (strncmp(utline, "uucp", 4) == 0 && isdigit(utline[4]))
64                 utline[4] = 0;
65  
66 @@ -666,10 +666,10 @@ int main(int argc, char **argv)
67     *   Which file do we want to read?
68     */
69    if (strcmp(progname, "lastb") == 0) {
70 -       ufile = BTMP_FILE;
71 +       ufile = TRANSFORM_UTMP_FILE_NAME(BTMP_FILE);
72         lastb = 1;
73    } else
74 -       ufile = WTMP_FILE;
75 +       ufile = TRANSFORM_UTMP_FILE_NAME(WTMP_FILE);
76    if (altufile)
77         ufile = altufile;
78    time(&lastdown);
79 --- sysvinit-2.88dsf/src/utmp.c.wiget   2009-11-24 11:03:19.000000000 +0100
80 +++ sysvinit-2.88dsf/src/utmp.c 2011-12-03 22:49:25.353492892 +0100
81 @@ -76,7 +76,9 @@ char *line)                   /* Which line is this */
82          *      this if we have updwtmp() so we can see if the
83          *      wtmp file is accessible.
84          */
85 +#if !HAVE_UPDWTMP
86         if ((fd = open(WTMP_FILE, O_WRONLY|O_APPEND)) < 0) return;
87 +#endif
88  
89  #ifdef INIT_MAIN
90         /*
91 @@ -160,8 +162,10 @@ char *oldline)                     /* Line of old utmp ent
92         /*
93          *      Can't do much if UTMP_FILE is not present or not writable.
94          */
95 +#if !HAVE_UPDWTMP
96         if (access(UTMP_FILE, W_OK) < 0)
97                 return;
98 +#endif
99  
100  #ifdef INIT_MAIN
101         /*
This page took 0.087504 seconds and 3 git commands to generate.