1LOGIN(3)                  Linux System Administration                 LOGIN(3)
2
3
4

NAME

6       login, logout - write utmp and wtmp entries
7

SYNOPSIS

9       #include <utmp.h>
10
11       void login(const struct utmp *ut);
12       int logout(const char *ut_line);
13

DESCRIPTION

15       The utmp file records who is currently using the system.  The wtmp file
16       records all logins and logouts. See utmp(5).
17
18       The function login() takes the supplied struct utmp ut, and  writes  it
19       to both utmp and wtmp file.
20
21       The function logout() clears the entry in the utmp file again.
22

GNU DETAILS

24       More  precisely,  login() takes the argument ut struct, fills the field
25       ut->ut_type (if there is such a field) with the value USER_PROCESS, and
26       fills  the field ut->ut_pid (if there is such a field) with the process
27       ID  of  the  calling  process.   Then  it  tries  to  fill  the   field
28       ut->ut_line.   It  takes  the  first of stdin, stdout, stderr that is a
29       tty, and stores the corresponding pathname  minus  a  possible  leading
30       /dev/ into this field, and then writes the struct to the utmp file.  On
31       the other hand, if no tty name was found, this  field  is  filled  with
32       "???"  and the struct is not written to the utmp file.  After this, the
33       struct is written to the wtmp file.
34
35       The logout() function searches the utmp file for an entry matching  the
36       ut_line  argument.  If  a record is found, it is updated by zeroing out
37       the ut_name and ut_host fields, updating the ut_tv timestamp field  and
38       setting ut_type (if there is such a field) to DEAD_PROCESS.
39

RETURN VALUES

41       The  logout()  function returns 1 if the entry was successfully written
42       to the database, or 0 if an error occurred.
43

NOTE

45       These functions are included in  libutil,  hence  you'll  need  to  add
46       -lutil to your compiler command line.
47
48       Note  that  the member ut_user of struct utmp is called ut_name in BSD.
49       Therefore, ut_name is defined as an alias for ut_user in <utmp.h>.
50

FILES

52       /var/run/utmp
53              user  accounting  database,  configured  through  _PATH_UTMP  in
54              <paths.h>
55
56       /var/log/wtmp
57              user  accounting  log  file,  configured  through  _PATH_WTMP in
58              <paths.h>
59

CONFORMING TO

61       Not in POSIX.1-2001.  Present on the BSDs.
62

SEE ALSO

64       getutent(3), utmp(5)
65
66
67
68GNU/Linux                         2004-05-06                          LOGIN(3)
Impressum