OSDN Git Service

(split) LDP_man-pages: update original to v3.34.
[linuxjm/LDP_man-pages.git] / original / man3 / setnetgrent.3
1 .\"  Copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de)
2 .\"  Distributed under GPL
3 .\"  based on glibc infopages
4 .\" polished - aeb
5 .TH SETNETGRENT 3 2007-07-26 "GNU" "Linux Programmer's Manual"
6 .SH NAME
7 setnetgrent, endnetgrent, getnetgrent, getnetgrent_r, innetgr \-
8 handle network group entries
9 .SH SYNOPSIS
10 .nf
11 .B #include <netdb.h>
12
13 .BI "int setnetgrent(const char *" netgroup );
14
15 .B "void endnetgrent(void);"
16
17 .BI "int getnetgrent(char **" host ", char **" user ", char **" domain );
18
19 .BI "int getnetgrent_r(char **" host ", char **" user ","
20 .BI "                  char **" domain ", char *" buf ", int " buflen );
21
22 .BI "int innetgr(const char *" netgroup ", const char *" host ","
23 .BI "            const char *" user ", const char *" domain );
24 .fi
25 .sp
26 .in -4n
27 Feature Test Macro Requirements for glibc (see
28 .BR feature_test_macros (7)):
29 .in
30 .sp
31 .ad l
32 .BR setnetgrent (),
33 .BR endnetgrent (),
34 .BR getnetgrent (),
35 .BR getnetgrent_r (),
36 .BR innetgr ():
37 _BSD_SOURCE || _SVID_SOURCE
38 .ad b
39 .SH DESCRIPTION
40 The
41 .I netgroup
42 is a SunOS invention.
43 A netgroup database is a list of string triples
44 .RI ( hostname ", " username ", " domainname )
45 or other netgroup names.
46 Any of the elements in a triple can be empty,
47 which means that anything matches.
48 The functions described here allow access to the netgroup databases.
49 The file
50 .I /etc/nsswitch.conf
51 defines what database is searched.
52 .PP
53 The
54 .BR setnetgrent ()
55 call defines the netgroup that will be searched by subsequent
56 .BR getnetgrent ()
57 calls.
58 The
59 .BR getnetgrent ()
60 function retrieves the next netgroup entry, and returns pointers in
61 .IR host ,
62 .IR user ,
63 .IR domain .
64 A NULL pointer means that the corresponding entry matches any string.
65 The pointers are valid only as long as there is no call to other
66 netgroup-related functions.
67 To avoid this problem you can use the GNU function
68 .BR getnetgrent_r ()
69 that stores the strings in the supplied buffer.
70 To free all allocated buffers use
71 .BR endnetgrent ().
72 .PP
73 In most cases you only want to check if the triplet
74 .RI ( hostname ", " username ", " domainname )
75 is a member of a netgroup.
76 The function
77 .BR innetgr ()
78 can be used for this without calling the above three functions.
79 Again, a NULL pointer is a wildcard and matches any string.
80 The function is thread-safe.
81 .SH "RETURN VALUE"
82 These functions return 1 on success and 0 for failure.
83 .SH FILES
84 .I /etc/netgroup
85 .br
86 .I /etc/nsswitch.conf
87 .SH CONFORMING TO
88 These functions are not in POSIX.1-2001, but
89 .BR setnetgrent (),
90 .BR endnetgrent (),
91 .BR getnetgrent (),
92 and
93 .BR innetgr ()
94 are available on most UNIX systems.
95 .BR getnetgrent_r ()
96 is not widely available on other systems.
97 .\" getnetgrent_r() is on Solaris 8 and AIX 5.1, but not the BSDs.
98 .SH NOTES
99 In the BSD implementation,
100 .BR setnetgrent ()
101 returns void.
102 .SH "SEE ALSO"
103 .BR sethostent (3),
104 .BR setprotoent (3),
105 .BR setservent (3)