systemd socker activation: check listener

activation.Listeners() can return an net.Listener array which contains
nil entries if it cannot listen on the given fds. This can cause podman
to panic so we should check the we have non nil net.Listener first.

[NO NEW TESTS NEEDED] No idea how to reproduce this.

Fixes #13911

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger 2022-04-21 14:07:54 +02:00
parent 13c6fd067c
commit eb71712626
No known key found for this signature in database
GPG Key ID: EB145DD938A3CAF2
1 changed files with 4 additions and 0 deletions

View File

@ -79,6 +79,10 @@ func newServer(runtime *libpod.Runtime, listener net.Listener, opts entities.Ser
return nil, fmt.Errorf("wrong number of file descriptors for socket activation protocol (%d != 1)", len(listeners))
}
listener = listeners[0]
// note that activation.Listeners() return nil when it cannot listen on the fd (i.e. udp connection)
if listener == nil {
return nil, fmt.Errorf("unexpected fd received from systemd: cannot listen on it")
}
}
if opts.CorsHeaders == "" {
logrus.Debug("CORS Headers were not set")