@node Users and Groups, System Information, Job Control, Top
@chapter Users and Groups
Every user who can log in on the system is identified by a unique number
called the @dfn{user ID}. Each process has an effective user ID which
says which user's access permissions it has.
Users are classified into @dfn{groups} for access control purposes. Each
process has one or more @dfn{group ID values} which say which groups the
process can use for access to files.
The effective user and group IDs of a process collectively form its
@dfn{persona}. This determines which files the process can access.
Normally, a process inherits its persona from the parent process, but
under special circumstances a process can change its persona and thus
change its access permissions.
Each file in the system also has a user ID and a group ID. Access
control works by comparing the user and group IDs of the file with those
of the running process.
The system keeps a database of all the registered users, and another
database of all the defined groups. There are library functions you
can use to examine these databases.
@menu
* User and Group IDs:: Each user has a unique numeric ID;
likewise for groups.
* Process Persona:: The user IDs and group IDs of a process.
* Why Change Persona:: Why a program might need to change
its user and/or group IDs.
* How Change Persona:: Changing the user and group IDs.
* Reading Persona:: How to examine the user and group IDs.
* Setting User ID:: Functions for setting the user ID.
* Setting Groups:: Functions for setting the group IDs.
* Enable/Disable Setuid:: Turning setuid access on and off.
* Setuid Program Example:: The pertinent parts of one sample program.
* Tips for Setuid:: How to avoid granting unlimited access.
* Who Logged In:: Getting the name of the user who logged in,
or of the real user ID of the current process.
* User Database:: Functions and data structures for
accessing the user database.
* Group Database:: Functions and data structures for
accessing the group database.
* Database Example:: Example program showing use of database
inquiry functions.
@end menu
@node User and Group IDs
@section User and Group IDs
@cindex login name
@cindex user name
@cindex user ID
Each user account on a computer system is identified by a @dfn{user
name} (or @dfn{login name}) and @dfn{user ID}. Normally, each user name
has a unique user ID, but it is possible for several login names to have
the same user ID. The user names and corresponding user IDs are stored
in a data base which you can access as described in @ref{User Database}.
@cindex group name
@cindex group ID
Users are classified in @dfn{groups}. Each user name also belongs to
one or more groups, and h