Changeset 3621 in MondoRescue for branches/3.3/mindi-busybox/libbb/utmp.c
- Timestamp:
- Dec 20, 2016, 4:07:32 PM (7 years ago)
- Location:
- branches/3.3
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3/mindi-busybox/libbb/utmp.c
r3232 r3621 17 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 20 char *id; 21 21 unsigned width; … … 46 46 strncpy(id, tty_name, width); 47 47 48 touch(_PATH_UTMP );49 //utmp name(_PATH_UTMP);50 setut ent();48 touch(_PATH_UTMPX); 49 //utmpxname(_PATH_UTMPX); 50 setutxent(); 51 51 /* Append new one (hopefully, unless we collide on ut_id) */ 52 putut line(&utent);53 endut ent();52 pututxline(&utent); 53 endutxent(); 54 54 55 55 #if ENABLE_FEATURE_WTMP 56 56 /* "man utmp" says wtmp file should *not* be created automagically */ 57 57 /*touch(bb_path_wtmp_file);*/ 58 updwtmp (bb_path_wtmp_file, &utent);58 updwtmpx(bb_path_wtmp_file, &utent); 59 59 #endif 60 60 } … … 65 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;68 struct utmp *utp;67 struct utmpx utent; 68 struct utmpx *utp; 69 69 70 touch(_PATH_UTMP );71 //utmp name(_PATH_UTMP);72 setut ent();70 touch(_PATH_UTMPX); 71 //utmpxname(_PATH_UTMPX); 72 setutxent(); 73 73 74 74 /* Did init/getty/telnetd/sshd/... create an entry for us? 75 75 * It should be (new_type-1), but we'd also reuse 76 76 * any other potentially stale xxx_PROCESS entry */ 77 while ((utp = getut ent()) != NULL) {77 while ((utp = getutxent()) != NULL) { 78 78 if (utp->ut_pid == pid 79 79 // && ut->ut_line[0] … … 89 89 memset(utp->ut_host, 0, sizeof(utp->ut_host)); 90 90 } 91 /* NB: putut line (see later) searches for matching utent92 * using getut id(utent) - we must not change ut_id91 /* NB: pututxline (see later) searches for matching utxent 92 * using getutxid(utent) - we must not change ut_id 93 93 * if we want *exactly this* record to be overwritten! 94 94 */ … … 96 96 } 97 97 } 98 //endut ent(); - no need, pututline can deal with (and actually likes)98 //endutxent(); - no need, pututxline can deal with (and actually likes) 99 99 //the situation when utmp file is positioned on found record 100 100 … … 103 103 write_new_utmp(pid, new_type, tty_name, username, hostname); 104 104 else 105 endut ent();105 endutxent(); 106 106 return; 107 107 } 108 108 109 /* Make a copy. We can't use *utp, putut line's internal getutid109 /* Make a copy. We can't use *utp, pututxline's internal getutxid 110 110 * will overwrite it before it is used! */ 111 111 utent = *utp; … … 121 121 122 122 /* Update, or append new one */ 123 //setut ent();124 putut line(&utent);125 endut ent();123 //setutxent(); 124 pututxline(&utent); 125 endutxent(); 126 126 127 127 #if ENABLE_FEATURE_WTMP 128 128 /* "man utmp" says wtmp file should *not* be created automagically */ 129 129 /*touch(bb_path_wtmp_file);*/ 130 updwtmp (bb_path_wtmp_file, &utent);130 updwtmpx(bb_path_wtmp_file, &utent); 131 131 #endif 132 132 } 133 134 /* man utmp: 135 * When init(8) finds that a process has exited, it locates its utmp entry 136 * by ut_pid, sets ut_type to DEAD_PROCESS, and clears ut_user, ut_host 137 * and ut_time with null bytes. 138 * [same applies to other processes which maintain utmp entries, like telnetd] 139 * 140 * We do not bother actually clearing fields: 141 * it might be interesting to know who was logged in and from where 142 */ 143 void FAST_FUNC update_utmp_DEAD_PROCESS(pid_t pid) 144 { 145 update_utmp(pid, DEAD_PROCESS, NULL, NULL, NULL); 146 }
Note:
See TracChangeset
for help on using the changeset viewer.