Merge pull request #8337 from poettering/resolve-fixes

various resolve-tool fixes
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2018-03-02 13:33:54 +01:00 committed by GitHub
commit a478fb9229
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 13 deletions

View file

@ -104,6 +104,36 @@
<command> --reset-statistics</command> <command> --reset-statistics</command>
</cmdsynopsis> </cmdsynopsis>
<cmdsynopsis>
<command>systemd-resolve</command>
<arg choice="opt" rep="repeat">OPTIONS</arg>
<command> --flush-caches</command>
</cmdsynopsis>
<cmdsynopsis>
<command>systemd-resolve</command>
<arg choice="opt" rep="repeat">OPTIONS</arg>
<command> --reset-server-features</command>
</cmdsynopsis>
<cmdsynopsis>
<command>systemd-resolve</command>
<arg choice="opt" rep="repeat">OPTIONS</arg>
<command> --status</command>
</cmdsynopsis>
<cmdsynopsis>
<command>systemd-resolve</command>
<arg choice="opt" rep="repeat">OPTIONS</arg>
<command> --set-dns=<replaceable>SERVER</replaceable></command> <command> --set-domain=<replaceable>DOMAIN</replaceable> --set-llmnr=<replaceable>MODE</replaceable> --set-mdns=<replaceable>MODE</replaceable> --set-dnssec=<replaceable>MODE</replaceable> --set-nta=<replaceable>DOMAIN</replaceable></command>
</cmdsynopsis>
<cmdsynopsis>
<command>systemd-resolve</command>
<arg choice="opt" rep="repeat">OPTIONS</arg>
<command> --revert</command>
</cmdsynopsis>
</refsynopsisdiv> </refsynopsisdiv>
<refsect1> <refsect1>

View file

@ -88,7 +88,7 @@ static char *arg_set_dnssec = NULL;
static char **arg_set_nta = NULL; static char **arg_set_nta = NULL;
static ServiceFamily service_family_from_string(const char *s) { static ServiceFamily service_family_from_string(const char *s) {
if (s == NULL || streq(s, "tcp")) if (!s || streq(s, "tcp"))
return SERVICE_FAMILY_TCP; return SERVICE_FAMILY_TCP;
if (streq(s, "udp")) if (streq(s, "udp"))
return SERVICE_FAMILY_UDP; return SERVICE_FAMILY_UDP;
@ -1940,12 +1940,10 @@ static int parse_argv(int argc, char *argv[]) {
arg_family = AF_INET6; arg_family = AF_INET6;
break; break;
case 'i': { case 'i':
int ifi; if (parse_ifindex(optarg, &arg_ifindex) < 0) {
int ifi;
if (parse_ifindex(optarg, &ifi) >= 0)
arg_ifindex = ifi;
else {
ifi = if_nametoindex(optarg); ifi = if_nametoindex(optarg);
if (ifi <= 0) if (ifi <= 0)
return log_error_errno(errno, "Unknown interface %s: %m", optarg); return log_error_errno(errno, "Unknown interface %s: %m", optarg);
@ -1954,7 +1952,6 @@ static int parse_argv(int argc, char *argv[]) {
} }
break; break;
}
case 't': case 't':
if (streq(optarg, "help")) { if (streq(optarg, "help")) {
@ -2134,8 +2131,10 @@ static int parse_argv(int argc, char *argv[]) {
r = dns_name_is_valid(p); r = dns_name_is_valid(p);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to validate specified domain %s: %m", p); return log_error_errno(r, "Failed to validate specified domain %s: %m", p);
if (r == 0) if (r == 0) {
return log_error_errno(r, "Domain not valid: %s", p); log_error("Domain not valid: %s", p);
return -EINVAL;
}
r = strv_extend(&arg_set_domain, optarg); r = strv_extend(&arg_set_domain, optarg);
if (r < 0) if (r < 0)
@ -2173,8 +2172,10 @@ static int parse_argv(int argc, char *argv[]) {
r = dns_name_is_valid(optarg); r = dns_name_is_valid(optarg);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to validate specified domain %s: %m", optarg); return log_error_errno(r, "Failed to validate specified domain %s: %m", optarg);
if (r == 0) if (r == 0) {
return log_error_errno(r, "Domain not valid: %s", optarg); log_error("Domain not valid: %s", optarg);
return -EINVAL;
}
r = strv_extend(&arg_set_nta, optarg); r = strv_extend(&arg_set_nta, optarg);
if (r < 0) if (r < 0)
@ -2415,7 +2416,6 @@ int main(int argc, char **argv) {
break; break;
case MODE_SET_LINK: case MODE_SET_LINK:
if (argc > optind) { if (argc > optind) {
log_error("Too many arguments."); log_error("Too many arguments.");

View file

@ -68,6 +68,7 @@ int manager_read_resolv_conf(Manager *m) {
_cleanup_fclose_ FILE *f = NULL; _cleanup_fclose_ FILE *f = NULL;
struct stat st; struct stat st;
char line[LINE_MAX]; char line[LINE_MAX];
unsigned n = 0;
int r; int r;
assert(m); assert(m);
@ -118,8 +119,10 @@ int manager_read_resolv_conf(Manager *m) {
const char *a; const char *a;
char *l; char *l;
n++;
l = strstrip(line); l = strstrip(line);
if (IN_SET(*l, '#', ';')) if (IN_SET(*l, '#', ';', 0))
continue; continue;
a = first_word(l, "nameserver"); a = first_word(l, "nameserver");
@ -139,6 +142,8 @@ int manager_read_resolv_conf(Manager *m) {
if (r < 0) if (r < 0)
log_warning_errno(r, "Failed to parse search domain string '%s', ignoring.", a); log_warning_errno(r, "Failed to parse search domain string '%s', ignoring.", a);
} }
log_syntax(NULL, LOG_DEBUG, "/etc/resolv.conf", n, 0, "Ignoring resolv.conf line: %s", l);
} }
m->resolv_conf_mtime = timespec_load(&st.st_mtim); m->resolv_conf_mtime = timespec_load(&st.st_mtim);