]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemctl: check if unit is masked in unit_find_paths()
authorgvenugo3 <gvenugo3@asu.edu>
Tue, 11 Nov 2025 16:55:59 +0000 (09:55 -0700)
committergvenugo3 <gvenugo3@asu.edu>
Tue, 11 Nov 2025 16:55:59 +0000 (09:55 -0700)
When operating in client-side mode (force_client_side=true), unit_find_paths()
now checks if the unit file is masked (symlinked to /dev/null or empty) and
returns -ERFKILL, matching the behavior of the server-side path.

This centralizes masked unit detection in one place, making it consistent
across both client-side and server-side operations.

src/systemctl/systemctl-util.c

index 71f14b8abf3c20e4291bf9cc5d73d41afe6df93b..20bae11fa2b9ac333dcd42c5de2b7e6199799797 100644 (file)
@@ -29,6 +29,7 @@
 #include "reboot-util.h"
 #include "runtime-scope.h"
 #include "set.h"
+#include "stat-util.h"
 #include "string-util.h"
 #include "strv.h"
 #include "systemctl.h"
@@ -589,6 +590,13 @@ int unit_find_paths(
                         return log_error_errno(r, "Failed to find fragment for '%s': %m", unit_name);
 
                 if (_path) {
+                        /* Check if unit is masked (symlinked to /dev/null or empty) */
+                        r = null_or_empty_path(_path);
+                        if (r < 0)
+                                return log_error_errno(r, "Failed to check if '%s' is masked: %m", unit_name);
+                        if (r > 0)
+                                return -ERFKILL; /* special case: no logging */
+
                         path = strdup(_path);
                         if (!path)
                                 return log_oom();