Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ getgrent(3C) — CX/UX 6.20

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

updatepwgr(1SX)

getlogin(3C)

getpwent(3C)

group(4)

getgrent(3C)

NAME

getgrent, getgrgid, getgrnam, setgrent, endgrent, fgetgrent − get group file entry

SYNOPSIS

#include <grp.h>

struct group ∗getgrent ( )

struct group ∗getgrgid (gid)
gid_t gid;

struct group ∗getgrnam (name)
char ∗name;

void setgrent ( )

void endgrent ( )

SYNOPSIS (SYSV.2)

struct group ∗fgetgrent (f)
FILE ∗f;

DESCRIPTION

getgrent, getgrgid and getgrnam each return pointers to an object with the following structure containing the broken-out fields of a line in the /etc/group file.  Each line contains a group structure, defined in the <grp.h> header file.  This structure has the following members:

char ∗gr_name;  /∗ the name of the group ∗/
char ∗gr_passwd; /∗ the encrypted group password ∗/
gid_tgr_gid;    /∗ the numerical group ID ∗/
char ∗∗gr_mem;   /∗ vector of pointers to member names ∗/

getgrent when first called returns a pointer to the first group structure in the file; thereafter, it returns a pointer to the next group structure in the file; so, successive calls may be used to search the entire file.  Getgrgid searches from the beginning of the file until a numerical group id matching gid is found and returns a pointer to the particular structure in which it was found.  Getgrnam searches from the beginning of the file until a group name matching name is found and returns a pointer to the particular structure in which it was found.  If an end-of-file or an error is encountered on reading, these functions return a NULL pointer. 

A call to setgrent has the effect of rewinding the group file to allow repeated searches.  Endgrent may be called to close the group file when processing is complete. 

Fgetgrent returns a pointer to the next group structure in the stream f, which matches the format of /etc/group. 

SECURITY FEATURES

In CX/SX, the encrypted group passwords and names of group members are kept in /mls/group which is unreadable except by components of the Trusted Computing Base.  The file "/etc/group", which is the "shadow" or "sanitized" group file, is readable by all users but does not contain the encrypted password or the group members. 

If the effective-user-id of the process is "root" then getgrent, getgrgid and getgrname attempt to open the real (unsanitized) group file (/mls/passwd).  If this fails then they attempt to open the user visible "shadow" copy of the group file (/etc/group). 

FILES

/etc/group, /mls/group

SEE ALSO

updatepwgr(1SX), getlogin(3C), getpwent(3C), group(4). 

DIAGNOSTICS

A NULL pointer is returned on EOF or error. 

WARNING

The above routines use <stdio.h>, which causes them to increase the size of programs, not otherwise using standard I/O, more than might be expected. 

BUGS

All information is contained in a static area, so it must be copied if it is to be saved. 

CX/UX Programmer’s Reference Manual

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026