mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-25 11:47:43 +03:00
OpenZFS 7290 - ZFS test suite needs to control what utilities it can run
Authored by: John Wren Kennedy <john.kennedy@delphix.com> Reviewed by: Dan Kimmel <dan.kimmel@delphix.com> Reviewed by: Matthew Ahrens <mahrens@delphix.com> Reviewed by: Dan McDonald <danmcd@omniti.com> Approved by: Gordon Ross <gordon.w.ross@gmail.com> Ported-by: Brian Behlendorf <behlendorf1@llnl.gov> Ported-by: George Melikov <mail@gmelikov.ru> Porting Notes: - Utilities which aren't available under Linux have been removed. - Because of sudo's default secure path behavior PATH must be explicitly reset at the top of libtest.shlib. This avoids the need for all users to customize secure path on their system. - Updated ZoL infrastructure to manage constrained path - Updated all test cases - Check permissions for usergroup tests - When testing in-tree create links under bin/ - Update fault cleanup such that missing files during cleanup aren't fatal. - Configure su environment with constrained path OpenZFS-issue: https://www.illumos.org/issues/7290 OpenZFS-commit: https://github.com/openzfs/openzfs/commit/1d32ba6 Closes #5903
This commit is contained in:
committed by
Brian Behlendorf
parent
7a4500a101
commit
c1d9abf905
@@ -24,22 +24,22 @@
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2013 by Delphix. All rights reserved.
|
||||
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
ZFS_USER=$($CAT /tmp/zfs-xattr-test-user.txt)
|
||||
$RM /tmp/zfs-xattr-test-user.txt
|
||||
ZFS_USER=$(cat /tmp/zfs-xattr-test-user.txt)
|
||||
rm /tmp/zfs-xattr-test-user.txt
|
||||
|
||||
USES_NIS=$($CAT /tmp/zfs-xattr-test-nis.txt)
|
||||
$RM /tmp/zfs-xattr-test-nis.txt
|
||||
USES_NIS=$(cat /tmp/zfs-xattr-test-nis.txt)
|
||||
rm /tmp/zfs-xattr-test-nis.txt
|
||||
|
||||
del_user $ZFS_USER
|
||||
|
||||
if [ "${USES_NIS}" == "true" ]
|
||||
then
|
||||
$SVCADM enable svc:/network/nis/client:default
|
||||
svcadm enable svc:/network/nis/client:default
|
||||
fi
|
||||
|
||||
default_cleanup
|
||||
|
||||
@@ -24,18 +24,18 @@
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2013 by Delphix. All rights reserved.
|
||||
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
# if we're running NIS, turn it off until we clean up
|
||||
# (it can cause useradd to take a long time, hitting our TIMEOUT)
|
||||
USES_NIS=FALSE
|
||||
$SVCS svc:/network/nis/client:default | $GREP online > /dev/null
|
||||
USES_NIS=false
|
||||
svcs svc:/network/nis/client:default | grep online > /dev/null
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
$SVCADM disable -t svc:/network/nis/client:default
|
||||
svcadm disable -t svc:/network/nis/client:default
|
||||
USES_NIS=true
|
||||
fi
|
||||
|
||||
@@ -45,7 +45,7 @@ ZFS_GROUP=staff
|
||||
while [ -z "${FOUND}" ]
|
||||
do
|
||||
COUNT=0
|
||||
USER_EXISTS=$( $GREP $ZFS_USER /etc/passwd )
|
||||
USER_EXISTS=$( grep $ZFS_USER /etc/passwd )
|
||||
if [ ! -z "${USER_EXISTS}" ]
|
||||
then
|
||||
ZFS_USER="${ZFS_USER}${COUNT}"
|
||||
@@ -57,8 +57,8 @@ done
|
||||
|
||||
log_must add_user $ZFS_GROUP $ZFS_USER
|
||||
|
||||
$ECHO $ZFS_USER > /tmp/zfs-xattr-test-user.txt
|
||||
$ECHO $USES_NIS > /tmp/zfs-xattr-test-nis.txt
|
||||
echo $ZFS_USER > /tmp/zfs-xattr-test-user.txt
|
||||
echo $USES_NIS > /tmp/zfs-xattr-test-nis.txt
|
||||
|
||||
DISK=${DISKS%% *}
|
||||
default_setup $DISK
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2013 by Delphix. All rights reserved.
|
||||
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
@@ -48,14 +48,14 @@ function cleanup {
|
||||
|
||||
if [ -f $TESTDIR/myfile.$$ ]
|
||||
then
|
||||
log_must $RM $TESTDIR/myfile.$$
|
||||
log_must rm $TESTDIR/myfile.$$
|
||||
fi
|
||||
}
|
||||
|
||||
log_assert "Create/read/write/append of xattrs works"
|
||||
log_onexit cleanup
|
||||
|
||||
log_must $TOUCH $TESTDIR/myfile.$$
|
||||
log_must touch $TESTDIR/myfile.$$
|
||||
create_xattr $TESTDIR/myfile.$$ passwd /etc/passwd
|
||||
verify_write_xattr $TESTDIR/myfile.$$ passwd
|
||||
delete_xattr $TESTDIR/myfile.$$ passwd
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2013 by Delphix. All rights reserved.
|
||||
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
@@ -42,7 +42,7 @@
|
||||
|
||||
function cleanup {
|
||||
|
||||
log_must $RM $TESTDIR/myfile.$$
|
||||
log_must rm $TESTDIR/myfile.$$
|
||||
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ log_assert "A read of a non-existent xattr fails"
|
||||
log_onexit cleanup
|
||||
|
||||
# create a file
|
||||
log_must $TOUCH $TESTDIR/myfile.$$
|
||||
log_mustnot eval "$CAT $TESTDIR/myfile.$$ not-here.txt > /dev/null 2>&1"
|
||||
log_must touch $TESTDIR/myfile.$$
|
||||
log_mustnot eval "cat $TESTDIR/myfile.$$ not-here.txt > /dev/null 2>&1"
|
||||
|
||||
log_pass "A read of a non-existent xattr fails"
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2013 by Delphix. All rights reserved.
|
||||
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
@@ -45,18 +45,18 @@
|
||||
|
||||
function cleanup {
|
||||
|
||||
log_must $RM $TESTDIR/myfile.$$
|
||||
log_must rm $TESTDIR/myfile.$$
|
||||
|
||||
}
|
||||
|
||||
log_assert "read/write xattr on a file with no permissions fails"
|
||||
log_onexit cleanup
|
||||
|
||||
log_must $TOUCH $TESTDIR/myfile.$$
|
||||
log_must touch $TESTDIR/myfile.$$
|
||||
create_xattr $TESTDIR/myfile.$$ passwd /etc/passwd
|
||||
|
||||
log_must $CHMOD 000 $TESTDIR/myfile.$$
|
||||
log_mustnot $SU $ZFS_USER -c "$RUNAT $TESTDIR/myfile.$$ $CAT passwd"
|
||||
log_mustnot $SU $ZFS_USER -c "$RUNAT $TESTDIR/myfile.$$ $CP /etc/passwd ."
|
||||
log_must chmod 000 $TESTDIR/myfile.$$
|
||||
log_mustnot su $ZFS_USER -c "runat $TESTDIR/myfile.$$ cat passwd"
|
||||
log_mustnot su $ZFS_USER -c "runat $TESTDIR/myfile.$$ cp /etc/passwd ."
|
||||
|
||||
log_pass "read/write xattr on a file with no permissions fails"
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2013 by Delphix. All rights reserved.
|
||||
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
@@ -52,8 +52,8 @@ function cleanup {
|
||||
|
||||
if [ $( ismounted /tmp/$NEWFS_DEFAULT_FS.$$ $NEWFS_DEFAULT_FS ) ]
|
||||
then
|
||||
log_must $UMOUNT /tmp/$NEWFS_DEFAULT_FS.$$
|
||||
log_must $RM -rf /tmp/$NEWFS_DEFAULT_FS.$$
|
||||
log_must umount /tmp/$NEWFS_DEFAULT_FS.$$
|
||||
log_must rm -rf /tmp/$NEWFS_DEFAULT_FS.$$
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -61,27 +61,27 @@ log_assert "Files from $NEWFS_DEFAULT_FS,tmpfs with xattrs copied to zfs retain
|
||||
log_onexit cleanup
|
||||
|
||||
# Create a UFS|EXT2 file system that we can work in
|
||||
log_must $ZFS create -V128m $TESTPOOL/$TESTFS/zvol
|
||||
log_must zfs create -V128m $TESTPOOL/$TESTFS/zvol
|
||||
block_device_wait
|
||||
log_must eval "$ECHO y | $NEWFS $ZVOL_DEVDIR/$TESTPOOL/$TESTFS/zvol > /dev/null 2>&1"
|
||||
log_must eval "echo y | $NEWFS $ZVOL_DEVDIR/$TESTPOOL/$TESTFS/zvol > /dev/null 2>&1"
|
||||
|
||||
log_must $MKDIR /tmp/$NEWFS_DEFAULT_FS.$$
|
||||
log_must $MOUNT $ZVOL_DEVDIR/$TESTPOOL/$TESTFS/zvol /tmp/$NEWFS_DEFAULT_FS.$$
|
||||
log_must mkdir /tmp/$NEWFS_DEFAULT_FS.$$
|
||||
log_must mount $ZVOL_DEVDIR/$TESTPOOL/$TESTFS/zvol /tmp/$NEWFS_DEFAULT_FS.$$
|
||||
|
||||
# Create files in ufs|ext2 and tmpfs, and set some xattrs on them.
|
||||
log_must $TOUCH /tmp/$NEWFS_DEFAULT_FS.$$/$NEWFS_DEFAULT_FS-file.$$
|
||||
log_must $TOUCH /tmp/tmpfs-file.$$
|
||||
log_must touch /tmp/$NEWFS_DEFAULT_FS.$$/$NEWFS_DEFAULT_FS-file.$$
|
||||
log_must touch /tmp/tmpfs-file.$$
|
||||
|
||||
log_must $RUNAT /tmp/$NEWFS_DEFAULT_FS.$$/$NEWFS_DEFAULT_FS-file.$$ $CP /etc/passwd .
|
||||
log_must $RUNAT /tmp/tmpfs-file.$$ $CP /etc/group .
|
||||
log_must runat /tmp/$NEWFS_DEFAULT_FS.$$/$NEWFS_DEFAULT_FS-file.$$ cp /etc/passwd .
|
||||
log_must runat /tmp/tmpfs-file.$$ cp /etc/group .
|
||||
|
||||
# copy those files to ZFS
|
||||
log_must $CP -@ /tmp/$NEWFS_DEFAULT_FS.$$/$NEWFS_DEFAULT_FS-file.$$ $TESTDIR
|
||||
log_must $CP -@ /tmp/tmpfs-file.$$ $TESTDIR
|
||||
log_must cp -@ /tmp/$NEWFS_DEFAULT_FS.$$/$NEWFS_DEFAULT_FS-file.$$ $TESTDIR
|
||||
log_must cp -@ /tmp/tmpfs-file.$$ $TESTDIR
|
||||
|
||||
# ensure the xattr information has been copied correctly
|
||||
log_must $RUNAT $TESTDIR/$NEWFS_DEFAULT_FS-file.$$ $DIFF passwd /etc/passwd
|
||||
log_must $RUNAT $TESTDIR/tmpfs-file.$$ $DIFF group /etc/group
|
||||
log_must runat $TESTDIR/$NEWFS_DEFAULT_FS-file.$$ diff passwd /etc/passwd
|
||||
log_must runat $TESTDIR/tmpfs-file.$$ diff group /etc/group
|
||||
|
||||
log_must $UMOUNT /tmp/$NEWFS_DEFAULT_FS.$$
|
||||
log_must umount /tmp/$NEWFS_DEFAULT_FS.$$
|
||||
log_pass "Files from $NEWFS_DEFAULT_FS,tmpfs with xattrs copied to zfs retain xattr info."
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2013 by Delphix. All rights reserved.
|
||||
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
@@ -44,22 +44,22 @@
|
||||
|
||||
function cleanup {
|
||||
|
||||
log_must $ZFS destroy $TESTPOOL/$TESTFS/clone
|
||||
log_must $ZFS destroy $TESTPOOL/$TESTFS@snapshot1
|
||||
log_must $RM $TESTDIR/myfile.$$
|
||||
log_must zfs destroy $TESTPOOL/$TESTFS/clone
|
||||
log_must zfs destroy $TESTPOOL/$TESTFS@snapshot1
|
||||
log_must rm $TESTDIR/myfile.$$
|
||||
}
|
||||
|
||||
log_assert "read/write/create/delete xattr on a clone filesystem"
|
||||
log_onexit cleanup
|
||||
|
||||
# create a file, and an xattr on it
|
||||
log_must $TOUCH $TESTDIR/myfile.$$
|
||||
log_must touch $TESTDIR/myfile.$$
|
||||
create_xattr $TESTDIR/myfile.$$ passwd /etc/passwd
|
||||
|
||||
# snapshot & clone the filesystem
|
||||
log_must $ZFS snapshot $TESTPOOL/$TESTFS@snapshot1
|
||||
log_must $ZFS clone $TESTPOOL/$TESTFS@snapshot1 $TESTPOOL/$TESTFS/clone
|
||||
log_must $ZFS set mountpoint=$TESTDIR/clone $TESTPOOL/$TESTFS/clone
|
||||
log_must zfs snapshot $TESTPOOL/$TESTFS@snapshot1
|
||||
log_must zfs clone $TESTPOOL/$TESTFS@snapshot1 $TESTPOOL/$TESTFS/clone
|
||||
log_must zfs set mountpoint=$TESTDIR/clone $TESTPOOL/$TESTFS/clone
|
||||
|
||||
# check for the xattrs on the clone
|
||||
verify_xattr $TESTDIR/clone/myfile.$$ passwd /etc/passwd
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2013 by Delphix. All rights reserved.
|
||||
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
@@ -42,8 +42,8 @@
|
||||
|
||||
function cleanup {
|
||||
|
||||
log_must $ZFS destroy $TESTPOOL/$TESTFS@snap
|
||||
log_must $RM $TESTDIR/myfile.$$
|
||||
log_must zfs destroy $TESTPOOL/$TESTFS@snap
|
||||
log_must rm $TESTDIR/myfile.$$
|
||||
|
||||
}
|
||||
|
||||
@@ -51,11 +51,11 @@ log_assert "read xattr on a snapshot"
|
||||
log_onexit cleanup
|
||||
|
||||
# create a file, and an xattr on it
|
||||
log_must $TOUCH $TESTDIR/myfile.$$
|
||||
log_must touch $TESTDIR/myfile.$$
|
||||
create_xattr $TESTDIR/myfile.$$ passwd /etc/passwd
|
||||
|
||||
# snapshot the filesystem
|
||||
log_must $ZFS snapshot $TESTPOOL/$TESTFS@snap
|
||||
log_must zfs snapshot $TESTPOOL/$TESTFS@snap
|
||||
|
||||
# check for the xattr on the snapshot
|
||||
verify_xattr $TESTDIR/.zfs/snapshot/snap/myfile.$$ passwd /etc/passwd
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2013 by Delphix. All rights reserved.
|
||||
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
@@ -46,11 +46,11 @@
|
||||
#
|
||||
|
||||
function cleanup {
|
||||
log_must $ZFS destroy $TESTPOOL/$TESTFS@snap
|
||||
log_must $RM $TESTDIR/myfile2.$$
|
||||
log_must $RM $TESTDIR/myfile.$$
|
||||
log_must $RM /tmp/output.$$
|
||||
[[ -e /tmp/expected_output.$$ ]] && log_must $RM \
|
||||
log_must zfs destroy $TESTPOOL/$TESTFS@snap
|
||||
log_must rm $TESTDIR/myfile2.$$
|
||||
log_must rm $TESTDIR/myfile.$$
|
||||
log_must rm /tmp/output.$$
|
||||
[[ -e /tmp/expected_output.$$ ]] && log_must rm \
|
||||
/tmp/expected_output.$$
|
||||
|
||||
}
|
||||
@@ -59,23 +59,23 @@ log_assert "create/write xattr on a snapshot fails"
|
||||
log_onexit cleanup
|
||||
|
||||
# create a file, and an xattr on it
|
||||
log_must $TOUCH $TESTDIR/myfile.$$
|
||||
log_must touch $TESTDIR/myfile.$$
|
||||
create_xattr $TESTDIR/myfile.$$ passwd /etc/passwd
|
||||
|
||||
# create another file that doesn't have an xattr
|
||||
log_must $TOUCH $TESTDIR/myfile2.$$
|
||||
log_must touch $TESTDIR/myfile2.$$
|
||||
|
||||
# snapshot the filesystem
|
||||
log_must $ZFS snapshot $TESTPOOL/$TESTFS@snap
|
||||
log_must zfs snapshot $TESTPOOL/$TESTFS@snap
|
||||
|
||||
# we shouldn't be able to alter the first file's xattr
|
||||
log_mustnot eval " $RUNAT $TESTDIR/.zfs/snapshot/snap/myfile.$$ \
|
||||
$CP /etc/passwd . >/tmp/output.$$ 2>&1"
|
||||
log_must $GREP -i Read-only /tmp/output.$$
|
||||
log_mustnot eval " runat $TESTDIR/.zfs/snapshot/snap/myfile.$$ \
|
||||
cp /etc/passwd . >/tmp/output.$$ 2>&1"
|
||||
log_must grep -i Read-only /tmp/output.$$
|
||||
|
||||
log_must eval "$RUNAT $TESTDIR/.zfs/snapshot/snap/myfile2.$$ \
|
||||
$LS >/tmp/output.$$ 2>&1"
|
||||
log_must eval "runat $TESTDIR/.zfs/snapshot/snap/myfile2.$$ \
|
||||
ls >/tmp/output.$$ 2>&1"
|
||||
create_expected_output /tmp/expected_output.$$ SUNWattr_ro SUNWattr_rw
|
||||
log_must $DIFF /tmp/output.$$ /tmp/expected_output.$$
|
||||
log_must diff /tmp/output.$$ /tmp/expected_output.$$
|
||||
|
||||
log_pass "create/write xattr on a snapshot fails"
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2013 by Delphix. All rights reserved.
|
||||
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
@@ -45,7 +45,7 @@ function cleanup {
|
||||
|
||||
for file in /tmp/output.$$ /tmp/expected-output.$$ \
|
||||
$TESTDIR/myfile.$$ ; do
|
||||
log_must $RM -f $file
|
||||
log_must rm -f $file
|
||||
done
|
||||
}
|
||||
|
||||
@@ -53,28 +53,28 @@ log_assert "special . and .. dirs work as expected for xattrs"
|
||||
log_onexit cleanup
|
||||
|
||||
# create a file, and an xattr on it
|
||||
log_must $TOUCH $TESTDIR/myfile.$$
|
||||
log_must touch $TESTDIR/myfile.$$
|
||||
create_xattr $TESTDIR/myfile.$$ passwd /etc/passwd
|
||||
|
||||
# listing the directory .
|
||||
log_must eval "$RUNAT $TESTDIR/myfile.$$ $LS . > /tmp/output.$$"
|
||||
log_must eval "runat $TESTDIR/myfile.$$ ls . > /tmp/output.$$"
|
||||
create_expected_output /tmp/expected-output.$$ \
|
||||
SUNWattr_ro SUNWattr_rw passwd
|
||||
log_must $DIFF /tmp/output.$$ /tmp/expected-output.$$
|
||||
log_must diff /tmp/output.$$ /tmp/expected-output.$$
|
||||
# list the directory . long form
|
||||
log_must eval "$RUNAT $TESTDIR/myfile.$$ $LS -a . > /tmp/output.$$"
|
||||
log_must eval "runat $TESTDIR/myfile.$$ ls -a . > /tmp/output.$$"
|
||||
create_expected_output /tmp/expected-output.$$ . .. \
|
||||
SUNWattr_ro SUNWattr_rw passwd
|
||||
log_must $DIFF /tmp/output.$$ /tmp/expected-output.$$
|
||||
log_must diff /tmp/output.$$ /tmp/expected-output.$$
|
||||
|
||||
# list the directory .. expecting one file
|
||||
OUTPUT=$($RUNAT $TESTDIR/myfile.$$ $LS ..)
|
||||
OUTPUT=$(runat $TESTDIR/myfile.$$ ls ..)
|
||||
if [ "$OUTPUT" != ".." ]
|
||||
then
|
||||
log_fail "Listing the .. directory doesn't show \"..\" as expected."
|
||||
fi
|
||||
|
||||
# verify we can't list ../
|
||||
log_mustnot eval "$RUNAT $TESTDIR/myfile.$$ $LS ../ > /dev/null 2>&1"
|
||||
log_mustnot eval "runat $TESTDIR/myfile.$$ ls ../ > /dev/null 2>&1"
|
||||
|
||||
log_pass "special . and .. dirs work as expected for xattrs"
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2013 by Delphix. All rights reserved.
|
||||
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
@@ -42,7 +42,7 @@
|
||||
|
||||
function cleanup {
|
||||
|
||||
log_must $RM $TESTDIR/myfile.$$
|
||||
log_must rm $TESTDIR/myfile.$$
|
||||
|
||||
}
|
||||
|
||||
@@ -50,13 +50,13 @@ log_assert "links between xattr and normal file namespace fail"
|
||||
log_onexit cleanup
|
||||
|
||||
# create a file, and an xattr on it
|
||||
log_must $TOUCH $TESTDIR/myfile.$$
|
||||
log_must touch $TESTDIR/myfile.$$
|
||||
create_xattr $TESTDIR/myfile.$$ passwd /etc/passwd
|
||||
|
||||
# Try to create a soft link from the xattr namespace to the default namespace
|
||||
log_mustnot $RUNAT $TESTDIR/myfile.$$ $LN -s /etc/passwd foo
|
||||
log_mustnot runat $TESTDIR/myfile.$$ $LN -s /etc/passwd foo
|
||||
|
||||
# Try to create a hard link from the xattr namespace to the default namespace
|
||||
log_mustnot $RUNAT $TESTDIR/myfile.$$ $LN /etc/passwd foo
|
||||
log_mustnot runat $TESTDIR/myfile.$$ $LN /etc/passwd foo
|
||||
|
||||
log_pass "links between xattr and normal file namespace fail"
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2013 by Delphix. All rights reserved.
|
||||
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
@@ -43,24 +43,24 @@
|
||||
|
||||
function cleanup {
|
||||
|
||||
log_must $RM $TESTDIR/myfile.$$
|
||||
log_must rm $TESTDIR/myfile.$$
|
||||
}
|
||||
|
||||
log_assert "mkdir, mknod fail"
|
||||
log_onexit cleanup
|
||||
|
||||
# create a file, and an xattr on it
|
||||
log_must $TOUCH $TESTDIR/myfile.$$
|
||||
log_must touch $TESTDIR/myfile.$$
|
||||
create_xattr $TESTDIR/myfile.$$ passwd /etc/passwd
|
||||
|
||||
# Try to create directory in the xattr namespace
|
||||
log_mustnot $RUNAT $TESTDIR/myfile.$$ $MKDIR foo
|
||||
log_mustnot runat $TESTDIR/myfile.$$ mkdir foo
|
||||
|
||||
# Try to create a range of different filetypes in the xattr namespace
|
||||
log_mustnot $RUNAT $TESTDIR/myfile.$$ $MKNOD block b 888 888
|
||||
log_mustnot runat $TESTDIR/myfile.$$ mknod block b 888 888
|
||||
|
||||
log_mustnot $RUNAT $TESTDIR/myfile.$$ $MKNOD char c
|
||||
log_mustnot runat $TESTDIR/myfile.$$ mknod char c
|
||||
|
||||
log_mustnot $RUNAT $TESTDIR/myfile.$$ $MKNOD fifo p
|
||||
log_mustnot runat $TESTDIR/myfile.$$ mknod fifo p
|
||||
|
||||
log_pass "mkdir, mknod fail"
|
||||
|
||||
@@ -24,11 +24,11 @@
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2012 by Delphix. All rights reserved.
|
||||
# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2013 by Delphix. All rights reserved.
|
||||
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
@@ -48,7 +48,7 @@
|
||||
|
||||
function cleanup {
|
||||
|
||||
log_must $RM $TESTDIR/myfile.$$
|
||||
log_must rm $TESTDIR/myfile.$$
|
||||
}
|
||||
|
||||
log_assert "Basic applications work with xattrs: cpio cp find mv pax tar"
|
||||
@@ -56,7 +56,7 @@ log_onexit cleanup
|
||||
|
||||
# Create a file, and set an xattr on it. This file is used in several of the
|
||||
# test scenarios below.
|
||||
log_must $TOUCH $TESTDIR/myfile.$$
|
||||
log_must touch $TESTDIR/myfile.$$
|
||||
create_xattr $TESTDIR/myfile.$$ passwd /etc/passwd
|
||||
|
||||
|
||||
@@ -67,127 +67,127 @@ create_xattr $TESTDIR/myfile.$$ passwd /etc/passwd
|
||||
|
||||
|
||||
log_note "Checking cpio"
|
||||
log_must $TOUCH $TESTDIR/cpio.$$
|
||||
log_must touch $TESTDIR/cpio.$$
|
||||
create_xattr $TESTDIR/cpio.$$ passwd /etc/passwd
|
||||
$ECHO $TESTDIR/cpio.$$ | $CPIO -o@ > /tmp/xattr.$$.cpio
|
||||
$ECHO $TESTDIR/cpio.$$ | $CPIO -o > /tmp/noxattr.$$.cpio
|
||||
echo $TESTDIR/cpio.$$ | cpio -o@ > /tmp/xattr.$$.cpio
|
||||
echo $TESTDIR/cpio.$$ | cpio -o > /tmp/noxattr.$$.cpio
|
||||
|
||||
# we should have no xattr here
|
||||
log_must $CPIO -iu < /tmp/xattr.$$.cpio
|
||||
log_mustnot eval "$RUNAT $TESTDIR/cpio.$$ $CAT passwd > /dev/null 2>&1"
|
||||
log_must cpio -iu < /tmp/xattr.$$.cpio
|
||||
log_mustnot eval "runat $TESTDIR/cpio.$$ cat passwd > /dev/null 2>&1"
|
||||
|
||||
# we should have an xattr here
|
||||
log_must $CPIO -iu@ < /tmp/xattr.$$.cpio
|
||||
log_must eval "$RUNAT $TESTDIR/cpio.$$ $CAT passwd > /dev/null 2>&1"
|
||||
log_must cpio -iu@ < /tmp/xattr.$$.cpio
|
||||
log_must eval "runat $TESTDIR/cpio.$$ cat passwd > /dev/null 2>&1"
|
||||
|
||||
# we should have no xattr here
|
||||
log_must $CPIO -iu < /tmp/noxattr.$$.cpio
|
||||
log_mustnot eval "$RUNAT $TESTDIR/cpio.$$ $CAT passwd > /dev/null 2>&1"
|
||||
log_must cpio -iu < /tmp/noxattr.$$.cpio
|
||||
log_mustnot eval "runat $TESTDIR/cpio.$$ cat passwd > /dev/null 2>&1"
|
||||
|
||||
# we should have no xattr here
|
||||
log_must $CPIO -iu@ < /tmp/noxattr.$$.cpio
|
||||
log_mustnot eval "$RUNAT $TESTDIR/cpio.$$ $CAT passwd > /dev/null 2>&1"
|
||||
log_must $RM $TESTDIR/cpio.$$ /tmp/xattr.$$.cpio /tmp/noxattr.$$.cpio
|
||||
log_must cpio -iu@ < /tmp/noxattr.$$.cpio
|
||||
log_mustnot eval "runat $TESTDIR/cpio.$$ cat passwd > /dev/null 2>&1"
|
||||
log_must rm $TESTDIR/cpio.$$ /tmp/xattr.$$.cpio /tmp/noxattr.$$.cpio
|
||||
|
||||
|
||||
|
||||
log_note "Checking cp"
|
||||
# check that with the right flag, the xattr is preserved
|
||||
log_must $CP -@ $TESTDIR/myfile.$$ $TESTDIR/myfile2.$$
|
||||
log_must cp -@ $TESTDIR/myfile.$$ $TESTDIR/myfile2.$$
|
||||
compare_xattrs $TESTDIR/myfile.$$ $TESTDIR/myfile2.$$ passwd
|
||||
log_must $RM $TESTDIR/myfile2.$$
|
||||
log_must rm $TESTDIR/myfile2.$$
|
||||
|
||||
# without the right flag, there should be no xattr
|
||||
log_must $CP $TESTDIR/myfile.$$ $TESTDIR/myfile2.$$
|
||||
log_mustnot eval "$RUNAT $TESTDIR/myfile2.$$ $LS passwd > /dev/null 2>&1"
|
||||
log_must $RM $TESTDIR/myfile2.$$
|
||||
log_must cp $TESTDIR/myfile.$$ $TESTDIR/myfile2.$$
|
||||
log_mustnot eval "runat $TESTDIR/myfile2.$$ ls passwd > /dev/null 2>&1"
|
||||
log_must rm $TESTDIR/myfile2.$$
|
||||
|
||||
|
||||
|
||||
log_note "Checking find"
|
||||
# create a file without xattrs, and check that find -xattr only finds
|
||||
# our test file that has an xattr.
|
||||
log_must $MKDIR $TESTDIR/noxattrs
|
||||
log_must $TOUCH $TESTDIR/noxattrs/no-xattr
|
||||
log_must mkdir $TESTDIR/noxattrs
|
||||
log_must touch $TESTDIR/noxattrs/no-xattr
|
||||
|
||||
$FIND $TESTDIR -xattr | $GREP myfile.$$
|
||||
find $TESTDIR -xattr | grep myfile.$$
|
||||
[[ $? -ne 0 ]] && \
|
||||
log_fail "find -xattr didn't find our file that had an xattr."
|
||||
$FIND $TESTDIR -xattr | $GREP no-xattr
|
||||
find $TESTDIR -xattr | grep no-xattr
|
||||
[[ $? -eq 0 ]] && \
|
||||
log_fail "find -xattr found a file that didn't have an xattr."
|
||||
log_must $RM -rf $TESTDIR/noxattrs
|
||||
log_must rm -rf $TESTDIR/noxattrs
|
||||
|
||||
|
||||
|
||||
log_note "Checking mv"
|
||||
# mv doesn't have any flags to preserve/ommit xattrs - they're
|
||||
# always moved.
|
||||
log_must $TOUCH $TESTDIR/mvfile.$$
|
||||
log_must touch $TESTDIR/mvfile.$$
|
||||
create_xattr $TESTDIR/mvfile.$$ passwd /etc/passwd
|
||||
log_must $MV $TESTDIR/mvfile.$$ $TESTDIR/mvfile2.$$
|
||||
log_must mv $TESTDIR/mvfile.$$ $TESTDIR/mvfile2.$$
|
||||
verify_xattr $TESTDIR/mvfile2.$$ passwd /etc/passwd
|
||||
log_must $RM $TESTDIR/mvfile2.$$
|
||||
log_must rm $TESTDIR/mvfile2.$$
|
||||
|
||||
|
||||
log_note "Checking pax"
|
||||
log_must $TOUCH $TESTDIR/pax.$$
|
||||
log_must touch $TESTDIR/pax.$$
|
||||
create_xattr $TESTDIR/pax.$$ passwd /etc/passwd
|
||||
log_must $PAX -w -f $TESTDIR/noxattr.pax $TESTDIR/pax.$$
|
||||
log_must $PAX -w@ -f $TESTDIR/xattr.pax $TESTDIR/pax.$$
|
||||
log_must $RM $TESTDIR/pax.$$
|
||||
log_must pax -w -f $TESTDIR/noxattr.pax $TESTDIR/pax.$$
|
||||
log_must pax -w@ -f $TESTDIR/xattr.pax $TESTDIR/pax.$$
|
||||
log_must rm $TESTDIR/pax.$$
|
||||
|
||||
# we should have no xattr here
|
||||
log_must $PAX -r -f $TESTDIR/noxattr.pax
|
||||
log_mustnot eval "$RUNAT $TESTDIR/pax.$$ $CAT passwd > /dev/null 2>&1"
|
||||
log_must $RM $TESTDIR/pax.$$
|
||||
log_must pax -r -f $TESTDIR/noxattr.pax
|
||||
log_mustnot eval "runat $TESTDIR/pax.$$ cat passwd > /dev/null 2>&1"
|
||||
log_must rm $TESTDIR/pax.$$
|
||||
|
||||
# we should have no xattr here
|
||||
log_must $PAX -r@ -f $TESTDIR/noxattr.pax
|
||||
log_mustnot eval "$RUNAT $TESTDIR/pax.$$ $CAT passwd > /dev/null 2>&1"
|
||||
log_must $RM $TESTDIR/pax.$$
|
||||
log_must pax -r@ -f $TESTDIR/noxattr.pax
|
||||
log_mustnot eval "runat $TESTDIR/pax.$$ cat passwd > /dev/null 2>&1"
|
||||
log_must rm $TESTDIR/pax.$$
|
||||
|
||||
|
||||
# we should have an xattr here
|
||||
log_must $PAX -r@ -f $TESTDIR/xattr.pax
|
||||
log_must pax -r@ -f $TESTDIR/xattr.pax
|
||||
verify_xattr $TESTDIR/pax.$$ passwd /etc/passwd
|
||||
log_must $RM $TESTDIR/pax.$$
|
||||
log_must rm $TESTDIR/pax.$$
|
||||
|
||||
# we should have no xattr here
|
||||
log_must $PAX -r -f $TESTDIR/xattr.pax $TESTDIR
|
||||
log_mustnot eval "$RUNAT $TESTDIR/pax.$$ $CAT passwd > /dev/null 2>&1"
|
||||
log_must $RM $TESTDIR/pax.$$ $TESTDIR/noxattr.pax $TESTDIR/xattr.pax
|
||||
log_must pax -r -f $TESTDIR/xattr.pax $TESTDIR
|
||||
log_mustnot eval "runat $TESTDIR/pax.$$ cat passwd > /dev/null 2>&1"
|
||||
log_must rm $TESTDIR/pax.$$ $TESTDIR/noxattr.pax $TESTDIR/xattr.pax
|
||||
|
||||
|
||||
log_note "Checking tar"
|
||||
log_must $TOUCH $TESTDIR/tar.$$
|
||||
log_must touch $TESTDIR/tar.$$
|
||||
create_xattr $TESTDIR/tar.$$ passwd /etc/passwd
|
||||
|
||||
log_must cd $TESTDIR
|
||||
|
||||
log_must $TAR cf noxattr.tar tar.$$
|
||||
log_must $TAR c@f xattr.tar tar.$$
|
||||
log_must $RM $TESTDIR/tar.$$
|
||||
log_must tar cf noxattr.tar tar.$$
|
||||
log_must tar c@f xattr.tar tar.$$
|
||||
log_must rm $TESTDIR/tar.$$
|
||||
|
||||
# we should have no xattr here
|
||||
log_must $TAR xf xattr.tar
|
||||
log_mustnot eval "$RUNAT $TESTDIR/tar.$$ $CAT passwd > /dev/null 2>&1"
|
||||
log_must $RM $TESTDIR/tar.$$
|
||||
log_must tar xf xattr.tar
|
||||
log_mustnot eval "runat $TESTDIR/tar.$$ cat passwd > /dev/null 2>&1"
|
||||
log_must rm $TESTDIR/tar.$$
|
||||
|
||||
# we should have an xattr here
|
||||
log_must $TAR x@f xattr.tar
|
||||
log_must tar x@f xattr.tar
|
||||
verify_xattr tar.$$ passwd /etc/passwd
|
||||
log_must $RM $TESTDIR/tar.$$
|
||||
log_must rm $TESTDIR/tar.$$
|
||||
|
||||
# we should have no xattr here
|
||||
log_must $TAR xf $TESTDIR/noxattr.tar
|
||||
log_mustnot eval "$RUNAT $TESTDIR/tar.$$ $CAT passwd > /dev/null 2>&1"
|
||||
log_must $RM $TESTDIR/tar.$$
|
||||
log_must tar xf $TESTDIR/noxattr.tar
|
||||
log_mustnot eval "runat $TESTDIR/tar.$$ cat passwd > /dev/null 2>&1"
|
||||
log_must rm $TESTDIR/tar.$$
|
||||
|
||||
# we should have no xattr here
|
||||
log_must $TAR x@f $TESTDIR/noxattr.tar
|
||||
log_mustnot eval "$RUNAT $TESTDIR/tar.$$ $CAT passwd > /dev/null 2>&1"
|
||||
log_must $RM $TESTDIR/tar.$$ $TESTDIR/noxattr.tar $TESTDIR/xattr.tar
|
||||
log_must tar x@f $TESTDIR/noxattr.tar
|
||||
log_mustnot eval "runat $TESTDIR/tar.$$ cat passwd > /dev/null 2>&1"
|
||||
log_must rm $TESTDIR/tar.$$ $TESTDIR/noxattr.tar $TESTDIR/xattr.tar
|
||||
|
||||
|
||||
log_assert "Basic applications work with xattrs: cpio cp find mv pax tar"
|
||||
|
||||
@@ -24,11 +24,11 @@
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2012 by Delphix. All rights reserved.
|
||||
# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2013 by Delphix. All rights reserved.
|
||||
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
@@ -46,18 +46,18 @@
|
||||
#
|
||||
|
||||
function cleanup {
|
||||
log_must $RM $TESTDIR/myfile.$$
|
||||
log_must rm $TESTDIR/myfile.$$
|
||||
}
|
||||
|
||||
function get_pool_size {
|
||||
poolname=$1
|
||||
psize=$($ZPOOL list -H -o allocated $poolname)
|
||||
psize=$(zpool list -H -o allocated $poolname)
|
||||
if [[ $psize == *[mM] ]]
|
||||
then
|
||||
returnvalue=$($ECHO $psize | $SED -e 's/m//g' -e 's/M//g')
|
||||
returnvalue=$(echo $psize | sed -e 's/m//g' -e 's/M//g')
|
||||
returnvalue=$((returnvalue * 1024))
|
||||
else
|
||||
returnvalue=$($ECHO $psize | $SED -e 's/k//g' -e 's/K//g')
|
||||
returnvalue=$(echo $psize | sed -e 's/k//g' -e 's/K//g')
|
||||
fi
|
||||
echo $returnvalue
|
||||
}
|
||||
@@ -65,7 +65,7 @@ function get_pool_size {
|
||||
log_assert "xattr file sizes count towards normal disk usage"
|
||||
log_onexit cleanup
|
||||
|
||||
log_must $TOUCH $TESTDIR/myfile.$$
|
||||
log_must touch $TESTDIR/myfile.$$
|
||||
|
||||
POOL_SIZE=0
|
||||
NEW_POOL_SIZE=0
|
||||
@@ -77,12 +77,12 @@ then
|
||||
POOL_SIZE=$(get_pool_size $TESTPOOL)
|
||||
fi
|
||||
|
||||
FS_SIZE=$($ZFS get -p -H -o value used $TESTPOOL/$TESTFS)
|
||||
FS_SIZE=$(zfs get -p -H -o value used $TESTPOOL/$TESTFS)
|
||||
|
||||
log_must $RUNAT $TESTDIR/myfile.$$ $MKFILE 200m xattr
|
||||
log_must runat $TESTDIR/myfile.$$ mkfile 200m xattr
|
||||
|
||||
#Make sure the newly created file is counted into zpool usage
|
||||
log_must $SYNC
|
||||
log_must sync
|
||||
|
||||
# now check to see if our pool disk usage has increased
|
||||
if is_global_zone
|
||||
@@ -95,7 +95,7 @@ then
|
||||
fi
|
||||
|
||||
# also make sure our filesystem usage has increased
|
||||
NEW_FS_SIZE=$($ZFS get -p -H -o value used $TESTPOOL/$TESTFS)
|
||||
NEW_FS_SIZE=$(zfs get -p -H -o value used $TESTPOOL/$TESTFS)
|
||||
(($NEW_FS_SIZE <= $FS_SIZE)) && \
|
||||
log_fail "The new filesystem size $NEW_FS_SIZE was less \
|
||||
than or equal to the old filesystem size $FS_SIZE."
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2013 by Delphix. All rights reserved.
|
||||
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
@@ -45,44 +45,44 @@
|
||||
|
||||
function cleanup {
|
||||
|
||||
log_must $RM $TESTDIR/myfile.$$
|
||||
log_must rm $TESTDIR/myfile.$$
|
||||
}
|
||||
|
||||
|
||||
log_assert "The noxattr mount option functions as expected"
|
||||
log_onexit cleanup
|
||||
|
||||
$ZFS set 2>&1 | $GREP xattr > /dev/null
|
||||
zfs set 2>&1 | grep xattr > /dev/null
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
log_unsupported "noxattr mount option not supported on this release."
|
||||
fi
|
||||
|
||||
log_must $TOUCH $TESTDIR/myfile.$$
|
||||
log_must touch $TESTDIR/myfile.$$
|
||||
create_xattr $TESTDIR/myfile.$$ passwd /etc/passwd
|
||||
|
||||
log_must $UMOUNT $TESTDIR
|
||||
log_must $ZFS mount -o noxattr $TESTPOOL/$TESTFS
|
||||
log_must umount $TESTDIR
|
||||
log_must zfs mount -o noxattr $TESTPOOL/$TESTFS
|
||||
|
||||
# check that we can't perform xattr operations
|
||||
log_mustnot eval "$RUNAT $TESTDIR/myfile.$$ $CAT passwd > /dev/null 2>&1"
|
||||
log_mustnot eval "$RUNAT $TESTDIR/myfile.$$ $RM passwd > /dev/null 2>&1"
|
||||
log_mustnot eval "$RUNAT $TESTDIR/myfile.$$ $CP /etc/passwd . > /dev/null 2>&1"
|
||||
log_mustnot eval "runat $TESTDIR/myfile.$$ cat passwd > /dev/null 2>&1"
|
||||
log_mustnot eval "runat $TESTDIR/myfile.$$ rm passwd > /dev/null 2>&1"
|
||||
log_mustnot eval "runat $TESTDIR/myfile.$$ cp /etc/passwd . > /dev/null 2>&1"
|
||||
|
||||
log_must $TOUCH $TESTDIR/new.$$
|
||||
log_mustnot eval "$RUNAT $TESTDIR/new.$$ $CP /etc/passwd . > /dev/null 2>&1"
|
||||
log_mustnot eval "$RUNAT $TESTDIR/new.$$ $RM passwd > /dev/null 2>&1"
|
||||
log_must touch $TESTDIR/new.$$
|
||||
log_mustnot eval "runat $TESTDIR/new.$$ cp /etc/passwd . > /dev/null 2>&1"
|
||||
log_mustnot eval "runat $TESTDIR/new.$$ rm passwd > /dev/null 2>&1"
|
||||
|
||||
# now mount the filesystem again as normal
|
||||
log_must $UMOUNT $TESTDIR
|
||||
log_must $ZFS mount $TESTPOOL/$TESTFS
|
||||
log_must umount $TESTDIR
|
||||
log_must zfs mount $TESTPOOL/$TESTFS
|
||||
|
||||
# we should still have an xattr on the first file
|
||||
verify_xattr $TESTDIR/myfile.$$ passwd /etc/passwd
|
||||
|
||||
# there should be no xattr on the file we created while the fs was mounted
|
||||
# -o noxattr
|
||||
log_mustnot eval "$RUNAT $TESTDIR/new.$$ $CAT passwd > /dev/null 2>&1"
|
||||
log_mustnot eval "runat $TESTDIR/new.$$ cat passwd > /dev/null 2>&1"
|
||||
create_xattr $TESTDIR/new.$$ passwd /etc/passwd
|
||||
|
||||
log_pass "The noxattr mount option functions as expected"
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2013 by Delphix. All rights reserved.
|
||||
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
@@ -39,9 +39,9 @@ function create_xattr { # filename xattr_name xattr_contents
|
||||
typeset XATTR_CONTENTS=$3
|
||||
|
||||
# read any empty xattr on that file
|
||||
log_must $RUNAT $FILE $LS
|
||||
log_must runat $FILE ls
|
||||
# create the xattr
|
||||
log_must $RUNAT $FILE $CP $XATTR_CONTENTS $XATTR_NAME
|
||||
log_must runat $FILE cp $XATTR_CONTENTS $XATTR_NAME
|
||||
|
||||
verify_xattr $FILE $XATTR_NAME $XATTR_CONTENTS
|
||||
}
|
||||
@@ -53,11 +53,11 @@ function compare_xattrs { # filename1 filename2 xattr_name
|
||||
typeset FILE2=$2
|
||||
typeset XATTR_NAME=$3
|
||||
|
||||
$RUNAT $FILE1 $CAT $XATTR_NAME > /tmp/file1.$$
|
||||
$RUNAT $FILE2 $CAT $XATTR_NAME > /tmp/file2.$$
|
||||
runat $FILE1 cat $XATTR_NAME > /tmp/file1.$$
|
||||
runat $FILE2 cat $XATTR_NAME > /tmp/file2.$$
|
||||
|
||||
log_must $DIFF /tmp/file1.$$ /tmp/file2.$$
|
||||
log_must $RM /tmp/file1.$$ /tmp/file2.$$
|
||||
log_must diff /tmp/file1.$$ /tmp/file2.$$
|
||||
log_must rm /tmp/file1.$$ /tmp/file2.$$
|
||||
}
|
||||
|
||||
function verify_xattr { # filename xattr_name xattr_contents
|
||||
@@ -66,9 +66,9 @@ function verify_xattr { # filename xattr_name xattr_contents
|
||||
typeset XATTR_CONTENTS=$3
|
||||
|
||||
# read the xattr, writing it to a temp file
|
||||
log_must eval "$RUNAT $FILE $CAT $XATTR_NAME > /tmp/$XATTR_NAME.$$ 2>&1"
|
||||
log_must $DIFF $XATTR_CONTENTS /tmp/$XATTR_NAME.$$
|
||||
$RM /tmp/$XATTR_NAME.$$
|
||||
log_must eval "runat $FILE cat $XATTR_NAME > /tmp/$XATTR_NAME.$$ 2>&1"
|
||||
log_must diff $XATTR_CONTENTS /tmp/$XATTR_NAME.$$
|
||||
rm /tmp/$XATTR_NAME.$$
|
||||
}
|
||||
|
||||
function delete_xattr { # filename xattr_name
|
||||
@@ -76,8 +76,8 @@ function delete_xattr { # filename xattr_name
|
||||
typeset XATTR_NAME=$2
|
||||
|
||||
# delete the xattr
|
||||
log_must $RUNAT $FILE $RM $XATTR_NAME
|
||||
log_mustnot eval "$RUNAT $FILE $LS $XATTR_NAME > /dev/null 2>&1"
|
||||
log_must runat $FILE rm $XATTR_NAME
|
||||
log_mustnot eval "runat $FILE ls $XATTR_NAME > /dev/null 2>&1"
|
||||
}
|
||||
|
||||
# not sure about this : really this should be testing write/append
|
||||
@@ -85,11 +85,11 @@ function verify_write_xattr { # filename xattr_name
|
||||
typeset FILE=$1
|
||||
typeset XATTR_NAME=$2
|
||||
|
||||
log_must eval "$RUNAT $FILE $DD if=/etc/passwd of=$XATTR_NAME"
|
||||
log_must eval "$RUNAT $FILE $CAT $XATTR_NAME > /tmp/$XATTR_NAME.$$ 2>&1"
|
||||
log_must $DD if=/etc/passwd of=/tmp/passwd_dd.$$
|
||||
log_must $DIFF /tmp/passwd_dd.$$ /tmp/$XATTR_NAME.$$
|
||||
log_must $RM /tmp/passwd_dd.$$ /tmp/$XATTR_NAME.$$
|
||||
log_must eval "runat $FILE dd if=/etc/passwd of=$XATTR_NAME"
|
||||
log_must eval "runat $FILE cat $XATTR_NAME > /tmp/$XATTR_NAME.$$ 2>&1"
|
||||
log_must dd if=/etc/passwd of=/tmp/passwd_dd.$$
|
||||
log_must diff /tmp/passwd_dd.$$ /tmp/$XATTR_NAME.$$
|
||||
log_must rm /tmp/passwd_dd.$$ /tmp/$XATTR_NAME.$$
|
||||
}
|
||||
|
||||
# this function is to create the expected output
|
||||
@@ -97,11 +97,11 @@ function create_expected_output { # expected_output_file contents_of_the_outpu
|
||||
typeset FILE=$1
|
||||
shift
|
||||
if [[ -f $FILE ]]; then
|
||||
log_must $RM $FILE
|
||||
log_must rm $FILE
|
||||
fi
|
||||
|
||||
for line in $@
|
||||
do
|
||||
log_must eval "$ECHO $line >> $FILE"
|
||||
log_must eval "echo $line >> $FILE"
|
||||
done
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user