The C and C++ Include Header Files
/usr/include/ntirpc/rpc/auth.h
$ cat -n /usr/include/ntirpc/rpc/auth.h 1 /* $NetBSD: auth.h,v 1.15 2000/06/02 22:57:55 fvdl Exp $ */ 2 3 /* 4 * Copyright (c) 2009, Sun Microsystems, Inc. 5 * Copyright (c) 2012-2017 Red Hat, Inc. and/or its affiliates. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions are met: 10 * - Redistributions of source code must retain the above copyright notice, 11 * this list of conditions and the following disclaimer. 12 * - Redistributions in binary form must reproduce the above copyright notice, 13 * this list of conditions and the following disclaimer in the documentation 14 * and/or other materials provided with the distribution. 15 * - Neither the name of Sun Microsystems, Inc. nor the names of its 16 * contributors may be used to endorse or promote products derived 17 * from this software without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 * 31 * from: @(#)auth.h 1.17 88/02/08 SMI 32 * from: @(#)auth.h 2.3 88/08/07 4.0 RPCSRC 33 * from: @(#)auth.h 1.43 98/02/02 SMI 34 * $FreeBSD: src/include/rpc/auth.h,v 1.20 2003/01/01 18:48:42 schweikh Exp $ 35 */ 36 37 /* 38 * auth.h, Authentication interface. 39 * 40 * Copyright (C) 1984, Sun Microsystems, Inc. 41 * 42 * The data structures are completely opaque to the client. The client 43 * is required to pass an AUTH * to routines that create rpc 44 * "sessions". 45 */ 46 47 #ifndef _TIRPC_AUTH_H 48 #define _TIRPC_AUTH_H 49 50 #include
51 #include
52 #include
53 54 #include
55 #if !defined(_WIN32) 56 #include
57 #endif 58 #include
59 60 #define MAX_AUTH_BYTES 400 /* maximum length of opaque auth */ 61 #define MAXNETNAMELEN 255 /* maximum length of network user's name */ 62 63 /* 64 * Client side authentication/security data 65 */ 66 67 typedef struct sec_data { 68 u_int secmod; /* security mode number e.g. in nfssec.conf */ 69 u_int rpcflavor; /* rpc flavors:AUTH_UNIX,AUTH_DES,RPCSEC_GSS */ 70 int flags; /* AUTH_F_xxx flags */ 71 void *data; /* opaque data per flavor */ 72 } sec_data_t; 73 74 #ifdef _SYSCALL32_IMPL 75 struct sec_data32 { 76 uint32_t secmod; /* security mode number e.g. in nfssec.conf */ 77 uint32_t rpcflavor; /* rpc flavors:AUTH_UNIX,AUTH_DES,RPCSEC_GSS */ 78 int32_t flags; /* AUTH_F_xxx flags */ 79 void *data; /* opaque data per flavor */ 80 }; 81 #endif /* _SYSCALL32_IMPL */ 82 83 /* 84 * authentication/security specific flags 85 */ 86 #define AUTH_F_RPCTIMESYNC 0x001 /* use RPC to do time sync */ 87 #define AUTH_F_TRYNONE 0x002 /* allow fall back to AUTH_NONE */ 88 89 typedef u_int32_t u_int32; /* 32-bit unsigned integers */ 90 91 union des_block { 92 struct { 93 u_int32_t high; 94 u_int32_t low; 95 } key; 96 char c[8]; 97 }; 98 typedef union des_block des_block; 99 __BEGIN_DECLS 100 extern bool xdr_des_block(XDR *, des_block *); 101 __END_DECLS 102 /* 103 * Authentication info. Opaque to client. 104 */ 105 struct opaque_auth { 106 enum_t oa_flavor; /* flavor of auth */ 107 u_int oa_length; /* not to exceed MAX_AUTH_BYTES */ 108 char oa_body[MAX_AUTH_BYTES]; 109 }; 110 111 /* 112 * Auth handle, interface to client side authenticators. 113 */ 114 typedef struct __auth { 115 struct auth_ops { 116 /* nextverf */ 117 void (*ah_nextverf) (struct __auth *); 118 119 /* serialize */ 120 bool(*ah_marshal) (struct __auth *, XDR *); 121 122 /* validate verifier */ 123 bool(*ah_validate) (struct __auth *, struct opaque_auth *); 124 125 /* refresh credentials */ 126 bool(*ah_refresh) (struct __auth *, void *); 127 128 /* destroy this structure */ 129 void (*ah_destroy) (struct __auth *); 130 131 /* encode data for wire */ 132 bool(*ah_wrap) (struct __auth *, XDR *, xdrproc_t, void *); 133 134 /* decode data for wire */ 135 bool(*ah_unwrap) (struct __auth *, XDR *, xdrproc_t, void *); 136 } *ah_ops; 137 138 union des_block ah_key; 139 struct rpc_err ah_error; 140 struct opaque_auth ah_cred; 141 struct opaque_auth ah_verf; 142 143 void *ah_private; 144 int ah_refcnt; 145 } AUTH; 146 147 static inline int auth_get(AUTH *auth) 148 { 149 return atomic_add_int32_t(&auth->ah_refcnt, 1); 150 } 151 152 static inline int auth_put(AUTH *auth) 153 { 154 return atomic_sub_int32_t(&auth->ah_refcnt, 1); 155 } 156 157 /* 158 * Authentication ops. 159 * The ops and the auth handle provide the interface to the authenticators. 160 * 161 * AUTH *auth; 162 * XDR *xdrs; 163 * struct opaque_auth verf; 164 */ 165 #define AUTH_FAILURE(auth) ((auth)->ah_error.re_status != RPC_SUCCESS) 166 #define AUTH_SUCCESS(auth) ((auth)->ah_error.re_status == RPC_SUCCESS) 167 168 #define AUTH_NEXTVERF(auth) \ 169 ((*((auth)->ah_ops->ah_nextverf))(auth)) 170 #define auth_nextverf(auth) \ 171 ((*((auth)->ah_ops->ah_nextverf))(auth)) 172 173 #define AUTH_MARSHALL(auth, xdrs) \ 174 ((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) 175 #define auth_marshall(auth, xdrs) \ 176 ((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) 177 178 #define AUTH_VALIDATE(auth, verfp) \ 179 ((*((auth)->ah_ops->ah_validate))((auth), verfp)) 180 #define auth_validate(auth, verfp) \ 181 ((*((auth)->ah_ops->ah_validate))((auth), verfp)) 182 183 #define AUTH_REFRESH(auth, msg) \ 184 ((*((auth)->ah_ops->ah_refresh))(auth, msg)) 185 #define auth_refresh(auth, msg) \ 186 ((*((auth)->ah_ops->ah_refresh))(auth, msg)) 187 188 #define AUTH_DESTROY(auth) \ 189 do { \ 190 int refs = auth_put((auth)); \ 191 if (refs == 0) \ 192 ((*((auth)->ah_ops->ah_destroy))(auth)); \ 193 __warnx(TIRPC_DEBUG_FLAG_AUTH, \ 194 "%s: auth_put(), refs %d\n", \ 195 __func__, refs); \ 196 } while (0) 197 198 #define auth_destroy(auth) \ 199 do { \ 200 int refs = auth_put((auth)); \ 201 if (refs == 0) \ 202 ((*((auth)->ah_ops->ah_destroy))(auth)); \ 203 __warnx(TIRPC_DEBUG_FLAG_AUTH, \ 204 "%s: auth_put(), refs %d\n", \ 205 __func__, refs); \ 206 } while (0) 207 208 #define AUTH_WRAP(auth, xdrs, xfunc, xwhere) \ 209 ((*((auth)->ah_ops->ah_wrap))(auth, xdrs, \ 210 xfunc, xwhere)) 211 #define auth_wrap(auth, xdrs, xfunc, xwhere) \ 212 ((*((auth)->ah_ops->ah_wrap))(auth, xdrs, \ 213 xfunc, xwhere)) 214 215 #define AUTH_UNWRAP(auth, xdrs, xfunc, xwhere) \ 216 ((*((auth)->ah_ops->ah_unwrap))(auth, xdrs, \ 217 xfunc, xwhere)) 218 #define auth_unwrap(auth, xdrs, xfunc, xwhere) \ 219 ((*((auth)->ah_ops->ah_unwrap))(auth, xdrs, \ 220 xfunc, xwhere)) 221 222 __BEGIN_DECLS 223 extern struct opaque_auth _null_auth; 224 __END_DECLS 225 /* 226 * Any style authentication. These routines can be used by any 227 * authentication style that does not use the wrap/unwrap functions. 228 */ 229 int authany_wrap(void), authany_unwrap(void); 230 231 /* 232 * These are the various implementations of client side authenticators. 233 * 234 * Always returns AUTH. Must check ah_error.re_status, 235 * followed by AUTH_DESTROY() as necessary. 236 */ 237 238 /* 239 * System style authentication 240 * AUTH *authunix_create(machname, uid, gid, len, aup_gids) 241 * char *machname; 242 * int uid; 243 * int gid; 244 * int len; 245 * int *aup_gids; 246 */ 247 __BEGIN_DECLS 248 extern AUTH *authunix_ncreate(char *, uid_t, uid_t, int, uid_t *); 249 extern AUTH *authunix_ncreate_default(void); /* takes no parameters */ 250 extern AUTH *authnone_ncreate(void); /* takes no parameters */ 251 extern AUTH *authnone_ncreate_dummy(void); /* takes no parameters */ 252 __END_DECLS 253 /* 254 * Netname manipulation routines. 255 */ 256 __BEGIN_DECLS 257 extern int getnetname(char *); 258 extern int host2netname(char *, const char *, const char *); 259 extern int user2netname(char *, const uid_t, const char *); 260 extern int netname2user(char *, uid_t *, gid_t *, int *, gid_t *); 261 extern int netname2host(char *, char *, const int); 262 extern void passwd2des(char *, char *); 263 __END_DECLS 264 /* 265 * 266 * These routines interface to the keyserv daemon 267 * 268 */ 269 __BEGIN_DECLS 270 extern int key_decryptsession(const char *, des_block *); 271 extern int key_encryptsession(const char *, des_block *); 272 extern int key_gendes(des_block *); 273 extern int key_setsecret(const char *); 274 extern int key_secretkey_is_set(void); 275 extern int key_encryptsession_pk(char *, netobj *, des_block *); 276 __END_DECLS 277 /* 278 * Publickey routines. 279 */ 280 __BEGIN_DECLS 281 extern int getpublickey(const char *, char *); 282 extern int getpublicandprivatekey(char *, char *); 283 extern int getsecretkey(char *, char *, char *); 284 __END_DECLS 285 286 __BEGIN_DECLS 287 struct svc_req; 288 enum auth_stat _svcauth_none(struct svc_req *); 289 enum auth_stat _svcauth_short(struct svc_req *); 290 enum auth_stat _svcauth_unix(struct svc_req *); 291 enum auth_stat _svcauth_gss(struct svc_req *, bool *); 292 __END_DECLS 293 294 #define AUTH_NONE 0 /* no authentication */ 295 #define AUTH_NULL 0 /* backward compatibility */ 296 #define AUTH_SYS 1 /* unix style (uid, gids) */ 297 #define AUTH_UNIX AUTH_SYS 298 #define AUTH_SHORT 2 /* short hand unix style */ 299 #define AUTH_DH 3 /* for Diffie-Hellman mechanism */ 300 #define AUTH_DES AUTH_DH /* for backward compatibility */ 301 #define AUTH_KERB 4 /* kerberos style */ 302 #define RPCSEC_GSS 6 /* RPCSEC_GSS */ 303 304 #endif /* !_TIRPC_AUTH_H */
Contact us
|
About us
|
Term of use
|
Copyright © 2000-2024 MyWebUniversity.com ™