cb5caa98562cf06753163f558cbcfe30b8f4673adjl/*
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * CDDL HEADER START
cb5caa98562cf06753163f558cbcfe30b8f4673adjl *
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * The contents of this file are subject to the terms of the
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * Common Development and Distribution License (the "License").
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * You may not use this file except in compliance with the License.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl *
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * or http://www.opensolaris.org/os/licensing.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * See the License for the specific language governing permissions
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * and limitations under the License.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl *
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * When distributing Covered Code, include this CDDL HEADER in each
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * If applicable, add the following below this CDDL HEADER, with the
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * fields enclosed by brackets "[]" replaced with your own identifying
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * information: Portions Copyright [yyyy] [name of copyright owner]
cb5caa98562cf06753163f558cbcfe30b8f4673adjl *
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * CDDL HEADER END
cb5caa98562cf06753163f558cbcfe30b8f4673adjl */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl/*
b57459abfba36eb3068cfe44c6921168b4c4f774Julian Pullen * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * Use is subject to license terms.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#ifndef _NSCD_FRONTEND_H
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define _NSCD_FRONTEND_H
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#ifdef __cplusplus
cb5caa98562cf06753163f558cbcfe30b8f4673adjlextern "C" {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#endif
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#include "cache.h"
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
606f6aa3d37f0f8e8282e483c1400bae5275aeebmichen#define NSCD_N2NBUF_MAXLEN 1024 * 8
606f6aa3d37f0f8e8282e483c1400bae5275aeebmichen#define NSCD_PHDR_MAXLEN 1024 * 8
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_LOOKUP_BUFSIZE 1024 * 16
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_DOORBUF_MAXLEN 1024 * 512
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_PHDR_LEN(hdrp) ((hdrp)->data_off)
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_DATA_LEN(hdrp) ((hdrp)->data_len)
b57459abfba36eb3068cfe44c6921168b4c4f774Julian Pullen/* used to check clients required privileges */
b57459abfba36eb3068cfe44c6921168b4c4f774Julian Pullen#define NSCD_ALL_PRIV 0
b57459abfba36eb3068cfe44c6921168b4c4f774Julian Pullen#define NSCD_READ_PRIV 1
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_ALLOC_LOOKUP_BUFFER(bufp, bufsiz, hdrp, space, spsiz) \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl if ((hdrp)->pbufsiz <= spsiz) { \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (void) memcpy(space, (hdrp), NSCD_PHDR_LEN((hdrp))); \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl bufp = space; \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl bufsiz = spsiz; \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl hdrp = (nss_pheader_t *)(void *)space; \
606f6aa3d37f0f8e8282e483c1400bae5275aeebmichen (hdrp)->pbufsiz = bufsiz; \
606f6aa3d37f0f8e8282e483c1400bae5275aeebmichen (hdrp)->data_len = bufsiz - (hdrp)->data_off; \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl } else { \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (bufp) = NULL; \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl bufsiz = (hdrp)->pbufsiz; \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl if (bufsiz > spsiz) \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl bufsiz = NSCD_DOORBUF_MAXLEN; \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (bufp) = alloca(bufsiz); \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl if ((bufp) != NULL) { \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (void) memcpy((bufp), (hdrp), NSCD_PHDR_LEN(hdrp)); \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (hdrp) = (nss_pheader_t *)(void *)(bufp); \
606f6aa3d37f0f8e8282e483c1400bae5275aeebmichen (hdrp)->pbufsiz = bufsiz; \
606f6aa3d37f0f8e8282e483c1400bae5275aeebmichen (hdrp)->data_len = bufsiz - (hdrp)->data_off; \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl } else { \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl NSCD_SET_STATUS((hdrp), NSS_ERROR, ENOMEM); \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (void) door_return((char *)(hdrp), \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl NSCD_PHDR_LEN(hdrp), NULL, 0); \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl } \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl }
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_SET_RETURN_ARG(hdrp, arg_size) \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl if (NSCD_STATUS_IS_OK((nss_pheader_t *)(hdrp))) \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl arg_size = NSCD_PHDR_LEN(hdrp) + (NSCD_DATA_LEN(hdrp) > 0 ? \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl NSCD_DATA_LEN(hdrp) + 1 : 0); \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl else \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl arg_size = NSCD_PHDR_LEN(hdrp);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl/* prototypes */
cb5caa98562cf06753163f558cbcfe30b8f4673adjluid_t _nscd_get_client_euid();
b57459abfba36eb3068cfe44c6921168b4c4f774Julian Pullenint _nscd_check_client_priv(int);
cb5caa98562cf06753163f558cbcfe30b8f4673adjlint _nscd_setup_server(char *execname, char **argv);
cb5caa98562cf06753163f558cbcfe30b8f4673adjlint _nscd_setup_child_server(int did);
cb5caa98562cf06753163f558cbcfe30b8f4673adjlint _nscd_get_clearance(sema_t *sema);
cb5caa98562cf06753163f558cbcfe30b8f4673adjlint _nscd_release_clearance(sema_t *sema);
cb5caa98562cf06753163f558cbcfe30b8f4673adjlvoid _nscd_init_cache_sema(sema_t *sema, char *cache_name);
cb5caa98562cf06753163f558cbcfe30b8f4673adjlnscd_rc_t _nscd_alloc_frontend_cfg();
e37190e5b4531a897e4191a30b8f41678b582e25michenvoid _nscd_APP_check_cred(void *buf, pid_t *pidp, char *dc_str,
e37190e5b4531a897e4191a30b8f41678b582e25michen int log_comp, int log_level);
80b80bf0416a7eb4be4215b2e192cafd03ca80b7michenvoid _nscd_restart_if_cfgfile_changed();
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#ifdef __cplusplus
cb5caa98562cf06753163f558cbcfe30b8f4673adjl}
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#endif
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#endif /* _NSCD_FRONTEND_H */