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.
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.
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]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 * Copyright (c) 2017, Joyent, INc.
31 * Common code and structures used by name-service-switch "files" backends.
34 #ifndef _FILES_COMMON_H
35 #define _FILES_COMMON_H
37 #include <nss_common.h>
38 #include <nss_dbdefs.h>
45 typedef struct files_backend
*files_backend_ptr_t
;
46 typedef nss_status_t (*files_backend_op_t
)(files_backend_ptr_t
, void *);
48 typedef uint_t (*files_hash_func
)(nss_XbyY_args_t
*, int, const char *, int);
50 typedef struct files_hashent
{
51 struct files_hashent
*h_first
;
52 struct files_hashent
*h_next
;
66 files_hash_func
*fh_hash_func
;
72 files_linetab_t
*fh_line
;
73 files_hashent_t
*fh_table
;
76 struct files_backend
{
77 files_backend_op_t
*ops
;
83 files_hash_t
*hashinfo
;
87 * Iterator function for _nss_files_do_all(), which probably calls yp_all().
88 * NSS_NOTFOUND means "keep enumerating", NSS_SUCCESS means"return now",
89 * other values don't make much sense. In other words we're abusing
90 * (overloading) the meaning of nss_status_t, but hey...
91 * _nss_files_XY_all() is a wrapper around _nss_files_do_all() that does the
92 * generic work for nss_XbyY_args_t backends (calls cstr2ent etc).
94 typedef nss_status_t (*files_do_all_func_t
)(const char *, int, void *args
);
95 typedef int (*files_XY_check_func
)(nss_XbyY_args_t
*,
99 extern nss_backend_t
*_nss_files_constr(files_backend_op_t
*ops
,
101 const char *filename
,
104 extern nss_status_t
_nss_files_destr(files_backend_ptr_t
, void *dummy
);
105 extern nss_status_t
_nss_files_setent(files_backend_ptr_t
, void *dummy
);
106 extern nss_status_t
_nss_files_endent(files_backend_ptr_t
, void *dummy
);
107 extern nss_status_t
_nss_files_getent_rigid(files_backend_ptr_t
, void *);
108 extern nss_status_t
_nss_files_getent_netdb(files_backend_ptr_t
, void *);
109 extern nss_status_t
_nss_files_do_all(files_backend_ptr_t
,
112 files_do_all_func_t func
);
113 extern nss_status_t
_nss_files_XY_all(files_backend_ptr_t be
,
114 nss_XbyY_args_t
*args
,
117 files_XY_check_func check
);
118 extern nss_status_t
_nss_files_XY_hash(files_backend_ptr_t be
,
119 nss_XbyY_args_t
*args
,
123 files_XY_check_func check
);
124 int _nss_files_read_line(FILE *f
, char *buffer
, int buflen
);
126 extern nss_backend_t
*_nss_files_constr();
127 extern nss_status_t
_nss_files_destr();
128 extern nss_status_t
_nss_files_setent();
129 extern nss_status_t
_nss_files_endent();
130 extern nss_status_t
_nss_files_getent_rigid();
131 extern nss_status_t
_nss_files_getent_netdb();
132 extern nss_status_t
_nss_files_do_all();
133 extern nss_status_t
_nss_files_XY_all();
134 extern nss_status_t
_nss_files_XY_hash();
137 int _nss_files_check_name_aliases(nss_XbyY_args_t
*, const char *, int);
138 int _nss_files_check_name_colon(nss_XbyY_args_t
*, const char *, int);
140 /* passwd and group validation functions */
141 extern int validate_group_ids(char *line
, int *linelenp
, int buflen
,
142 int extra_chars
, files_XY_check_func check
);
143 extern int validate_passwd_ids(char *line
, int *linelenp
, int buflen
,
147 * Destructors used by different bits.
149 extern void getexecattr_fini(void);
155 #endif /* _FILES_COMMON_H */