summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--man/systemd-detect-virt.xml5
-rw-r--r--man/systemd.unit.xml1
-rw-r--r--src/basic/virt.c19
-rw-r--r--src/basic/virt.h1
4 files changed, 26 insertions, 0 deletions
diff --git a/man/systemd-detect-virt.xml b/man/systemd-detect-virt.xml
index d599ac20f1..77bdd80f32 100644
--- a/man/systemd-detect-virt.xml
+++ b/man/systemd-detect-virt.xml
@@ -167,6 +167,11 @@
<entry><varname>wsl</varname></entry>
<entry><ulink url="https://docs.microsoft.com/en-us/windows/wsl/about">Windows Subsystem for Linux</ulink></entry>
</row>
+
+ <row>
+ <entry><varname>proot</varname></entry>
+ <entry><ulink url="https://proot-me.github.io/">proot</ulink> userspace chroot/bind mount emulation</entry>
+ </row>
</tbody>
</tgroup>
</table>
diff --git a/man/systemd.unit.xml b/man/systemd.unit.xml
index d0de9aa500..c26937e752 100644
--- a/man/systemd.unit.xml
+++ b/man/systemd.unit.xml
@@ -1170,6 +1170,7 @@
<literal>podman</literal>,
<literal>rkt</literal>,
<literal>wsl</literal>,
+ <literal>proot</literal>,
<literal>acrn</literal> to test
against a specific implementation, or
<literal>private-users</literal> to check whether we are running in a user namespace. See
diff --git a/src/basic/virt.c b/src/basic/virt.c
index f567696265..c22bcf9aea 100644
--- a/src/basic/virt.c
+++ b/src/basic/virt.c
@@ -441,6 +441,7 @@ static const char *const container_table[_VIRTUALIZATION_MAX] = {
[VIRTUALIZATION_PODMAN] = "podman",
[VIRTUALIZATION_RKT] = "rkt",
[VIRTUALIZATION_WSL] = "wsl",
+ [VIRTUALIZATION_PROOT] = "proot",
};
DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING(container, int);
@@ -449,6 +450,7 @@ int detect_container(void) {
static thread_local int cached_found = _VIRTUALIZATION_INVALID;
_cleanup_free_ char *m = NULL;
_cleanup_free_ char *o = NULL;
+ _cleanup_free_ char *p = NULL;
const char *e = NULL;
int r;
@@ -472,6 +474,22 @@ int detect_container(void) {
goto finish;
}
+ /* proot doesn't use PID namespacing, so we can just check if we have a matching tracer for this
+ * invocation without worrying about it being elsewhere.
+ */
+ r = get_proc_field("/proc/self/status", "TracerPid", WHITESPACE, &p);
+ if (r == 0 && !streq(p, "0")) {
+ pid_t ptrace_pid;
+ r = parse_pid(p, &ptrace_pid);
+ if (r == 0) {
+ const char *pf = procfs_file_alloca(ptrace_pid, "comm");
+ _cleanup_free_ char *ptrace_comm = NULL;
+ r = read_one_line_file(pf, &ptrace_comm);
+ if (r >= 0 && startswith(ptrace_comm, "proot"))
+ return VIRTUALIZATION_PROOT;
+ }
+ }
+
if (getpid_cached() == 1) {
/* If we are PID 1 we can just check our own environment variable, and that's authoritative.
* We distinguish three cases:
@@ -660,6 +678,7 @@ static const char *const virtualization_table[_VIRTUALIZATION_MAX] = {
[VIRTUALIZATION_PODMAN] = "podman",
[VIRTUALIZATION_RKT] = "rkt",
[VIRTUALIZATION_WSL] = "wsl",
+ [VIRTUALIZATION_PROOT] = "proot",
[VIRTUALIZATION_CONTAINER_OTHER] = "container-other",
};
diff --git a/src/basic/virt.h b/src/basic/virt.h
index 26f409afd0..d58c582c91 100644
--- a/src/basic/virt.h
+++ b/src/basic/virt.h
@@ -34,6 +34,7 @@ enum {
VIRTUALIZATION_PODMAN,
VIRTUALIZATION_RKT,
VIRTUALIZATION_WSL,
+ VIRTUALIZATION_PROOT,
VIRTUALIZATION_CONTAINER_OTHER,
VIRTUALIZATION_CONTAINER_LAST = VIRTUALIZATION_CONTAINER_OTHER,