mirror of
https://github.com/containers/podman
synced 2024-10-20 17:23:30 +00:00
Merge pull request #1798 from giuseppe/fix-notify-socket
systemd: fix NOTIFY_SOCKET with patched runc
This commit is contained in:
commit
22d53e2b54
|
@ -591,6 +591,9 @@ func (r *OCIRuntime) startContainer(ctr *Container) error {
|
|||
return err
|
||||
}
|
||||
env := []string{fmt.Sprintf("XDG_RUNTIME_DIR=%s", runtimeDir)}
|
||||
if notify, ok := os.LookupEnv("NOTIFY_SOCKET"); ok {
|
||||
env = append(env, fmt.Sprintf("NOTIFY_SOCKET=%s", notify))
|
||||
}
|
||||
if err := utils.ExecCmdWithStdStreams(os.Stdin, os.Stdout, os.Stderr, env, r.path, "start", ctr.ID()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package integration
|
|||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
@ -287,14 +288,27 @@ var _ = Describe("Podman run", func() {
|
|||
})
|
||||
|
||||
It("podman run notify_socket", func() {
|
||||
sock := "/run/notify"
|
||||
host := GetHostDistributionInfo()
|
||||
if host.Distribution != "rhel" && host.Distribution != "centos" && host.Distribution != "fedora" {
|
||||
Skip("this test requires a working runc")
|
||||
}
|
||||
sock := filepath.Join(podmanTest.TempDir, "notify")
|
||||
addr := net.UnixAddr{
|
||||
Name: sock,
|
||||
Net: "unixgram",
|
||||
}
|
||||
socket, err := net.ListenUnixgram("unixgram", &addr)
|
||||
Expect(err).To(BeNil())
|
||||
defer os.Remove(sock)
|
||||
defer socket.Close()
|
||||
|
||||
os.Setenv("NOTIFY_SOCKET", sock)
|
||||
defer os.Unsetenv("NOTIFY_SOCKET")
|
||||
|
||||
session := podmanTest.Podman([]string{"run", "--rm", ALPINE, "printenv", "NOTIFY_SOCKET"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session.ExitCode()).To(Equal(0))
|
||||
match, _ := session.GrepString(sock)
|
||||
Expect(match).Should(BeTrue())
|
||||
os.Unsetenv("NOTIFY_SOCKET")
|
||||
Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 0))
|
||||
})
|
||||
|
||||
It("podman run log-opt", func() {
|
||||
|
|
Loading…
Reference in a new issue