Next: , Previous: File System, Up: POSIX


38.4 User Information

The facilities in this section provide an interface to the user and group database. They should be used with care since they are not reentrant.

The following functions accept an object representing user information and return a selected component:

passwd:name
The name of the userid.
passwd:passwd
The encrypted passwd.
passwd:uid
The user id number.
passwd:gid
The group id number.
passwd:gecos
The full name.
passwd:dir
The home directory.
passwd:shell
The login shell.
— Scheme Procedure: getpwuid uid

Look up an integer userid in the user database.

— Scheme Procedure: getpwnam name

Look up a user name string in the user database.

— Scheme Procedure: setpwent

Initialize a stream used by getpwent to read from the user database. The next use of getpwent returns the first entry. The return value is unspecified.

— Scheme Procedure: getpwent

Return the next entry in the user database, using the stream set by setpwent.

— Scheme Procedure: endpwent

Close the stream used by getpwent. The return value is unspecified.

— Scheme Procedure: setpw [arg]
— C Function: scm_setpwent (arg) |0 |1 |0

If called with a true argument, initialize or reset the password data stream. Otherwise, close the stream. The setpwent and endpwent procedures are implemented on top of this.

— Scheme Procedure: getpw obj
— C Function: scm_getpwuid (obj)

Look up an entry in the user database. obj can be an integer, a string, or omitted, giving the behaviour of getpwuid(3), getpwnam(3) or getpwent(3) respectively.

The following functions accept an object representing group information and return a selected component:

group:name
The group name.
group:passwd
The encrypted group password.
group:gid
The group id number.
group:mem
A list of userids which have this group as a supplementary group.
— Scheme Procedure: getgrgid id

Look up an integer group id in the group database.

— Scheme Procedure: getgrnam name

Look up a group name in the group database.

— Scheme Procedure: setgrent

Initialize a stream used by getgrent to read from the group database. The next use of getgrent returns the first entry. The return value is unspecified.

— Scheme Procedure: getgrent

Return the next entry in the group database, using the stream set by setgrent.

— Scheme Procedure: endgrent

Close the stream used by getgrent. The return value is unspecified.

— Scheme Procedure: setgr [arg]
— C Function: scm_setgrent (arg) |0 |1 |0

If called with a true argument, initialize or reset the group data stream. Otherwise, close the stream. The setgrent and endgrent procedures are implemented on top of this.

— Scheme Procedure: getgr obj
— C Function: scm_getgrgid (obj)

Look up an entry in the group database. obj can be an integer, a string, or omitted, giving the behaviour of getgrgid(3), getgrnam(3) or getgrent(3) respectively.

Note: Guile provides neither cuserid nor getlogin primarily because the manpage for these functions warns against using the former (use (getpwuid (geteuid)) instead), and says the latter can be easily fooled.