tests: update several bare-user-only checks

This commit is contained in:
Luca BRUNO 2021-08-23 09:46:22 +00:00
parent 3e2360e3bb
commit 00660eae79
No known key found for this signature in database
GPG Key ID: A9834A2252078E4E
2 changed files with 19 additions and 27 deletions

View File

@ -29,10 +29,8 @@ COMMIT_ARGS=""
DIFF_ARGS=""
if is_bare_user_only_repo repo; then
# In bare-user-only repos we can only represent files with uid/gid 0, no
# xattrs and canonical permissions, so we need to commit them as such, or
# we end up with repos that don't pass fsck
COMMIT_ARGS="--no-xattrs"
DIFF_ARGS="--owner-uid=0 --owner-gid=0 --no-xattrs"
# xattrs and canonical permissions.
DIFF_ARGS="--owner-uid=0 --owner-gid=0"
# Also, since we can't check out uid=0 files we need to check out in user mode
CHECKOUT_U_ARG="-U"
CHECKOUT_H_ARGS="-U -H"
@ -314,7 +312,7 @@ echo "ok diff revisions"
cd ${test_tmpdir}/checkout-test2-4
echo afile > oh-look-a-file
$OSTREE diff test2 ./ > ${test_tmpdir}/diff-test2-2
$OSTREE diff ${DIFF_ARGS} test2 ./ > ${test_tmpdir}/diff-test2-2
rm oh-look-a-file
cd ${test_tmpdir}
assert_file_has_content diff-test2-2 'A *oh-look-a-file$'
@ -787,11 +785,14 @@ cd ${test_tmpdir}
rm files -rf && mkdir files
mkdir files/worldwritable-dir
chmod a+w files/worldwritable-dir
$CMD_PREFIX ostree --repo=repo commit -b content-with-dir-world-writable --tree=dir=files
$OSTREE commit ${COMMIT_ARGS} -b content-with-dir-world-writable --tree=dir=files
$OSTREE fsck
rm dir-co -rf
$CMD_PREFIX ostree --repo=repo checkout -U -H -M content-with-dir-world-writable dir-co
$OSTREE checkout -U -H -M content-with-dir-world-writable dir-co
if is_bare_user_only_repo repo; then
assert_file_has_mode dir-co/worldwritable-dir 755
else
assert_file_has_mode dir-co/worldwritable-dir 775
if ! is_bare_user_only_repo repo; then
rm dir-co -rf
$CMD_PREFIX ostree --repo=repo checkout -U -H content-with-dir-world-writable dir-co
assert_file_has_mode dir-co/worldwritable-dir 777

View File

@ -25,7 +25,7 @@ set -euo pipefail
mode="bare-user-only"
setup_test_repository "$mode"
extra_basic_tests=7
extra_basic_tests=6
. $(dirname $0)/basic-test.sh
$CMD_PREFIX ostree --version > version.yaml
@ -63,8 +63,8 @@ rm files -rf && mkdir files
echo "a group writable file" > files/some-group-writable
chmod 0664 files/some-group-writable
$CMD_PREFIX ostree --repo=repo-input commit -b content-with-group-writable --tree=dir=files
$CMD_PREFIX ostree pull-local --repo=repo repo-input
$CMD_PREFIX ostree --repo=repo checkout -U -H content-with-group-writable groupwritable-co
$OSTREE pull-local repo-input
$OSTREE checkout -U -H content-with-group-writable groupwritable-co
assert_file_has_mode groupwritable-co/some-group-writable 664
echo "ok supported group writable"
@ -75,8 +75,8 @@ rm files -rf && mkdir files
mkdir files/worldwritable-dir
chmod a+w files/worldwritable-dir
$CMD_PREFIX ostree --repo=repo-input commit -b content-with-dir-world-writable --tree=dir=files
$CMD_PREFIX ostree pull-local --repo=repo repo-input
$CMD_PREFIX ostree --repo=repo checkout -U -H content-with-dir-world-writable dir-co
$OSTREE pull-local repo-input
$OSTREE checkout -U -H content-with-dir-world-writable dir-co
assert_file_has_mode dir-co/worldwritable-dir 775
echo "ok didn't make world-writable dir"
@ -106,21 +106,12 @@ rm repo -rf
ostree_repo_init repo init --mode=bare-user-only
rm files -rf && mkdir files
echo afile > files/afile
chmod 0777 files/afile
$OSTREE commit ${COMMIT_ARGS} -b perms files
$OSTREE fsck
rm out -rf
$OSTREE checkout --force-copy perms out
assert_file_has_mode out/afile 755
$OSTREE checkout ${CHECKOUT_H_ARGS} --union-identical perms out
$OSTREE fsck
echo "ok checkout checksum with canonical perms"
cd ${test_tmpdir}
rm repo -rf
ostree_repo_init repo init --mode=bare-user-only
rm files -rf && mkdir files
echo afile > files/afile
$OSTREE commit ${COMMIT_ARGS} -b perms files
rm out -rf
$OSTREE checkout --force-copy perms out
$OSTREE checkout ${CHECKOUT_H_ARGS} --union-identical perms out
$OSTREE fsck
assert_file_has_mode out/afile 755
echo "ok automatic canonical perms for bare-user-only"