DragonFly On-Line Manual Pages

Search: Section:  

ENDUTXENT(3)	      DragonFly Library Functions Manual	  ENDUTXENT(3)


endutxent, getutxent, getutxid, getutxline, pututxline, setutxent, setutxdb -- user accounting database functions


Standard C Library (libc, -lc)


#include <utmpx.h> void endutxent(void); struct utmpx * getutxent(void); struct utmpx * getutxid(const struct utmpx *); struct utmpx * getutxline(const struct utmpx *); struct utmpx * pututxline(const struct utmpx *); void setutxent(void); int setutxdb(utx_db_t db, char *fname);


These functions provide access to the utmpx(5) and wtmpx(5) user account- ing database. getutxent() reads the next entry from the database; if the database was not yet open, it also opens it. setutxent() resets the database, so that the next getutxent() call will get the first entry. endutxent() closes the database. getutxid() returns the next entry of the type specified in its argument's ut_type field, or NULL if none is found. getutxline() returns the next LOGIN_PROCESS or USER_PROCESS entry which has the same name as specified in the ut_line field, or NULL if no match is found. pututxline() adds the argument utmpx(5) entry line to the accounting database, replacing a previous entry for the same user if it exists. By default the aforementioned functions work on the default utmpx(5) database. The function setutxdb() allows to change the database type being operated on, as well as changing the path to that database. The first parameter db can be UTX_DB_UTMPX or UTX_DB_WTMPX and specifies which database to open. If fname is NULL the default path for each of these is used as described in utmpx(5) and wtmpx(5). Otherwise the path specified in fname is used as the database. The utmpx structure The utmpx structure has the following definition: struct utmpx { char ut_name[_UTX_USERSIZE]; /* login name */ char ut_id[_UTX_IDSIZE]; /* inittab id */ char ut_line[_UTX_LINESIZE]; /* tty name */ char ut_host[_UTX_HOSTSIZE]; /* host name */ uint16_t ut_session; /* session id used for windowing */ uint16_t ut_type; /* type of this entry */ pid_t ut_pid; /* process id creating the entry */ struct { uint16_t e_termination; /* process termination signal */ uint16_t e_exit; /* process exit status */ } ut_exit; struct sockaddr_storage ut_ss; /* address where entry was made from */ struct timeval ut_tv; /* time entry was created */ uint32_t ut_pad[10]; /* reserved for future use */ }; Valid entries for ut_type are: BOOT_TIME Time of a system boot. DEAD_PROCESS A session leader exited. EMPTY No valid user accounting information. INIT_PROCESS A process spawned by init(8). LOGIN_PROCESS The session leader of a logged-in user. NEW_TIME Time after system clock change. OLD_TIME Time before system clock change. RUN_LVL Run level. Provided for compatibility, not used on NetBSD. USER_PROCESS A user process.


getutxent() returns the next entry, or NULL on failure (end of database or problems reading from the database). getutxid() and getutxline() return the matching structure on success, or NULL if no match was found. pututxline() returns the structure that was successfully written, or NULL. setutxdb() returns 0 on success. Otherwise a negative value is returned and the global variable errno is set to indicate the error.


logwtmpx(3), utmpx(5)


The endutxent(), getutxent(), getutxid(), getutxline(), pututxline(), setutxent() all conform to IEEE Std 1003.1-2001 (``POSIX.1'') (XSI exten- sion), and previously to X/Open Portability Guide Issue 4, Version 2 (``XPG4.2''). The fields ut_user, ut_id, ut_line, ut_pid, ut_type, and ut_tv conform to IEEE Std 1003.1-2001 (``POSIX.1'') (XSI extension), and previously to X/Open Portability Guide Issue 4, Version 2 (``XPG4.2''). DragonFly 4.7 December 20, 2010 DragonFly 4.7

Search: Section: