1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
$NetBSD: patch-ah,v 1.5 2005/12/05 20:51:15 rillig Exp $
--- src/utmp.c.orig Thu Jun 27 14:15:53 2002
+++ src/utmp.c Sat Dec 14 21:44:17 2002
@@ -38,7 +38,7 @@
# endif
/* don't go off end of ut_id & remember if an entry has been made */
-# if defined(USE_SYSV_UTMP) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__)
+# if defined(USE_SYSV_UTMP) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__)
static char ut_id[5]; /* remember if entry to utmp made */
# else
static int utmp_pos; /* BSD position of utmp-stamp */
@@ -47,8 +47,13 @@ static int utmp_pos; /* BSD p
# ifdef USE_SYSV_UTMP
# ifdef HAVE_UTMPX_H
+# include <utmp.h>
# undef WTMP_FILENAME
-# define WTMP_FILENAME WTMPX_FILE
+# if defined(WTMPX_FILE)
+# define WTMP_FILENAME WTMPX_FILE
+# else
+# define WTMP_FILENAME _PATH_WTMPX
+# endif
# define update_wtmp updwtmpx
# else /* HAVE_UTMPX_H */
@@ -128,9 +133,9 @@ add_utmp_entry(const char *pty, const ch
privileges(INVOKE);
# ifdef HAVE_UTMPX_H
getutmp(&utmp, &utmp2);
- getutid(&utmp2); /* position to entry in utmp file */
+ getutxid(&utmp); /* position to entry in utmp file */
# else
- getutid(&utmp); /* position to entry in utmp file */
+ getutxid(&utmp); /* position to entry in utmp file */
# endif
/* set up the new entry */
@@ -152,16 +157,15 @@ add_utmp_entry(const char *pty, const ch
/*
* write a utmp entry to the utmp file
*/
- utmpname(UTMP_FILENAME);
+ utmpxname(UTMP_FILENAME);
# ifdef HAVE_UTMPX_H
getutmp(&utmp, &utmp2);
- pututline(&utmp2);
pututxline(&utmp);
# else
pututline(&utmp);
# endif
update_wtmp(WTMP_FILENAME, &utmp);
- endutent(); /* close the file */
+ endutxent(); /* close the file */
privileges(REVERT);
return;
fd = 0;
@@ -177,19 +181,19 @@ remove_utmp_entry(void)
if (!ut_id[0])
return; /* entry not made */
- utmpname(UTMP_FILENAME);
- setutent();
- strncpy(utmp.ut_id, ut_id, sizeof(utmp.ut_id));
- utmp.ut_type = USER_PROCESS;
- if (getutid(&utmp) == NULL) {
+ utmpxname(UTMP_FILENAME);
+ setutxent();
+ strncpy(utmpx.ut_id, ut_id, sizeof(utmpx.ut_id));
+ utmpx.ut_type = USER_PROCESS;
+ if (getutxid(&utmp) == NULL) {
return;
}
- utmp.ut_type = DEAD_PROCESS;
+ utmpx.ut_type = DEAD_PROCESS;
utmp.ut_time = time(NULL);
- pututline(&utmp);
+ pututxline(&utmpx);
getutmpx(&utmp, &utmpx);
update_wtmp(WTMP_FILENAME, &utmpx);
- endutent();
+ endutxent();
# else /* HAVE_UTMPX_H */
struct utmp *putmp;
@@ -222,7 +226,7 @@ remove_utmp_entry(void)
# else /* USE_SYSV_UTMP */
/* BSD utmp support */
-# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__bsdi__)
+# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__bsdi__) || defined(__DragonFly__)
/* used to hold the line we are using */
static char ut_line[32];
@@ -348,7 +352,7 @@ add_utmp_entry(const char *pty, const ch
return;
}
-# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__bsdi__)
+# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__bsdi__) || defined(__DragonFly__)
strncpy(ut_line, pty, 31);
strncpy(utmp.ut_line, pty, UT_LINESIZE);
@@ -376,7 +380,7 @@ add_utmp_entry(const char *pty, const ch
void
remove_utmp_entry(void)
{
-# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__bsdi__)
+# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__bsdi__) || defined(__DragonFly__)
logout(ut_line);
logwtmp(ut_line, "", "");
# else /* __FreeBSD__ */
|