Made releng/auto_isocontent ready to test FreeBSD extattr

This commit is contained in:
Thomas Schmitt 2011-08-23 10:45:46 +00:00
parent f48548fc22
commit a82cc372f9
1 changed files with 62 additions and 16 deletions

View File

@ -95,22 +95,45 @@ is_valid_iso9660() {
}
# Create test file and find out whether ACLs and/or xattr are available.
#
# Users known on GNU/Linux and FreeBSD: root games daemon man
# Groups : daemon games bin sshd sys
# On both systems, ACLs are manipulated by setfacl/getfacl
#
acl_xattr_test_file="$on_disk"/acl_xattr_test_file
acl_xattr_copy_file="$copy_on_disk"/acl_xattr_test_file
acl_xattr_test_dir="$on_disk"/acl_xattr_test_dir
acl_xattr_iso_dir="$in_iso"/acl_xattr_test_dir
acl_xattr_copy_dir="$copy_on_disk"/acl_xattr_test_dir
mkdir "$acl_xattr_test_dir"
echo echo hello world >"$acl_xattr_test_file" || exit 1
sys=$(uname -s)
acls=no
if ( setfacl -m u::rwx,u:root:rwx,g:sys:rwx,u:daemon:r,mask::rwx \
default_acls=no
if ( setfacl -m u::rwx,g::r-x,o::---,u:root:rwx,g::r-x,g:sys:rwx,u:daemon:r--,mask::rwx \
"$acl_xattr_test_file" ) >/dev/null 2>&1
then
if ( getfacl "$acl_xattr_test_file" ) >/dev/null 2>&1
then
acls=yes
if ( setfacl -m u::rwx,g::r-x,o::---,u:root:rwx,g::r-x,g:sys:rwx,u:daemon:r--,mask::rwx \
"$acl_xattr_test_dir" ) >/dev/null 2>&1
then
acls=yes
# Setting of "default" ACLs will fail on FreeBSD. It will nevertheless be
# done in the image by a xorriso command. Restoring is supposed to skip
# "default" ACLs if none could be recorded.
if setfacl -m u::rwx,g::r-x,o::---,u:root:rwx,g:sys:rwx,u:daemon:r--,mask::rwx,d:u::rwx,d:g::r-x,d:o::---,d:u:root:rwx,d:g:sys:rwx,d:u:daemon:r--,d:mask::rwx "$acl_xattr_iso_dir" 2>/dev/null
then
default_acls=yes
fi
fi
fi
fi
# GNU/Linux and FreeBSD have different tools for Extended Attributes
xattrs=no
extattrs=no
# Try GNU/Linux style setattr/getattr
if ( setfattr -n user.test_xattr -v test_value "$acl_xattr_test_file" ) \
>/dev/null 2>&1
then
@ -123,14 +146,24 @@ then
fi
if test "$xattrs" = no
then
# >>> Try FreeBSD style setextattr
dummy=dummy
# Try FreeBSD style setextattr
if ( setextattr user test_xattr test_value "$acl_xattr_test_file" ) \
>/dev/null 2>&1
then
if ( getextattr user test_xattr "$acl_xattr_test_file" ) >/dev/null 2>&1
then
setextattr user long_data 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 "$acl_xattr_test_file"
setextattr user more_data 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 "$acl_xattr_test_file"
if ( lsextattr user "$acl_xattr_test_file" ) >/dev/null 2>&1
then
extattrs=yes
fi
fi
fi
fi
echo
echo "${SELF}: Detected sys='$sys' , acls=$acls , xattrs=$xattrs , extattrs=$extattrs"
echo "${SELF}: Detected sys='$sys' , acls=$acls , d_acls=$default_acls , xattrs=$xattrs , extattrs=$extattrs"
# Examine capabilities of xorriso
xorriso_acls=no
@ -154,13 +187,13 @@ fi
if test "$xorriso_xattrs" = no
then
xattrs=no
extattrs=no
fi
echo "${SELF}: Detected xorriso_acls=$xorriso_acls , xorriso_xattrs=$xorriso_xattrs"
echo
ls -l "$on_disk"/*
echo -e "\n${SELF}: Producing simple image via -o" >&2
"$xorriso" -as mkisofs "$on_disk" -o "$workdir"/image_minus_o.iso
is_valid_iso9660 "$workdir"/image_minus_o.iso
@ -180,8 +213,10 @@ echo -e "\n${SELF}: Producing simple image with for_backup/update_r/hardlinks" >
-outdev "$image_file" \
-volid TEST_AUTO_ISOCONTENT \
-update_r "$on_disk" "$in_iso" \
-setfacl u::rwx,g::r-x,o::---,u:root:rwx,g:sys:rwx,u:daemon:r--,mask::rwx,d:u::rwx,d:g::r-x,d:o::---,d:u:root:rwx,d:g:sys:rwx,d:u:daemon:r--,d:mask::rwx "$acl_xattr_iso_dir" -- \
-hardlinks perform_update
ret=$?
if test "$ret" -gt 0 -a "$ret" -lt 32
then
printf "\nFAIL : ${SELF} : xorriso write run failed\n\n"
@ -253,7 +288,7 @@ fi
printf "\n${SELF}: Checking for hardlinks being siblings...\n"
ls -l "$copy_on_disk"/*
x=$(echo $(ls -l "$copy_on_disk"/* | awk '{print $2}'))
x=$(echo $(ls -ld "$copy_on_disk"/*file* | awk '{print $2}'))
expected="1 3 3 3 2 2"
if test x"$x" = x"$expected"
then
@ -269,8 +304,7 @@ if test "$acls" = yes
then
printf "\n${SELF}: Checking ACLs ...\n" >&2
acl_on_disk=$(getfacl "$acl_xattr_test_file" | grep -v '^# file:' | sort)
acl_in_copy=$(getfacl "$copy_on_disk"/acl_xattr_test_file |
grep -v '^# file:' | sort)
acl_in_copy=$(getfacl "$acl_xattr_copy_file" | grep -v '^# file:' | sort)
if test "$acl_on_disk" = "$acl_in_copy"
then
printf "${SELF}: Checking ACLs done: ok.\n" >&2
@ -287,7 +321,7 @@ then
printf "\n${SELF}: Checking xattr via getfattr ...\n" >&2
xattr_on_disk=$(getfattr "$acl_xattr_test_file" | \
grep -v '^# file:' | grep -v '^$' | \sort)
xattr_in_copy=$(getfattr "$copy_on_disk"/acl_xattr_test_file |
xattr_in_copy=$(getfattr "$acl_xattr_copy_file" |
grep -v '^# file:' | grep -v '^$' | sort)
if test "$xattr_on_disk" = "$xattr_in_copy"
then
@ -299,11 +333,23 @@ then
printf "\nCopy:\n${xattr_in_copy}\n"
failure=1
fi
elif test "$extattr" = yes
elif test "$extattrs" = yes
then
# >>> Compare xattr of "$acl_xattr_test_file" by getextattr
dummy=dummy
printf "\n${SELF}: Checking xattr via lsextattr and getextattr ...\n" >&2
lsext_on_disk=$(lsextattr -q user "$acl_xattr_test_file")
xattr_on_disk=$(for i in $lsext_on_disk ; do echo $i $(getextattr -q user $i "$acl_xattr_test_file"); done | sort)
lsext_in_copy=$(lsextattr -q user "$acl_xattr_copy_file")
xattr_in_copy=$(for i in $lsext_in_copy ; do echo $i $(getextattr -q user $i "$acl_xattr_copy_file"); done | sort)
if test "$xattr_on_disk" = "$xattr_in_copy"
then
num_xattr=$(echo "$xattr_on_disk" | wc -l)
printf "${SELF}: Checking xattr done: $num_xattr attributes, ok.\n" >&2
else
printf "\nFAIL : ${SELF} : xattr mismatch between original and extracted copy\n"
printf "\nOriginal:\n${xattr_on_disk}\n"
printf "\nCopy:\n${xattr_in_copy}\n"
failure=1
fi
fi