Qore Programming Language Reference Manual 2.2.1
Loading...
Searching...
No Matches
UNIX User and Group Functions

Functions

*hash Qore::getgrgid (softint gid)
 Returns a group information hash representing the group information for the group ID passed, or, if the group ID does not exist NOTHING is returned.
hash Qore::getgrgid2 (softint gid)
 Returns a group information hash representing the group information for the group ID passed, or, if the group ID does not exist, a GETGRGID2-ERROR exception is thrown.
*hash Qore::getgrnam (string name)
 Returns a group information hash representing the group information for the group name passed, or, if the group does not exist NOTHING is returned.
hash Qore::getgrnam2 (string name)
 Returns a group information hash representing the group information for the group name passed, or, if the group does not exist, a GETGRNAM2-ERROR exception is thrown.
hash Qore::getpwnam (string name)
 Returns a password information hash representing the user information for the user name passed, or, if the user does not exist NOTHING is returned.
hash Qore::getpwnam2 (string name)
 Returns a password information hash representing the user information for the user name passed, or, if the user does not exist, a GETPWNAM2-ERROR exception is thrown.
nothing Qore::getpwuid ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.
*hash Qore::getpwuid (softint uid)
 Returns a password information hash representing the user information for the user ID passed, or, if the user ID does not exist NOTHING is returned.
hash Qore::getpwuid2 (softint uid)
 Returns a password information hash representing the user information for the user ID passed, or, if the user ID does not exist, a GETPWUID2-ERROR exception is thrown.

Detailed Description

UNIX user and group functions

Group Information Hash

KeyTypeDescription
gr_name stringThe name of the group
gr_passwd stringThe encrypted password for the group
gr_gid intThe group id
gr_mem listList of strings giving the usernames of members of the group

Password Information Hash

KeyTypeDescription
pw_name stringThe username of the user
pw_passwd stringThe encrypted password for the user
pw_gecos stringThe real name or description of the user
pw_dir stringThe user's home directory
pw_shell stringThe user's login shell
pw_uid intThe user's userid
pw_gid intThe group id of the user's primary group

Function Documentation

◆ getgrgid()

*hash Qore::getgrgid ( softint gid)

Returns a group information hash representing the group information for the group ID passed, or, if the group ID does not exist NOTHING is returned.

Platform Availability:
Qore::Option::HAVE_UNIX_USERMGT
Restrictions:
Qore::PO_NO_EXTERNAL_INFO
Code Flags:
CONSTANT
Parameters
gidthe group ID to look up
Returns
a group information hash representing the group information for the group ID passed, or, if the group ID does not exist NOTHING is returned
Example:
*hash hash = getgrgid(0);
See also
getgrgid2() for a similar function that throws an exception if the group ID is invalid

◆ getgrgid2()

hash Qore::getgrgid2 ( softint gid)

Returns a group information hash representing the group information for the group ID passed, or, if the group ID does not exist, a GETGRGID2-ERROR exception is thrown.

Platform Availability:
Qore::Option::HAVE_UNIX_USERMGT
Restrictions:
Qore::PO_NO_EXTERNAL_INFO
Code Flags:
RET_VALUE_ONLY
Parameters
gidthe group ID to look up
Returns
a group information hash representing the group information for the group ID passed, or, if the group ID does not exist, a GETGRGID2-ERROR exception is thrown
Example:
*hash hash = getgrgid2(0);
Exceptions
GETGRGID2-ERRORinvalid gid or error reading group information
See also
getgrgid() for a similar function that does not throw an exception if the group ID is invalid

◆ getgrnam()

*hash Qore::getgrnam ( string name)

Returns a group information hash representing the group information for the group name passed, or, if the group does not exist NOTHING is returned.

Platform Availability:
Qore::Option::HAVE_UNIX_USERMGT
Restrictions:
Qore::PO_NO_EXTERNAL_INFO
Code Flags:
CONSTANT
Parameters
namethe group name to look up
Returns
a group information hash representing the group information for the group name passed, or, if the group does not exist NOTHING is returned
Example:
*hash hash = getgrnam("root");
See also
getgrnam2() for a similar function that throws an exception if the group is invalid

