Skip to content

Commit 42bc554

Browse files
committed
libcontainer.Process no longer supports User field
see opencontainers/runc#3999
1 parent 837a971 commit 42bc554

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

drivers/shared/executor/executor_linux.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"os/signal"
1515
"path"
1616
"path/filepath"
17+
"strconv"
1718
"strings"
1819
"sync/atomic"
1920
"syscall"
@@ -229,13 +230,15 @@ func (l *LibcontainerExecutor) Launch(command *ExecCommand) (*ProcessState, erro
229230
}
230231

231232
if command.User != "" {
232-
process.User = command.User
233-
234233
// Override HOME and USER environment variables
235234
u, err := users.Lookup(command.User)
236235
if err != nil {
237236
return nil, err
238237
}
238+
process.UID = func() int {
239+
u, _ := strconv.Atoi(u.Uid)
240+
return u
241+
}()
239242
process.Env = append(process.Env, fmt.Sprintf("USER=%s", u.Username))
240243
process.Env = append(process.Env, fmt.Sprintf("LOGNAME=%s", u.Username))
241244
process.Env = append(process.Env, fmt.Sprintf("HOME=%s", u.HomeDir))
@@ -577,7 +580,7 @@ func (l *LibcontainerExecutor) ExecStreaming(ctx context.Context, cmd []string,
577580
process := &libcontainer.Process{
578581
Args: cmd,
579582
Env: l.userProc.Env,
580-
User: l.userProc.User,
583+
UID: l.userProc.UID,
581584
Init: false,
582585
Cwd: l.command.WorkDir,
583586
}

0 commit comments

Comments
 (0)