1*2140Srmesta /* 2*2140Srmesta * CDDL HEADER START 3*2140Srmesta * 4*2140Srmesta * The contents of this file are subject to the terms of the 5*2140Srmesta * Common Development and Distribution License (the "License"). 6*2140Srmesta * You may not use this file except in compliance with the License. 7*2140Srmesta * 8*2140Srmesta * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*2140Srmesta * or http://www.opensolaris.org/os/licensing. 10*2140Srmesta * See the License for the specific language governing permissions 11*2140Srmesta * and limitations under the License. 12*2140Srmesta * 13*2140Srmesta * When distributing Covered Code, include this CDDL HEADER in each 14*2140Srmesta * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*2140Srmesta * If applicable, add the following below this CDDL HEADER, with the 16*2140Srmesta * fields enclosed by brackets "[]" replaced with your own identifying 17*2140Srmesta * information: Portions Copyright [yyyy] [name of copyright owner] 18*2140Srmesta * 19*2140Srmesta * CDDL HEADER END 20*2140Srmesta */ 21*2140Srmesta /* 22*2140Srmesta * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 23*2140Srmesta * Use is subject to license terms. 24*2140Srmesta */ 25*2140Srmesta 26*2140Srmesta #ifndef _AUTH_H 27*2140Srmesta #define _AUTH_H 28*2140Srmesta 29*2140Srmesta #pragma ident "%Z%%M% %I% %E% SMI" 30*2140Srmesta 31*2140Srmesta 32*2140Srmesta /* 33*2140Srmesta * nfsauth_prot.x (The NFSAUTH Protocol) 34*2140Srmesta * 35*2140Srmesta * This protocol is used by the kernel to authorize NFS clients. This svc 36*2140Srmesta * lives in the mount daemon and checks the client's access for an export 37*2140Srmesta * with a given authentication flavor. 38*2140Srmesta * 39*2140Srmesta * The status result determines what kind of access the client is permitted. 40*2140Srmesta * 41*2140Srmesta * The result is cached in the kernel, so the authorization call will be 42*2140Srmesta * made * only the first time the client mounts the filesystem. 43*2140Srmesta * 44*2140Srmesta * const A_MAXPATH = 1024; 45*2140Srmesta * 46*2140Srmesta * struct auth_req { 47*2140Srmesta * netobj req_client; # client's address 48*2140Srmesta * string req_netid<>; # Netid of address 49*2140Srmesta * string req_path<A_MAXPATH>; # export path 50*2140Srmesta * int req_flavor; # auth flavor 51*2140Srmesta * }; 52*2140Srmesta * 53*2140Srmesta * const NFSAUTH_DENIED = 0x01; # Access denied 54*2140Srmesta * const NFSAUTH_RO = 0x02; # Read-only 55*2140Srmesta * const NFSAUTH_RW = 0x04; # Read-write 56*2140Srmesta * const NFSAUTH_ROOT = 0x08; # Root access 57*2140Srmesta * const NFSAUTH_WRONGSEC = 0x10; # Advise NFS v4 clients to 58*2140Srmesta * # try a different flavor 59*2140Srmesta * # 60*2140Srmesta * # The following are not part of the protocol. 61*2140Srmesta * # 62*2140Srmesta * const NFSAUTH_DROP = 0x20; # Drop request 63*2140Srmesta * const NFSAUTH_MAPNONE = 0x40; # Mapped flavor to AUTH_NONE 64*2140Srmesta * const NFSAUTH_LIMITED = 0x80; # Access limited to visible nodes 65*2140Srmesta * 66*2140Srmesta * struct auth_res { 67*2140Srmesta * int auth_perm; 68*2140Srmesta * }; 69*2140Srmesta * 70*2140Srmesta * program NFSAUTH_PROG { 71*2140Srmesta * version NFSAUTH_VERS { 72*2140Srmesta * # 73*2140Srmesta * # Authorization Request 74*2140Srmesta * # 75*2140Srmesta * auth_res 76*2140Srmesta * NFSAUTH_ACCESS(auth_req) = 1; 77*2140Srmesta * 78*2140Srmesta * } = 1; 79*2140Srmesta * } = 100231; 80*2140Srmesta */ 81*2140Srmesta 82*2140Srmesta #ifndef _KERNEL 83*2140Srmesta #include <stddef.h> 84*2140Srmesta #endif 85*2140Srmesta #include <sys/sysmacros.h> 86*2140Srmesta #include <sys/types.h> 87*2140Srmesta #include <rpc/xdr.h> 88*2140Srmesta 89*2140Srmesta #ifdef __cplusplus 90*2140Srmesta extern "C" { 91*2140Srmesta #endif 92*2140Srmesta 93*2140Srmesta 94*2140Srmesta /* --8<-- Start: nfsauth_prot.x definitions --8<-- */ 95*2140Srmesta 96*2140Srmesta #define A_MAXPATH 1024 97*2140Srmesta 98*2140Srmesta #define NFSAUTH_ACCESS 1 99*2140Srmesta 100*2140Srmesta #define NFSAUTH_DENIED 0x01 101*2140Srmesta #define NFSAUTH_RO 0x02 102*2140Srmesta #define NFSAUTH_RW 0x04 103*2140Srmesta #define NFSAUTH_ROOT 0x08 104*2140Srmesta #define NFSAUTH_WRONGSEC 0x10 105*2140Srmesta #define NFSAUTH_DROP 0x20 106*2140Srmesta #define NFSAUTH_MAPNONE 0x40 107*2140Srmesta #define NFSAUTH_LIMITED 0x80 108*2140Srmesta 109*2140Srmesta struct auth_req { 110*2140Srmesta netobj req_client; 111*2140Srmesta char *req_netid; 112*2140Srmesta char *req_path; 113*2140Srmesta int req_flavor; 114*2140Srmesta }; 115*2140Srmesta typedef struct auth_req auth_req; 116*2140Srmesta 117*2140Srmesta struct auth_res { 118*2140Srmesta int auth_perm; 119*2140Srmesta }; 120*2140Srmesta typedef struct auth_res auth_res; 121*2140Srmesta 122*2140Srmesta /* --8<-- End: nfsauth_prot.x definitions --8<-- */ 123*2140Srmesta 124*2140Srmesta 125*2140Srmesta #define NFSAUTH_DR_OKAY 0x0 /* success */ 126*2140Srmesta #define NFSAUTH_DR_BADCMD 0x100 /* NFSAUTH_ACCESS is only cmd allowed */ 127*2140Srmesta #define NFSAUTH_DR_DECERR 0x200 /* mountd could not decode arguments */ 128*2140Srmesta #define NFSAUTH_DR_EFAIL 0x400 /* mountd could not encode results */ 129*2140Srmesta #define NFSAUTH_DR_TRYCNT 5 /* door handle acquisition retry cnt */ 130*2140Srmesta 131*2140Srmesta #if defined(DEBUG) && !defined(_KERNEL) 132*2140Srmesta #define MOUNTD_DOOR "/var/run/mountd_door" 133*2140Srmesta #endif 134*2140Srmesta 135*2140Srmesta /* 136*2140Srmesta * Only cmd is added to the args. We need to know "what" we want 137*2140Srmesta * the daemon to do for us. Also, 'stat' returns the status from 138*2140Srmesta * the daemon down to the kernel in addition to perms. 139*2140Srmesta */ 140*2140Srmesta struct nfsauth_arg { 141*2140Srmesta uint_t cmd; 142*2140Srmesta auth_req areq; 143*2140Srmesta }; 144*2140Srmesta typedef struct nfsauth_arg nfsauth_arg_t; 145*2140Srmesta 146*2140Srmesta struct nfsauth_res { 147*2140Srmesta uint_t stat; 148*2140Srmesta auth_res ares; 149*2140Srmesta }; 150*2140Srmesta typedef struct nfsauth_res nfsauth_res_t; 151*2140Srmesta 152*2140Srmesta /* 153*2140Srmesta * For future extensibility, we version the data structures so 154*2140Srmesta * future incantations of mountd(1m) will know how to XDR decode 155*2140Srmesta * the arguments. 156*2140Srmesta */ 157*2140Srmesta enum vtypes { 158*2140Srmesta V_ERROR = 0, 159*2140Srmesta V_PROTO = 1 160*2140Srmesta }; 161*2140Srmesta typedef enum vtypes vtypes; 162*2140Srmesta 163*2140Srmesta typedef struct varg { 164*2140Srmesta uint_t vers; 165*2140Srmesta union { 166*2140Srmesta nfsauth_arg_t arg; 167*2140Srmesta /* additional args versions go here */ 168*2140Srmesta } arg_u; 169*2140Srmesta } varg_t; 170*2140Srmesta 171*2140Srmesta extern bool_t xdr_varg(XDR *, varg_t *); 172*2140Srmesta extern bool_t xdr_nfsauth_arg(XDR *, nfsauth_arg_t *); 173*2140Srmesta extern bool_t xdr_nfsauth_res(XDR *, nfsauth_res_t *); 174*2140Srmesta 175*2140Srmesta #ifdef __cplusplus 176*2140Srmesta } 177*2140Srmesta #endif 178*2140Srmesta 179*2140Srmesta #endif /* _AUTH_H */ 180