Skip to content

Commit

Permalink
resolvconf: fixes for the compatibility interface
Browse files Browse the repository at this point in the history
Also use compat_main() when called as `resolvconf`, since the interface
is closer to that of `systemd-resolve`.

Use a heap allocated string to set arg_ifname, since a stack allocated
one would be lost after the function returns. (This last one broke the
case where an interface name was suffixed with a dot, such as in
`resolvconf -a tap0.dhcp`.)

Tested:
  $ build/resolvconf -a nonexistent.abc </etc/resolv.conf
  Unknown interface 'nonexistent': No such device

Fixes #9423.
  • Loading branch information
filbranden committed Jun 27, 2018
1 parent ad4bc33 commit 5a01b3f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/resolve/resolvconf-compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ static int parse_nameserver(const char *string) {

if (strv_push(&arg_set_dns, word) < 0)
return log_oom();

word = NULL;
}

return 0;
Expand Down Expand Up @@ -202,7 +204,7 @@ int resolvconf_parse_argv(int argc, char *argv[]) {

dot = strchr(argv[optind], '.');
if (dot) {
iface = strndupa(argv[optind], dot - argv[optind]);
iface = strndup(argv[optind], dot - argv[optind]);
log_debug("Ignoring protocol specifier '%s'.", dot + 1);
} else
iface = argv[optind];
Expand Down
2 changes: 1 addition & 1 deletion src/resolve/resolvectl.c
Original file line number Diff line number Diff line change
Expand Up @@ -3092,7 +3092,7 @@ int main(int argc, char **argv) {
goto finish;
}

if (streq(program_invocation_short_name, "systemd-resolve"))
if (STR_IN_SET(program_invocation_short_name, "systemd-resolve", "resolvconf"))
r = compat_main(argc, argv, bus);
else
r = native_main(argc, argv, bus);
Expand Down

0 comments on commit 5a01b3f

Please sign in to comment.