Skip to content

Commit

Permalink
tests: Add a test for bare-user-only failing to commit suid content
Browse files Browse the repository at this point in the history
We didn't have coverage of this before, and adding the test infrastructure will
help ensure we have coverage for more changes here.

Closes: #913
Approved by: alexlarsson
  • Loading branch information
cgwalters authored and rh-atomic-bot committed Jun 7, 2017
1 parent 4418ab7 commit e85b9b4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tests/basic-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

set -euo pipefail

echo "1..66"
echo "1..$((66 + ${extra_basic_tests:-0}))"

$CMD_PREFIX ostree --version > version.yaml
python -c 'import yaml; yaml.safe_load(open("version.yaml"))'
Expand Down
24 changes: 24 additions & 0 deletions tests/test-basic-user-only.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,28 @@ set -euo pipefail
. $(dirname $0)/libtest.sh

setup_test_repository "bare-user-only"
extra_basic_tests=1
. $(dirname $0)/basic-test.sh

# Reset things so we don't inherit a lot of state from earlier tests
cd ${test_tmpdir}
rm repo files -rf
ostree --repo=repo init --mode=bare-user-only

# Init an archive repo where we'll store content that can't go into bare-user
cd ${test_tmpdir}
rm repo-input -rf
ostree --repo=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 repo-input 2>err.txt; then
assert_not_reached "copying suid file into bare-user worked?"
fi
assert_file_has_content err.txt "Invalid mode.*with bits 040.*in bare-user-only"
echo "ok failed to commit suid"

0 comments on commit e85b9b4

Please sign in to comment.