]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolvectl: Only strip ifname suffixes when being resolvconf
authorMike Crowe <mac@mcrowe.com>
Thu, 24 Jun 2021 14:25:58 +0000 (15:25 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 20 Jul 2021 15:59:39 +0000 (17:59 +0200)
Only treat interface names containing dots specially when resolvectl is
pretending to be resolvconf to fix
https://github.com/systemd/systemd/issues/20014 .

Move the special suffix-stripping behaviour of ifname_mangle out to the
new ifname_resolvconf_mangle to be called from resolvconf only.

(cherry picked from commit 7875170f01991a1d28cfe284cc7075630cd69055)
(cherry picked from commit 6ec5680beaa8df4b4b87e9aa614d29561c0e98fe)

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

index 5bc936faa709673564325a36ec4ec570b664086e..8dc559801dce8f04efe670346a40de4adc498c77 100644 (file)
@@ -212,7 +212,7 @@ int resolvconf_parse_argv(int argc, char *argv[]) {
                 return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
                                        "Expected interface name as argument.");
 
-        r = ifname_mangle(argv[optind]);
+        r = ifname_resolvconf_mangle(argv[optind]);
         if (r <= 0)
                 return r;
 
index b479335769105d4beb125c5a16a80e3c81cce222..3a805245de69cf799098a3684dac96ba96c7d8b6 100644 (file)
@@ -100,18 +100,11 @@ static int interface_info_compare(const InterfaceInfo *a, const InterfaceInfo *b
 
 int ifname_mangle(const char *s) {
         _cleanup_free_ char *iface = NULL;
-        const char *dot;
         int ifi;
 
         assert(s);
 
-        dot = strchr(s, '.');
-        if (dot) {
-                log_debug("Ignoring protocol specifier '%s'.", dot + 1);
-                iface = strndup(s, dot - s);
-
-        } else
-                iface = strdup(s);
+        iface = strdup(s);
         if (!iface)
                 return log_oom();
 
@@ -134,6 +127,24 @@ int ifname_mangle(const char *s) {
         return 1;
 }
 
+int ifname_resolvconf_mangle(const char *s) {
+        const char *dot;
+
+        assert(s);
+
+        dot = strchr(s, '.');
+        if (dot) {
+                _cleanup_free_ char *iface = NULL;
+
+                log_debug("Ignoring protocol specifier '%s'.", dot + 1);
+                iface = strndup(s, dot - s);
+                if (!iface)
+                        return log_oom();
+                return ifname_mangle(iface);
+        } else
+                return ifname_mangle(s);
+}
+
 static void print_source(uint64_t flags, usec_t rtt) {
         char rtt_str[FORMAT_TIMESTAMP_MAX];
 
index 830c81d6923f143e90ef61a105e0dc3bb36c58db..3d55bf78da135e4bdfda705683e7057b8e181f1c 100644 (file)
@@ -27,3 +27,4 @@ extern char **arg_set_domain;
 extern bool arg_ifindex_permissive;
 
 int ifname_mangle(const char *s);
+int ifname_resolvconf_mangle(const char *s);