]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/dbus-cgroup: actually allow empty assignment for BindNetworkInterface=
authorMike Yuan <me@yhndnzj.com>
Wed, 24 Dec 2025 18:21:41 +0000 (19:21 +0100)
committerMike Yuan <me@yhndnzj.com>
Sat, 27 Dec 2025 22:47:55 +0000 (23:47 +0100)
src/core/dbus-cgroup.c

index 29b59ea7057e2a3a654801447e0166dfa2ec319a..92c59cd4ecf59d6c1a5c4fa1105eb183bab72e37 100644 (file)
@@ -1893,6 +1893,7 @@ int bus_cgroup_set_property(
 
                 return 1;
         }
+
         if (streq(name, "RestrictNetworkInterfaces")) {
                 int is_allow_list;
                 _cleanup_strv_free_ char **l = NULL;
@@ -1958,19 +1959,15 @@ int bus_cgroup_set_property(
                 if (r < 0)
                         return r;
 
-                if (!ifname_valid_full(s, IFNAME_VALID_ALTERNATIVE))
+                if (!isempty(s) && !ifname_valid_full(s, IFNAME_VALID_ALTERNATIVE))
                         return sd_bus_error_setf(reterr_error, SD_BUS_ERROR_INVALID_ARGS, "Invalid interface name: %s", s);
 
                 if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
-                        if (isempty(s))
-                                c->bind_network_interface = mfree(c->bind_network_interface);
-                        else {
-                                r = free_and_strdup_warn(&c->bind_network_interface, s);
-                                if (r < 0)
-                                        return r;
-                        }
-
-                        unit_write_settingf(u, flags, name, "BindNetworkInterface=%s", strempty(s));
+                        r = free_and_strdup_warn(&c->bind_network_interface, empty_to_null(s));
+                        if (r < 0)
+                                return r;
+                        if (r > 0)
+                                unit_write_settingf(u, flags, name, "BindNetworkInterface=%s", s);
                 }
 
                 return 1;