]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: add unmanaged interface checks to Link.Renew and Link.ForceRenew Varlink... 40780/head
authornoxiouz <atiurin@proton.me>
Thu, 19 Mar 2026 11:50:26 +0000 (11:50 +0000)
committernoxiouz <atiurin@proton.me>
Thu, 19 Mar 2026 11:50:45 +0000 (11:50 +0000)
The D-Bus counterparts (bus_link_method_renew, bus_link_method_force_renew)
reject calls on unmanaged interfaces with BUS_ERROR_UNMANAGED_INTERFACE,
but the Varlink methods silently succeed. Add the same guard to both
Varlink methods, returning io.systemd.Network.Link.InterfaceUnmanaged,
and declare the error in the IDL.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
src/network/networkctl-link-info.c
src/network/networkd-link-varlink.c
src/shared/varlink-io.systemd.Network.Link.c

index 05990bffbc83e8f650852f5b6dc86e7c7f7a6d73..0b40b442537ac901d7068dbe4bd30ea0a61f9cae 100644 (file)
@@ -2,8 +2,8 @@
 
 #include <linux/if_tunnel.h>
 
-#include "sd-netlink.h"
 #include "sd-json.h"
+#include "sd-netlink.h"
 
 #include "alloc-util.h"
 #include "device-util.h"
index 5864132ef82fc46d7888d2a6e1e3b79be8ae9585..c802c7fb43f68abd34222095f5e0f093bd68058c 100644 (file)
@@ -136,6 +136,9 @@ int vl_method_link_renew(sd_varlink *vlink, sd_json_variant *parameters, sd_varl
         if (r != 0)
                 return r;
 
+        if (!link->network)
+                return sd_varlink_error(vlink, "io.systemd.Network.Link.InterfaceUnmanaged", NULL);
+
         r = varlink_verify_polkit_async(
                         vlink,
                         manager->bus,
@@ -163,6 +166,9 @@ int vl_method_link_force_renew(sd_varlink *vlink, sd_json_variant *parameters, s
         if (r != 0)
                 return r;
 
+        if (!link->network)
+                return sd_varlink_error(vlink, "io.systemd.Network.Link.InterfaceUnmanaged", NULL);
+
         r = varlink_verify_polkit_async(
                         vlink,
                         manager->bus,
index 5474e5e47539364f1635d5c9de0c17fa2cebbf83..82807939e32298ee30c76e8ec5a5058651d2a30b 100644 (file)
@@ -41,6 +41,8 @@ static SD_VARLINK_DEFINE_METHOD(
                 VARLINK_NETWORK_INTERFACE_INPUTS,
                 VARLINK_DEFINE_POLKIT_INPUT);
 
+static SD_VARLINK_DEFINE_ERROR(InterfaceUnmanaged);
+
 SD_VARLINK_DEFINE_INTERFACE(
                 io_systemd_Network_Link,
                 "io.systemd.Network.Link",
@@ -56,6 +58,8 @@ SD_VARLINK_DEFINE_INTERFACE(
                 &vl_method_Reconfigure,
                 SD_VARLINK_SYMBOL_COMMENT("Describe the specified link by index or name."),
                 &vl_method_Describe,
+                SD_VARLINK_SYMBOL_COMMENT("The specified interface is not managed by systemd-networkd."),
+                &vl_error_InterfaceUnmanaged,
                 &vl_type_Address,
                 &vl_type_BitRates,
                 &vl_type_DHCPLease,