chiark / gitweb /
resolve-host: make arg_type an int
[elogind.git] / src / resolve / resolved-bus.c
index bfb060d86bcdca5541a1645aad16681d55132ad0..e158fdc22b188bd5f36d9f338f27fd5771b0f947 100644 (file)
@@ -22,8 +22,8 @@
 #include "bus-errors.h"
 #include "bus-util.h"
 
-#include "resolved.h"
 #include "resolved-dns-domain.h"
+#include "resolved-bus.h"
 
 static int reply_query_state(DnsQuery *q) {
         _cleanup_free_ char *ip = NULL;
@@ -275,7 +275,8 @@ static int bus_method_resolve_hostname(sd_bus *bus, sd_bus_message *message, voi
         if (!IN_SET(family, AF_INET, AF_INET6, AF_UNSPEC))
                 return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Unknown address family %i", family);
 
-        if (!hostname_is_valid(hostname))
+        r = dns_name_normalize(hostname, NULL);
+        if (r < 0)
                 return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid hostname '%s'", hostname);
 
         question = dns_question_new(family == AF_UNSPEC ? 2 : 1);
@@ -551,7 +552,6 @@ finish:
 static int bus_method_resolve_record(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
         _cleanup_(dns_resource_key_unrefp) DnsResourceKey *key = NULL;
         _cleanup_(dns_question_unrefp) DnsQuestion *question = NULL;
-        _cleanup_free_ char *reverse = NULL;
         Manager *m = userdata;
         DnsQuery *q;
         int r;
@@ -566,6 +566,10 @@ static int bus_method_resolve_record(sd_bus *bus, sd_bus_message *message, void
         if (r < 0)
                 return r;
 
+        r = dns_name_normalize(name, NULL);
+        if (r < 0)
+                return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid name '%s'", name);
+
         question = dns_question_new(1);
         if (!question)
                 return -ENOMEM;