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 2019 Joyent, Inc.
25 * Copyright (c) 2011, 2016 by Delphix. All rights reserved.
26 * Copyright (c) 2012 DEY Storage Systems, Inc. All rights reserved.
27 * Copyright (c) 2011-2012 Pawel Jakub Dawidek. All rights reserved.
28 * Copyright (c) 2013 Martin Matuska. All rights reserved.
29 * Copyright (c) 2013 Steven Hartland. All rights reserved.
30 * Copyright (c) 2014 Integros [integros.com]
31 * Copyright 2017 Nexenta Systems, Inc.
32 * Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>
33 * Copyright 2017-2018 RackTop Systems.
34 */
35
36 #include <ctype.h>
37 #include <errno.h>
38 #include <libintl.h>
39 #include <math.h>
40 #include <stdio.h>
41 #include <stdlib.h>
42 #include <strings.h>
43 #include <unistd.h>
44 #include <stddef.h>
45 #include <zone.h>
46 #include <fcntl.h>
47 #include <sys/mntent.h>
48 #include <sys/mount.h>
49 #include <priv.h>
50 #include <pwd.h>
51 #include <grp.h>
1294 break;
1295 }
1296 (void) zfs_error(hdl, EZFS_BADPROP, errbuf);
1297 goto error;
1298 }
1299 }
1300
1301 /*FALLTHRU*/
1302
1303 case ZFS_PROP_SHARESMB:
1304 case ZFS_PROP_SHARENFS:
1305 /*
1306 * For the mountpoint and sharenfs or sharesmb
1307 * properties, check if it can be set in a
1308 * global/non-global zone based on
1309 * the zoned property value:
1310 *
1311 * global zone non-global zone
1312 * --------------------------------------------------
1313 * zoned=on mountpoint (no) mountpoint (yes)
1314 * sharenfs (no) sharenfs (no)
1315 * sharesmb (no) sharesmb (no)
1316 *
1317 * zoned=off mountpoint (yes) N/A
1318 * sharenfs (yes)
1319 * sharesmb (yes)
1320 */
1321 if (zoned) {
1322 if (getzoneid() == GLOBAL_ZONEID) {
1323 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
1324 "'%s' cannot be set on "
1325 "dataset in a non-global zone"),
1326 propname);
1327 (void) zfs_error(hdl, EZFS_ZONED,
1328 errbuf);
1329 goto error;
1330 } else if (prop == ZFS_PROP_SHARENFS ||
1331 prop == ZFS_PROP_SHARESMB) {
1332 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
1333 "'%s' cannot be set in "
1334 "a non-global zone"), propname);
1335 (void) zfs_error(hdl, EZFS_ZONED,
1336 errbuf);
1337 goto error;
1338 }
1339 } else if (getzoneid() != GLOBAL_ZONEID) {
1340 /*
1341 * If zoned property is 'off', this must be in
1342 * a global zone. If not, something is wrong.
1343 */
1344 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
1345 "'%s' cannot be set while dataset "
1346 "'zoned' property is set"), propname);
1347 (void) zfs_error(hdl, EZFS_ZONED, errbuf);
1348 goto error;
1349 }
1350
1351 /*
1352 * At this point, it is legitimate to set the
1353 * property. Now we want to make sure that the
1354 * property value is valid if it is sharenfs.
1355 */
1356 if ((prop == ZFS_PROP_SHARENFS ||
|
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) 2013, Joyent, Inc. All rights reserved.
28 * Copyright (c) 2011, 2016 by Delphix. All rights reserved.
29 * Copyright (c) 2012 DEY Storage Systems, Inc. All rights reserved.
30 * Copyright (c) 2011-2012 Pawel Jakub Dawidek. All rights reserved.
31 * Copyright (c) 2013 Martin Matuska. All rights reserved.
32 * Copyright (c) 2013 Steven Hartland. All rights reserved.
33 * Copyright (c) 2014 Integros [integros.com]
34 * Copyright 2018 Nexenta Systems, Inc.
35 * Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>
36 * Copyright 2017-2018 RackTop Systems.
37 */
38
39 #include <ctype.h>
40 #include <errno.h>
41 #include <libintl.h>
42 #include <math.h>
43 #include <stdio.h>
44 #include <stdlib.h>
45 #include <strings.h>
46 #include <unistd.h>
47 #include <stddef.h>
48 #include <zone.h>
49 #include <fcntl.h>
50 #include <sys/mntent.h>
51 #include <sys/mount.h>
52 #include <priv.h>
53 #include <pwd.h>
54 #include <grp.h>
1297 break;
1298 }
1299 (void) zfs_error(hdl, EZFS_BADPROP, errbuf);
1300 goto error;
1301 }
1302 }
1303
1304 /*FALLTHRU*/
1305
1306 case ZFS_PROP_SHARESMB:
1307 case ZFS_PROP_SHARENFS:
1308 /*
1309 * For the mountpoint and sharenfs or sharesmb
1310 * properties, check if it can be set in a
1311 * global/non-global zone based on
1312 * the zoned property value:
1313 *
1314 * global zone non-global zone
1315 * --------------------------------------------------
1316 * zoned=on mountpoint (no) mountpoint (yes)
1317 * sharenfs (no) sharenfs (yes)
1318 * sharesmb (no) sharesmb (yes)
1319 *
1320 * zoned=off mountpoint (yes) N/A
1321 * sharenfs (yes)
1322 * sharesmb (yes)
1323 */
1324 if (zoned) {
1325 if (getzoneid() == GLOBAL_ZONEID) {
1326 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
1327 "'%s' cannot be set on "
1328 "dataset in a non-global zone"),
1329 propname);
1330 (void) zfs_error(hdl, EZFS_ZONED,
1331 errbuf);
1332 goto error;
1333 }
1334 } else if (getzoneid() != GLOBAL_ZONEID) {
1335 /*
1336 * If zoned property is 'off', this must be in
1337 * a global zone. If not, something is wrong.
1338 */
1339 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
1340 "'%s' cannot be set while dataset "
1341 "'zoned' property is set"), propname);
1342 (void) zfs_error(hdl, EZFS_ZONED, errbuf);
1343 goto error;
1344 }
1345
1346 /*
1347 * At this point, it is legitimate to set the
1348 * property. Now we want to make sure that the
1349 * property value is valid if it is sharenfs.
1350 */
1351 if ((prop == ZFS_PROP_SHARENFS ||
|