summaryrefslogtreecommitdiff
path: root/src/resolve/resolved-link-bus.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-06-12 18:28:30 -0400
committerGitHub <noreply@github.com>2016-06-12 18:28:30 -0400
commitaf4ddf529e5e172962a668fac0bbe2305a2e24a5 (patch)
tree0d1ca129ba7519d1b6361fbe387b6278f2a497d0 /src/resolve/resolved-link-bus.c
parent7f401340b0cfd680a996c89cf2ccfe1b445b34ef (diff)
parent04b764bf76a74943ca652691cfd5b511ed8fe96c (diff)
Merge pull request #3502 from poettering/resolved-flush-cache
resolved: allow clients request cache flushes
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);