From a6d9462cb1daaa3e40920164fc4e7b66c8959473 Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Wed, 17 Jan 2024 00:48:12 +0900 Subject: [PATCH] (*Daemon).fillRootlessVersion: fix nil panic Fix issue 47085 Signed-off-by: Akihiro Suda --- daemon/info_unix.go | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/daemon/info_unix.go b/daemon/info_unix.go index b12de6f601..c5abc39709 100644 --- a/daemon/info_unix.go +++ b/daemon/info_unix.go @@ -239,16 +239,27 @@ func (daemon *Daemon) fillRootlessVersion(ctx context.Context, v *types.Version) if err != nil { return errors.Wrap(err, "failed to retrieve RootlessKit version") } - v.Components = append(v.Components, types.ComponentVersion{ + rlV := types.ComponentVersion{ Name: "rootlesskit", Version: rlInfo.Version, Details: map[string]string{ - "ApiVersion": rlInfo.APIVersion, - "StateDir": rlInfo.StateDir, - "NetworkDriver": rlInfo.NetworkDriver.Driver, - "PortDriver": rlInfo.PortDriver.Driver, + "ApiVersion": rlInfo.APIVersion, + "StateDir": rlInfo.StateDir, }, - }) + } + if netDriver := rlInfo.NetworkDriver; netDriver != nil { + // netDriver is nil for the "host" network driver + // (not used for Rootless Docker) + rlV.Details["NetworkDriver"] = netDriver.Driver + } + if portDriver := rlInfo.PortDriver; portDriver != nil { + // portDriver is nil for the "implicit" port driver + // (used with "pasta" network driver) + // + // Because the ports are not managed via RootlessKit API in this case. + rlV.Details["PortDriver"] = portDriver.Driver + } + v.Components = append(v.Components, rlV) switch rlInfo.NetworkDriver.Driver { case "slirp4netns":