Copyright | (c) The University of Glasgow 2002 |
---|---|
License | BSD-style (see the file libraries/base/LICENSE) |
Maintainer | libraries@haskell.org |
Stability | provisional |
Portability | non-portable (requires POSIX) |
Safe Haskell | Trustworthy |
Language | Haskell2010 |
System.Posix.User
Description
POSIX user/group support
Synopsis
- getRealUserID :: IOUserID
- getRealGroupID :: IOGroupID
- getEffectiveUserID :: IOUserID
- getEffectiveGroupID :: IOGroupID
- getGroups :: IO [GroupID]
- getLoginName :: IOString
- getEffectiveUserName :: IOString
- groupName :: GroupEntry -> String
- groupPassword :: GroupEntry -> String
- groupID :: GroupEntry -> GroupID
- groupMembers :: GroupEntry -> [String]
- patternGroupEntry :: String -> String -> GroupID -> [String] -> GroupEntry
- getGroupEntryForID :: GroupID -> IOGroupEntry
- getGroupEntryForName :: String -> IOGroupEntry
- getAllGroupEntries :: IO [GroupEntry]
- userName :: UserEntry -> String
- userPassword :: UserEntry -> String
- userID :: UserEntry -> UserID
- userGroupID :: UserEntry -> GroupID
- userGecos :: UserEntry -> String
- homeDirectory :: UserEntry -> String
- userShell :: UserEntry -> String
- patternUserEntry :: String -> String -> UserID -> GroupID -> String -> String -> String -> UserEntry
- getUserEntryForID :: UserID -> IOUserEntry
- getUserEntryForName :: String -> IOUserEntry
- getAllUserEntries :: IO [UserEntry]
- setUserID :: UserID -> IO ()
- setGroupID :: GroupID -> IO ()
- setEffectiveUserID :: UserID -> IO ()
- setEffectiveGroupID :: GroupID -> IO ()
- setGroups :: [GroupID] -> IO ()
User environment
Querying the user environment
getRealUserID :: IOUserIDSource#
getRealUserID
calls getuid
to obtain the real UserID
associated with the current process.
getRealGroupID :: IOGroupIDSource#
getRealGroupID
calls getgid
to obtain the real GroupID
associated with the current process.
getEffectiveUserID :: IOUserIDSource#
getEffectiveUserID
calls geteuid
to obtain the effective UserID
associated with the current process.
getEffectiveGroupID :: IOGroupIDSource#
getEffectiveGroupID
calls getegid
to obtain the effective GroupID
associated with the current process.
getGroups :: IO [GroupID] Source#
getGroups
calls getgroups
to obtain the list of supplementary GroupID
s associated with the current process.
getLoginName :: IOStringSource#
getLoginName
calls getlogin
to obtain the login name associated with the current process.
getEffectiveUserName :: IOStringSource#
getEffectiveUserName
gets the name associated with the effective UserID
of the process.
The group database
groupName :: GroupEntry -> StringSource#
groupID :: GroupEntry -> GroupIDSource#
groupMembers :: GroupEntry -> [String] Source#
patternGroupEntrySource#
Arguments
:: String | The name of this group (gr_name) |
-> String | The password for this group (gr_passwd) |
-> GroupID | The unique numeric ID for this group (gr_gid) |
-> [String] | A list of zero or more usernames that are members (gr_mem) |
-> GroupEntry |
Manually constructing GroupEntry
in String modules is discouraged. It will truncate Chars to 8bit. Use ByteString
instead.
getGroupEntryForID :: GroupID -> IOGroupEntrySource#
getGroupEntryForID gid
calls getgrgid_r
to obtain the GroupEntry
information associated with GroupID
gid
. This operation may fail with isDoesNotExistError
if no such group exists.
getGroupEntryForName :: String -> IOGroupEntrySource#
getGroupEntryForName name
calls getgrnam_r
to obtain the GroupEntry
information associated with the group called name
. This operation may fail with isDoesNotExistError
if no such group exists.
getAllGroupEntries :: IO [GroupEntry] Source#
getAllGroupEntries
returns all group entries on the system by repeatedly calling getgrent
The user database
Arguments
:: String | Textual name of this user (pw_name) |
-> String | Password -- may be empty or fake if shadow is in use (pw_passwd) |
-> UserID | Numeric ID for this user (pw_uid) |
-> GroupID | Primary group ID (pw_gid) |
-> String | Usually the real name for the user (pw_gecos) |
-> String | Home directory (pw_dir) |
-> String | Default shell (pw_shell) |
-> UserEntry |
Manually constructing UserEntry
in String modules is discouraged. It will truncate Chars to 8bit. Use ByteString
instead.
getUserEntryForID :: UserID -> IOUserEntrySource#
getUserEntryForID uid
calls getpwuid_r
to obtain the UserEntry
information associated with UserID
uid
. This operation may fail with isDoesNotExistError
if no such user exists.
getUserEntryForName :: String -> IOUserEntrySource#
getUserEntryForName name
calls getpwnam_r
to obtain the UserEntry
information associated with the user login name
. This operation may fail with isDoesNotExistError
if no such user exists.
getAllUserEntries :: IO [UserEntry] Source#
getAllUserEntries
returns all user entries on the system by repeatedly calling getpwent
Modifying the user environment
setUserID :: UserID -> IO () Source#
setUserID uid
calls setuid
to set the real, effective, and saved set-user-id associated with the current process to uid
.
setGroupID :: GroupID -> IO () Source#
setGroupID gid
calls setgid
to set the real, effective, and saved set-group-id associated with the current process to gid
.
setEffectiveUserID :: UserID -> IO () Source#
setEffectiveUserID uid
calls seteuid
to set the effective user-id associated with the current process to uid
. This does not update the real user-id or set-user-id.
setEffectiveGroupID :: GroupID -> IO () Source#
setEffectiveGroupID uid
calls setegid
to set the effective group-id associated with the current process to gid
. This does not update the real group-id or set-group-id.