diff options
author | Jhon Honce <jhonce@redhat.com> | 2020-04-17 16:27:17 -0700 |
---|---|---|
committer | Jhon Honce <jhonce@redhat.com> | 2020-04-17 16:39:59 -0700 |
commit | 4e0326241b35d2549fdba5666f343c31279e18e4 (patch) | |
tree | 2d8b1e2a46ff4b5db3bb4d102667cae43854dbdb /pkg/systemd/activation.go | |
parent | aa97cb5f42a35de02d520f6c3006600505a3d6d9 (diff) | |
download | podman-4e0326241b35d2549fdba5666f343c31279e18e4.tar.gz podman-4e0326241b35d2549fdba5666f343c31279e18e4.tar.bz2 podman-4e0326241b35d2549fdba5666f343c31279e18e4.zip |
V2 Fix support for tcp://[::]<port> connections
* Fix support for socket activation, on remote and service
$ systemd-socket-activate -l 8083 --fdname=podman bin/podman system service --log-level=debug --time=30
$ bin/podman-remote --remote=tcp://[::]:8083 image ls
Or, use the podman.{socket,service} unit files
$ bin/podman-remote --remote=unix:///run/podman/podman.sock image ls
Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'pkg/systemd/activation.go')
-rw-r--r-- | pkg/systemd/activation.go | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/pkg/systemd/activation.go b/pkg/systemd/activation.go index c8b2389dc..8f75f9cca 100644 --- a/pkg/systemd/activation.go +++ b/pkg/systemd/activation.go @@ -3,38 +3,33 @@ package systemd import ( "os" "strconv" - "strings" ) // SocketActivated determine if podman is running under the socket activation protocol +// Criteria is based on the expectations of "github.com/coreos/go-systemd/v22/activation" func SocketActivated() bool { - pid, pid_found := os.LookupEnv("LISTEN_PID") - fds, fds_found := os.LookupEnv("LISTEN_FDS") - fdnames, fdnames_found := os.LookupEnv("LISTEN_FDNAMES") - - if !(pid_found && fds_found && fdnames_found) { + pid, found := os.LookupEnv("LISTEN_PID") + if !found { return false } - p, err := strconv.Atoi(pid) if err != nil || p != os.Getpid() { return false } + fds, found := os.LookupEnv("LISTEN_FDS") + if !found { + return false + } nfds, err := strconv.Atoi(fds) - if err != nil || nfds < 1 { + if err != nil || nfds == 0 { return false } - // First available file descriptor is always 3. - if nfds > 1 { - names := strings.Split(fdnames, ":") - for _, n := range names { - if strings.Contains(n, "podman") { - return true - } - } + // "github.com/coreos/go-systemd/v22/activation" will use and validate this variable's + // value. We're just providing a fast fail + if _, found = os.LookupEnv("LISTEN_FDNAMES"); !found { + return false } - return true } |