2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
23 *
24 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
25 * Use is subject to license terms.
26 *
27 * Database-specific definitions for the getXXXbyYYY routines
28 * (e.g getpwuid_r(), ether_ntohost()) that use the name-service switch.
29 * Database-independent definitions are in <nss_common.h>
30 *
31 * Ideally, this is the only switch header file one would add things
32 * to in order to support a new database.
33 *
34 * NOTE: The interfaces documented in this file may change in a minor
35 * release. It is intended that in the future a stronger committment
36 * will be made to these interface definitions which will guarantee
37 * them across minor releases.
38 */
39
40 #ifndef _NSS_DBDEFS_H
41 #define _NSS_DBDEFS_H
131 #define NSS_DEFCONF_AUDITUSER NSS_DEFCONF_PASSWD
132 #define NSS_DEFCONF_USERATTR NSS_DEFCONF_PASSWD
133 #define NSS_DEFCONF_AUTHATTR NSS_DEFCONF_ATTRDB
134 #define NSS_DEFCONF_PROFATTR NSS_DEFCONF_ATTRDB
135 #define NSS_DEFCONF_EXECATTR NSS_DEFCONF_PROFATTR
136
137 #define NSS_DEFCONF_TSOL_TP NSS_TSOL_FALLBACK
138 #define NSS_DEFCONF_TSOL_RH NSS_TSOL_FALLBACK
139 #define NSS_DEFCONF_TSOL_ZC NSS_TSOL_FALLBACK
140
141 /*
142 * Line-lengths that the "files" and "compat" backends will try to support.
143 * It may be reasonable (even advisable) to use smaller values than these.
144 */
145
146 #define NSS_BUFSIZ 1024
147
148 #define NSS_LINELEN_GROUP ((NSS_BUFSIZ) * 8)
149 #define NSS_LINELEN_HOSTS ((NSS_BUFSIZ) * 8)
150 #define NSS_LINELEN_IPNODES ((NSS_BUFSIZ) * 8)
151 #define NSS_LINELEN_NETMASKS NSS_BUFSIZ
152 #define NSS_LINELEN_NETWORKS NSS_BUFSIZ
153 #define NSS_LINELEN_PASSWD NSS_BUFSIZ
154 #define NSS_LINELEN_PRINTERS NSS_BUFSIZ
155 #define NSS_LINELEN_PROJECT ((NSS_BUFSIZ) * 4)
156 #define NSS_LINELEN_PROTOCOLS NSS_BUFSIZ
157 #define NSS_LINELEN_PUBLICKEY NSS_BUFSIZ
158 #define NSS_LINELEN_RPC NSS_BUFSIZ
159 #define NSS_LINELEN_SERVICES NSS_BUFSIZ
160 #define NSS_LINELEN_SHADOW NSS_BUFSIZ
161 #define NSS_LINELEN_ETHERS NSS_BUFSIZ
162 #define NSS_LINELEN_BOOTPARAMS NSS_BUFSIZ
163
164 #define NSS_LINELEN_ATTRDB NSS_BUFSIZ
165
166 #define NSS_LINELEN_AUDITUSER NSS_LINELEN_ATTRDB
167 #define NSS_LINELEN_AUTHATTR NSS_LINELEN_ATTRDB
168 #define NSS_LINELEN_EXECATTR NSS_LINELEN_ATTRDB
169 #define NSS_LINELEN_PROFATTR NSS_LINELEN_ATTRDB
170 #define NSS_LINELEN_USERATTR NSS_LINELEN_ATTRDB
341 enum nss_netgr_status status;
342 char *retp[NSS_NETGR_N];
343 };
344
345 typedef unsigned nss_innetgr_argc; /* 0 means wildcard */
346 typedef char ** nss_innetgr_argv; /* === Do we really need these? */
347
348 struct nss_innetgr_1arg {
349 nss_innetgr_argc argc;
350 nss_innetgr_argv argv;
351 };
352
353 struct nss_innetgr_args {
354 /* in: */
355 struct nss_innetgr_1arg arg[NSS_NETGR_N];
356 struct nss_innetgr_1arg groups;
357 /* out: */
358 enum nss_netgr_status status;
359 };
360
361 /*
362 * nss_XbyY_buf_t -- structure containing the generic arguments passwd to
363 * getXXXbyYYY_r() and getXXXent_r() routines. The (void *) value points to
364 * a struct of the appropriate type, e.g. struct passwd or struct hostent.
365 *
366 * The functions that allocate and free these structures do no locking at
367 * all, since the routines that use them are inherently MT-unsafe anyway.
368 */
369
370 typedef struct {
371 void *result; /* "result" parameter to getXbyY_r() */
372 char *buffer; /* "buffer" " " */
373 int buflen; /* "buflen" " " */
374 } nss_XbyY_buf_t;
375
376 extern nss_XbyY_buf_t *_nss_XbyY_buf_alloc(int struct_size, int buffer_size);
377 extern void _nss_XbyY_buf_free(nss_XbyY_buf_t *);
378
379 #define NSS_XbyY_ALLOC(bufpp, str_size, buf_size) (\
380 (*bufpp) == 0 \
762
763 #define NSS_DBOP_NETWORKS_BYNAME (NSS_DBOP_next_iter)
764 #define NSS_DBOP_NETWORKS_BYADDR (NSS_DBOP_NETWORKS_BYNAME + 1)
765
766 #define NSS_DBOP_SERVICES_BYNAME (NSS_DBOP_next_iter)
767 #define NSS_DBOP_SERVICES_BYPORT (NSS_DBOP_SERVICES_BYNAME + 1)
768
769 #define NSS_DBOP_PROTOCOLS_BYNAME (NSS_DBOP_next_iter)
770 #define NSS_DBOP_PROTOCOLS_BYNUMBER (NSS_DBOP_PROTOCOLS_BYNAME + 1)
771
772 #define NSS_DBOP_ETHERS_HOSTTON (NSS_DBOP_next_noiter)
773 #define NSS_DBOP_ETHERS_NTOHOST (NSS_DBOP_ETHERS_HOSTTON + 1)
774
775 #define NSS_DBOP_BOOTPARAMS_BYNAME (NSS_DBOP_next_noiter)
776 #define NSS_DBOP_NETMASKS_BYNET (NSS_DBOP_next_noiter)
777
778 #define NSS_DBOP_PRINTERS_BYNAME (NSS_DBOP_next_iter)
779
780 /*
781 * The "real" backend for netgroup (__multi_innetgr, setnetgrent)
782 */
783 #define NSS_DBOP_NETGROUP_IN (NSS_DBOP_next_iter)
784 #define NSS_DBOP_NETGROUP_SET (NSS_DBOP_NETGROUP_IN + 1)
785
786 /*
787 * The backend for getpublickey and getsecretkey (getkeys)
788 */
789 #define NSS_DBOP_KEYS_BYNAME (NSS_DBOP_next_iter)
790
791 /*
792 * The pseudo-backend for netgroup (returned by setnetgrent) doesn't have
793 * any getXXXbyYYY operations, just the usual destr/end/set/get ops,
794 * so needs no definitions here.
795 */
796
797 #define NSS_DBOP_ATTRDB_BYNAME (NSS_DBOP_next_iter)
798
799 #define NSS_DBOP_AUDITUSER_BYNAME NSS_DBOP_ATTRDB_BYNAME
800 #define NSS_DBOP_AUTHATTR_BYNAME NSS_DBOP_ATTRDB_BYNAME
801 #define NSS_DBOP_EXECATTR_BYNAME NSS_DBOP_ATTRDB_BYNAME
802 #define NSS_DBOP_EXECATTR_BYID (NSS_DBOP_EXECATTR_BYNAME + 1)
803 #define NSS_DBOP_EXECATTR_BYNAMEID (NSS_DBOP_EXECATTR_BYID + 1)
804 #define NSS_DBOP_PROFATTR_BYNAME NSS_DBOP_ATTRDB_BYNAME
|
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
23 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
24 *
25 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
26 * Use is subject to license terms.
27 *
28 * Database-specific definitions for the getXXXbyYYY routines
29 * (e.g getpwuid_r(), ether_ntohost()) that use the name-service switch.
30 * Database-independent definitions are in <nss_common.h>
31 *
32 * Ideally, this is the only switch header file one would add things
33 * to in order to support a new database.
34 *
35 * NOTE: The interfaces documented in this file may change in a minor
36 * release. It is intended that in the future a stronger committment
37 * will be made to these interface definitions which will guarantee
38 * them across minor releases.
39 */
40
41 #ifndef _NSS_DBDEFS_H
42 #define _NSS_DBDEFS_H
132 #define NSS_DEFCONF_AUDITUSER NSS_DEFCONF_PASSWD
133 #define NSS_DEFCONF_USERATTR NSS_DEFCONF_PASSWD
134 #define NSS_DEFCONF_AUTHATTR NSS_DEFCONF_ATTRDB
135 #define NSS_DEFCONF_PROFATTR NSS_DEFCONF_ATTRDB
136 #define NSS_DEFCONF_EXECATTR NSS_DEFCONF_PROFATTR
137
138 #define NSS_DEFCONF_TSOL_TP NSS_TSOL_FALLBACK
139 #define NSS_DEFCONF_TSOL_RH NSS_TSOL_FALLBACK
140 #define NSS_DEFCONF_TSOL_ZC NSS_TSOL_FALLBACK
141
142 /*
143 * Line-lengths that the "files" and "compat" backends will try to support.
144 * It may be reasonable (even advisable) to use smaller values than these.
145 */
146
147 #define NSS_BUFSIZ 1024
148
149 #define NSS_LINELEN_GROUP ((NSS_BUFSIZ) * 8)
150 #define NSS_LINELEN_HOSTS ((NSS_BUFSIZ) * 8)
151 #define NSS_LINELEN_IPNODES ((NSS_BUFSIZ) * 8)
152 #define NSS_LINELEN_NETGROUP ((NSS_BUFSIZ) * 32)
153 #define NSS_LINELEN_NETMASKS NSS_BUFSIZ
154 #define NSS_LINELEN_NETWORKS NSS_BUFSIZ
155 #define NSS_LINELEN_PASSWD NSS_BUFSIZ
156 #define NSS_LINELEN_PRINTERS NSS_BUFSIZ
157 #define NSS_LINELEN_PROJECT ((NSS_BUFSIZ) * 4)
158 #define NSS_LINELEN_PROTOCOLS NSS_BUFSIZ
159 #define NSS_LINELEN_PUBLICKEY NSS_BUFSIZ
160 #define NSS_LINELEN_RPC NSS_BUFSIZ
161 #define NSS_LINELEN_SERVICES NSS_BUFSIZ
162 #define NSS_LINELEN_SHADOW NSS_BUFSIZ
163 #define NSS_LINELEN_ETHERS NSS_BUFSIZ
164 #define NSS_LINELEN_BOOTPARAMS NSS_BUFSIZ
165
166 #define NSS_LINELEN_ATTRDB NSS_BUFSIZ
167
168 #define NSS_LINELEN_AUDITUSER NSS_LINELEN_ATTRDB
169 #define NSS_LINELEN_AUTHATTR NSS_LINELEN_ATTRDB
170 #define NSS_LINELEN_EXECATTR NSS_LINELEN_ATTRDB
171 #define NSS_LINELEN_PROFATTR NSS_LINELEN_ATTRDB
172 #define NSS_LINELEN_USERATTR NSS_LINELEN_ATTRDB
343 enum nss_netgr_status status;
344 char *retp[NSS_NETGR_N];
345 };
346
347 typedef unsigned nss_innetgr_argc; /* 0 means wildcard */
348 typedef char ** nss_innetgr_argv; /* === Do we really need these? */
349
350 struct nss_innetgr_1arg {
351 nss_innetgr_argc argc;
352 nss_innetgr_argv argv;
353 };
354
355 struct nss_innetgr_args {
356 /* in: */
357 struct nss_innetgr_1arg arg[NSS_NETGR_N];
358 struct nss_innetgr_1arg groups;
359 /* out: */
360 enum nss_netgr_status status;
361 };
362
363 /* For NSS_DBOP_NETGROUP_BYNAME */
364 struct nss_netgrent {
365 char *netgr_name;
366 char *netgr_members;
367 };
368
369 /*
370 * nss_XbyY_buf_t -- structure containing the generic arguments passwd to
371 * getXXXbyYYY_r() and getXXXent_r() routines. The (void *) value points to
372 * a struct of the appropriate type, e.g. struct passwd or struct hostent.
373 *
374 * The functions that allocate and free these structures do no locking at
375 * all, since the routines that use them are inherently MT-unsafe anyway.
376 */
377
378 typedef struct {
379 void *result; /* "result" parameter to getXbyY_r() */
380 char *buffer; /* "buffer" " " */
381 int buflen; /* "buflen" " " */
382 } nss_XbyY_buf_t;
383
384 extern nss_XbyY_buf_t *_nss_XbyY_buf_alloc(int struct_size, int buffer_size);
385 extern void _nss_XbyY_buf_free(nss_XbyY_buf_t *);
386
387 #define NSS_XbyY_ALLOC(bufpp, str_size, buf_size) (\
388 (*bufpp) == 0 \
770
771 #define NSS_DBOP_NETWORKS_BYNAME (NSS_DBOP_next_iter)
772 #define NSS_DBOP_NETWORKS_BYADDR (NSS_DBOP_NETWORKS_BYNAME + 1)
773
774 #define NSS_DBOP_SERVICES_BYNAME (NSS_DBOP_next_iter)
775 #define NSS_DBOP_SERVICES_BYPORT (NSS_DBOP_SERVICES_BYNAME + 1)
776
777 #define NSS_DBOP_PROTOCOLS_BYNAME (NSS_DBOP_next_iter)
778 #define NSS_DBOP_PROTOCOLS_BYNUMBER (NSS_DBOP_PROTOCOLS_BYNAME + 1)
779
780 #define NSS_DBOP_ETHERS_HOSTTON (NSS_DBOP_next_noiter)
781 #define NSS_DBOP_ETHERS_NTOHOST (NSS_DBOP_ETHERS_HOSTTON + 1)
782
783 #define NSS_DBOP_BOOTPARAMS_BYNAME (NSS_DBOP_next_noiter)
784 #define NSS_DBOP_NETMASKS_BYNET (NSS_DBOP_next_noiter)
785
786 #define NSS_DBOP_PRINTERS_BYNAME (NSS_DBOP_next_iter)
787
788 /*
789 * The "real" backend for netgroup (__multi_innetgr, setnetgrent)
790 * Note: _BYNAME is implemented only in "files" (for now).
791 */
792 #define NSS_DBOP_NETGROUP_IN (NSS_DBOP_next_iter)
793 #define NSS_DBOP_NETGROUP_SET (NSS_DBOP_NETGROUP_IN + 1)
794 #define NSS_DBOP_NETGROUP_BYNAME (NSS_DBOP_NETGROUP_SET + 1)
795
796 /*
797 * The backend for getpublickey and getsecretkey (getkeys)
798 */
799 #define NSS_DBOP_KEYS_BYNAME (NSS_DBOP_next_iter)
800
801 /*
802 * The pseudo-backend for netgroup (returned by setnetgrent) doesn't have
803 * any getXXXbyYYY operations, just the usual destr/end/set/get ops,
804 * so needs no definitions here.
805 */
806
807 #define NSS_DBOP_ATTRDB_BYNAME (NSS_DBOP_next_iter)
808
809 #define NSS_DBOP_AUDITUSER_BYNAME NSS_DBOP_ATTRDB_BYNAME
810 #define NSS_DBOP_AUTHATTR_BYNAME NSS_DBOP_ATTRDB_BYNAME
811 #define NSS_DBOP_EXECATTR_BYNAME NSS_DBOP_ATTRDB_BYNAME
812 #define NSS_DBOP_EXECATTR_BYID (NSS_DBOP_EXECATTR_BYNAME + 1)
813 #define NSS_DBOP_EXECATTR_BYNAMEID (NSS_DBOP_EXECATTR_BYID + 1)
814 #define NSS_DBOP_PROFATTR_BYNAME NSS_DBOP_ATTRDB_BYNAME
|