xref: /titanic_51/usr/src/cmd/nscd/nscd_frontend.h (revision 853389e344087efe23a5cc688693e5301a1cb90d)
1 /*
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 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _NSCD_FRONTEND_H
27 #define	_NSCD_FRONTEND_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 #include "cache.h"
36 
37 #define	NSCD_N2NBUF_MAXLEN	1024 * 8
38 #define	NSCD_PHDR_MAXLEN	1024 * 8
39 #define	NSCD_LOOKUP_BUFSIZE	1024 * 16
40 #define	NSCD_DOORBUF_MAXLEN	1024 * 512
41 #define	NSCD_PHDR_LEN(hdrp)	((hdrp)->data_off)
42 #define	NSCD_DATA_LEN(hdrp)	((hdrp)->data_len)
43 
44 #define	NSCD_ALLOC_LOOKUP_BUFFER(bufp, bufsiz, hdrp, space, spsiz)  \
45 	if ((hdrp)->pbufsiz <= spsiz) { \
46 		(void) memcpy(space, (hdrp), NSCD_PHDR_LEN((hdrp))); \
47 		bufp = space; \
48 		bufsiz = spsiz; \
49 		hdrp = (nss_pheader_t *)(void *)space; \
50 		(hdrp)->pbufsiz = bufsiz; \
51 		(hdrp)->data_len = bufsiz - (hdrp)->data_off; \
52 	} else { \
53 		(bufp) = NULL; \
54 		bufsiz = (hdrp)->pbufsiz; \
55 		if (bufsiz > spsiz) \
56 			bufsiz = NSCD_DOORBUF_MAXLEN; \
57 		(bufp) = alloca(bufsiz); \
58 		if ((bufp) != NULL) { \
59 			(void) memcpy((bufp), (hdrp), NSCD_PHDR_LEN(hdrp)); \
60 			(hdrp) = (nss_pheader_t *)(void *)(bufp); \
61 			(hdrp)->pbufsiz = bufsiz; \
62 			(hdrp)->data_len = bufsiz - (hdrp)->data_off; \
63 		} else { \
64 			NSCD_SET_STATUS((hdrp), NSS_ERROR, ENOMEM); \
65 			(void) door_return((char *)(hdrp), \
66 				NSCD_PHDR_LEN(hdrp), NULL, 0); \
67 		} \
68 	}
69 
70 #define	NSCD_SET_RETURN_ARG(hdrp, arg_size)  \
71 	if (NSCD_STATUS_IS_OK((nss_pheader_t *)(hdrp))) \
72 		arg_size = NSCD_PHDR_LEN(hdrp) + (NSCD_DATA_LEN(hdrp) > 0 ? \
73 		NSCD_DATA_LEN(hdrp) + 1 : 0); \
74 	else \
75 		arg_size = NSCD_PHDR_LEN(hdrp);
76 
77 /* prototypes */
78 uid_t _nscd_get_client_euid();
79 int _nscd_check_client_read_priv();
80 int _nscd_setup_server(char *execname, char **argv);
81 int _nscd_setup_child_server(int did);
82 int _nscd_get_clearance(sema_t *sema);
83 int _nscd_release_clearance(sema_t *sema);
84 void _nscd_init_cache_sema(sema_t *sema, char *cache_name);
85 nscd_rc_t _nscd_alloc_frontend_cfg();
86 void _nscd_APP_check_cred(void *buf, pid_t *pidp, char *dc_str,
87 	int log_comp, int log_level);
88 void _nscd_restart_if_cfgfile_changed();
89 #ifdef	__cplusplus
90 }
91 #endif
92 
93 #endif	/* _NSCD_FRONTEND_H */
94