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>,
|
||||
<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
|
||||
may be used to configure additional per-interface DNSSEC NTA domains. For details about these settings, their
|
||||
possible values and their effect, see the corresponding options in
|
||||
may be used to configure additional per-interface DNSSEC NTA domains.</para></listitem>
|
||||
|
||||
<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>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
|
|
@ -1930,6 +1930,9 @@ static int verb_dns(int argc, char **argv, void *userdata) {
|
|||
if (r < 0)
|
||||
return bus_log_create_error(r);
|
||||
|
||||
/* If only argument is the empty string, then call SetLinkDNS() with an
|
||||
* 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;
|
||||
|
||||
|
@ -1953,6 +1956,7 @@ static int verb_dns(int argc, char **argv, void *userdata) {
|
|||
if (r < 0)
|
||||
return bus_log_create_error(r);
|
||||
}
|
||||
}
|
||||
|
||||
r = sd_bus_message_close_container(req);
|
||||
if (r < 0)
|
||||
|
@ -2010,6 +2014,9 @@ static int verb_domain(int argc, char **argv, void *userdata) {
|
|||
if (r < 0)
|
||||
return bus_log_create_error(r);
|
||||
|
||||
/* If only argument is the empty string, then call SetLinkDomains() with an
|
||||
* 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;
|
||||
|
||||
|
@ -2027,6 +2034,7 @@ static int verb_domain(int argc, char **argv, void *userdata) {
|
|||
if (r < 0)
|
||||
return bus_log_create_error(r);
|
||||
}
|
||||
}
|
||||
|
||||
r = sd_bus_message_close_container(req);
|
||||
if (r < 0)
|
||||
|
@ -2209,6 +2217,7 @@ static int verb_nta(int argc, char **argv, void *userdata) {
|
|||
sd_bus *bus = userdata;
|
||||
char **p;
|
||||
int r;
|
||||
bool clear;
|
||||
|
||||
assert(bus);
|
||||
|
||||
|
@ -2222,6 +2231,11 @@ static int verb_nta(int argc, char **argv, void *userdata) {
|
|||
if (argc == 2)
|
||||
return status_ifindex(bus, arg_ifindex, NULL, STATUS_NTA, NULL);
|
||||
|
||||
/* If only argument is the empty string, then call SetLinkDNSSECNegativeTrustAnchors()
|
||||
* with an empty list, which will clear the list of domains for an interface. */
|
||||
clear = strv_equal(argv + 2, STRV_MAKE(""));
|
||||
|
||||
if (!clear)
|
||||
STRV_FOREACH(p, argv + 2) {
|
||||
r = dns_name_is_valid(*p);
|
||||
if (r < 0)
|
||||
|
@ -2246,7 +2260,7 @@ static int verb_nta(int argc, char **argv, void *userdata) {
|
|||
if (r < 0)
|
||||
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)
|
||||
return bus_log_create_error(r);
|
||||
|
||||
|
|
Loading…
Reference in a new issue