Skip to content

Commit e029b79

Browse files
authored
Merge pull request containerd#54 from tonistiigi/notify-socket
avoid setting NOTIFY_SOCKET from calling process
2 parents b4bc25a + c0c55f3 commit e029b79

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

command_linux.go

+16-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"context"
2121
"os"
2222
"os/exec"
23+
"strings"
2324
"syscall"
2425
)
2526

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

4041
return cmd
4142
}
43+
44+
func filterEnv(in []string, names ...string) []string {
45+
out := make([]string, 0, len(in))
46+
loop0:
47+
for _, v := range in {
48+
for _, k := range names {
49+
if strings.HasPrefix(v, k+"=") {
50+
continue loop0
51+
}
52+
}
53+
out = append(out, v)
54+
}
55+
return out
56+
}

0 commit comments

Comments
 (0)