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