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 /* 23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _NSCD_DOOR_H 28 #define _NSCD_DOOR_H 29 30 #pragma ident "%Z%%M% %I% %E% SMI" 31 32 /* 33 * Definitions for nscd to nscd door interfaces 34 */ 35 36 #ifdef __cplusplus 37 extern "C" { 38 #endif 39 40 #include <alloca.h> 41 #include <nss_dbdefs.h> 42 43 /* door for Trusted Extensions */ 44 #define TSOL_NAME_SERVICE_DOOR "/var/tsol/doors/name_service_door" 45 46 /* nscd v2 nscd -> nscd call numbers */ 47 #define NSCD_PING (NSCD_CALLCAT_N2N|0x01) 48 #define NSCD_GETADMIN (NSCD_CALLCAT_N2N|0x02) 49 #define NSCD_SETADMIN (NSCD_CALLCAT_N2N|0x03) 50 #define NSCD_GETPUADMIN (NSCD_CALLCAT_N2N|0x04) 51 #define NSCD_SETPUADMIN (NSCD_CALLCAT_N2N|0x05) 52 #define NSCD_KILLSERVER (NSCD_CALLCAT_N2N|0x06) 53 54 #define NSCD_IMHERE (NSCD_CALLCAT_N2N|0x10) /* IMHERE+WHOAMI */ 55 #define NSCD_FORK (NSCD_CALLCAT_N2N|0x20) 56 #define NSCD_SETUID (NSCD_CALLCAT_N2N|0x30) 57 #define NSCD_KILL (NSCD_CALLCAT_N2N|0x40) 58 #define NSCD_PULSE (NSCD_CALLCAT_N2N|0x50) 59 #define NSCD_REFRESH (NSCD_CALLCAT_N2N|0x60) 60 61 /* nscd v2 nscd identities */ 62 63 #define NSCD_MAIN 0x00000001 64 #define NSCD_FORKER 0x00000002 65 #define NSCD_CHILD 0x00000004 66 #define NSCD_WHOAMI 0x0000000F 67 68 #define NSCD_ALLOC_DOORBUF(cn, dsz, uptr, usz) \ 69 usz = (sizeof (nss_pheader_t) + (dsz)); \ 70 uptr = alloca(usz); \ 71 (void) memset(uptr, 0, usz); \ 72 ((nss_pheader_t *)uptr)->nsc_callnumber = (cn); \ 73 ((nss_pheader_t *)uptr)->p_version = NSCD_HEADER_REV; \ 74 ((nss_pheader_t *)uptr)->pbufsiz = usz; \ 75 ((nss_pheader_t *)uptr)->data_off = sizeof (nss_pheader_t); \ 76 ((nss_pheader_t *)uptr)->key_off = sizeof (nss_pheader_t); \ 77 ((nss_pheader_t *)uptr)->dbd_off = sizeof (nss_pheader_t); \ 78 ((nss_pheader_t *)uptr)->data_len = dsz; 79 80 #define NSCD_N2N_DOOR_DATA(type, buf) \ 81 (type *)((void *)(((char *)(buf)) + sizeof (nss_pheader_t))) 82 83 #define NSCD_N2N_DOOR_BUF_SIZE(struct) \ 84 sizeof (nss_pheader_t) + sizeof (struct) 85 86 #define NSCD_SET_STATUS(ph, st, errno) \ 87 { \ 88 int e = errno; \ 89 (ph)->p_status = st; \ 90 if (e != -1) \ 91 (ph)->p_errno = e; \ 92 } 93 94 #define NSCD_SET_HERRNO(ph, herrno) \ 95 (ph)->p_herrno = herrno; 96 97 98 #define NSCD_RETURN_STATUS(ph, st, errno) \ 99 { \ 100 int e = errno; \ 101 (ph)->p_status = st; \ 102 if (e != -1) \ 103 (ph)->p_errno = e; \ 104 return; \ 105 } 106 107 #define NSCD_SET_STATUS_SUCCESS(ph) \ 108 (ph)->p_status = NSS_SUCCESS; \ 109 (ph)->p_errno = 0; 110 111 #define NSCD_RETURN_STATUS_SUCCESS(ph) \ 112 (ph)->p_status = NSS_SUCCESS; \ 113 (ph)->p_errno = 0; \ 114 return; 115 116 #define NSCD_SET_N2N_STATUS(ph, st, errno, n2nst) \ 117 { \ 118 int e = errno; \ 119 (ph)->p_status = st; \ 120 if (e != -1) \ 121 (ph)->p_errno = e; \ 122 (ph)->nscdpriv = n2nst; \ 123 } 124 125 #define NSCD_RETURN_N2N_STATUS(ph, st, errno, n2nst) \ 126 { \ 127 int e = errno; \ 128 (ph)->p_status = st; \ 129 if (e != -1) \ 130 (ph)->p_errno = e; \ 131 (ph)->nscdpriv = n2nst; \ 132 return; \ 133 } 134 135 #define NSCD_STATUS_IS_OK(ph) \ 136 (((ph)->p_status) == NSS_SUCCESS) 137 138 #define NSCD_STATUS_IS_NOT_OK(ph) \ 139 (((ph)->p_status) != NSS_SUCCESS) 140 141 #define NSCD_GET_STATUS(ph) \ 142 (((nss_pheader_t *)(ph))->p_status) 143 144 #define NSCD_GET_ERRNO(ph) \ 145 (((nss_pheader_t *)(ph))->p_errno) 146 147 #define NSCD_GET_HERRNO(ph) \ 148 (((nss_pheader_t *)(ph))->p_herrno) 149 150 #define NSCD_GET_NSCD_STATUS(ph) \ 151 (((nss_pheader_t *)(ph))->nscdpriv) 152 153 #define NSCD_CLEAR_STATUS(ph) \ 154 (ph)->p_status = 0; \ 155 (ph)->p_errno = 0; \ 156 (ph)->nscdpriv = 0; 157 158 #define NSCD_COPY_STATUS(ph, ph1) \ 159 (ph)->p_status = (ph1)->p_status; \ 160 (ph)->p_errno = (ph1)->p_errno; \ 161 (ph)->nscdpriv = (ph1)->nscdpriv; 162 163 nss_status_t _nscd_doorcall(int callnum); 164 nss_status_t _nscd_doorcall_data(int callnum, void *indata, 165 int indlen, void *outdata, int outdlen, 166 nss_pheader_t *phdr); 167 168 nss_status_t _nscd_doorcall_fd(int fd, int callnum, void *indata, 169 int indlen, void *outdata, int outdlen, 170 nss_pheader_t *phdr); 171 172 nss_status_t _nscd_doorcall_sendfd(int fd, int callnum, 173 void *indata, int indlen, nss_pheader_t *phdr); 174 175 #ifdef __cplusplus 176 } 177 #endif 178 179 #endif /* _NSCD_DOOR_H */ 180