Skip to content

Commit 83b0fb4

Browse files
committed
Fix permission on secrets directory
This directory needs to be world searchable so users can access it from different user namespaces. Fixes: #12779 Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
1 parent 3404ad0 commit 83b0fb4

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

libpod/runtime_ctr.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ func (r *Runtime) setupContainer(ctx context.Context, ctr *Container) (_ *Contai
429429
}()
430430

431431
ctr.config.SecretsPath = filepath.Join(ctr.config.StaticDir, "secrets")
432-
err = os.MkdirAll(ctr.config.SecretsPath, 0644)
432+
err = os.MkdirAll(ctr.config.SecretsPath, 0755)
433433
if err != nil {
434434
return nil, err
435435
}

test/system/170-run-userns.bats

+16
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,19 @@ EOF
7878
# Then check that the main user is not mapped into the user namespace
7979
CONTAINERS_CONF=$PODMAN_TMPDIR/userns_auto.conf run_podman 0 run --rm $IMAGE awk '{if($2 == "0"){exit 1}}' /proc/self/uid_map /proc/self/gid_map
8080
}
81+
82+
@test "podman userns=auto and secrets" {
83+
ns_user="containers"
84+
if is_rootless; then
85+
ns_user=$(id -un)
86+
fi
87+
egrep -q "${ns_user}:" /etc/subuid || skip "no IDs allocated for user ${ns_user}"
88+
test_name="test_$(random_string 12)"
89+
secret_file=$PODMAN_TMPDIR/secret$(random_string 12)
90+
secret_content=$(random_string)
91+
echo ${secret_content} > ${secret_file}
92+
run_podman secret create ${test_name} ${secret_file}
93+
run_podman run --rm --secret=${test_name} --userns=auto:size=1000 $IMAGE cat /run/secrets/${test_name}
94+
is ${output} ${secret_content} "Secrets should work with user namespace"
95+
run_podman secret rm ${test_name}
96+
}

0 commit comments

Comments
 (0)