ryantimwilson / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone
52b84b
From 9b7aa39e7db5a6446d3c034741e64cda1a9dd200 Mon Sep 17 00:00:00 2001
52b84b
From: Filipe Brandenburger <filbranden@google.com>
52b84b
Date: Mon, 25 Jun 2018 18:07:48 -0700
52b84b
Subject: [PATCH] resolvconf: fixes for the compatibility interface
52b84b
52b84b
Also use compat_main() when called as `resolvconf`, since the interface
52b84b
is closer to that of `systemd-resolve`.
52b84b
52b84b
Use a heap allocated string to set arg_ifname, since a stack allocated
52b84b
one would be lost after the function returns. (This last one broke the
52b84b
case where an interface name was suffixed with a dot, such as in
52b84b
`resolvconf -a tap0.dhcp`.)
52b84b
52b84b
Tested:
52b84b
  $ build/resolvconf -a nonexistent.abc 
52b84b
  Unknown interface 'nonexistent': No such device
52b84b
52b84b
Fixes #9423.
52b84b
52b84b
(cherry picked from commit 5a01b3f35d7b6182c78b6973db8d99bdabd4f9c3)
52b84b
52b84b
Resolves: #1835594
52b84b
---
52b84b
 src/resolve/resolvconf-compat.c | 4 +++-
52b84b
 src/resolve/resolvectl.c        | 2 +-
52b84b
 2 files changed, 4 insertions(+), 2 deletions(-)
52b84b
52b84b
diff --git a/src/resolve/resolvconf-compat.c b/src/resolve/resolvconf-compat.c
52b84b
index d7e68003e6..0723458945 100644
52b84b
--- a/src/resolve/resolvconf-compat.c
52b84b
+++ b/src/resolve/resolvconf-compat.c
52b84b
@@ -53,6 +53,8 @@ static int parse_nameserver(const char *string) {
52b84b
 
52b84b
                 if (strv_push(&arg_set_dns, word) < 0)
52b84b
                         return log_oom();
52b84b
+
52b84b
+                word = NULL;
52b84b
         }
52b84b
 
52b84b
         return 0;
52b84b
@@ -202,7 +204,7 @@ int resolvconf_parse_argv(int argc, char *argv[]) {
52b84b
 
52b84b
         dot = strchr(argv[optind], '.');
52b84b
         if (dot) {
52b84b
-                iface = strndupa(argv[optind], dot - argv[optind]);
52b84b
+                iface = strndup(argv[optind], dot - argv[optind]);
52b84b
                 log_debug("Ignoring protocol specifier '%s'.", dot + 1);
52b84b
         } else
52b84b
                 iface = argv[optind];
52b84b
diff --git a/src/resolve/resolvectl.c b/src/resolve/resolvectl.c
52b84b
index cf1ec323a4..355e5c62b1 100644
52b84b
--- a/src/resolve/resolvectl.c
52b84b
+++ b/src/resolve/resolvectl.c
52b84b
@@ -3090,7 +3090,7 @@ int main(int argc, char **argv) {
52b84b
                 goto finish;
52b84b
         }
52b84b
 
52b84b
-        if (streq(program_invocation_short_name, "systemd-resolve"))
52b84b
+        if (STR_IN_SET(program_invocation_short_name, "systemd-resolve", "resolvconf"))
52b84b
                 r = compat_main(argc, argv, bus);
52b84b
         else
52b84b
                 r = native_main(argc, argv, bus);