anitazha / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone

Blame SOURCES/0357-test-process-util-skip-several-verifications-when-ru.patch

be3800
From 6f3d631982c7914f63f1e5e8eb171a1646105395 Mon Sep 17 00:00:00 2001
be3800
From: Yu Watanabe <watanabe.yu+github@gmail.com>
be3800
Date: Thu, 20 Sep 2018 16:08:38 +0900
be3800
Subject: [PATCH] test-process-util: skip several verifications when running in
be3800
 unprivileged container
be3800
be3800
(cherry picked from commit 767eab47501b06327a0e6030e5c54860a3fc427f)
be3800
(cherry picked from commit 2bc26a0ac181124ba06022bcf4744ae7d5bdcc9d)
be3800
be3800
Resolves: #1836979
be3800
---
be3800
 src/test/test-process-util.c | 13 +++++++++----
be3800
 1 file changed, 9 insertions(+), 4 deletions(-)
be3800
be3800
diff --git a/src/test/test-process-util.c b/src/test/test-process-util.c
be3800
index fd4d17408d..26e3247993 100644
be3800
--- a/src/test/test-process-util.c
be3800
+++ b/src/test/test-process-util.c
be3800
@@ -394,12 +394,17 @@ static void test_rename_process_now(const char *p, int ret) {
be3800
         log_info("comm = <%s>", comm);
be3800
         assert_se(strneq(comm, p, TASK_COMM_LEN-1));
be3800
 
be3800
-        assert_se(get_process_cmdline(0, 0, false, &cmdline) >= 0);
be3800
+        r = get_process_cmdline(0, 0, false, &cmdline);
be3800
+        assert_se(r >= 0);
be3800
         /* we cannot expect cmdline to be renamed properly without privileges */
be3800
         if (geteuid() == 0) {
be3800
-                log_info("cmdline = <%s>", cmdline);
be3800
-                assert_se(strneq(p, cmdline, STRLEN("test-process-util")));
be3800
-                assert_se(startswith(p, cmdline));
be3800
+                if (r == 0 && detect_container() > 0)
be3800
+                        log_info("cmdline = <%s> (not verified, Running in unprivileged container?)", cmdline);
be3800
+                else {
be3800
+                        log_info("cmdline = <%s>", cmdline);
be3800
+                        assert_se(strneq(p, cmdline, STRLEN("test-process-util")));
be3800
+                        assert_se(startswith(p, cmdline));
be3800
+                }
be3800
         } else
be3800
                 log_info("cmdline = <%s> (not verified)", cmdline);
be3800
 }