xref: /titanic_50/usr/src/lib/libsmbfs/netsmb/smbfs_acl.h (revision 0b5ce10aee80822ecc7df77df92a5e24078ba196)
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 2010 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _NETSMB_SMBFS_ACL_H
28 #define	_NETSMB_SMBFS_ACL_H
29 
30 /*
31  * Get/set ACL via contracted interface in libsmbfs.
32  * The ACL is in the form used by libsec (type=ACE_T)
33  * but we need to carry the uid/gid info here too.
34  */
35 
36 #include <sys/acl.h>
37 
38 #ifdef	__cplusplus
39 extern "C" {
40 #endif
41 
42 /*
43  * Get a ZFS-style acl from an FD opened in smbfs.
44  * Intentionally similar to: facl_get(3SEC)
45  *
46  * Allocates an acl_t via libsec.  Free with: acl_free(3SEC)
47  * Get owner/group IDs too if ID pointers != NULL
48  */
49 int smbfs_acl_get(int fd, acl_t **, uid_t *, gid_t *);
50 
51 /*
52  * Set a ZFS-style acl onto an FD opened in smbfs.
53  * Intentionally similar to: facl_set(3SEC)
54  *
55  * The acl_t must be of type ACE_T (from libsec).
56  * Set owner/group IDs too if ID values != -1
57  */
58 int smbfs_acl_set(int fd, acl_t *, uid_t, gid_t);
59 
60 
61 /*
62  * Slightly lower-level functions, allowing access to
63  * the raw Windows Security Descriptor (SD)
64  *
65  * The struct i_ntsid is opaque in this I/F.
66  * Real decl. in: common/smbclnt/smbfs_ntacl.h
67  */
68 struct i_ntsd;
69 
70 /*
71  * Get an "internal form" SD from the FD (opened in smbfs).
72  * Allocates a hierarchy in isdp.  Caller must free it via
73  * smbfs_acl_free_isd()
74  */
75 int smbfs_acl_getsd(int fd, uint32_t, struct i_ntsd **);
76 
77 /*
78  * Set an "internal form" SD onto the FD (opened in smbfs).
79  */
80 int smbfs_acl_setsd(int fd, uint32_t, struct i_ntsd *);
81 
82 /*
83  * Selector bits (2nd arg above) copied from smb.h so we
84  * don't need that whole thing exposed to our consumers.
85  * Any mismatch would be detected in smb/acl_api.c
86  */
87 #define	OWNER_SECURITY_INFORMATION		0x00000001
88 #define	GROUP_SECURITY_INFORMATION		0x00000002
89 #define	DACL_SECURITY_INFORMATION		0x00000004
90 #define	SACL_SECURITY_INFORMATION		0x00000008
91 
92 struct __FILE;
93 void smbfs_acl_print_sd(struct __FILE *, struct i_ntsd *);
94 
95 /*
96  * These are duplicated from common/smbclnt/smbfs_ntacl.h
97  * rather than exporting that header for this library.
98  * Any mismatch would be detected in smb/acl_api.c
99  */
100 int smbfs_acl_sd2zfs(struct i_ntsd *, acl_t *, uid_t *, gid_t *);
101 int smbfs_acl_zfs2sd(acl_t *, uid_t, gid_t, uint32_t, struct i_ntsd **);
102 void smbfs_acl_free_sd(struct i_ntsd *);
103 
104 #ifdef	__cplusplus
105 }
106 #endif
107 
108 #endif	/* _NETSMB_SMBFS_ACL_H */
109