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


Ulm's Modula-2 Library:
EtcGroup


NAME

EtcGroup - scanning and searching the /etc/group file

SYNOPSIS

TYPE MemberList = POINTER TO Member;
TYPE Member =
         RECORD
            logname:  ARRAY [0..7] OF CHAR;
            nextmem:  MemberList;
         END;
TYPE Grent =
         RECORD
            grname:   ARRAY [0..7] OF CHAR;
            password: ARRAY [0..15] OF CHAR;
            gid:      CARDINAL;
            members:  MemberList;
         END;


PROCEDURE OpenGr(filename: ARRAY OF CHAR): BOOLEAN; PROCEDURE GetGrent(VAR grent: Grent): BOOLEAN; PROCEDURE GetGrgid(gid: CARDINAL; VAR grent: Grent): BOOLEAN; PROCEDURE GetGrnam(grn: ARRAY OF CHAR; VAR grent: Grent): BOOLEAN; PROCEDURE ReopenGr(): BOOLEAN; PROCEDURE CloseGr(): BOOLEAN; PROCEDURE FetchGrgid(gid: CARDINAL; VAR grent: Grent): BOOLEAN; PROCEDURE FetchGrnam(grn: ARRAY OF CHAR; VAR grent: Grent): BOOLEAN;

DESCRIPTION

The EtcGroup module can be used to scan entries of files that have a structure as described in group(4) into a Grent type record.
Within Grent, the members field is a (possibly empty) NIL-terminated list of users allowed in the group.

Between OpenGr and CloseGr, any (using GetGrent) or the next entry whose gid cf. grname field matches gid cf. grn (using GetGrgid cf. GetGrnam) that has not yet been read will be written into the grent record.
At end of file, the GetXXX functions return FALSE and the data in grent is not valid.
ReopenGr restarts reading the file from the top if it is seekable, otherwise reports an error.

Opening the file "/etc/group", searching for a single group ID cf. group name and closing the file again, can all be done at once using FetchGrgid cf. FetchGrnam. This is useful for mapping numerical group IDs to group names, e.g., which is the main purpose of this module.

DIAGNOSTICS

All BOOLEAN functions return TRUE on success, otherwise FALSE.

FILES

/etc/group

SEE ALSO

group(4), Passwd, StdIO

AUTHOR

Martin Hasch, University of Ulm

BUGS

/etc/nswitch.conf is not honored.
Edited by: borchert, last change: 1997/02/25, revision: 1.2, converted to HTML: 1997/04/28

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