Skip to content

Commit 15dd6b5

Browse files
authored
Merge pull request #154 from adrianreber/2024-12-14-755
Create directories with 700 and not 644
2 parents 8a3ffb9 + da73a77 commit 15dd6b5

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

internal/container.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ func UntarFiles(src, dest string, files []string) error {
244244
for _, file := range files {
245245
if strings.Contains(header.Name, file) {
246246
// Create the destination folder
247-
if err := os.MkdirAll(filepath.Join(dest, filepath.Dir(header.Name)), 0o644); err != nil {
247+
if err := os.MkdirAll(filepath.Join(dest, filepath.Dir(header.Name)), 0o700); err != nil {
248248
return err
249249
}
250250
// Create the destination file

test/checkpointctl.bats

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ function checkpointctl() {
1717
function setup() {
1818
TEST_TMP_DIR1=$(mktemp -d)
1919
TEST_TMP_DIR2=$(mktemp -d)
20+
NON_ROOT_TMP1=$(sudo -u 'nobody' mktemp -d)
2021
}
2122

2223
function teardown() {
2324
[ "$TEST_TMP_DIR1" != "" ] && rm -rf "$TEST_TMP_DIR1"
2425
[ "$TEST_TMP_DIR2" != "" ] && rm -rf "$TEST_TMP_DIR2"
26+
[ "$NON_ROOT_TMP1" != "" ] && rm -rf "$NON_ROOT_TMP1"
2527
}
2628

2729
@test "Run checkpointctl" {
@@ -301,6 +303,31 @@ function teardown() {
301303
[[ ${lines[10]} == *"piggie/piggie"* ]]
302304
}
303305

306+
@test "Run checkpointctl inspect with tar file and --ps-tree-cmd as non-root" {
307+
if [ "$CHECKPOINTCTL" == "../checkpointctl.coverage" ]; then
308+
skip "non-root test cannot access the coverage directory"
309+
fi
310+
cp data/config.dump \
311+
data/spec.dump "$TEST_TMP_DIR1"
312+
mkdir "$TEST_TMP_DIR1"/checkpoint
313+
cp test-imgs/pstree.img \
314+
test-imgs/core-*.img \
315+
test-imgs/pagemap-*.img \
316+
test-imgs/pages-*.img \
317+
test-imgs/mm-*.img "$TEST_TMP_DIR1"/checkpoint
318+
( cd "$TEST_TMP_DIR1" && tar cf "$NON_ROOT_TMP1"/test.tar . )
319+
chmod 644 "$NON_ROOT_TMP1"/test.tar
320+
NON_ROOT_BIN=$(mktemp)
321+
cp "$CHECKPOINTCTL" "$NON_ROOT_BIN"
322+
chmod 755 "$NON_ROOT_BIN"
323+
run sudo -u 'nobody' "$NON_ROOT_BIN" inspect "$NON_ROOT_TMP1"/test.tar --ps-tree-cmd
324+
echo "$output"
325+
rm -f "$NON_ROOT_BIN"
326+
[ "$status" -eq 0 ]
327+
[[ ${lines[9]} == *"Process tree"* ]]
328+
[[ ${lines[10]} == *"piggie/piggie"* ]]
329+
}
330+
304331
@test "Run checkpointctl inspect with tar file and --ps-tree-cmd and missing pages-*.img" {
305332
cp data/config.dump \
306333
data/spec.dump "$TEST_TMP_DIR1"

0 commit comments

Comments
 (0)