daandemeyer / rpms / systemd

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