Qore Programming Language Reference Manual  0.8.13.5
 All Classes Namespaces Functions Variables Groups Pages
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. More...
 
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. More...
 
*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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
*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. More...
 
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. More...
 

Detailed Description

UNIX user and group functions

Group Information Hash

Key Type Description
gr_name string The name of the group
gr_passwd string The encrypted password for the group
gr_gid int The group id
gr_mem list List of strings giving the usernames of members of the group

Password Information Hash

Key Type Description
pw_name string The username of the user
pw_passwd string The encrypted password for the user
pw_gecos string The real name or description of the user
pw_dir string The user's home directory
pw_shell string The user's login shell
pw_uid int The user's userid
pw_gid int The group id of the user's primary group

Function Documentation

*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:
1 *hash hash = getgrgid(0);
See Also
getgrgid2() for a similar function that throws an exception if the group ID is invalid
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:
1 *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
*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:
1 *hash hash = getgrnam("root");
See Also
getgrnam2() for a similar function that throws an exception if the group is invalid
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:
1 *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
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:
1 *hash hash = getpwnam("root");
See Also
getpwnam2() for a similar function that throws an exception if the user is invalid
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:
1 *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
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
*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:
1 *hash hash = getpwuid(0);
See Also
getpwuid2() for a similar function that throws an exception if the user ID is invalid
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:
1 *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