| Skip Navigation Links | |
| Exit Print View | |
![]() | man pages section 3: Basic Library Functions Oracle Solaris 11 Information Library |
enable_extended_FILE_stdio(3C)
posix_spawnattr_getschedparam(3C)
posix_spawnattr_getschedpolicy(3C)
posix_spawnattr_getsigdefault(3C)
posix_spawnattr_getsigignore_np(3C)
posix_spawnattr_getsigmask(3C)
posix_spawnattr_setschedparam(3C)
posix_spawnattr_setschedpolicy(3C)
posix_spawnattr_setsigdefault(3C)
posix_spawnattr_setsigignore_np(3C)
posix_spawnattr_setsigmask(3C)
posix_spawn_file_actions_addclose(3C)
posix_spawn_file_actions_addclosefrom_np(3C)
posix_spawn_file_actions_adddup2(3C)
posix_spawn_file_actions_addopen(3C)
posix_spawn_file_actions_destroy(3C)
posix_spawn_file_actions_init(3C)
pthread_attr_getdetachstate(3C)
pthread_attr_getinheritsched(3C)
pthread_attr_getschedparam(3C)
pthread_attr_getschedpolicy(3C)
pthread_attr_setdetachstate(3C)
pthread_attr_setinheritsched(3C)
pthread_attr_setschedparam(3C)
pthread_attr_setschedpolicy(3C)
pthread_barrierattr_destroy(3C)
pthread_barrierattr_getpshared(3C)
pthread_barrierattr_setpshared(3C)
pthread_condattr_getpshared(3C)
pthread_condattr_setpshared(3C)
pthread_cond_reltimedwait_np(3C)
pthread_key_create_once_np(3C)
pthread_mutexattr_getprioceiling(3C)
pthread_mutexattr_getprotocol(3C)
pthread_mutexattr_getpshared(3C)
pthread_mutexattr_getrobust(3C)
pthread_mutexattr_setprioceiling(3C)
pthread_mutexattr_setprotocol(3C)
pthread_mutexattr_setpshared(3C)
pthread_mutexattr_setrobust(3C)
pthread_mutex_getprioceiling(3C)
pthread_mutex_reltimedlock_np(3C)
pthread_mutex_setprioceiling(3C)
pthread_rwlockattr_destroy(3C)
pthread_rwlockattr_getpshared(3C)
pthread_rwlockattr_setpshared(3C)
pthread_rwlock_reltimedrdlock_np(3C)
pthread_rwlock_reltimedwrlock_np(3C)
pthread_rwlock_timedrdlock(3C)
pthread_rwlock_timedwrlock(3C)
rctlblk_get_enforced_value(3C)
- user accounting database functions
#include <utmpx.h>struct utmpx *getutxent(void);
struct utmpx *getutxid(const struct utmpx *id);
struct utmpx *getutxline(const struct utmpx *line);
struct utmpx *pututxline(const struct utmpx *utmpx);
voidsetutxent(void);
voidendutxent(void);
intutmpxname(const char *file);
voidgetutmp(struct utmpx *utmpx,struct utmp *utmp);
voidgetutmpx(struct utmp *utmp,struct utmpx *utmpx);
voidupdwtmp(char *wfile,struct utmp *utmp);
voidupdwtmpx(char *wfilex,struct utmpx *utmpx);
These functions provide access to the user accounting database,utmpx (seeutmpx(4)).Entries in the database are described by the definitions and data structures in<utmpx.h>.
Theutmpx structure contains the following members:
char ut_user[32]; /* user login name */char ut_id[4]; /* /etc/inittab id */ /* (usually line #) */char ut_line[32]; /* device name */ /* (console, lnxx) */pid_t ut_pid; /* process id */short ut_type; /* type of entry */struct exit_status ut_exit; /* exit status of a process */ /* marked as DEAD_PROCESS */struct timeval ut_tv; /* time entry was made */int ut_session; /* session ID, used for */ /* windowing */short ut_syslen; /* significant length of */ /* ut_host */ /* including terminating null */char ut_host[257]; /* host name, if remote */
Theexit_status structure includes the following members:
short e_termination; /* termination status */short e_exit; /* exit status */
Thegetutxent() function reads in the next entry from autmpx database.If the database is not already open, it opens it. If itreaches the end of the database, it fails.
Thegetutxid() function searches forward from the current point in theutmpxdatabase until it finds an entry with aut_type matchingid–>ut_type, ifthe type specified isRUN_LVL,BOOT_TIME,DOWN_TIME,OLD_TIME, orNEW_TIME. If thetype specified inid isINIT_PROCESS,LOGIN_PROCESS,USER_PROCESS, orDEAD_PROCESS, thengetutxid() willreturn a pointer to the first entry whose type is one ofthese four and whoseut_id member matchesid–>ut_id. If the end ofdatabase is reached without a match, it fails.
Thegetutxline() function searches forward from the current point in theutmpxdatabase until it finds an entry of the typeLOGIN_PROCESS orUSER_PROCESSwhich also has aut_line string matching theline->ut_line string. If theend of the database is reached without a match, it fails.
Thepututxline() function writes the suppliedutmpx structure into theutmpx database. It usesgetutxid() to search forward for the proper place ifit finds that it is not already at the proper place. It is expected that normally the user ofpututxline() will have searched forthe proper entry using one of thegetutx() routines. If so,pututxline() will not search. Ifpututxline() does not find a matchingslot for the new entry, it will add a new entry to theend of the database. It returns a pointer to theutmpx structure. When called by a non-root user,pututxline() invokes asetuid()root program to verify and write the entry, since theutmpx database isnormally writable only by root. In this event, theut_name membermust correspond to the actual user name associated with the process; theut_type member must be eitherUSER_PROCESS orDEAD_PROCESS; and theut_linemember must be a device special file and be writable by theuser.
Thesetutxent() function resets the input stream to the beginning. This shouldbe done before each search for a new entry if it isdesired that the entire database be examined.
Theendutxent() function closes the currently open database.
Theutmpxname() function allows the user to change the name of thedatabase file examined from/var/adm/utmpx to any other file, most often/var/adm/wtmpx. If the file does not exist, this will not be apparentuntil the first attempt to reference the file is made. Theutmpxname()function does not open the file, but closes the old file ifit is currently open and saves the new file name. The newfile name must end with the “x” character to allow the nameof the correspondingutmp file to be easily obtainable.; otherwise, an error valueof0 is returned. The function returns1 on success.
Thegetutmp() function copies the information stored in the members of theutmpx structure to the corresponding members of theutmp structure. If theinformation in any member ofutmpx does not fit in thecorrespondingutmp member, the data is silently truncated. (Seegetutent(3C) forutmp structure)
Thegetutmpx() function copies the information stored in the members of theutmp structure to the corresponding members of theutmpx structure. (Seegetutent(3C)forutmp structure)
Theupdwtmp() function can be used in two ways.
Ifwfile is/var/adm/wtmp, theutmp format record supplied by the calleris converted to autmpxformat record and the/var/adm/wtmpx file is updated(because the/var/adm/wtmp file no longer exists, operations onwtmp are converted tooperations onwtmpx by the library functions.
Ifwfile is a file other than/var/adm/wtmp, it is assumed tobe an old file inutmp format and is updated directly withtheutmp format record supplied by the caller.
Theupdwtmpx() function writes the contents of theutmpx structure pointed tobyutmpx to the database.
The values of thee_termination ande_exit members of theut_exit structureare valid only for records of typeDEAD_PROCESS. Forutmpx entries createdbyinit(1M), these values are set according to the result ofthewait() call thatinit performs on the process when the processexits. See thewait(3C), manual page for the valuesinit uses. Applicationscreatingutmpx entries can setut_exit values using the following code example:
u->ut_exit.e_termination = WTERMSIG(process->p_exit)u->ut_exit.e_exit = WEXITSTATUS(process->p_exit)
Seewait.h(3HEAD) for descriptions of theWTERMSIG andWEXITSTATUS macros.
Theut_session member is not acted upon by the operating system. Itis used by applications interested in creatingutmpx entries.
For records of typeUSER_PROCESS, thenonuser() andnonuserx() macros use thevalue of theut_exit.e_exit member to markutmpx entries as real logins(as opposed to multiple xterms started by the same user on a windowsystem). This allows the system utilities that display users to obtainan accurate indication of the number of actual users, while still permittingeachpty to have autmpx record (as most applications expect.). TheNONROOT_USER macro defines the value thatlogin places in theut_exit.e_exit member.
Upon successful completion,getutxent(),getutxid(), andgetutxline() each return a pointer toautmpx structure containing a copy of the requested entry in theuser accounting database. Otherwise a null pointer is returned.
The return value may point to a static area which is overwrittenby a subsequent call togetutxid () orgetutxline().
Upon successful completion,pututxline() returns a pointer to autmpx structure containinga copy of the entry added to the user accounting database. Otherwise a null pointer is returned.
Theendutxent() andsetutxent() functions return no value.
A null pointer is returned upon failure to read, whether for permissionsor having reached the end of file, or upon failure to write.
These functions use buffered standard I/O for input, butpututxline() uses anunbuffered write to avoid race conditions between processes trying to modify theutmpx andwtmpx files.
Applications should not access theutmpx andwtmpx databases directly, but shoulduse these functions to ensure that these databases are maintained consistently.
user access and accounting information
history of user access and accounting information
Seeattributes(5) for descriptions of the following attributes:
|
Theendutxent(),getutxent(),getutxid(),getutxline(),pututxline(), andsetutxent() functions are Standard.
getutent(3C),ttyslot(3C),wait(3C),wait.h(3HEAD),utmpx(4),attributes(5),standards(5)
The most current entry is saved in a static structure. Multipleaccesses require that it be copied before further accesses are made. Oneach call to eithergetutxid() orgetutxline(), the routine examines the staticstructure before performing more I/O. If the contents of the static structure matchwhat it is searching for, it looks no further. For this reason,to usegetutxline() to search for multiple occurrences it would be necessaryto zero out the static after each success, orgetutxline() would just returnthe same structure over and over again. There is one exception tothe rule about emptying the structure before further reads are done. The implicit read done bypututxline() (if it finds that it isnot already at the correct place in the file) will not hurtthe contents of the static structure returned by thegetutxent(),getutxid(), orgetutxline()routines, if the user has just modified those contents and passed thepointer back topututxline().
Copyright © 2011, Oracle and/or its affiliates. All rights reserved.Legal Notices | ![]() ![]() |