Skip to content

Commit

Permalink
avoid setting NOTIFY_SOCKET from calling process
Browse files Browse the repository at this point in the history
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
  • Loading branch information
tonistiigi committed Sep 11, 2019
1 parent b4bc25a commit c0c55f3
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion command_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"os"
"os/exec"
"strings"
"syscall"
)

Expand All @@ -32,10 +33,24 @@ func (r *Runc) command(context context.Context, args ...string) *exec.Cmd {
cmd.SysProcAttr = &syscall.SysProcAttr{
Setpgid: r.Setpgid,
}
cmd.Env = os.Environ()
cmd.Env = filterEnv(os.Environ(), "NOTIFY_SOCKET") // NOTIFY_SOCKET introduces a special behavior in runc but should only be set if invoked from systemd
if r.PdeathSignal != 0 {
cmd.SysProcAttr.Pdeathsig = r.PdeathSignal
}

return cmd
}

func filterEnv(in []string, names ...string) []string {
out := make([]string, 0, len(in))
loop0:
for _, v := range in {
for _, k := range names {
if strings.HasPrefix(v, k+"=") {
continue loop0
}
}
out = append(out, v)
}
return out
}

0 comments on commit c0c55f3

Please sign in to comment.