mirror of
https://github.com/systemd/systemd
synced 2024-10-14 20:17:52 +00:00
resolvectl: Take empty string argument to clear lists in "dns", "domain" and "nta" options
The current CLI does not support a way to clear these lists, since without any additional arguments, the command will list the current values. Introduce a new way to clear the lists by passing a single '' argument to these subcommands. Update the man page to document this. Tested: $ build/resolvectl domain eth1 Link 3 (eth1): ~. $ build/resolvectl domain eth1 '' $ build/resolvectl domain eth1 Link 3 (eth1): $ build/resolvectl domain eth1 '~.' '~example.com' $ build/resolvectl domain eth1 Link 3 (eth1): ~. ~example.com $ build/resolvectl domain eth1 '' $ build/resolvectl domain eth1 Link 3 (eth1): $ build/resolvectl domain eth1 '~.' $ build/resolvectl domain eth1 Link 3 (eth1): ~. And similar for "dns" and "nta".
This commit is contained in:
parent
81d39f0d2c
commit
06c28aa0d8
|
@ -258,8 +258,12 @@
|
||||||
<literal>~</literal>, and configures a per-interface search or route-only domain. The <option>llmnr</option>,
|
<literal>~</literal>, and configures a per-interface search or route-only domain. The <option>llmnr</option>,
|
||||||
<option>mdns</option>, <option>dnssec</option> and <option>dnsovertls</option> commands may be used to configure
|
<option>mdns</option>, <option>dnssec</option> and <option>dnsovertls</option> commands may be used to configure
|
||||||
the per-interface LLMNR, MulticastDNS, DNSSEC and DNSOverTLS settings. Finally, <option>nta</option> command
|
the per-interface LLMNR, MulticastDNS, DNSSEC and DNSOverTLS settings. Finally, <option>nta</option> command
|
||||||
may be used to configure additional per-interface DNSSEC NTA domains. For details about these settings, their
|
may be used to configure additional per-interface DNSSEC NTA domains.</para></listitem>
|
||||||
possible values and their effect, see the corresponding options in
|
|
||||||
|
<listitem><para>Options <option>dns</option>, <option>domain</option> and <option>nta</option> can take
|
||||||
|
a single empty string argument to clear their respective value lists.</para></listitem>
|
||||||
|
|
||||||
|
<listitem><para>For details about these settings, their possible values and their effect, see the corresponding options in
|
||||||
<citerefentry><refentrytitle>systemd.network</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
|
<citerefentry><refentrytitle>systemd.network</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
|
@ -1930,28 +1930,32 @@ static int verb_dns(int argc, char **argv, void *userdata) {
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return bus_log_create_error(r);
|
return bus_log_create_error(r);
|
||||||
|
|
||||||
STRV_FOREACH(p, argv + 2) {
|
/* If only argument is the empty string, then call SetLinkDNS() with an
|
||||||
struct in_addr_data data;
|
* empty list, which will clear the list of domains for an interface. */
|
||||||
|
if (!strv_equal(argv + 2, STRV_MAKE(""))) {
|
||||||
|
STRV_FOREACH(p, argv + 2) {
|
||||||
|
struct in_addr_data data;
|
||||||
|
|
||||||
r = in_addr_from_string_auto(*p, &data.family, &data.address);
|
r = in_addr_from_string_auto(*p, &data.family, &data.address);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to parse DNS server address: %s", *p);
|
return log_error_errno(r, "Failed to parse DNS server address: %s", *p);
|
||||||
|
|
||||||
r = sd_bus_message_open_container(req, 'r', "iay");
|
r = sd_bus_message_open_container(req, 'r', "iay");
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return bus_log_create_error(r);
|
return bus_log_create_error(r);
|
||||||
|
|
||||||
r = sd_bus_message_append(req, "i", data.family);
|
r = sd_bus_message_append(req, "i", data.family);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return bus_log_create_error(r);
|
return bus_log_create_error(r);
|
||||||
|
|
||||||
r = sd_bus_message_append_array(req, 'y', &data.address, FAMILY_ADDRESS_SIZE(data.family));
|
r = sd_bus_message_append_array(req, 'y', &data.address, FAMILY_ADDRESS_SIZE(data.family));
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return bus_log_create_error(r);
|
return bus_log_create_error(r);
|
||||||
|
|
||||||
r = sd_bus_message_close_container(req);
|
r = sd_bus_message_close_container(req);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return bus_log_create_error(r);
|
return bus_log_create_error(r);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
r = sd_bus_message_close_container(req);
|
r = sd_bus_message_close_container(req);
|
||||||
|
@ -2010,22 +2014,26 @@ static int verb_domain(int argc, char **argv, void *userdata) {
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return bus_log_create_error(r);
|
return bus_log_create_error(r);
|
||||||
|
|
||||||
STRV_FOREACH(p, argv + 2) {
|
/* If only argument is the empty string, then call SetLinkDomains() with an
|
||||||
const char *n;
|
* empty list, which will clear the list of domains for an interface. */
|
||||||
|
if (!strv_equal(argv + 2, STRV_MAKE(""))) {
|
||||||
|
STRV_FOREACH(p, argv + 2) {
|
||||||
|
const char *n;
|
||||||
|
|
||||||
n = **p == '~' ? *p + 1 : *p;
|
n = **p == '~' ? *p + 1 : *p;
|
||||||
|
|
||||||
r = dns_name_is_valid(n);
|
r = dns_name_is_valid(n);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to validate specified domain %s: %m", n);
|
return log_error_errno(r, "Failed to validate specified domain %s: %m", n);
|
||||||
if (r == 0) {
|
if (r == 0) {
|
||||||
log_error("Domain not valid: %s", n);
|
log_error("Domain not valid: %s", n);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
r = sd_bus_message_append(req, "(sb)", n, **p == '~');
|
||||||
|
if (r < 0)
|
||||||
|
return bus_log_create_error(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
r = sd_bus_message_append(req, "(sb)", n, **p == '~');
|
|
||||||
if (r < 0)
|
|
||||||
return bus_log_create_error(r);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
r = sd_bus_message_close_container(req);
|
r = sd_bus_message_close_container(req);
|
||||||
|
@ -2209,6 +2217,7 @@ static int verb_nta(int argc, char **argv, void *userdata) {
|
||||||
sd_bus *bus = userdata;
|
sd_bus *bus = userdata;
|
||||||
char **p;
|
char **p;
|
||||||
int r;
|
int r;
|
||||||
|
bool clear;
|
||||||
|
|
||||||
assert(bus);
|
assert(bus);
|
||||||
|
|
||||||
|
@ -2222,15 +2231,20 @@ static int verb_nta(int argc, char **argv, void *userdata) {
|
||||||
if (argc == 2)
|
if (argc == 2)
|
||||||
return status_ifindex(bus, arg_ifindex, NULL, STATUS_NTA, NULL);
|
return status_ifindex(bus, arg_ifindex, NULL, STATUS_NTA, NULL);
|
||||||
|
|
||||||
STRV_FOREACH(p, argv + 2) {
|
/* If only argument is the empty string, then call SetLinkDNSSECNegativeTrustAnchors()
|
||||||
r = dns_name_is_valid(*p);
|
* with an empty list, which will clear the list of domains for an interface. */
|
||||||
if (r < 0)
|
clear = strv_equal(argv + 2, STRV_MAKE(""));
|
||||||
return log_error_errno(r, "Failed to validate specified domain %s: %m", *p);
|
|
||||||
if (r == 0) {
|
if (!clear)
|
||||||
log_error("Domain not valid: %s", *p);
|
STRV_FOREACH(p, argv + 2) {
|
||||||
return -EINVAL;
|
r = dns_name_is_valid(*p);
|
||||||
|
if (r < 0)
|
||||||
|
return log_error_errno(r, "Failed to validate specified domain %s: %m", *p);
|
||||||
|
if (r == 0) {
|
||||||
|
log_error("Domain not valid: %s", *p);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
r = sd_bus_message_new_method_call(
|
r = sd_bus_message_new_method_call(
|
||||||
bus,
|
bus,
|
||||||
|
@ -2246,7 +2260,7 @@ static int verb_nta(int argc, char **argv, void *userdata) {
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return bus_log_create_error(r);
|
return bus_log_create_error(r);
|
||||||
|
|
||||||
r = sd_bus_message_append_strv(req, argv + 2);
|
r = sd_bus_message_append_strv(req, clear ? NULL : argv + 2);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return bus_log_create_error(r);
|
return bus_log_create_error(r);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue