Skip to content

Commit

Permalink
Merge pull request #54 from tonistiigi/notify-socket
Browse files Browse the repository at this point in the history
avoid setting NOTIFY_SOCKET from calling process
  • Loading branch information
AkihiroSuda authored Sep 11, 2019
2 parents b4bc25a + c0c55f3 commit e029b79
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 e029b79

Please sign in to comment.