From a83398b6761c5139a4efa4b5f914684ab2d6f541 Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@collabora.com>
Date: Thu, 14 Jan 2021 11:24:23 +0000
Subject: [PATCH] system-info: Add support for detecting Podman

Podman is a lot like Docker, but can run unprivileged.

Signed-off-by: Simon McVittie <smcv@collabora.com>
---
 steam-runtime-tools/system-info.c | 9 +++++++++
 steam-runtime-tools/system-info.h | 2 ++
 2 files changed, 11 insertions(+)

diff --git a/steam-runtime-tools/system-info.c b/steam-runtime-tools/system-info.c
index 4862b6fda..3e9652010 100644
--- a/steam-runtime-tools/system-info.c
+++ b/steam-runtime-tools/system-info.c
@@ -3469,6 +3469,7 @@ static const ContainerTypeName container_types[] =
 {
   { SRT_CONTAINER_TYPE_DOCKER, "docker" },
   { SRT_CONTAINER_TYPE_FLATPAK, "flatpak" },
+  { SRT_CONTAINER_TYPE_PODMAN, "podman" },
   { SRT_CONTAINER_TYPE_PRESSURE_VESSEL, "pressure-vessel" },
 };
 
@@ -3566,6 +3567,14 @@ ensure_container_info (SrtSystemInfo *self)
       goto out;
     }
 
+  if (_srt_file_test_in_sysroot (self->sysroot, self->sysroot_fd,
+                                 "/run/.containerenv", G_FILE_TEST_EXISTS))
+    {
+      self->container.type = SRT_CONTAINER_TYPE_PODMAN;
+      g_debug ("Podman based on /run/.containerenv");
+      goto out;
+    }
+
   if (_srt_file_get_contents_in_sysroot (self->sysroot_fd,
                                          "/proc/1/cgroup",
                                          &contents, NULL, NULL))
diff --git a/steam-runtime-tools/system-info.h b/steam-runtime-tools/system-info.h
index 63f1b8008..4c57ec8cd 100644
--- a/steam-runtime-tools/system-info.h
+++ b/steam-runtime-tools/system-info.h
@@ -82,6 +82,7 @@ typedef enum
  * @SRT_CONTAINER_TYPE_PRESSURE_VESSEL: Running in a Steam Runtime container
  *  using pressure-vessel
  * @SRT_CONTAINER_TYPE_DOCKER: Running in a Docker container
+ * @SRT_CONTAINER_TYPE_PODMAN: Running in a Podman container
  *
  * A type of container.
  */
@@ -91,6 +92,7 @@ typedef enum
   SRT_CONTAINER_TYPE_FLATPAK,
   SRT_CONTAINER_TYPE_PRESSURE_VESSEL,
   SRT_CONTAINER_TYPE_DOCKER,
+  SRT_CONTAINER_TYPE_PODMAN,
   SRT_CONTAINER_TYPE_UNKNOWN = -1
 } SrtContainerType;
 
-- 
GitLab