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 (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
24 */
25
26 /*
27 * This is a helper file to get/set Windows SD. This is used by
28 * SRVSVC service.
29 */
30 #include <strings.h>
31 #include <libzfs.h>
32
33 #include <smbsrv/libsmb.h>
34 #include <smbsrv/libmlsvc.h>
35 #include <smbsrv/ndl/srvsvc.ndl>
36
37 /* Size of offset members in mslm_security_descriptor structure */
38 #define SRVSVC_SD_OFFSET_SZ 16
39
40 #define SRVSVC_ACE_OFFSET 8
41 #define SRVSVC_SID_OFFSET 8
42
43 uint32_t srvsvc_sd_set_relative(smb_sd_t *, uint8_t *);
44
45 static uint32_t srvsvc_sd_get_autohome(const smb_share_t *, smb_sd_t *);
46 static uint32_t srvsvc_sd_status_to_error(uint32_t);
47 static uint32_t srvsvc_sd_set_absolute(uint8_t *, smb_sd_t *);
48
49 /*
50 * This method computes ACL on share path from a share name.
51 * Return 0 upon success, -1 upon failure.
52 */
53 static int
54 srvsvc_shareacl_getpath(smb_share_t *si, char *shr_acl_path)
55 {
56 char dataset[MAXPATHLEN];
57 char mp[ZFS_MAXPROPLEN];
58 libzfs_handle_t *libhd;
59 zfs_handle_t *zfshd;
60 int ret = 0;
61
62 ret = smb_getdataset(si->shr_path, dataset, MAXPATHLEN);
63 if (ret != 0)
64 return (ret);
65
66 if ((libhd = libzfs_init()) == NULL)
67 return (-1);
68
69 if ((zfshd = zfs_open(libhd, dataset, ZFS_TYPE_DATASET)) == NULL) {
70 libzfs_fini(libhd);
71 return (-1);
72 }
73
74 if (zfs_prop_get(zfshd, ZFS_PROP_MOUNTPOINT, mp, sizeof (mp), NULL,
75 NULL, 0, B_FALSE) != 0) {
76 zfs_close(zfshd);
77 libzfs_fini(libhd);
78 return (-1);
79 }
80
81 zfs_close(zfshd);
82 libzfs_fini(libhd);
83
84 (void) snprintf(shr_acl_path, MAXPATHLEN, "%s/.zfs/shares/%s",
85 mp, si->shr_name);
86
87 return (ret);
88 }
|
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 (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2018 Nexenta Systems, Inc. All rights reserved.
25 */
26
27 /*
28 * This is a helper file to get/set Windows SD. This is used by
29 * SRVSVC service.
30 */
31 #include <strings.h>
32 #include <libzfs.h>
33
34 #include <smbsrv/libsmb.h>
35 #include <smbsrv/libmlsvc.h>
36 #include <smbsrv/ndl/srvsvc.ndl>
37
38 /* Size of offset members in mslm_security_descriptor structure */
39 #define SRVSVC_SD_OFFSET_SZ 16
40
41 #define SRVSVC_ACE_OFFSET 8
42 #define SRVSVC_SID_OFFSET 8
43
44 uint32_t srvsvc_sd_set_relative(smb_sd_t *, uint8_t *);
45
46 static uint32_t srvsvc_sd_get_autohome(const smb_share_t *, smb_sd_t *);
47 static uint32_t srvsvc_sd_status_to_error(uint32_t);
48 static uint32_t srvsvc_sd_set_absolute(uint8_t *, smb_sd_t *);
49
50 /*
51 * This method computes ACL on share path from a share name.
52 * Return 0 upon success, -1 upon failure.
53 */
54 static int
55 srvsvc_shareacl_getpath(smb_share_t *si, char *shr_acl_path)
56 {
57 char dataset[MAXPATHLEN];
58 char mp[ZFS_MAXPROPLEN];
59 libzfs_handle_t *libhd;
60 zfs_handle_t *zfshd;
61 int ret = 0;
62
63 if ((libhd = libzfs_init()) == NULL)
64 return (-1);
65
66 ret = smb_getdataset(libhd, si->shr_path, dataset, MAXPATHLEN);
67 if (ret != 0) {
68 libzfs_fini(libhd);
69 return (ret);
70 }
71
72
73 if ((zfshd = zfs_open(libhd, dataset, ZFS_TYPE_DATASET)) == NULL) {
74 libzfs_fini(libhd);
75 return (-1);
76 }
77
78 if (zfs_prop_get(zfshd, ZFS_PROP_MOUNTPOINT, mp, sizeof (mp), NULL,
79 NULL, 0, B_FALSE) != 0) {
80 zfs_close(zfshd);
81 libzfs_fini(libhd);
82 return (-1);
83 }
84
85 zfs_close(zfshd);
86 libzfs_fini(libhd);
87
88 (void) snprintf(shr_acl_path, MAXPATHLEN, "%s/.zfs/shares/%s",
89 mp, si->shr_name);
90
91 return (ret);
92 }
|