xref: /illumos-gate/usr/src/uts/common/nfs/nfsid_map.h (revision 2f172c55)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*2f172c55SRobert Thurlow  * Common Development and Distribution License (the "License").
6*2f172c55SRobert Thurlow  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*2f172c55SRobert Thurlow  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef _NFSID_MAP_H
277c478bd9Sstevel@tonic-gate #define	_NFSID_MAP_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #ifndef _KERNEL
307c478bd9Sstevel@tonic-gate #include <stddef.h>
317c478bd9Sstevel@tonic-gate #endif
327c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h>
337c478bd9Sstevel@tonic-gate #include <sys/types.h>
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate /*
367c478bd9Sstevel@tonic-gate  * NFSv4 id mapping daemon
377c478bd9Sstevel@tonic-gate  *
387c478bd9Sstevel@tonic-gate  * This daemon is used by the kernel to map strings in the form
397c478bd9Sstevel@tonic-gate  * "user@dns_domain" from an integer form or vice-versa.  The daemon
407c478bd9Sstevel@tonic-gate  * uses the system configured name services for the mapping.
417c478bd9Sstevel@tonic-gate  *
427c478bd9Sstevel@tonic-gate  * The status results determines if a mapping was successful.
437c478bd9Sstevel@tonic-gate  *
447c478bd9Sstevel@tonic-gate  * The mapping is cached in the kernel, so that expensive upcalls are
457c478bd9Sstevel@tonic-gate  * reduced to a minimum.
467c478bd9Sstevel@tonic-gate  */
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
497c478bd9Sstevel@tonic-gate extern "C" {
507c478bd9Sstevel@tonic-gate #endif
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate /*
537c478bd9Sstevel@tonic-gate  * mapid commands
547c478bd9Sstevel@tonic-gate  */
557c478bd9Sstevel@tonic-gate #define	NFSMAPID_STR_UID	1
567c478bd9Sstevel@tonic-gate #define	NFSMAPID_UID_STR	2
577c478bd9Sstevel@tonic-gate #define	NFSMAPID_STR_GID	3
587c478bd9Sstevel@tonic-gate #define	NFSMAPID_GID_STR	4
59*2f172c55SRobert Thurlow #define	NFSMAPID_SRV_NETINFO	5
607c478bd9Sstevel@tonic-gate 
617c478bd9Sstevel@tonic-gate /*
627c478bd9Sstevel@tonic-gate  * We are passing in arguments in a variable length struct
637c478bd9Sstevel@tonic-gate  * similar to a dirent_t. We break apart a utf8string into
647c478bd9Sstevel@tonic-gate  * its components and allocate a struct long enough to hold
657c478bd9Sstevel@tonic-gate  * the string and a NUL terminator.  The caller must ensure the
667c478bd9Sstevel@tonic-gate  * terminator is set.
677c478bd9Sstevel@tonic-gate  */
687c478bd9Sstevel@tonic-gate struct mapid_arg {
697c478bd9Sstevel@tonic-gate 	uint_t	cmd;
707c478bd9Sstevel@tonic-gate 	union {
717c478bd9Sstevel@tonic-gate 		uid_t		uid;
727c478bd9Sstevel@tonic-gate 		gid_t		gid;
737c478bd9Sstevel@tonic-gate 		int		len;
747c478bd9Sstevel@tonic-gate 	} u_arg;
757c478bd9Sstevel@tonic-gate 	char str[1];
767c478bd9Sstevel@tonic-gate };
777c478bd9Sstevel@tonic-gate typedef struct mapid_arg mapid_arg_t;
787c478bd9Sstevel@tonic-gate 
797c478bd9Sstevel@tonic-gate /*
807c478bd9Sstevel@tonic-gate  * The actual required size of the args, rounded up to a 64 bit boundary
817c478bd9Sstevel@tonic-gate  */
827c478bd9Sstevel@tonic-gate #define	MAPID_ARG_LEN(str_length)	\
837c478bd9Sstevel@tonic-gate 	((offsetof(mapid_arg_t, str[0]) + 1 + (str_length) + 7) & ~ 7)
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate /*
867c478bd9Sstevel@tonic-gate  * Return status codes
877c478bd9Sstevel@tonic-gate  */
887c478bd9Sstevel@tonic-gate #define	NFSMAPID_OK		0
897c478bd9Sstevel@tonic-gate 
907c478bd9Sstevel@tonic-gate /*
917c478bd9Sstevel@tonic-gate  * numeric string is mapped to its literal number
927c478bd9Sstevel@tonic-gate  */
937c478bd9Sstevel@tonic-gate #define	NFSMAPID_NUMSTR		1
947c478bd9Sstevel@tonic-gate 
957c478bd9Sstevel@tonic-gate /*
967c478bd9Sstevel@tonic-gate  * Value cannot be mapped, badly formed string
977c478bd9Sstevel@tonic-gate  */
987c478bd9Sstevel@tonic-gate #define	NFSMAPID_UNMAPPABLE	2
997c478bd9Sstevel@tonic-gate 
1007c478bd9Sstevel@tonic-gate /*
1017c478bd9Sstevel@tonic-gate  * Caller provided invalid arguments
1027c478bd9Sstevel@tonic-gate  */
1037c478bd9Sstevel@tonic-gate #define	NFSMAPID_INVALID	3
1047c478bd9Sstevel@tonic-gate 
1057c478bd9Sstevel@tonic-gate /*
1067c478bd9Sstevel@tonic-gate  * Internal error in daemon e.g. out of memory, can't return result
1077c478bd9Sstevel@tonic-gate  */
1087c478bd9Sstevel@tonic-gate #define	NFSMAPID_INTERNAL	4
1097c478bd9Sstevel@tonic-gate 
1107c478bd9Sstevel@tonic-gate /*
1117c478bd9Sstevel@tonic-gate  * Incorrect domain used
1127c478bd9Sstevel@tonic-gate  */
1137c478bd9Sstevel@tonic-gate #define	NFSMAPID_BADDOMAIN	5
1147c478bd9Sstevel@tonic-gate 
1157c478bd9Sstevel@tonic-gate /*
1167c478bd9Sstevel@tonic-gate  * Out of range uid/gid
1177c478bd9Sstevel@tonic-gate  */
1187c478bd9Sstevel@tonic-gate #define	NFSMAPID_BADID		6
1197c478bd9Sstevel@tonic-gate 
1207c478bd9Sstevel@tonic-gate /*
1217c478bd9Sstevel@tonic-gate  * User or group cannot be found in nameservice
1227c478bd9Sstevel@tonic-gate  */
1237c478bd9Sstevel@tonic-gate #define	NFSMAPID_NOTFOUND	7
1247c478bd9Sstevel@tonic-gate 
1257c478bd9Sstevel@tonic-gate /*
1267c478bd9Sstevel@tonic-gate  * Similar to the arguments, the result is variable length.
1277c478bd9Sstevel@tonic-gate  * The returner must ensure the string terminator is set.
1287c478bd9Sstevel@tonic-gate  */
1297c478bd9Sstevel@tonic-gate struct mapid_res {
1307c478bd9Sstevel@tonic-gate 	uint_t	status;
1317c478bd9Sstevel@tonic-gate 	union {
1327c478bd9Sstevel@tonic-gate 		uid_t		uid;
1337c478bd9Sstevel@tonic-gate 		gid_t		gid;
1347c478bd9Sstevel@tonic-gate 		int		len;
1357c478bd9Sstevel@tonic-gate 	} u_res;
1367c478bd9Sstevel@tonic-gate 	char str[1];
1377c478bd9Sstevel@tonic-gate };
1387c478bd9Sstevel@tonic-gate typedef struct mapid_res mapid_res_t;
1397c478bd9Sstevel@tonic-gate 
1407c478bd9Sstevel@tonic-gate /*
1417c478bd9Sstevel@tonic-gate  * The actual required size of the result, rounded up to a 64 bit boundary
1427c478bd9Sstevel@tonic-gate  */
1437c478bd9Sstevel@tonic-gate #define	MAPID_RES_LEN(str_length)	\
1447c478bd9Sstevel@tonic-gate 	((offsetof(mapid_res_t, str[0]) + 1 + (str_length) + 7) & ~ 7)
1457c478bd9Sstevel@tonic-gate 
146*2f172c55SRobert Thurlow /*
147*2f172c55SRobert Thurlow  * Support for referral name resolution by the NFS client
148*2f172c55SRobert Thurlow  */
149*2f172c55SRobert Thurlow typedef struct refd_door_args {
150*2f172c55SRobert Thurlow 	int		cmd;		/* NFS4_FS_LOCATIONS/NFS4_SRV_NETINFO */
151*2f172c55SRobert Thurlow 	int		xdr_len;	/* Length of xdr Buffer */
152*2f172c55SRobert Thurlow 	char		xdr_arg[1];	/* Buffer holding xdr encoded data */
153*2f172c55SRobert Thurlow } refd_door_args_t;
154*2f172c55SRobert Thurlow 
155*2f172c55SRobert Thurlow typedef struct refd_door_res {
156*2f172c55SRobert Thurlow 	int		res_status;
157*2f172c55SRobert Thurlow 	int		xdr_len;
158*2f172c55SRobert Thurlow 	char		xdr_res[1];
159*2f172c55SRobert Thurlow } refd_door_res_t;
160*2f172c55SRobert Thurlow 
161*2f172c55SRobert Thurlow #ifdef _SYSCALL32
162*2f172c55SRobert Thurlow typedef struct refd_door_args32 {
163*2f172c55SRobert Thurlow 	int32_t		cmd;
164*2f172c55SRobert Thurlow 	int32_t		xdr_len;
165*2f172c55SRobert Thurlow 	char		xdr_arg[1];
166*2f172c55SRobert Thurlow } refd_door_args32_t;
167*2f172c55SRobert Thurlow 
168*2f172c55SRobert Thurlow typedef struct 	refd_door_res32 {
169*2f172c55SRobert Thurlow 	int32_t		res_status;
170*2f172c55SRobert Thurlow 	int32_t		xdr_len;
171*2f172c55SRobert Thurlow 	char		xdr_res[1];
172*2f172c55SRobert Thurlow } refd_door_res32_t;
173*2f172c55SRobert Thurlow #endif
174*2f172c55SRobert Thurlow 
1757c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1767c478bd9Sstevel@tonic-gate }
1777c478bd9Sstevel@tonic-gate #endif
1787c478bd9Sstevel@tonic-gate 
1797c478bd9Sstevel@tonic-gate #endif /* _NFSID_MAP_H */
180