]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared/cgroup-show: do not format path twice
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 9 Aug 2023 14:43:28 +0000 (16:43 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 16 Aug 2023 10:52:56 +0000 (12:52 +0200)
Also, invert the "negative" condition to positive so that it matches the assert
right above. Also, print the path in the debug message.

src/shared/cgroup-show.c

index 0fd8d73303d007f6d5b6411e8ebb52933471b350..d2d0339910844f9e8256212c0a222d5b7d350095 100644 (file)
@@ -134,21 +134,23 @@ static int is_delegated(int cgfd, const char *path) {
 
         assert(cgfd >= 0 || path);
 
-        r = getxattr_malloc(cgfd < 0 ? path : FORMAT_PROC_FD_PATH(cgfd), "trusted.delegate", &b);
+        const char *t = cgfd >= 0 ? FORMAT_PROC_FD_PATH(cgfd) : path;
+
+        r = getxattr_malloc(t, "trusted.delegate", &b);
         if (ERRNO_IS_NEG_XATTR_ABSENT(r)) {
                 /* If the trusted xattr isn't set (preferred), then check the untrusted one. Under the
                  * assumption that whoever is trusted enough to own the cgroup, is also trusted enough to
                  * decide if it is delegated or not this should be safe. */
-                r = getxattr_malloc(cgfd < 0 ? path : FORMAT_PROC_FD_PATH(cgfd), "user.delegate", &b);
+                r = getxattr_malloc(t, "user.delegate", &b);
                 if (ERRNO_IS_NEG_XATTR_ABSENT(r))
                         return false;
         }
         if (r < 0)
-                return log_debug_errno(r, "Failed to read delegate xattr, ignoring: %m");
+                return log_debug_errno(r, "Failed to read delegate xattr from %s, ignoring: %m", t);
 
         r = parse_boolean(b);
         if (r < 0)
-                return log_debug_errno(r, "Failed to parse delegate xattr boolean value, ignoring: %m");
+                return log_debug_errno(r, "Failed to parse delegate xattr from %s, ignoring: %m", t);
 
         return r;
 }