ryantimwilson / rpms / systemd

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