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