]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: clean up ambient capability logging
authorMike Yuan <me@yhndnzj.com>
Wed, 31 Jul 2024 16:38:14 +0000 (18:38 +0200)
committerMike Yuan <me@yhndnzj.com>
Wed, 31 Jul 2024 19:40:28 +0000 (21:40 +0200)
Follow-up for e0ebc81b2d194206c519375394bd67baa19e67ce

src/core/executor.c
src/core/main.c

index acd0872d23e8db669d816fff6c3e6dc348cd5694..23dcf6b57f73b465c203b557b2ca14be1cd2104f 100644 (file)
@@ -210,7 +210,9 @@ static int run(int argc, char *argv[]) {
         /* Clear ambient capabilities, so services do not inherit them implicitly. Dropping them does
          * not affect the permitted and effective sets which are important for the executor itself to
          * operate. */
-        capability_ambient_set_apply(0, /* also_inherit= */ false);
+        r = capability_ambient_set_apply(0, /* also_inherit= */ false);
+        if (r < 0)
+                log_warning_errno(r, "Failed to clear ambient capabilities, ignoring: %m");
 
         /* This call would collect all passed fds and enable CLOEXEC. We'll unset it in exec_invoke (flag_fds)
          * for fds that shall be passed to the child.
index 401e4b5b9467ce347c81bf46070732d92f5dbbd0..078b968ae4df08adb8e7a17d6236d59ea819a556 100644 (file)
@@ -2001,7 +2001,7 @@ static int do_reexecute(
 
         r = capability_ambient_set_apply(capability_ambient_set, /* also_inherit= */ false);
         if (r < 0)
-                log_error_errno(r, "Failed to apply the starting ambient set, ignoring: %m.");
+                log_warning_errno(r, "Failed to apply the starting ambient set, ignoring: %m");
 
         args_size = argc + 5;
         args = newa(const char*, args_size);
@@ -2383,6 +2383,7 @@ static int initialize_runtime(
 
         int r;
 
+        assert(original_ambient_set);
         assert(ret_error_message);
 
         /* Sets up various runtime parameters. Many of these initializations are conditionalized:
@@ -2506,7 +2507,7 @@ static int initialize_runtime(
          * Preserve the ambient set for later use with sd-executor processes. */
         r = capability_get_ambient(original_ambient_set);
         if (r < 0)
-                log_error_errno(r, "Failed to save ambient capabilities, ignoring: %m.");
+                log_warning_errno(r, "Failed to save ambient capabilities, ignoring: %m");
 
         /* Clear ambient capabilities, so services do not inherit them implicitly. Dropping them does
          * not affect the permitted and effective sets which are important for the manager itself to