xref: /openbsd-src/lib/libc/gen/getnetgrent.3 (revision b2ea75c1b17e1a9a339660e7ed45cd24946b230e)
1.\"	$OpenBSD: getnetgrent.3,v 1.10 1999/07/09 13:35:17 aaron Exp $
2.\"
3.\" Copyright (c) 1992, 1993
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\"    must display the following acknowledgement:
16.\"	This product includes software developed by the University of
17.\"	California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\"    may be used to endorse or promote products derived from this software
20.\"    without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.Dd July 8, 1997
35.Dt GETNETGRENT 3
36.Os
37.Sh NAME
38.Nm getnetgrent ,
39.Nm innetgr ,
40.Nm setnetgrent ,
41.Nm endnetgrent
42.Nd netgroup database operations
43.Sh SYNOPSIS
44.Fd #include <netgroup.h>
45.Ft int
46.Fn getnetgrent "const char **host" "const char **user" "const char **domain"
47.Ft int
48.Fn innetgr "const char *netgroup" "const char *host" "const char *user" "const char *domain"
49.Ft void
50.Fn setnetgrent "const char *netgroup"
51.Ft void
52.Fn endnetgrent void
53.Sh DESCRIPTION
54These functions operate on the netgroup database file
55.Pa /etc/netgroup.db
56which is described
57in
58.Xr netgroup 5 .
59If that file does not exist, and the system supports YP,
60then the netgroup YP databases are used instead.
61The database defines a set of netgroups, each made up of one or more triples:
62.Bd -literal -offset indent
63(host, user, domain)
64.Ed
65.Pp
66that defines a combination of host, user, and domain.
67Any of the three fields may be specified as
68.Dq wildcards
69that match any string.
70.Pp
71The function
72.Fn getnetgrent
73sets the three pointer arguments to the strings of the next member of the
74current netgroup.
75If any of the string pointers are
76.Fa (char *)0 ,
77those fields are considered wildcards.
78.Pp
79The functions
80.Fn setnetgrent
81and
82.Fn endnetgrent
83set the current netgroup and terminate the current netgroup respectively.
84If
85.Fn setnetgrent
86is called with a different netgroup than the previous call, an implicit
87.Fn endnetgrent
88is implied.
89.Fn setnetgrent
90also sets the offset to the first member of the netgroup.
91.Pp
92The function
93.Fn innetgr
94searches for a match of all fields within the specified group.
95If any of the
96.Ar host ,
97.Ar user ,
98or
99.Ar domain
100arguments are
101.Fa (char *)0 ,
102those fields will match any string value in the netgroup member.
103.Sh RETURN VALUES
104The function
105.Fn getnetgrent
106returns 0 for
107.Dq no more netgroup members
108or 1 otherwise.
109The function
110.Fn innetgr
111returns 1 for a successful match or 0 otherwise.
112The functions
113.Fn setnetgrent
114and
115.Fn endnetgrent
116have no return value.
117.Sh FILES
118.Bl -tag -width /etc/netgroup.db -compact
119.It Pa /etc/netgroup.db
120netgroup database file
121.El
122.Sh SEE ALSO
123.Xr netgroup 5
124.Sh BUGS
125The function
126.Fn getnetgrent
127returns pointers to dynamically allocated data areas that are
128.Xr free 3 Ns 'd when
129the function
130.Fn endnetgrent
131is called.
132