daandemeyer / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
803fb7
From f3750cbfd21b2e5f6f46077082f60e3a74ee4807 Mon Sep 17 00:00:00 2001
803fb7
From: Lukas Nykryn <lnykryn@redhat.com>
803fb7
Date: Mon, 17 Oct 2016 08:09:58 +0200
803fb7
Subject: [PATCH] virt: add possibility to skip the check for chroot
803fb7
803fb7
Cherry-picked from: 08a28eeca70eeefb55af61191b63e4c938daca73
803fb7
Resolves: #1379852
803fb7
---
803fb7
 src/shared/env-util.c | 10 ++++++++++
803fb7
 src/shared/env-util.h |  2 ++
803fb7
 src/shared/util.c     |  3 +++
803fb7
 3 files changed, 15 insertions(+)
803fb7
803fb7
diff --git a/src/shared/env-util.c b/src/shared/env-util.c
803fb7
index 038246d21..e8da4c978 100644
803fb7
--- a/src/shared/env-util.c
803fb7
+++ b/src/shared/env-util.c
803fb7
@@ -449,3 +449,13 @@ char **strv_env_clean_with_callback(char **e, void (*invalid_callback)(const cha
803fb7
 
803fb7
         return e;
803fb7
 }
803fb7
+
803fb7
+int getenv_bool(const char *p) {
803fb7
+        const char *e;
803fb7
+
803fb7
+        e = getenv(p);
803fb7
+        if (!e)
803fb7
+                return -ENXIO;
803fb7
+
803fb7
+        return parse_boolean(e);
803fb7
+}
803fb7
diff --git a/src/shared/env-util.h b/src/shared/env-util.h
803fb7
index 618441a65..252d87be1 100644
803fb7
--- a/src/shared/env-util.h
803fb7
+++ b/src/shared/env-util.h
803fb7
@@ -45,3 +45,5 @@ char **strv_env_unset_many(char **l, ...) _sentinel_;
803fb7
 
803fb7
 char *strv_env_get_n(char **l, const char *name, size_t k) _pure_;
803fb7
 char *strv_env_get(char **x, const char *n) _pure_;
803fb7
+
803fb7
+int getenv_bool(const char *p);
803fb7
diff --git a/src/shared/util.c b/src/shared/util.c
803fb7
index 357fbfe7d..eab5ab816 100644
803fb7
--- a/src/shared/util.c
803fb7
+++ b/src/shared/util.c
803fb7
@@ -3776,6 +3776,9 @@ int files_same(const char *filea, const char *fileb) {
803fb7
 int running_in_chroot(void) {
803fb7
         int ret;
803fb7
 
803fb7
+        if (getenv_bool("SYSTEMD_IGNORE_CHROOT") > 0)
803fb7
+                return 0;
803fb7
+
803fb7
         ret = files_same("/proc/1/root", "/");
803fb7
         if (ret < 0)
803fb7
                 return ret;