Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create directories with 700 and not 644 #154

Merged
merged 1 commit into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func UntarFiles(src, dest string, files []string) error {
for _, file := range files {
if strings.Contains(header.Name, file) {
// Create the destination folder
if err := os.MkdirAll(filepath.Join(dest, filepath.Dir(header.Name)), 0o644); err != nil {
if err := os.MkdirAll(filepath.Join(dest, filepath.Dir(header.Name)), 0o700); err != nil {
return err
}
// Create the destination file
Expand Down
27 changes: 27 additions & 0 deletions test/checkpointctl.bats
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ function checkpointctl() {
function setup() {
TEST_TMP_DIR1=$(mktemp -d)
TEST_TMP_DIR2=$(mktemp -d)
NON_ROOT_TMP1=$(sudo -u 'nobody' mktemp -d)
}

function teardown() {
[ "$TEST_TMP_DIR1" != "" ] && rm -rf "$TEST_TMP_DIR1"
[ "$TEST_TMP_DIR2" != "" ] && rm -rf "$TEST_TMP_DIR2"
[ "$NON_ROOT_TMP1" != "" ] && rm -rf "$NON_ROOT_TMP1"
}

@test "Run checkpointctl" {
Expand Down Expand Up @@ -301,6 +303,31 @@ function teardown() {
[[ ${lines[10]} == *"piggie/piggie"* ]]
}

@test "Run checkpointctl inspect with tar file and --ps-tree-cmd as non-root" {
if [ "$CHECKPOINTCTL" == "../checkpointctl.coverage" ]; then
skip "non-root test cannot access the coverage directory"
fi
cp data/config.dump \
data/spec.dump "$TEST_TMP_DIR1"
mkdir "$TEST_TMP_DIR1"/checkpoint
cp test-imgs/pstree.img \
test-imgs/core-*.img \
test-imgs/pagemap-*.img \
test-imgs/pages-*.img \
test-imgs/mm-*.img "$TEST_TMP_DIR1"/checkpoint
( cd "$TEST_TMP_DIR1" && tar cf "$NON_ROOT_TMP1"/test.tar . )
chmod 644 "$NON_ROOT_TMP1"/test.tar
NON_ROOT_BIN=$(mktemp)
cp "$CHECKPOINTCTL" "$NON_ROOT_BIN"
chmod 755 "$NON_ROOT_BIN"
run sudo -u 'nobody' "$NON_ROOT_BIN" inspect "$NON_ROOT_TMP1"/test.tar --ps-tree-cmd
echo "$output"
rm -f "$NON_ROOT_BIN"
[ "$status" -eq 0 ]
[[ ${lines[9]} == *"Process tree"* ]]
[[ ${lines[10]} == *"piggie/piggie"* ]]
}

@test "Run checkpointctl inspect with tar file and --ps-tree-cmd and missing pages-*.img" {
cp data/config.dump \
data/spec.dump "$TEST_TMP_DIR1"
Expand Down
Loading