xref: /freebsd/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_008_pos.ksh (revision 61145dc2b94f12f6a47344fb9aac702321880e43)
1#!/bin/ksh -p
2# SPDX-License-Identifier: CDDL-1.0
3#
4# CDDL HEADER START
5#
6# The contents of this file are subject to the terms of the
7# Common Development and Distribution License (the "License").
8# You may not use this file except in compliance with the License.
9#
10# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11# or https://opensource.org/licenses/CDDL-1.0.
12# See the License for the specific language governing permissions
13# and limitations under the License.
14#
15# When distributing Covered Code, include this CDDL HEADER in each
16# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17# If applicable, add the following below this CDDL HEADER, with the
18# fields enclosed by brackets "[]" replaced with your own identifying
19# information: Portions Copyright [yyyy] [name of copyright owner]
20#
21# CDDL HEADER END
22#
23
24. $STF_SUITE/include/libtest.shlib
25
26#
27# DESCRIPTION:
28# Verify that datasets mounted at directories with whitespace are properly escaped
29# both going in (for mountd consumption) and going out (for removing from export list)
30#
31# STRATEGY:
32# 1. Create and share a dataset with spaces, tabs, and newlines
33# 2. Verify it's shared
34# 3. Unshare it
35# 4. Verify it's not shared
36#
37
38shares_can_have_whitespace || log_unsupported "Platform doesn't permit whitespace in NFS shares"
39basename='a + b
40 c	d'
41escname='a\040+\040b\012\040c\011d'
42
43verify_runnable "global"
44
45function cleanup
46{
47	datasetexists "$TESTPOOL/$TESTFS/shared1" && \
48		destroy_dataset "$TESTPOOL/$TESTFS/shared1" -f
49}
50
51log_assert "Datasets with spaces are properly shared and unshared."
52log_onexit cleanup
53
54log_must    zfs create -o sharenfs=on -o mountpoint="$TESTDIR/$basename" "$TESTPOOL/$TESTFS/shared1"
55log_must    is_shared "$TESTDIR/$escname"
56log_must    zfs unshare "$TESTPOOL/$TESTFS/shared1"
57log_mustnot is_shared "$TESTDIR/$escname"
58
59log_pass "Datasets with spaces are properly shared and unshared."
60