File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -411,8 +411,9 @@ func fixStdioPermissions(u *user.ExecUser) error {
411411 return & os.PathError {Op : "fstat" , Path : file .Name (), Err : err }
412412 }
413413
414- // Skip chown if uid is already the one we want.
415- if int (s .Uid ) == u .Uid {
414+ // Skip chown if uid is already the one we want or any of the STDIO descriptors
415+ // were redirected to /dev/null.
416+ if int (s .Uid ) == u .Uid || s .Rdev == null .Rdev {
416417 continue
417418 }
418419
Original file line number Diff line number Diff line change @@ -125,10 +125,25 @@ function teardown() {
125125
126126 runc exec --user 1000:1000 test_busybox id
127127 [ " $status " -eq 0 ]
128-
129128 [[ " ${output} " == " uid=1000 gid=1000" * ]]
130129}
131130
131+ # https://github.com/opencontainers/runc/issues/3674.
132+ @test " runc exec --user vs /dev/null ownership" {
133+ requires root
134+
135+ runc run -d --console-socket " $CONSOLE_SOCKET " test_busybox
136+ [ " $status " -eq 0 ]
137+
138+ ls -l /dev/null
139+ __runc exec -d --user 1000:1000 test_busybox id < /dev/null
140+ ls -l /dev/null
141+ UG=$( stat -c %u:%g /dev/null)
142+
143+ # Host's /dev/null must be owned by root.
144+ [ " $UG " = " 0:0" ]
145+ }
146+
132147@test " runc exec --additional-gids" {
133148 requires root
134149
You can’t perform that action at this time.
0 commit comments