Made releng/auto_isocontent ready to test FreeBSD extattr
This commit is contained in:
parent
7b6e14a2bf
commit
b22a756af4
@ -95,22 +95,45 @@ is_valid_iso9660() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Create test file and find out whether ACLs and/or xattr are available.
|
# Create test file and find out whether ACLs and/or xattr are available.
|
||||||
|
#
|
||||||
# Users known on GNU/Linux and FreeBSD: root games daemon man
|
# Users known on GNU/Linux and FreeBSD: root games daemon man
|
||||||
# Groups : daemon games bin sshd sys
|
# 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_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
|
echo echo hello world >"$acl_xattr_test_file" || exit 1
|
||||||
sys=$(uname -s)
|
sys=$(uname -s)
|
||||||
acls=no
|
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
|
"$acl_xattr_test_file" ) >/dev/null 2>&1
|
||||||
then
|
then
|
||||||
if ( getfacl "$acl_xattr_test_file" ) >/dev/null 2>&1
|
if ( getfacl "$acl_xattr_test_file" ) >/dev/null 2>&1
|
||||||
then
|
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
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# GNU/Linux and FreeBSD have different tools for Extended Attributes
|
||||||
xattrs=no
|
xattrs=no
|
||||||
extattrs=no
|
extattrs=no
|
||||||
|
# Try GNU/Linux style setattr/getattr
|
||||||
if ( setfattr -n user.test_xattr -v test_value "$acl_xattr_test_file" ) \
|
if ( setfattr -n user.test_xattr -v test_value "$acl_xattr_test_file" ) \
|
||||||
>/dev/null 2>&1
|
>/dev/null 2>&1
|
||||||
then
|
then
|
||||||
@ -123,14 +146,24 @@ then
|
|||||||
fi
|
fi
|
||||||
if test "$xattrs" = no
|
if test "$xattrs" = no
|
||||||
then
|
then
|
||||||
|
# Try FreeBSD style setextattr
|
||||||
# >>> Try FreeBSD style setextattr
|
if ( setextattr user test_xattr test_value "$acl_xattr_test_file" ) \
|
||||||
dummy=dummy
|
>/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
|
fi
|
||||||
|
|
||||||
echo
|
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
|
# Examine capabilities of xorriso
|
||||||
xorriso_acls=no
|
xorriso_acls=no
|
||||||
@ -154,13 +187,13 @@ fi
|
|||||||
if test "$xorriso_xattrs" = no
|
if test "$xorriso_xattrs" = no
|
||||||
then
|
then
|
||||||
xattrs=no
|
xattrs=no
|
||||||
|
extattrs=no
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "${SELF}: Detected xorriso_acls=$xorriso_acls , xorriso_xattrs=$xorriso_xattrs"
|
echo "${SELF}: Detected xorriso_acls=$xorriso_acls , xorriso_xattrs=$xorriso_xattrs"
|
||||||
echo
|
echo
|
||||||
ls -l "$on_disk"/*
|
ls -l "$on_disk"/*
|
||||||
|
|
||||||
|
|
||||||
echo -e "\n${SELF}: Producing simple image via -o" >&2
|
echo -e "\n${SELF}: Producing simple image via -o" >&2
|
||||||
"$xorriso" -as mkisofs "$on_disk" -o "$workdir"/image_minus_o.iso
|
"$xorriso" -as mkisofs "$on_disk" -o "$workdir"/image_minus_o.iso
|
||||||
is_valid_iso9660 "$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" \
|
-outdev "$image_file" \
|
||||||
-volid TEST_AUTO_ISOCONTENT \
|
-volid TEST_AUTO_ISOCONTENT \
|
||||||
-update_r "$on_disk" "$in_iso" \
|
-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
|
-hardlinks perform_update
|
||||||
ret=$?
|
ret=$?
|
||||||
|
|
||||||
if test "$ret" -gt 0 -a "$ret" -lt 32
|
if test "$ret" -gt 0 -a "$ret" -lt 32
|
||||||
then
|
then
|
||||||
printf "\nFAIL : ${SELF} : xorriso write run failed\n\n"
|
printf "\nFAIL : ${SELF} : xorriso write run failed\n\n"
|
||||||
@ -253,7 +288,7 @@ fi
|
|||||||
|
|
||||||
printf "\n${SELF}: Checking for hardlinks being siblings...\n"
|
printf "\n${SELF}: Checking for hardlinks being siblings...\n"
|
||||||
ls -l "$copy_on_disk"/*
|
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"
|
expected="1 3 3 3 2 2"
|
||||||
if test x"$x" = x"$expected"
|
if test x"$x" = x"$expected"
|
||||||
then
|
then
|
||||||
@ -269,8 +304,7 @@ if test "$acls" = yes
|
|||||||
then
|
then
|
||||||
printf "\n${SELF}: Checking ACLs ...\n" >&2
|
printf "\n${SELF}: Checking ACLs ...\n" >&2
|
||||||
acl_on_disk=$(getfacl "$acl_xattr_test_file" | grep -v '^# file:' | sort)
|
acl_on_disk=$(getfacl "$acl_xattr_test_file" | grep -v '^# file:' | sort)
|
||||||
acl_in_copy=$(getfacl "$copy_on_disk"/acl_xattr_test_file |
|
acl_in_copy=$(getfacl "$acl_xattr_copy_file" | grep -v '^# file:' | sort)
|
||||||
grep -v '^# file:' | sort)
|
|
||||||
if test "$acl_on_disk" = "$acl_in_copy"
|
if test "$acl_on_disk" = "$acl_in_copy"
|
||||||
then
|
then
|
||||||
printf "${SELF}: Checking ACLs done: ok.\n" >&2
|
printf "${SELF}: Checking ACLs done: ok.\n" >&2
|
||||||
@ -287,7 +321,7 @@ then
|
|||||||
printf "\n${SELF}: Checking xattr via getfattr ...\n" >&2
|
printf "\n${SELF}: Checking xattr via getfattr ...\n" >&2
|
||||||
xattr_on_disk=$(getfattr "$acl_xattr_test_file" | \
|
xattr_on_disk=$(getfattr "$acl_xattr_test_file" | \
|
||||||
grep -v '^# file:' | grep -v '^$' | \sort)
|
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)
|
grep -v '^# file:' | grep -v '^$' | sort)
|
||||||
if test "$xattr_on_disk" = "$xattr_in_copy"
|
if test "$xattr_on_disk" = "$xattr_in_copy"
|
||||||
then
|
then
|
||||||
@ -299,11 +333,23 @@ then
|
|||||||
printf "\nCopy:\n${xattr_in_copy}\n"
|
printf "\nCopy:\n${xattr_in_copy}\n"
|
||||||
failure=1
|
failure=1
|
||||||
fi
|
fi
|
||||||
elif test "$extattr" = yes
|
elif test "$extattrs" = yes
|
||||||
then
|
then
|
||||||
|
printf "\n${SELF}: Checking xattr via lsextattr and getextattr ...\n" >&2
|
||||||
# >>> Compare xattr of "$acl_xattr_test_file" by getextattr
|
lsext_on_disk=$(lsextattr -q user "$acl_xattr_test_file")
|
||||||
dummy=dummy
|
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
|
fi
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user