]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolvconf: fixes for the compatibility interface
authorFilipe Brandenburger <filbranden@google.com>
Tue, 26 Jun 2018 01:07:48 +0000 (18:07 -0700)
committerFilipe Brandenburger <filbranden@google.com>
Wed, 27 Jun 2018 06:09:36 +0000 (23:09 -0700)
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.

src/resolve/resolvconf-compat.c
src/resolve/resolvectl.c

index d7e68003e688aedef2e1616b455a56b71380de21..07234589450200ab814b1f48cb2afec9133f4cff 100644 (file)
@@ -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;
@@ -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];
index e96c13fea68b19dd3e7a73bdcd4566ac94316868..e9e395e3ef8fafec08d10027d12ed62fd8098492 100644 (file)
@@ -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);