mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
runc exec: improve options parsing
1. Do not ask for the same option value twice. 2. For tty, we always want false, unless specified, and this is what GetBool gets us. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -219,9 +219,9 @@ func getProcess(context *cli.Context, bundle string) (*specs.Process, error) {
|
|||||||
}
|
}
|
||||||
p := spec.Process
|
p := spec.Process
|
||||||
p.Args = context.Args()[1:]
|
p.Args = context.Args()[1:]
|
||||||
// override the cwd, if passed
|
// Override the cwd, if passed.
|
||||||
if context.String("cwd") != "" {
|
if cwd := context.String("cwd"); cwd != "" {
|
||||||
p.Cwd = context.String("cwd")
|
p.Cwd = cwd
|
||||||
}
|
}
|
||||||
if ap := context.String("apparmor"); ap != "" {
|
if ap := context.String("apparmor"); ap != "" {
|
||||||
p.ApparmorProfile = ap
|
p.ApparmorProfile = ap
|
||||||
@@ -240,17 +240,14 @@ func getProcess(context *cli.Context, bundle string) (*specs.Process, error) {
|
|||||||
// append the passed env variables
|
// append the passed env variables
|
||||||
p.Env = append(p.Env, context.StringSlice("env")...)
|
p.Env = append(p.Env, context.StringSlice("env")...)
|
||||||
|
|
||||||
// set the tty
|
// Always set tty to false, unless explicitly enabled from CLI.
|
||||||
p.Terminal = false
|
p.Terminal = context.Bool("tty")
|
||||||
if context.IsSet("tty") {
|
|
||||||
p.Terminal = context.Bool("tty")
|
|
||||||
}
|
|
||||||
if context.IsSet("no-new-privs") {
|
if context.IsSet("no-new-privs") {
|
||||||
p.NoNewPrivileges = context.Bool("no-new-privs")
|
p.NoNewPrivileges = context.Bool("no-new-privs")
|
||||||
}
|
}
|
||||||
// override the user, if passed
|
// Override the user, if passed.
|
||||||
if context.String("user") != "" {
|
if user := context.String("user"); user != "" {
|
||||||
u := strings.SplitN(context.String("user"), ":", 2)
|
u := strings.SplitN(user, ":", 2)
|
||||||
if len(u) > 1 {
|
if len(u) > 1 {
|
||||||
gid, err := strconv.Atoi(u[1])
|
gid, err := strconv.Atoi(u[1])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user