logwtmp

Name

logwtmp -- append an entry to the wtmp file

Synopsis

#include <utmp.h>

void logwtmp (const char * line , const char * name , const char * host );

Description

If the process has permission to update the user accounting databases, the logwtmp() function shall append a record to the user accounting database that records all logins and logouts. The record to be appended shall be constructed as follows:

  1. The ut_line field shall be initialized from line. If the user accounting database imposes a limit on the size of the ut_line field, it shall truncate the value, but any such limit shall not be smaller than UT_LINESIZE (including a terminating null character).

  2. The ut_name field shall be initialized from name. If the user accounting database imposes a limit on the size of the ut_name field, it shall truncate the value, but any such limit shall not be smaller than UT_NAMESIZE (including a terminating null character).

  3. The ut_host field shall be initialized from host. If the user accounting database imposes a limit on the size of the ut_host field, it shall truncate the value, but any such limit shall not be smaller than UT_HOSTSIZE (including a terminating null character).

  4. If the name parameter does not refer to an empty string (i.e. ""), the ut_type field shall be set to USER_PROCESS; otherwise the ut_type field shall be set to DEAD_PROCESS.

  5. The ut_id field shall be set to the process identifier for the current process.

  6. The ut_tv field shall be set to the current time of day.

Note: If a process does not have write access to the the user accounting database, the logwtmp() function will not update it. Since the function does not return any value, an application has no way of knowing whether it succeeded or failed.

Return Value

None.