1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- AT_SETUP([selinux: basic store/restore])
- AT_KEYWORDS([xattrs selinux selnx01])
- AT_TAR_CHECK([
- AT_XATTRS_UTILS_PREREQ
- AT_SELINUX_PREREQ
- mkdir dir
- genfile --file dir/file
- ln -s file dir/link
- getfattr -h -d -msecurity.selinux dir dir/file dir/link > start
- restorecon -R dir
- chcon -h --user=system_u dir
- chcon -h --user=unconfined_u dir/file
- chcon -h --user=system_u dir/link
- tar --selinux -cf archive.tar dir
- rm -rf dir
- tar --selinux -xf archive.tar
- cp archive.tar archive_origin.tar
- getfattr -h -d dir dir/file dir/link -msecurity.selinux | \
- grep -v -e '^#' -e ^$ | cut -d: -f1
- getfattr -h -d -msecurity.selinux dir dir/file dir/link > with_selinux
- rm -rf dir
- tar -xf archive.tar
- getfattr -h -d -msecurity.selinux dir dir/file dir/link > without_selinux
- diff with_selinux without_selinux > diff_with_without
- if test "$?" -eq "0"; then
- echo "selinux contexts probably restored while --selinux is off"
- fi
- tar -cf archive.tar dir
- rm -rf dir
- tar --selinux -xf archive.tar dir
- getfattr -h -d -msecurity.selinux dir dir/file dir/link > final
- diff start final > final_diff
- if test "$?" -ne "0"; then
- echo "bad result"
- fi
- ],
- [0],
- [security.selinux="system_u
- security.selinux="unconfined_u
- security.selinux="system_u
- ])
- AT_CLEANUP
|