nscd_door.h revision 606f6aa3d37f0f8e8282e483c1400bae5275aeeb
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
cb5caa98562cf06753163f558cbcfe30b8f4673adjl/*
606f6aa3d37f0f8e8282e483c1400bae5275aeebmichen * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * Use is subject to license terms.
cb5caa98562cf06753163f558cbcfe30b8f4673adjl */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#ifndef _NSCD_DOOR_H
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define _NSCD_DOOR_H
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#pragma ident "%Z%%M% %I% %E% SMI"
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl/*
cb5caa98562cf06753163f558cbcfe30b8f4673adjl * Definitions for nscd to nscd door interfaces
cb5caa98562cf06753163f558cbcfe30b8f4673adjl */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#ifdef __cplusplus
cb5caa98562cf06753163f558cbcfe30b8f4673adjlextern "C" {
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#endif
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#include <alloca.h>
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#include <nss_dbdefs.h>
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl/* door for Trusted Extensions */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define TSOL_NAME_SERVICE_DOOR "/var/tsol/doors/name_service_door"
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl/* nscd v2 nscd -> nscd call numbers */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_PING (NSCD_CALLCAT_N2N|0x01)
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_GETADMIN (NSCD_CALLCAT_N2N|0x02)
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_SETADMIN (NSCD_CALLCAT_N2N|0x03)
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_GETPUADMIN (NSCD_CALLCAT_N2N|0x04)
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_SETPUADMIN (NSCD_CALLCAT_N2N|0x05)
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_KILLSERVER (NSCD_CALLCAT_N2N|0x06)
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_IMHERE (NSCD_CALLCAT_N2N|0x10) /* IMHERE+WHOAMI */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_FORK (NSCD_CALLCAT_N2N|0x20)
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_SETUID (NSCD_CALLCAT_N2N|0x30)
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_KILL (NSCD_CALLCAT_N2N|0x40)
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_PULSE (NSCD_CALLCAT_N2N|0x50)
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_REFRESH (NSCD_CALLCAT_N2N|0x60)
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl/* nscd v2 nscd identities */
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_MAIN 0x00000001
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_FORKER 0x00000002
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_CHILD 0x00000004
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_WHOAMI 0x0000000F
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_ALLOC_DOORBUF(cn, dsz, uptr, usz) \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl usz = (sizeof (nss_pheader_t) + (dsz)); \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl uptr = alloca(usz); \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (void) memset(uptr, 0, usz); \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl ((nss_pheader_t *)uptr)->nsc_callnumber = (cn); \
606f6aa3d37f0f8e8282e483c1400bae5275aeebmichen ((nss_pheader_t *)uptr)->p_version = NSCD_HEADER_REV; \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl ((nss_pheader_t *)uptr)->pbufsiz = usz; \
606f6aa3d37f0f8e8282e483c1400bae5275aeebmichen ((nss_pheader_t *)uptr)->data_off = sizeof (nss_pheader_t); \
606f6aa3d37f0f8e8282e483c1400bae5275aeebmichen ((nss_pheader_t *)uptr)->key_off = sizeof (nss_pheader_t); \
606f6aa3d37f0f8e8282e483c1400bae5275aeebmichen ((nss_pheader_t *)uptr)->dbd_off = sizeof (nss_pheader_t); \
606f6aa3d37f0f8e8282e483c1400bae5275aeebmichen ((nss_pheader_t *)uptr)->data_len = dsz;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_N2N_DOOR_DATA(type, buf) \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (type *)((void *)(((char *)(buf)) + sizeof (nss_pheader_t)))
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_N2N_DOOR_BUF_SIZE(struct) \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl sizeof (nss_pheader_t) + sizeof (struct)
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_SET_STATUS(ph, st, errno) \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl { \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl int e = errno; \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (ph)->p_status = st; \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl if (e != -1) \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (ph)->p_errno = e; \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl }
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_SET_HERRNO(ph, herrno) \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (ph)->p_herrno = herrno;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_RETURN_STATUS(ph, st, errno) \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl { \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl int e = errno; \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (ph)->p_status = st; \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl if (e != -1) \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (ph)->p_errno = e; \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl return; \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl }
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_SET_STATUS_SUCCESS(ph) \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (ph)->p_status = NSS_SUCCESS; \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (ph)->p_errno = 0;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_RETURN_STATUS_SUCCESS(ph) \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (ph)->p_status = NSS_SUCCESS; \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (ph)->p_errno = 0; \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl return;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_SET_N2N_STATUS(ph, st, errno, n2nst) \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl { \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl int e = errno; \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (ph)->p_status = st; \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl if (e != -1) \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (ph)->p_errno = e; \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (ph)->nscdpriv = n2nst; \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl }
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_RETURN_N2N_STATUS(ph, st, errno, n2nst) \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl { \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl int e = errno; \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (ph)->p_status = st; \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl if (e != -1) \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (ph)->p_errno = e; \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (ph)->nscdpriv = n2nst; \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl return; \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl }
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_STATUS_IS_OK(ph) \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (((ph)->p_status) == NSS_SUCCESS)
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_STATUS_IS_NOT_OK(ph) \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (((ph)->p_status) != NSS_SUCCESS)
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_GET_STATUS(ph) \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (((nss_pheader_t *)(ph))->p_status)
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_GET_ERRNO(ph) \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (((nss_pheader_t *)(ph))->p_errno)
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_GET_HERRNO(ph) \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (((nss_pheader_t *)(ph))->p_herrno)
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_GET_NSCD_STATUS(ph) \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (((nss_pheader_t *)(ph))->nscdpriv)
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_CLEAR_STATUS(ph) \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (ph)->p_status = 0; \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (ph)->p_errno = 0; \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (ph)->nscdpriv = 0;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#define NSCD_COPY_STATUS(ph, ph1) \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (ph)->p_status = (ph1)->p_status; \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (ph)->p_errno = (ph1)->p_errno; \
cb5caa98562cf06753163f558cbcfe30b8f4673adjl (ph)->nscdpriv = (ph1)->nscdpriv;
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjlnss_status_t _nscd_doorcall(int callnum);
cb5caa98562cf06753163f558cbcfe30b8f4673adjlnss_status_t _nscd_doorcall_data(int callnum, void *indata,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl int indlen, void *outdata, int outdlen,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl nss_pheader_t *phdr);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjlnss_status_t _nscd_doorcall_fd(int fd, int callnum, void *indata,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl int indlen, void *outdata, int outdlen,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl nss_pheader_t *phdr);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjlnss_status_t _nscd_doorcall_sendfd(int fd, int callnum,
cb5caa98562cf06753163f558cbcfe30b8f4673adjl void *indata, int indlen, nss_pheader_t *phdr);
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#ifdef __cplusplus
cb5caa98562cf06753163f558cbcfe30b8f4673adjl}
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#endif
cb5caa98562cf06753163f558cbcfe30b8f4673adjl
cb5caa98562cf06753163f558cbcfe30b8f4673adjl#endif /* _NSCD_DOOR_H */