]> git.pld-linux.org Git - packages/SysVinit.git/blob - sysvinit-wtmp.patch
- updated to 3.04
[packages/SysVinit.git] / sysvinit-wtmp.patch
1 diff -ruNp sysvinit-2.96.orig/src/last.c sysvinit-2.96/src/last.c
2 --- sysvinit-2.96.orig/src/last.c       2019-09-11 19:43:12.000000000 +0200
3 +++ sysvinit-2.96/src/last.c    2019-12-01 05:14:37.344902512 +0100
4 @@ -44,6 +44,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 @@ -251,28 +270,6 @@ int uread(FILE *fp, struct utmp *u, int
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[PATH_MAX + 5];  /* max path + btmp + null terminator */
41 -       char *p;
42 -
43 -        memset(btmp, '\0', PATH_MAX + 5);
44 -       strncpy(btmp, WTMP_FILE, PATH_MAX);
45 -       if ((p = strrchr(btmp, '/')) == NULL)
46 -               p = btmp;
47 -       else
48 -               p++;
49 -       *p = 0;
50 -       strcat(btmp, "btmp");
51 -       return btmp;
52 -}
53 -#endif
54 -
55 -/*
56   *     Print a short date.
57   */
58  char *showdate()
59 @@ -381,6 +378,8 @@ int list(struct utmp *p, time_t t, int w
60         strncat(utline, p->ut_line, UT_LINESIZE);
61         if (strncmp(utline, "ftp", 3) == 0 && isdigit(utline[3]))
62                 utline[3] = 0;
63 +       if (strncmp(utline, "ftpd", 4) == 0 && isdigit(utline[4]))
64 +               utline[4] = 0;
65         if (strncmp(utline, "uucp", 4) == 0 && isdigit(utline[4]))
66                 utline[4] = 0;
67  
68 @@ -708,10 +707,10 @@ int main(int argc, char **argv)
69     *   Which file do we want to read?
70     */
71    if (strcmp(progname, "lastb") == 0) {
72 -       ufile = BTMP_FILE;
73 +       ufile = TRANSFORM_UTMP_FILE_NAME(BTMP_FILE);
74         lastb = 1;
75    } else
76 -       ufile = WTMP_FILE;
77 +       ufile = TRANSFORM_UTMP_FILE_NAME(WTMP_FILE);
78    if (altufile)
79         ufile = altufile;
80    time(&lastdown);
81 diff -ruNp sysvinit-2.96.orig/src/utmp.c sysvinit-2.96/src/utmp.c
82 --- sysvinit-2.96.orig/src/utmp.c       2019-09-11 19:43:12.000000000 +0200
83 +++ sysvinit-2.96/src/utmp.c    2019-12-01 05:15:12.143729210 +0100
84 @@ -80,7 +80,9 @@ char *line)                   /* Which line is this */
85          *      this if we have updwtmp() so we can see if the
86          *      wtmp file is accessible.
87          */
88 +#if !HAVE_UPDWTMP
89         if ((fd = open(WTMP_FILE, O_WRONLY|O_APPEND)) < 0) return;
90 +#endif
91  
92  #ifdef INIT_MAIN
93         /*
94 @@ -140,8 +142,8 @@ char *line)                 /* Which line is this */
95         updwtmp(WTMP_FILE, &utmp);
96  #else
97         write(fd, (char *)&utmp, sizeof(utmp));
98 -#endif
99         close(fd);
100 +#endif
101  }
102  
103  /*
104 @@ -164,8 +166,10 @@ char *oldline)                     /* Line of old utmp ent
105         /*
106          *      Can't do much if UTMP_FILE is not present or not writable.
107          */
108 +#if !HAVE_UPDWTMP
109         if (access(UTMP_FILE, W_OK) < 0)
110                 return;
111 +#endif
112  
113  #ifdef INIT_MAIN
114         /*
This page took 0.037031 seconds and 3 git commands to generate.