1utmp(5) File Formats Manual utmp(5)
2
3
4
6 utmp, wtmp - login records
7
9 #include <utmp.h>
10
12 The utmp file allows one to discover information about who is currently
13 using the system. There may be more users currently using the system,
14 because not all programs use utmp logging.
15
16 Warning: utmp must not be writable by the user class "other", because
17 many system programs (foolishly) depend on its integrity. You risk
18 faked system logfiles and modifications of system files if you leave
19 utmp writable to any user other than the owner and group owner of the
20 file.
21
22 The file is a sequence of utmp structures, declared as follows in
23 <utmp.h> (note that this is only one of several definitions around; de‐
24 tails depend on the version of libc):
25
26 /* Values for ut_type field, below */
27
28 #define EMPTY 0 /* Record does not contain valid info
29 (formerly known as UT_UNKNOWN on Linux) */
30 #define RUN_LVL 1 /* Change in system run-level (see
31 init(1)) */
32 #define BOOT_TIME 2 /* Time of system boot (in ut_tv) */
33 #define NEW_TIME 3 /* Time after system clock change
34 (in ut_tv) */
35 #define OLD_TIME 4 /* Time before system clock change
36 (in ut_tv) */
37 #define INIT_PROCESS 5 /* Process spawned by init(1) */
38 #define LOGIN_PROCESS 6 /* Session leader process for user login */
39 #define USER_PROCESS 7 /* Normal process */
40 #define DEAD_PROCESS 8 /* Terminated process */
41 #define ACCOUNTING 9 /* Not implemented */
42
43 #define UT_LINESIZE 32
44 #define UT_NAMESIZE 32
45 #define UT_HOSTSIZE 256
46
47 struct exit_status { /* Type for ut_exit, below */
48 short e_termination; /* Process termination status */
49 short e_exit; /* Process exit status */
50 };
51
52 struct utmp {
53 short ut_type; /* Type of record */
54 pid_t ut_pid; /* PID of login process */
55 char ut_line[UT_LINESIZE]; /* Device name of tty - "/dev/" */
56 char ut_id[4]; /* Terminal name suffix,
57 or inittab(5) ID */
58 char ut_user[UT_NAMESIZE]; /* Username */
59 char ut_host[UT_HOSTSIZE]; /* Hostname for remote login, or
60 kernel version for run-level
61 messages */
62 struct exit_status ut_exit; /* Exit status of a process
63 marked as DEAD_PROCESS; not
64 used by Linux init(1) */
65 /* The ut_session and ut_tv fields must be the same size when
66 compiled 32- and 64-bit. This allows data files and shared
67 memory to be shared between 32- and 64-bit applications. */
68 #if __WORDSIZE == 64 && defined __WORDSIZE_COMPAT32
69 int32_t ut_session; /* Session ID (getsid(2)),
70 used for windowing */
71 struct {
72 int32_t tv_sec; /* Seconds */