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