diff options
author | Brent Baude <bbaude@redhat.com> | 2020-06-03 14:52:01 -0500 |
---|---|---|
committer | Brent Baude <bbaude@redhat.com> | 2020-06-03 15:20:37 -0500 |
commit | d023909c0be103f1b02f2ddac0b937fff2d4e4f0 (patch) | |
tree | 52073a9a6bef47b47f7cf30afca1f73e0b3a8e20 /pkg/domain | |
parent | bba0a8be1a715fb0903ffc69abd5700a624d47e4 (diff) | |
download | podman-d023909c0be103f1b02f2ddac0b937fff2d4e4f0.tar.gz podman-d023909c0be103f1b02f2ddac0b937fff2d4e4f0.tar.bz2 podman-d023909c0be103f1b02f2ddac0b937fff2d4e4f0.zip |
add socket information to podman info
this is step 1 to self-discovery of remote ssh connections. we add a remotesocket struct to info to detect what the socket path might be.
Co-authored-by: Jhon Honce <jhonce@redhat.com>
Signed-off-by: Brent Baude <bbaude@redhat.com>
Diffstat (limited to 'pkg/domain')
-rw-r--r-- | pkg/domain/infra/abi/system.go | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/pkg/domain/infra/abi/system.go b/pkg/domain/infra/abi/system.go index 52dfaba7d..9b538b301 100644 --- a/pkg/domain/infra/abi/system.go +++ b/pkg/domain/infra/abi/system.go @@ -25,7 +25,38 @@ import ( ) func (ic *ContainerEngine) Info(ctx context.Context) (*define.Info, error) { - return ic.Libpod.Info() + info, err := ic.Libpod.Info() + if err != nil { + return nil, err + } + xdg, err := util.GetRuntimeDir() + if err != nil { + return nil, err + } + if len(xdg) == 0 { + // If no xdg is returned, assume root socket + xdg = "/run" + } + + // Glue the socket path together + socketPath := filepath.Join(xdg, "podman", "podman.sock") + rs := define.RemoteSocket{ + Path: socketPath, + Exists: false, + } + + // Check if the socket exists + if fi, err := os.Stat(socketPath); err == nil { + if fi.Mode()&os.ModeSocket != 0 { + rs.Exists = true + } + } + // TODO + // it was suggested future versions of this could perform + // a ping on the socket for greater confidence the socket is + // actually active. + info.Host.RemoteSocket = &rs + return info, err } func (ic *ContainerEngine) SetupRootless(_ context.Context, cmd *cobra.Command) error { |