◆ getgrnam2()

hash Qore::getgrnam2 ( string name)

Returns a group information hash representing the group information for the group name passed, or, if the group does not exist, a GETGRNAM2-ERROR exception is thrown.

Platform Availability:
Qore::Option::HAVE_UNIX_USERMGT
Restrictions:
Qore::PO_NO_EXTERNAL_INFO
Code Flags:
RET_VALUE_ONLY
Parameters
namethe group name to look up
Returns
a group information hash representing the group information for the group name passed, or, if the group does not exist, a GETGRNAM2-ERROR exception is thrown
Example:
*hash hash = getgrnam2("root");
Exceptions
GETGRNAM2-ERRORinvalid group or error reading group information
See also
getgrnam() for a similar function that does not throw an exception if the group is invalid

◆ getpwnam()

hash Qore::getpwnam ( string name)

Returns a password information hash representing the user information for the user name passed, or, if the user does not exist NOTHING is returned.

Platform Availability:
Qore::Option::HAVE_UNIX_USERMGT
Restrictions:
Qore::PO_NO_EXTERNAL_INFO
Code Flags:
CONSTANT
Parameters
namethe user name to look up
Returns
a password information hash representing the user information for the user name passed, or, if the user does not exist NOTHING is returned
Example:
*hash hash = getpwnam("root");
See also
getpwnam2() for a similar function that throws an exception if the user is invalid

◆ getpwnam2()

hash Qore::getpwnam2 ( string name)

Returns a password information hash representing the user information for the user name passed, or, if the user does not exist, a GETPWNAM2-ERROR exception is thrown.

Platform Availability:
Qore::Option::HAVE_UNIX_USERMGT
Restrictions:
Qore::PO_NO_EXTERNAL_INFO
Code Flags:
RET_VALUE_ONLY
Parameters
namethe user name to look up
Returns
a password information hash representing the user information for the user name passed, or, if the user does not exist, a GETPWNAM2-ERROR exception is thrown
Example:
*hash hash = getpwnam2("root");
Exceptions
GETPWNAM2-ERRORinvalid user or error reading user information
See also
getpwnam() for a similar function that does not throw an exception if the user is invalid

◆ getpwuid() [1/2]

nothing Qore::getpwuid ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Restrictions:
Qore::PO_NO_EXTERNAL_INFO
Code Flags:
RUNTIME_NOOP

◆ getpwuid() [2/2]

*hash Qore::getpwuid ( softint uid)

Returns a password information hash representing the user information for the user ID passed, or, if the user ID does not exist NOTHING is returned.

Platform Availability:
Qore::Option::HAVE_UNIX_USERMGT
Restrictions:
Qore::PO_NO_EXTERNAL_INFO
Code Flags:
CONSTANT
Parameters
uidthe user ID to look up
Returns
a password information hash representing the user information for the user ID passed, or, if the user ID does not exist NOTHING is returned
Example:
*hash hash = getpwuid(0);
See also
getpwuid2() for a similar function that throws an exception if the user ID is invalid

◆ getpwuid2()

hash Qore::getpwuid2 ( softint uid)

Returns a password information hash representing the user information for the user ID passed, or, if the user ID does not exist, a GETPWUID2-ERROR exception is thrown.

Platform Availability:
Qore::Option::HAVE_UNIX_USERMGT
Restrictions:
Qore::PO_NO_EXTERNAL_INFO
Code Flags:
RET_VALUE_ONLY
Parameters
uidthe user ID to look up
Returns
a password information hash representing the user information for the user ID passed, or, if the user ID does not exist, a GETPWUID2-ERROR exception is thrown
Example:
*hash hash = getpwuid2(0);
Exceptions
GETPWUID2-ERRORinvalid uid or error reading user information
See also
getpwuid() for a similar function that does not throw an exception if the user ID is invalid