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) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright (c) 2011-2012 Pawel Jakub Dawidek. All rights reserved.
25 * Portions Copyright 2011 Martin Matuska
26 * Copyright 2015, OmniTI Computer Consulting, Inc. All rights reserved.
27 * Copyright 2016 Nexenta Systems, Inc. All rights reserved.
28 * Copyright 2019 Joyent, Inc.
29 * Copyright (c) 2011, 2017 by Delphix. All rights reserved.
30 * Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
31 * Copyright (c) 2013 Steven Hartland. All rights reserved.
32 * Copyright (c) 2014 Integros [integros.com]
33 * Copyright 2016 Toomas Soome <tsoome@me.com>
34 * Copyright (c) 2017, loli10K <ezomori.nozomu@gmail.com>. All rights reserved.
35 * Copyright 2017 RackTop Systems.
36 * Copyright (c) 2017, Datto, Inc. All rights reserved.
37 */
38
39 /*
40 * ZFS ioctls.
41 *
42 * This file handles the ioctls to /dev/zfs, used for configuring ZFS storage
43 * pools and filesystems, e.g. with /sbin/zfs and /sbin/zpool.
44 *
45 * There are two ways that we handle ioctls: the legacy way where almost
46 * all of the logic is in the ioctl callback, and the new way where most
47 * of the marshalling is handled in the common entry point, zfsdev_ioctl().
770 NO_FOLLOW, NULL, &vp)) != 0)
771 return (error);
772
773 /* Now make sure mntpnt and dataset are ZFS */
774
775 if (vp->v_vfsp->vfs_fstype != zfsfstype ||
776 (strcmp((char *)refstr_value(vp->v_vfsp->vfs_resource),
777 zc->zc_name) != 0)) {
778 VN_RELE(vp);
779 return (SET_ERROR(EPERM));
780 }
781
782 VN_RELE(vp);
783 return (dsl_deleg_access(zc->zc_name,
784 ZFS_DELEG_PERM_SHARE, cr));
785 }
786
787 int
788 zfs_secpolicy_share(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
789 {
790 if (!INGLOBALZONE(curproc))
791 return (SET_ERROR(EPERM));
792
793 if (secpolicy_nfs(cr) == 0) {
794 return (0);
795 } else {
796 return (zfs_secpolicy_deleg_share(zc, innvl, cr));
797 }
798 }
799
800 int
801 zfs_secpolicy_smb_acl(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
802 {
803 if (!INGLOBALZONE(curproc))
804 return (SET_ERROR(EPERM));
805
806 if (secpolicy_smb(cr) == 0) {
807 return (0);
808 } else {
809 return (zfs_secpolicy_deleg_share(zc, innvl, cr));
810 }
811 }
812
813 static int
814 zfs_get_parent(const char *datasetname, char *parent, int parentsize)
815 {
816 char *cp;
817
818 /*
819 * Remove the @bla or /bla from the end of the name to get the parent.
820 */
821 (void) strncpy(parent, datasetname, parentsize);
822 cp = strrchr(parent, '@');
823 if (cp != NULL) {
824 cp[0] = '\0';
825 } else {
|
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) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
24 */
25
26 /*
27 * Copyright (c) 2011-2012 Pawel Jakub Dawidek. All rights reserved.
28 * Portions Copyright 2011 Martin Matuska
29 * Copyright 2015, OmniTI Computer Consulting, Inc. All rights reserved.
30 * Copyright 2018 Nexenta Systems, Inc. All rights reserved.
31 * Copyright 2019 Joyent, Inc.
32 * Copyright (c) 2011, 2017 by Delphix. All rights reserved.
33 * Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
34 * Copyright (c) 2013 Steven Hartland. All rights reserved.
35 * Copyright (c) 2014 Integros [integros.com]
36 * Copyright 2016 Toomas Soome <tsoome@me.com>
37 * Copyright (c) 2017, loli10K <ezomori.nozomu@gmail.com>. All rights reserved.
38 * Copyright 2017 RackTop Systems.
39 * Copyright (c) 2017, Datto, Inc. All rights reserved.
40 */
41
42 /*
43 * ZFS ioctls.
44 *
45 * This file handles the ioctls to /dev/zfs, used for configuring ZFS storage
46 * pools and filesystems, e.g. with /sbin/zfs and /sbin/zpool.
47 *
48 * There are two ways that we handle ioctls: the legacy way where almost
49 * all of the logic is in the ioctl callback, and the new way where most
50 * of the marshalling is handled in the common entry point, zfsdev_ioctl().
773 NO_FOLLOW, NULL, &vp)) != 0)
774 return (error);
775
776 /* Now make sure mntpnt and dataset are ZFS */
777
778 if (vp->v_vfsp->vfs_fstype != zfsfstype ||
779 (strcmp((char *)refstr_value(vp->v_vfsp->vfs_resource),
780 zc->zc_name) != 0)) {
781 VN_RELE(vp);
782 return (SET_ERROR(EPERM));
783 }
784
785 VN_RELE(vp);
786 return (dsl_deleg_access(zc->zc_name,
787 ZFS_DELEG_PERM_SHARE, cr));
788 }
789
790 int
791 zfs_secpolicy_share(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
792 {
793 if (secpolicy_nfs(cr) == 0) {
794 return (0);
795 } else {
796 return (zfs_secpolicy_deleg_share(zc, innvl, cr));
797 }
798 }
799
800 int
801 zfs_secpolicy_smb_acl(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
802 {
803 if (secpolicy_smb(cr) == 0) {
804 return (0);
805 } else {
806 return (zfs_secpolicy_deleg_share(zc, innvl, cr));
807 }
808 }
809
810 static int
811 zfs_get_parent(const char *datasetname, char *parent, int parentsize)
812 {
813 char *cp;
814
815 /*
816 * Remove the @bla or /bla from the end of the name to get the parent.
817 */
818 (void) strncpy(parent, datasetname, parentsize);
819 cp = strrchr(parent, '@');
820 if (cp != NULL) {
821 cp[0] = '\0';
822 } else {
|