teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame SOURCES/0392-resolvconf-fixes-for-the-compatibility-interface.patch

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