|
|
1.1 root 1: .\" Copyright (c) 1989 The Regents of the University of California.
2: .\" All rights reserved.
3: .\"
4: .\" Redistribution and use in source and binary forms are permitted provided
5: .\" that: (1) source distributions retain this entire copyright notice and
6: .\" comment, and (2) distributions including binaries display the following
7: .\" acknowledgement: ``This product includes software developed by the
8: .\" University of California, Berkeley and its contributors'' in the
9: .\" documentation or other materials provided with the distribution and in
10: .\" all advertising materials mentioning features or use of this software.
11: .\" Neither the name of the University nor the names of its contributors may
12: .\" be used to endorse or promote products derived from this software without
13: .\" specific prior written permission.
14: .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
15: .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
16: .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17: .\"
18: .\" @(#)getgrent.3 6.5 (Berkeley) 6/23/90
19: .\"
20: .TH GETGRENT 3 "June 23, 1990"
21: .AT 3
22: .SH NAME
23: getgrent, getgrnam, getgrgid, setgroupent, setgrfile, setgrent,
24: endgrent \- get group file entry
25: .SH SYNOPSIS
26: .nf
27: .B #include <grp.h>
28: .PP
29: .B struct group *getgrent()
30: .PP
31: .B struct group *getgrnam(name)
32: .B char *name;
33: .PP
34: .B struct group *getgrgid(gid)
35: .B gid_t gid;
36: .PP
37: .B setgroupent(stayopen)
38: .B int stayopen;
39: .PP
40: .B void setgrfile(name)
41: .B char *name;
42: .PP
43: .B setgrent()
44: .PP
45: .B void endgrent()
46: .fi
47: .SH DESCRIPTION
48: .I Getgrent,
49: .I getgrgid
50: and
51: .I getgrnam
52: each return a pointer to a structure containing the broken-out fields
53: of a line in the group file. This structure is defined by the include
54: file
55: .IR < grp.h >,
56: and contains the following fields:
57: .PP
58: .RS
59: .nf
60: struct group {
61: char *gr_name; /* group name */
62: char *gr_passwd; /* group password */
63: gid_t gr_gid; /* group id */
64: char **gr_mem; /* group members */
65: };
66: .ft R
67: .ad
68: .fi
69: .RE
70: .PP
71: These fields are more completely described in
72: .IR group (5).
73: .PP
74: .I Getgrnam
75: and
76: .I getgrgid
77: search the group database for a matching group name or group id,
78: respectively, returning the first one encountered. Identical group
79: names or group gids may result in undefined behavior.
80: .PP
81: .I Getgrent
82: sequentially reads the group database and is intended for programs
83: that wish to step through the complete list of groups.
84: .PP
85: All three routines will open the group file for reading, if necesssary.
86: .PP
87: .I Setgrfile
88: changes the default group file to
89: .IR file ,
90: thus allowing the use of alternate group files.
91: .PP
92: .I Setgroupent
93: opens the file, or rewinds it if it is already open. If
94: .I stayopen
95: is non-zero, file descriptors are left open, significantly speeding
96: up subsequent calls. This functionality is unnecessary for
97: .I getgrent
98: as it doesn't close its file descriptors by default. It should also
99: be noted that it is dangerous for long-running programs to use this
100: functionality as the group file may be updated.
101: .PP
102: .I Setgrent
103: is identical to
104: .I setgroupent
105: with an argument of zero.
106: .PP
107: .I Endgrent
108: closes any open files.
109: .PP
110: .PP
111: .SH FILES
112: /etc/group
113: .SH "SEE ALSO"
114: getpwent(3), group(5)
115: .SH DIAGNOSTICS
116: The routines
117: .IR getgrent ,
118: .IR getgrnam ,
119: and
120: .IR getgrgid ,
121: return a null pointer on EOF or error.
122: .I Setgroupent
123: and
124: .I setgrent
125: return 0 on failure, 1 on success.
126: .I Endgrent
127: and
128: .I setgrfile
129: have no return value.
130: .SH BUGS
131: All information is contained in a static buffer which is overwritten
132: by each new call. It must be copied elsewhere to be retained.
133: .PP
134: The routines
135: .IR getgrent ,
136: .IR endgrent ,
137: .IR setgroupent ,
138: and
139: .IR setgrent
140: are fairly useless in a networked environment and should be
141: avoided, if possible.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.