- Documentation
- Reference manual
- Packages
- SWI-Prolog C-library
- Introduction
- library(process): Create processes and redirect I/O
- library(filesex): Extended operations on files
- library(uid): User and group management on Unix systems
- library(syslog): Unix syslog interface
- library(socket): Network socket (TCP and UDP) library
- The stream_pool library
- library(uri): Process URIs
- CGI Support library
- Password encryption library
- library(uuid): Universally Unique Identifier (UUID) Library
- SHA* Secure Hash Algorithms
- library(md5): MD5 hashes
- library(hash_stream): Maintain a hash on a stream
- Memory files
- Time and alarm library
- library(unix): Unix specific operations
- Limiting process resources
- library(udp_broadcast): A UDP Broadcast Bridge
- library(prolog_stream): A stream with Prolog callbacks
- SWI-Prolog C-library
4 library(uid): User and group management on Unix systems
- See also
- Please check the documentation of your OS for details on the semantics of this predicates.
This module provides and interface to user and group information on Posix systems. In addition, it allows for changing user and group ids. When changing user and group settings for the calling process, bear in mind that:
- Changing user and groups of the calling process requires permission.
- The functions
setgroups()
andinitgroups()
are not part of the POSIX standard and therefore the derived predicates may not be present.
- [det]getuid(-UID)
- UID is the real user ID of the calling process.
- [det]getgid(-GID)
- GID is the real group ID of the calling process.
- [det]geteuid(-UID)
- UID is the effective user ID of the calling process.
- [det]getegid(-GID)
- GID is the effective group ID of the calling process.
- [det]getgroups(-GroupsIDs:list(integer))
- GroupsIDs is the set of supplementary group IDs of the calling process. Note that these are numeric identifiers. Use group_info/2 to obtain details on the returned group identifiers.
- [det]user_info(+User, -UserData)
- UserData represent the passwd information for User. User is either a numeric UID or a user name. The predicate user_data/3 can be used to extract information from UserData.
- user_data(?Field, ?UserData, ?Value)
- Value is the value for Field in UserData.
Defined fields are:
- name
- Name of the user
- password
- Password hash of the user (or
x
if this is not accessible) - uid
- Numeric user id of the user
- gid
- Numeric primary group id of the user
- comment
- The gecos field
- home
- Home directory of the user
- shell
- Default (login) shell of the user.
- [det]group_info(+Group, -GroupData)
- GroupData represent the group information for Group. Group is either a numeric GID or a group name. The predicate group_data/3 can be used to extract information from GroupData.
- group_data(?Field, ?GroupData, ?Value)
- Value is the value for Field GroupData.
Defined fields are:
- name
- Name of the user
- password
- Password hash of the user (or
x
if this is not accessible) - gid
- Numeric group id of the group
- members
- List of user-names that are member of this group.
- setuid(+UID)
- Set the user id of the calling process.
- seteuid(+UID)
- Set the effective user id of the calling process.
- setgid(+GID)
- Set the group id of the calling process.
- setegid(+GID)
- Set the effective group id of the calling process.
- [det]initgroups(+User, +Group)
- Initialise the group access list of the calling process to the registered groups for User and the group Group. This predicate is only available if the underlying OS provides it.
- [det]setgroups(+Groups:list(integer))
- Set the group access list of the caling process to the indicated groups. This predicate is only available if the underlying OS provides it.
- [det]set_user_and_group(+User)
- [det]set_user_and_group(+User, +Group)
- Set the UID and GID to the User. User is either a UID or a user name. If Group is not specified, the primary group of User is used. If initgroups/2 is available, the resulting group access list of the calling process consists of the registered groups for User and the specified Group.