valeriyvdovin / rpms / systemd

Forked from rpms/systemd 4 years ago
Clone

Blame SOURCES/0415-virt-add-possibility-to-skip-the-check-for-chroot.patch

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