summaryrefslogtreecommitdiff
path: root/src/resolve/resolved-link-bus.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/resolve/resolved-link-bus.c')
-rw-r--r--src/resolve/resolved-link-bus.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/resolve/resolved-link-bus.c b/src/resolve/resolved-link-bus.c
index 6aff427192..bfb87d78e7 100644
--- a/src/resolve/resolved-link-bus.c
+++ b/src/resolve/resolved-link-bus.c
@@ -18,6 +18,7 @@
***/
#include "alloc-util.h"
+#include "bus-common-errors.h"
#include "bus-util.h"
#include "parse-util.h"
#include "resolve-util.h"
@@ -158,6 +159,17 @@ static int property_get_dnssec_supported(
return sd_bus_message_append(reply, "b", link_dnssec_supported(l));
}
+static int verify_unmanaged_link(Link *l, sd_bus_error *error) {
+ assert(l);
+
+ if (l->flags & IFF_LOOPBACK)
+ return sd_bus_error_setf(error, BUS_ERROR_LINK_BUSY, "Link %s is loopback device.", l->name);
+ if (l->is_managed)
+ return sd_bus_error_setf(error, BUS_ERROR_LINK_BUSY, "Link %s is managed.", l->name);
+
+ return 0;
+}
+
int bus_link_method_set_dns_servers(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_free_ struct in_addr_data *dns = NULL;
size_t allocated = 0, n = 0;
@@ -168,6 +180,10 @@ int bus_link_method_set_dns_servers(sd_bus_message *message, void *userdata, sd_
assert(message);
assert(l);
+ r = verify_unmanaged_link(l, error);
+ if (r < 0)
+ return r;
+
r = sd_bus_message_enter_container(message, 'a', "(iay)");
if (r < 0)
return r;
@@ -249,6 +265,10 @@ int bus_link_method_set_domains(sd_bus_message *message, void *userdata, sd_bus_
assert(message);
assert(l);
+ r = verify_unmanaged_link(l, error);
+ if (r < 0)
+ return r;
+
r = sd_bus_message_enter_container(message, 'a', "(sb)");
if (r < 0)
return r;
@@ -328,6 +348,10 @@ int bus_link_method_set_llmnr(sd_bus_message *message, void *userdata, sd_bus_er
assert(message);
assert(l);
+ r = verify_unmanaged_link(l, error);
+ if (r < 0)
+ return r;
+
r = sd_bus_message_read(message, "s", &llmnr);
if (r < 0)
return r;
@@ -356,6 +380,10 @@ int bus_link_method_set_mdns(sd_bus_message *message, void *userdata, sd_bus_err
assert(message);
assert(l);
+ r = verify_unmanaged_link(l, error);
+ if (r < 0)
+ return r;
+
r = sd_bus_message_read(message, "s", &mdns);
if (r < 0)
return r;
@@ -384,6 +412,10 @@ int bus_link_method_set_dnssec(sd_bus_message *message, void *userdata, sd_bus_e
assert(message);
assert(l);
+ r = verify_unmanaged_link(l, error);
+ if (r < 0)
+ return r;
+
r = sd_bus_message_read(message, "s", &dnssec);
if (r < 0)
return r;
@@ -411,6 +443,10 @@ int bus_link_method_set_dnssec_negative_trust_anchors(sd_bus_message *message, v
assert(message);
assert(l);
+ r = verify_unmanaged_link(l, error);
+ if (r < 0)
+ return r;
+
r = sd_bus_message_read_strv(message, &ntas);
if (r < 0)
return r;
@@ -442,10 +478,15 @@ int bus_link_method_set_dnssec_negative_trust_anchors(sd_bus_message *message, v
int bus_link_method_revert(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Link *l = userdata;
+ int r;
assert(message);
assert(l);
+ r = verify_unmanaged_link(l, error);
+ if (r < 0)
+ return r;
+
link_flush_settings(l);
link_allocate_scopes(l);
link_add_rrs(l, false);