Modula-2 || Compiler & Tools || Library || Search Engine


Ulm's Modula-2 Library:
Passwd


NAME

Passwd - scanning and searching the password file

SYNOPSIS

TYPE Pwent =
         RECORD
            logname:  ARRAY [0..7] OF CHAR;
            password: ARRAY [0..15] OF CHAR;
            uid:      CARDINAL;
            gid:      CARDINAL;
            fullname: ARRAY [0..31] OF CHAR;
            dir:      ARRAY [0..31] OF CHAR;
            shell:    ARRAY [0..31] OF CHAR;
         END;


PROCEDURE OpenPw(filename: ARRAY OF CHAR): BOOLEAN; PROCEDURE GetPwent(VAR pwent: Pwent): BOOLEAN; PROCEDURE GetPwuid(uid: CARDINAL; VAR pwent: Pwent): BOOLEAN; PROCEDURE GetPwnam(logn: ARRAY OF CHAR; VAR pwent: Pwent): BOOLEAN; PROCEDURE ReopenPw(): BOOLEAN; PROCEDURE ClosePw(): BOOLEAN; PROCEDURE FetchPwuid(uid: CARDINAL; VAR pwent: Pwent): BOOLEAN; PROCEDURE FetchPwnam(logn: ARRAY OF CHAR; VAR pwent: Pwent): BOOLEAN;

DESCRIPTION

The Passwd module can be used to scan entries of files that have a structure as described in passwd(4) into a Pwent type record.

Between OpenPw and ClosePw, any (using GetPwent) or the next entry whose uid cf. logname field matches uid cf. logn (using GetPwuid cf. GetPwnam) that has not yet been read will be written into the pwent record.
At end of file, the GetXXX functions return FALSE and the data in pwent is not valid.
ReopenPw restarts reading the file from the top if it is seekable, otherwise reports an error.

Opening the file "/etc/passwd", searching for a single uid cf. logname and closing the file again, can all be done at once using FetchPwuid cf. FetchPwnam. This is useful for mapping numerical user IDs to names, e.g., which is the main purpose of this module.

DIAGNOSTICS

All BOOLEAN functions return TRUE on success, otherwise FALSE.

FILES

/etc/passwd

SEE ALSO

passwd(4), EtcGroup, StdIO

AUTHOR

Martin Hasch, University of Ulm

BUGS

The /etc/nsswitch.conf file is not honoured.
Edited by: borchert, last change: 1997/02/25, revision: 1.2, converted to HTML: 1997/04/28

Modula-2 || Compiler & Tools || Library || Search Engine