Files
podman/pkg/systemd/activation.go
Jhon Honce 4e0326241b 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>
2020-04-17 16:39:59 -07:00

36 lines
786 B
Go

package systemd
import (
"os"
"strconv"
)
// 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, 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 == 0 {
return false
}
// "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
}