diff options
Diffstat (limited to 'libbb/utmp.c')
-rw-r--r-- | libbb/utmp.c | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/libbb/utmp.c b/libbb/utmp.c index 8ad9ba27e..bd07670db 100644 --- a/libbb/utmp.c +++ b/libbb/utmp.c | |||
@@ -16,7 +16,7 @@ static void touch(const char *filename) | |||
16 | 16 | ||
17 | void FAST_FUNC write_new_utmp(pid_t pid, int new_type, const char *tty_name, const char *username, const char *hostname) | 17 | void FAST_FUNC write_new_utmp(pid_t pid, int new_type, const char *tty_name, const char *username, const char *hostname) |
18 | { | 18 | { |
19 | struct utmp utent; | 19 | struct utmpx utent; |
20 | char *id; | 20 | char *id; |
21 | unsigned width; | 21 | unsigned width; |
22 | 22 | ||
@@ -45,17 +45,17 @@ void FAST_FUNC write_new_utmp(pid_t pid, int new_type, const char *tty_name, con | |||
45 | tty_name += 3; | 45 | tty_name += 3; |
46 | strncpy(id, tty_name, width); | 46 | strncpy(id, tty_name, width); |
47 | 47 | ||
48 | touch(_PATH_UTMP); | 48 | touch(_PATH_UTMPX); |
49 | //utmpname(_PATH_UTMP); | 49 | //utmpxname(_PATH_UTMPX); |
50 | setutent(); | 50 | setutxent(); |
51 | /* Append new one (hopefully, unless we collide on ut_id) */ | 51 | /* Append new one (hopefully, unless we collide on ut_id) */ |
52 | pututline(&utent); | 52 | pututxline(&utent); |
53 | endutent(); | 53 | endutxent(); |
54 | 54 | ||
55 | #if ENABLE_FEATURE_WTMP | 55 | #if ENABLE_FEATURE_WTMP |
56 | /* "man utmp" says wtmp file should *not* be created automagically */ | 56 | /* "man utmp" says wtmp file should *not* be created automagically */ |
57 | /*touch(bb_path_wtmp_file);*/ | 57 | /*touch(bb_path_wtmp_file);*/ |
58 | updwtmp(bb_path_wtmp_file, &utent); | 58 | updwtmpx(bb_path_wtmp_file, &utent); |
59 | #endif | 59 | #endif |
60 | } | 60 | } |
61 | 61 | ||
@@ -64,17 +64,17 @@ void FAST_FUNC write_new_utmp(pid_t pid, int new_type, const char *tty_name, con | |||
64 | */ | 64 | */ |
65 | void FAST_FUNC update_utmp(pid_t pid, int new_type, const char *tty_name, const char *username, const char *hostname) | 65 | void FAST_FUNC update_utmp(pid_t pid, int new_type, const char *tty_name, const char *username, const char *hostname) |
66 | { | 66 | { |
67 | struct utmp utent; | 67 | struct utmpx utent; |
68 | struct utmp *utp; | 68 | struct utmpx *utp; |
69 | 69 | ||
70 | touch(_PATH_UTMP); | 70 | touch(_PATH_UTMPX); |
71 | //utmpname(_PATH_UTMP); | 71 | //utmpxname(_PATH_UTMPX); |
72 | setutent(); | 72 | setutxent(); |
73 | 73 | ||
74 | /* Did init/getty/telnetd/sshd/... create an entry for us? | 74 | /* Did init/getty/telnetd/sshd/... create an entry for us? |
75 | * It should be (new_type-1), but we'd also reuse | 75 | * It should be (new_type-1), but we'd also reuse |
76 | * any other potentially stale xxx_PROCESS entry */ | 76 | * any other potentially stale xxx_PROCESS entry */ |
77 | while ((utp = getutent()) != NULL) { | 77 | while ((utp = getutxent()) != NULL) { |
78 | if (utp->ut_pid == pid | 78 | if (utp->ut_pid == pid |
79 | // && ut->ut_line[0] | 79 | // && ut->ut_line[0] |
80 | && utp->ut_id[0] /* must have nonzero id */ | 80 | && utp->ut_id[0] /* must have nonzero id */ |
@@ -88,25 +88,25 @@ void FAST_FUNC update_utmp(pid_t pid, int new_type, const char *tty_name, const | |||
88 | /* Stale record. Nuke hostname */ | 88 | /* Stale record. Nuke hostname */ |
89 | memset(utp->ut_host, 0, sizeof(utp->ut_host)); | 89 | memset(utp->ut_host, 0, sizeof(utp->ut_host)); |
90 | } | 90 | } |
91 | /* NB: pututline (see later) searches for matching utent | 91 | /* NB: pututxline (see later) searches for matching utxent |
92 | * using getutid(utent) - we must not change ut_id | 92 | * using getutxid(utent) - we must not change ut_id |
93 | * if we want *exactly this* record to be overwritten! | 93 | * if we want *exactly this* record to be overwritten! |
94 | */ | 94 | */ |
95 | break; | 95 | break; |
96 | } | 96 | } |
97 | } | 97 | } |
98 | //endutent(); - no need, pututline can deal with (and actually likes) | 98 | //endutxent(); - no need, pututxline can deal with (and actually likes) |
99 | //the situation when utmp file is positioned on found record | 99 | //the situation when utmp file is positioned on found record |
100 | 100 | ||
101 | if (!utp) { | 101 | if (!utp) { |
102 | if (new_type != DEAD_PROCESS) | 102 | if (new_type != DEAD_PROCESS) |
103 | write_new_utmp(pid, new_type, tty_name, username, hostname); | 103 | write_new_utmp(pid, new_type, tty_name, username, hostname); |
104 | else | 104 | else |
105 | endutent(); | 105 | endutxent(); |
106 | return; | 106 | return; |
107 | } | 107 | } |
108 | 108 | ||
109 | /* Make a copy. We can't use *utp, pututline's internal getutid | 109 | /* Make a copy. We can't use *utp, pututxline's internal getutxid |
110 | * will overwrite it before it is used! */ | 110 | * will overwrite it before it is used! */ |
111 | utent = *utp; | 111 | utent = *utp; |
112 | 112 | ||
@@ -120,14 +120,14 @@ void FAST_FUNC update_utmp(pid_t pid, int new_type, const char *tty_name, const | |||
120 | utent.ut_tv.tv_sec = time(NULL); | 120 | utent.ut_tv.tv_sec = time(NULL); |
121 | 121 | ||
122 | /* Update, or append new one */ | 122 | /* Update, or append new one */ |
123 | //setutent(); | 123 | //setutxent(); |
124 | pututline(&utent); | 124 | pututxline(&utent); |
125 | endutent(); | 125 | endutxent(); |
126 | 126 | ||
127 | #if ENABLE_FEATURE_WTMP | 127 | #if ENABLE_FEATURE_WTMP |
128 | /* "man utmp" says wtmp file should *not* be created automagically */ | 128 | /* "man utmp" says wtmp file should *not* be created automagically */ |
129 | /*touch(bb_path_wtmp_file);*/ | 129 | /*touch(bb_path_wtmp_file);*/ |
130 | updwtmp(bb_path_wtmp_file, &utent); | 130 | updwtmpx(bb_path_wtmp_file, &utent); |
131 | #endif | 131 | #endif |
132 | } | 132 | } |
133 | 133 | ||