gr_private.h revision 1.2 1 1.2 martin /* $NetBSD: gr_private.h,v 1.2 2008/04/28 20:22:59 martin 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 *
19 1.1 lukem * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.1 lukem * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.1 lukem * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.1 lukem * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.1 lukem * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.1 lukem * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.1 lukem * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.1 lukem * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.1 lukem * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.1 lukem * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.1 lukem * POSSIBILITY OF SUCH DAMAGE.
30 1.1 lukem */
31 1.1 lukem
32 1.1 lukem /*
33 1.1 lukem * Structures and functions used by various group(5) public functions
34 1.1 lukem * and their back-end implementations.
35 1.1 lukem * These are subject to change without notice and should not be used
36 1.1 lukem * outside of libc (even by third-party nss_*.so modules implementing
37 1.1 lukem * group(5) back-ends).
38 1.1 lukem */
39 1.1 lukem
40 1.1 lukem #define _GROUP_COMPAT /* "group" defaults to compat, so always provide it */
41 1.1 lukem
42 1.1 lukem
43 1.1 lukem /*
44 1.1 lukem * mutex to serialize the public group(5) functions use of the
45 1.1 lukem * back-end implementations, which may not be reentrant.
46 1.1 lukem */
47 1.1 lukem extern mutex_t __grmutex;
48 1.1 lukem
49 1.1 lukem /*
50 1.1 lukem * files methods
51 1.1 lukem */
52 1.1 lukem struct __grstate_files { /* state shared between files methods */
53 1.1 lukem int stayopen; /* see getgroupent(3) */
54 1.1 lukem FILE *fp; /* groups file handle */
55 1.1 lukem };
56 1.1 lukem
57 1.1 lukem extern int __grstart_files(struct __grstate_files *);
58 1.1 lukem extern int __grend_files(struct __grstate_files *);
59 1.1 lukem extern int __grscan_files(int *, struct group *, char *, size_t,
60 1.1 lukem struct __grstate_files *, int, const char *, gid_t);
61 1.1 lukem
62 1.1 lukem /*
63 1.1 lukem * dns methods
64 1.1 lukem */
65 1.1 lukem struct __grstate_dns { /* state shared between dns methods */
66 1.1 lukem int stayopen; /* see getgroupent(3) */
67 1.1 lukem void *context; /* Hesiod context */
68 1.1 lukem int num; /* group index, -1 if no more */
69 1.1 lukem };
70 1.1 lukem
71 1.1 lukem extern int __grstart_dns(struct __grstate_dns *);
72 1.1 lukem extern int __grend_dns(struct __grstate_dns *state);
73 1.1 lukem extern int __grscan_dns(int *, struct group *, char *, size_t,
74 1.1 lukem struct __grstate_dns *, int, const char *, gid_t);
75 1.1 lukem
76 1.1 lukem /*
77 1.1 lukem * nis methods
78 1.1 lukem */
79 1.1 lukem struct __grstate_nis { /* state shared between nis methods */
80 1.1 lukem int stayopen; /* see getgroupent(3) */
81 1.1 lukem char *domain; /* NIS domain */
82 1.1 lukem int done; /* non-zero if search exhausted */
83 1.1 lukem char *current; /* current first/next match */
84 1.1 lukem int currentlen; /* length of _nis_current */
85 1.1 lukem };
86 1.1 lukem
87 1.1 lukem extern int __grstart_nis(struct __grstate_nis *);
88 1.1 lukem extern int __grend_nis(struct __grstate_nis *);
89 1.1 lukem extern int __grscan_nis(int *, struct group *, char *, size_t,
90 1.1 lukem struct __grstate_nis *, int, const char *, gid_t);
91 1.1 lukem
92 1.1 lukem /*
93 1.1 lukem * compat methods
94 1.1 lukem */
95 1.1 lukem struct __grstate_compat { /* state shared between compat methods */
96 1.1 lukem int stayopen; /* see getgroupent(3) */
97 1.1 lukem FILE *fp; /* file handle */
98 1.1 lukem /*
99 1.1 lukem * XXX: convert name to a separate compatstate enum and grow name as necessary
100 1.1 lukem * instead of using strdup & free for each + line
101 1.1 lukem */
102 1.1 lukem char *name; /* NULL if reading file, */
103 1.1 lukem /* "" if compat "+", */
104 1.1 lukem /* name if compat "+name" */
105 1.1 lukem };
106 1.1 lukem
107 1.1 lukem extern int __grbad_compat(void *nsrv, void *nscb, va_list ap);
108 1.1 lukem extern int __grstart_compat(struct __grstate_compat *);
109 1.1 lukem extern int __grend_compat(struct __grstate_compat *);
110 1.1 lukem extern int __grscan_compat(int *, struct group *, char *, size_t,
111 1.1 lukem struct __grstate_compat *, int, const char *, gid_t,
112 1.1 lukem int (*)(void *, struct group **), void *);
113