network: add unmanaged interface checks to Link.Renew and Link.ForceRenew Varlink methods

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>
This commit is contained in:
noxiouz
2026-03-19 11:50:45 +00:00
co-authored by Claude Opus 4.6
parent 1416d3b69c
commit 7d5ec30862
3 changed files with 11 additions and 1 deletions
+1 -1
View 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"
+6
View 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,
@@ -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,