systemctl: do not try to acquire triggering units for template units
authorMike Yuan <me@yhndnzj.com>
Sun, 30 Jun 2024 11:12:45 +0000 (13:12 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Fri, 19 Jul 2024 22:33:14 +0000 (00:33 +0200)
(cherry picked from commit 09d6038d833468ba7c24c658597387ef699ca4fd)

src/systemctl/systemctl-util.c

index 0854d3e0aa2d429adaab5a8a5336a4dd63322f5e..38e1f23740ed67da4e49acf1347b9e50b2f7efdf 100644 (file)
@@ -327,14 +327,15 @@ int get_active_triggering_units(sd_bus *bus, const char *unit, bool ignore_maske
         if (r < 0)
                 return r;
 
+        if (unit_name_is_valid(name, UNIT_NAME_TEMPLATE))
+                goto skip;
+
         if (ignore_masked) {
                 r = unit_is_masked(bus, name);
                 if (r < 0)
                         return r;
-                if (r > 0) {
-                        *ret = NULL;
-                        return 0;
-                }
+                if (r > 0)
+                        goto skip;
         }
 
         dbus_path = unit_dbus_path_from_name(name);
@@ -370,6 +371,10 @@ int get_active_triggering_units(sd_bus *bus, const char *unit, bool ignore_maske
 
         *ret = TAKE_PTR(active);
         return 0;
+
+skip:
+        *ret = NULL;
+        return 0;
 }
 
 void warn_triggering_units(sd_bus *bus, const char *unit, const char *operation, bool ignore_masked) {