lib/pull: Add OSTREE_REPO_PULL_FLAGS_BAREUSERONLY_FILES

This is an option which is intended mostly for flatpak;
see: https://github.com/flatpak/flatpak/issues/845

We're adding an option for pulling into *all*
repo modes that has an effect similar to the `bare-user-only`
change from https://github.com/ostreedev/ostree/pull/909

This way one can pull content into e.g. a root-owned `bare` repository and
ensure that there aren't any setuid or world-writable files.

Closes: #926
Approved by: alexlarsson
This commit is contained in:
Colin Walters authored and Atomic Bot committed 2017-06-13 18:44:28 +00:00
1 parent 74e3581ed6
commit 6ed824bf00
6 files changed
+160 -13

No files matched your search

+27 -1
View File
@@ -19,7 +19,7 @@
set -euo pipefail
echo "1..$((66 + ${extra_basic_tests:-0}))"
echo "1..$((68 + ${extra_basic_tests:-0}))"
$CMD_PREFIX ostree --version > version.yaml
python -c 'import yaml; yaml.safe_load(open("version.yaml"))'
@@ -267,6 +267,32 @@ test2_commit_relpath=/objects/${test2_commitid:0:2}/${test2_commitid:2}.commit
assert_files_hardlinked repo/${test2_commit_relpath} repo2/${test2_commit_relpath}
echo "ok pull-local (hardlinking metadata)"
cd ${test_tmpdir}
rm repo2 -rf && mkdir repo2
ostree_repo_init repo2 --mode=$opposite_mode
${CMD_PREFIX} ostree --repo=repo2 pull-local --bareuseronly-files repo test2
${CMD_PREFIX} ostree --repo=repo2 fsck -q
echo "ok pull-local --bareuseronly-files"
# This is mostly a copy of the suid test in test-basic-user-only.sh,
# but for the `pull --bareuseronly-files` case.
cd ${test_tmpdir}
rm repo-input -rf
ostree_repo_init repo-input init --mode=archive
cd ${test_tmpdir}
cat > statoverride.txt <<EOF
2048 /some-setuid
EOF
mkdir -p files/
echo "a setuid file" > files/some-setuid
chmod 0644 files/some-setuid
$CMD_PREFIX ostree --repo=repo-input commit -b content-with-suid --statoverride=statoverride.txt --tree=dir=files
if $CMD_PREFIX ostree pull-local --repo=repo --bareuseronly-files repo-input content-with-suid 2>err.txt; then
assert_not_reached "copying suid file with --bareuseronly-files worked?"
fi
assert_file_has_content err.txt 'object.*\.file: invalid mode.*with bits 040.*'
echo "ok pull-local (bareuseronly files)"
cd ${test_tmpdir}
${CMD_PREFIX} ostree --repo=repo2 checkout ${CHECKOUT_U_ARG} test2 test2-checkout-from-local-clone
cd test2-checkout-from-local-clone
+8 -1
View File
@@ -35,7 +35,7 @@ function verify_initial_contents() {
assert_file_has_content baz/cow '^moo$'
}
echo "1..20"
echo "1..21"
# Try both syntaxes
repo_init --no-gpg-verify
@@ -79,6 +79,13 @@ ${CMD_PREFIX} ostree --repo=mirrorrepo pull origin main
${CMD_PREFIX} ostree --repo=mirrorrepo fsck
echo "ok pull (refuses deltas)"
if ${CMD_PREFIX} ostree --repo=mirrorrepo \
pull origin main --bareuseronly-files 2>err.txt; then
assert_not_reached "--bareuseronly-files unexpectedly succeeded"
fi
assert_file_has_content err.txt 'bareuseronly-files with non-local'
echo "ok pull (refuses bareuseronly)"
cd ${test_tmpdir}
rm mirrorrepo/refs/remotes/* -rf
${CMD_PREFIX} ostree --repo=mirrorrepo prune --refs-only