gr_private.h revision 1.1 1 1.1 lukem /* $NetBSD: gr_private.h,v 1.1 2005/01/06 15:00:45 lukem Exp $ */
2 1.1 lukem
3 1.1 lukem /*-
4 1.1 lukem * Copyright (c) 2004-2005 The NetBSD Foundation, Inc.
5 1.1 lukem * All rights reserved.
6 1.1 lukem *
7 1.1 lukem * This code is derived from software contributed to The NetBSD Foundation
8 1.1 lukem * by Luke Mewburn.
9 1.1 lukem *
10 1.1 lukem * Redistribution and use in source and binary forms, with or without
11 1.1 lukem * modification, are permitted provided that the following conditions
12 1.1 lukem * are met:
13 1.1 lukem * 1. Redistributions of source code must retain the above copyright
14 1.1 lukem * notice, this list of conditions and the following disclaimer.
15 1.1 lukem * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 lukem * notice, this list of conditions and the following disclaimer in the
17 1.1 lukem * documentation and/or other materials provided with the distribution.
18 1.1 lukem * 3. All advertising materials mentioning features or use of this software
19 1.1 lukem * must display the following acknowledgement:
20 1.1 lukem * This product includes software developed by the NetBSD
21 1.1 lukem * Foundation, Inc. and its contributors.
22 1.1 lukem * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1 lukem * contributors may be used to endorse or promote products derived
24 1.1 lukem * from this software without specific prior written permission.
25 1.1 lukem *
26 1.1 lukem * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1 lukem * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1 lukem * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.1 lukem * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.1 lukem * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1 lukem * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1 lukem * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1 lukem * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1 lukem * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1 lukem * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1 lukem * POSSIBILITY OF SUCH DAMAGE.
37 1.1 lukem */
38 1.1 lukem
39 1.1 lukem /*
40 1.1 lukem * Structures and functions used by various group(5) public functions
41 1.1 lukem * and their back-end implementations.
42 1.1 lukem * These are subject to change without notice and should not be used
43 1.1 lukem * outside of libc (even by third-party nss_*.so modules implementing
44 1.1 lukem * group(5) back-ends).
45 1.1 lukem */
46 1.1 lukem
47 1.1 lukem #define _GROUP_COMPAT /* "group" defaults to compat, so always provide it */
48 1.1 lukem
49 1.1 lukem
50 1.1 lukem /*
51 1.1 lukem * mutex to serialize the public group(5) functions use of the
52 1.1 lukem * back-end implementations, which may not be reentrant.
53 1.1 lukem */
54 1.1 lukem extern mutex_t __grmutex;
55 1.1 lukem
56 1.1 lukem /*
57 1.1 lukem * files methods
58 1.1 lukem */
59 1.1 lukem struct __grstate_files { /* state shared between files methods */
60 1.1 lukem int stayopen; /* see getgroupent(3) */
61 1.1 lukem FILE *fp; /* groups file handle */
62 1.1 lukem };
63 1.1 lukem
64 1.1 lukem extern int __grstart_files(struct __grstate_files *);
65 1.1 lukem extern int __grend_files(struct __grstate_files *);
66 1.1 lukem extern int __grscan_files(int *, struct group *, char *, size_t,
67 1.1 lukem struct __grstate_files *, int, const char *, gid_t);
68 1.1 lukem
69 1.1 lukem /*
70 1.1 lukem * dns methods
71 1.1 lukem */
72 1.1 lukem struct __grstate_dns { /* state shared between dns methods */
73 1.1 lukem int stayopen; /* see getgroupent(3) */
74 1.1 lukem void *context; /* Hesiod context */
75 1.1 lukem int num; /* group index, -1 if no more */
76 1.1 lukem };
77 1.1 lukem
78 1.1 lukem extern int __grstart_dns(struct __grstate_dns *);
79 1.1 lukem extern int __grend_dns(struct __grstate_dns *state);
80 1.1 lukem extern int __grscan_dns(int *, struct group *, char *, size_t,
81 1.1 lukem struct __grstate_dns *, int, const char *, gid_t);
82 1.1 lukem
83 1.1 lukem /*
84 1.1 lukem * nis methods
85 1.1 lukem */
86 1.1 lukem struct __grstate_nis { /* state shared between nis methods */
87 1.1 lukem int stayopen; /* see getgroupent(3) */
88 1.1 lukem char *domain; /* NIS domain */
89 1.1 lukem int done; /* non-zero if search exhausted */
90 1.1 lukem char *current; /* current first/next match */
91 1.1 lukem int currentlen; /* length of _nis_current */
92 1.1 lukem };
93 1.1 lukem
94 1.1 lukem extern int __grstart_nis(struct __grstate_nis *);
95 1.1 lukem extern int __grend_nis(struct __grstate_nis *);
96 1.1 lukem extern int __grscan_nis(int *, struct group *, char *, size_t,
97 1.1 lukem struct __grstate_nis *, int, const char *, gid_t);
98 1.1 lukem
99 1.1 lukem /*
100 1.1 lukem * compat methods
101 1.1 lukem */
102 1.1 lukem struct __grstate_compat { /* state shared between compat methods */
103 1.1 lukem int stayopen; /* see getgroupent(3) */
104 1.1 lukem FILE *fp; /* file handle */
105 1.1 lukem /*
106 1.1 lukem * XXX: convert name to a separate compatstate enum and grow name as necessary
107 1.1 lukem * instead of using strdup & free for each + line
108 1.1 lukem */
109 1.1 lukem char *name; /* NULL if reading file, */
110 1.1 lukem /* "" if compat "+", */
111 1.1 lukem /* name if compat "+name" */
112 1.1 lukem };
113 1.1 lukem
114 1.1 lukem extern int __grbad_compat(void *nsrv, void *nscb, va_list ap);
115 1.1 lukem extern int __grstart_compat(struct __grstate_compat *);
116 1.1 lukem extern int __grend_compat(struct __grstate_compat *);
117 1.1 lukem extern int __grscan_compat(int *, struct group *, char *, size_t,
118 1.1 lukem struct __grstate_compat *, int, const char *, gid_t,
119 1.1 lukem int (*)(void *, struct group **), void *);
120