summaryrefslogtreecommitdiff
path: root/usr
diff options
context:
space:
mode:
authorJerry Jelinek <jerry.jelinek@joyent.com>2019-07-08 14:29:01 +0000
committerJerry Jelinek <jerry.jelinek@joyent.com>2019-07-09 20:01:09 +0000
commit08ae7ca2c9a60aaa6cd4c8e4950a523180c91ffd (patch)
treebcaf8a8efc7a28fb4fa12e2b5d18ad5f0bb5ded2 /usr
parent6d7141bf502e486d75c0ad6b3c65862b4c48d097 (diff)
downloadillumos-joyent-08ae7ca2c9a60aaa6cd4c8e4950a523180c91ffd.tar.gz
11309 zfs recv on delegated dataset inside a zone can fail
Reviewed by: Toomas Soome <tsoome@me.com> Reviewed by: Kody Kantor <kody.kantor@joyent.com> Reviewed by: Jason King <jason.king@joyent.com> Approved by: Gordon Ross <gwr@nexenta.com>
Diffstat (limited to 'usr')
-rw-r--r--usr/src/lib/libzfs/common/libzfs_sendrecv.c3
-rw-r--r--usr/src/pkg/manifests/system-test-zfstest.mf1
-rw-r--r--usr/src/test/zfs-tests/runfiles/delphix.run1
-rw-r--r--usr/src/test/zfs-tests/runfiles/omnios.run1
-rw-r--r--usr/src/test/zfs-tests/runfiles/openindiana.run1
-rw-r--r--usr/src/test/zfs-tests/tests/functional/rsend/recv_secpolicy.ksh71
6 files changed, 76 insertions, 2 deletions
diff --git a/usr/src/lib/libzfs/common/libzfs_sendrecv.c b/usr/src/lib/libzfs/common/libzfs_sendrecv.c
index 27f05f101e..56583244f4 100644
--- a/usr/src/lib/libzfs/common/libzfs_sendrecv.c
+++ b/usr/src/lib/libzfs/common/libzfs_sendrecv.c
@@ -22,7 +22,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2015 by Delphix. All rights reserved.
- * Copyright (c) 2012, Joyent, Inc. All rights reserved.
+ * Copyright 2019 Joyent, Inc.
* Copyright (c) 2012 Pawel Jakub Dawidek. All rights reserved.
* Copyright (c) 2013 Steven Hartland. All rights reserved.
* Copyright 2015, OmniTI Computer Consulting, Inc. All rights reserved.
@@ -3754,7 +3754,6 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
}
newfs = B_TRUE;
- *cp = '/';
}
zc.zc_begin_record = *drr_noswap;
diff --git a/usr/src/pkg/manifests/system-test-zfstest.mf b/usr/src/pkg/manifests/system-test-zfstest.mf
index e2a3c9fa2f..9e74a15465 100644
--- a/usr/src/pkg/manifests/system-test-zfstest.mf
+++ b/usr/src/pkg/manifests/system-test-zfstest.mf
@@ -2765,6 +2765,7 @@ file path=opt/zfs-tests/tests/functional/rootpool/rootpool_003_neg mode=0555
file path=opt/zfs-tests/tests/functional/rootpool/rootpool_007_pos mode=0555
file path=opt/zfs-tests/tests/functional/rootpool/setup mode=0555
file path=opt/zfs-tests/tests/functional/rsend/cleanup mode=0555
+file path=opt/zfs-tests/tests/functional/rsend/recv_secpolicy mode=0555
file path=opt/zfs-tests/tests/functional/rsend/rsend.cfg mode=0444
file path=opt/zfs-tests/tests/functional/rsend/rsend.kshlib mode=0444
file path=opt/zfs-tests/tests/functional/rsend/rsend_001_pos mode=0555
diff --git a/usr/src/test/zfs-tests/runfiles/delphix.run b/usr/src/test/zfs-tests/runfiles/delphix.run
index c1563223ec..deed0ebae0 100644
--- a/usr/src/test/zfs-tests/runfiles/delphix.run
+++ b/usr/src/test/zfs-tests/runfiles/delphix.run
@@ -598,6 +598,7 @@ tests = ['rsend_001_pos', 'rsend_002_pos', 'rsend_003_pos', 'rsend_004_pos',
'rsend_013_pos', 'rsend_014_pos',
'rsend_019_pos', 'rsend_020_pos',
'rsend_021_pos', 'rsend_022_pos', 'rsend_024_pos',
+ 'recv_secpolicy',
'send-c_verify_ratio', 'send-c_verify_contents', 'send-c_props',
'send-c_incremental', 'send-c_volume', 'send-c_zstreamdump',
'send-c_lz4_disabled', 'send-c_recv_lz4_disabled',
diff --git a/usr/src/test/zfs-tests/runfiles/omnios.run b/usr/src/test/zfs-tests/runfiles/omnios.run
index 8c26d6dfbd..194799ba81 100644
--- a/usr/src/test/zfs-tests/runfiles/omnios.run
+++ b/usr/src/test/zfs-tests/runfiles/omnios.run
@@ -597,6 +597,7 @@ tests = ['rsend_001_pos', 'rsend_002_pos', 'rsend_003_pos', 'rsend_004_pos',
'rsend_013_pos', 'rsend_014_pos',
'rsend_019_pos', 'rsend_020_pos',
'rsend_021_pos', 'rsend_022_pos', 'rsend_024_pos',
+ 'recv_secpolicy',
'send-c_verify_ratio', 'send-c_verify_contents', 'send-c_props',
'send-c_incremental', 'send-c_volume', 'send-c_zstreamdump',
'send-c_lz4_disabled', 'send-c_recv_lz4_disabled',
diff --git a/usr/src/test/zfs-tests/runfiles/openindiana.run b/usr/src/test/zfs-tests/runfiles/openindiana.run
index 5ee4230f66..80b9c837a2 100644
--- a/usr/src/test/zfs-tests/runfiles/openindiana.run
+++ b/usr/src/test/zfs-tests/runfiles/openindiana.run
@@ -597,6 +597,7 @@ tests = ['rsend_001_pos', 'rsend_002_pos', 'rsend_003_pos', 'rsend_004_pos',
'rsend_013_pos', 'rsend_014_pos',
'rsend_019_pos', 'rsend_020_pos',
'rsend_021_pos', 'rsend_022_pos', 'rsend_024_pos',
+ 'recv_secpolicy',
'send-c_verify_ratio', 'send-c_verify_contents', 'send-c_props',
'send-c_incremental', 'send-c_volume', 'send-c_zstreamdump',
'send-c_lz4_disabled', 'send-c_recv_lz4_disabled',
diff --git a/usr/src/test/zfs-tests/tests/functional/rsend/recv_secpolicy.ksh b/usr/src/test/zfs-tests/tests/functional/rsend/recv_secpolicy.ksh
new file mode 100644
index 0000000000..94ea8cec33
--- /dev/null
+++ b/usr/src/test/zfs-tests/tests/functional/rsend/recv_secpolicy.ksh
@@ -0,0 +1,71 @@
+#!/bin/ksh -p
+#
+# CDDL HEADER START
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2019 Joyent, Inc.
+#
+
+. $STF_SUITE/tests/functional/rsend/rsend.kshlib
+
+#
+# DESCRIPTION:
+# Verify that the parent dataset is passed to the kernel's zfs_secpolicy_recv
+# function during a zfs receive.
+#
+# STRATEGY:
+# 1. Create a hierarchy of datasets.
+# 2. Take a snapshot of the final child dataset and send it to a file.
+# 3. Use DTrace to run the zfs recv command and simultaneously monitor the
+# zc_name member of the zfs_cmd_t structure that is validated in
+# zfs_secpolicy_recv.
+# 4. Verify that the zc_name member is the parent dataset, as expected.
+#
+
+verify_runnable "both"
+
+function cleanup
+{
+ destroy_dataset $TESTPOOL/testfs2 "-r"
+ destroy_dataset $TESTPOOL/testfs1 "-r"
+ [[ -f $sendfile ]] && log_must rm $sendfile
+}
+log_onexit cleanup
+
+log_assert "Verify zfs_secpolicy_recv is passed the proper trimmed name"
+
+typeset sendfile=$TESTDIR/sendfile
+
+log_must zfs create $TESTPOOL/testfs1
+log_must zfs create $TESTPOOL/testfs1/data
+log_must zfs create $TESTPOOL/testfs1/data/foo
+
+log_must zfs create $TESTPOOL/testfs2
+log_must zfs create $TESTPOOL/testfs2/data
+
+log_must mkfile 4k /$TESTPOOL/testfs1/data/foo/testfile0
+
+log_must zfs snap $TESTPOOL/testfs1/data/foo@1
+
+log_must eval "zfs send $TESTPOOL/testfs1/data/foo@1 > $sendfile"
+
+zc_name=$(/usr/sbin/dtrace -q -n \
+ 'fbt::zfs_secpolicy_recv:entry {printf("%s", stringof(args[0]->zc_name));}' \
+ -c "zfs receive $TESTPOOL/testfs2/data/foo" < $sendfile)
+
+[[ "$zc_name" == "$TESTPOOL/testfs2/data" ]] || \
+ log_fail "zc_name mismatch: $zc_name != $TESTPOOL/testfs2/data"
+
+log_pass "zfs_secpolicy_recv is passed the proper trimmed name"