-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
keep toplevel dir modes and symlinks (#138)
In this commit, we are ensuring the dirs in the `/` root path of the temproot is as close as the 'real' one as possible. `$SANDBOX_DIR/temproot` is now being created with the same permission as the host, and every other directories on the top level are created with the same mode as the real one. Symlinks are now also created in the unshare, and removed after unshare finishes. Tests are created to check the mode, ownership, and symlink of the files in the `/` directory. Known issues In the test, we're ignoring files with the name swap. And also /proc, our current `mount -t proc proc /proc` invocation are creating the /proc dir with nobody and nogroup ownership. We're tracking this in #151 This PR currently assumes there are no regular files in the root dir besides the swap.img. We're tracking this in issue #150 * feat: keep toplevel dir perms in temproot - fixes #80 * feat: recreate symlinks in temproot - fixes #139 * feat: set correct permission for root dir, and remove symlink after unshare * feat: set temproot to be writible before removing symlinks * test: add new test to verify consistency of root dir (see known issues) * test(reuse_problematic_sandbox): set test to use a non-symblink dir * test(toplevel-perms): ignore acl bit, user&group ownership
- Loading branch information
Showing
3 changed files
with
74 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/sh | ||
|
||
TRY_TOP="${TRY_TOP:-$(git rev-parse --show-toplevel --show-superproject-working-tree)}" | ||
TRY="$TRY_TOP/try" | ||
|
||
cleanup() { | ||
cd / | ||
|
||
if [ -d "$try_workspace" ] | ||
then | ||
rm -rf "$try_workspace" >/dev/null 2>&1 | ||
fi | ||
|
||
if [ -f "$expected" ] | ||
then | ||
rm "$expected" | ||
fi | ||
|
||
if [ -f "$target" ] | ||
then | ||
rm "$target" | ||
fi | ||
|
||
if [ -f "$cmd" ] | ||
then | ||
rm "$cmd" | ||
fi | ||
} | ||
|
||
trap 'cleanup' EXIT | ||
|
||
try_workspace="$(mktemp -d)" | ||
cd "$try_workspace" || return 9 | ||
touch test | ||
|
||
cmd="$(mktemp)" | ||
echo "find / -maxdepth 1 -print0 | xargs -0 ls -ld | awk '{print substr(\$1, 1, 10), \$9, \$10, \$11}' | grep -v 'proc' | grep -v 'swap'" > "$cmd" | ||
# Use this after gidmapper to show user and group ownership | ||
#echo "find / -maxdepth 1 -print0 | xargs -0 ls -ld | awk '{print substr(\$1, 1, 10), \$3, \$4, \$9, \$10, \$11}' | grep -v 'proc' | grep -v 'swap'" > "$cmd" | ||
|
||
# Set up expected output | ||
expected="$(mktemp)" | ||
sh "$cmd" >"$expected" | ||
|
||
# Set up target output | ||
target="$(mktemp)" | ||
|
||
"$TRY" "sh $cmd" > "$target" || return 1 | ||
#diff -q "$expected" "$target" | ||
diff "$expected" "$target" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters