xref: /titanic_50/usr/src/uts/common/smbsrv/smb_idmap.h (revision c10c16dec587a0662068f6e2991c29ed3a9db943)
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  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _SMB_IDMAP_H
27 #define	_SMB_IDMAP_H
28 
29 #ifdef _KERNEL
30 #include <sys/kidmap.h>
31 #else
32 #include <idmap.h>
33 #endif
34 
35 #include <smbsrv/smb_sid.h>
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 /*
42  * SMB ID mapping
43  *
44  * Solaris ID mapping service (aka Winchester) works with domain SIDs
45  * and RIDs where domain SIDs are in string format. CIFS service works
46  * with binary SIDs understanable by CIFS clients. A layer of SMB ID
47  * mapping functions are implemeted to hide the SID conversion details
48  * and also hide the handling of array of batch mapping requests.
49  */
50 
51 #define	SMB_IDMAP_UNKNOWN	-1
52 #define	SMB_IDMAP_GROUP		0
53 #define	SMB_IDMAP_USER		1
54 #define	SMB_IDMAP_OWNERAT	2
55 #define	SMB_IDMAP_GROUPAT	3
56 #define	SMB_IDMAP_EVERYONE	4
57 
58 #define	SMB_IDMAP_SID2ID	0x0001
59 #define	SMB_IDMAP_ID2SID	0x0002
60 
61 /*
62  * smb_idmap_t
63  *
64  * sim_idtype: ID type (output in sid->uid mapping)
65  * sim_id:     UID/GID (output in sid->uid mapping)
66  */
67 typedef struct smb_idmap {
68 	int		sim_idtype;
69 	uid_t		*sim_id;
70 	char		*sim_domsid;
71 	uint32_t	sim_rid;
72 	smb_sid_t	*sim_sid;
73 	idmap_stat	sim_stat;
74 } smb_idmap_t;
75 
76 typedef struct smb_idmap_batch {
77 	uint16_t		sib_nmap;
78 	uint32_t		sib_flags;
79 	uint32_t		sib_size;
80 	smb_idmap_t 		*sib_maps;
81 	idmap_get_handle_t 	*sib_idmaph;
82 } smb_idmap_batch_t;
83 
84 idmap_stat smb_idmap_getsid(uid_t, int, smb_sid_t **);
85 idmap_stat smb_idmap_getid(smb_sid_t *, uid_t *, int *);
86 
87 void smb_idmap_batch_destroy(smb_idmap_batch_t *);
88 idmap_stat smb_idmap_batch_create(smb_idmap_batch_t *, uint16_t, int);
89 idmap_stat smb_idmap_batch_getmappings(smb_idmap_batch_t *);
90 idmap_stat smb_idmap_batch_getid(idmap_get_handle_t *, smb_idmap_t *,
91     smb_sid_t *, int);
92 idmap_stat smb_idmap_batch_getsid(idmap_get_handle_t *, smb_idmap_t *,
93     uid_t, int);
94 
95 #ifdef __cplusplus
96 }
97 #endif
98 
99 
100 #endif /* _SMB_IDMAP_H */
101