diff options
author | Mike Crowe <mac@mcrowe.com> | 2021-06-24 15:25:58 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2021-06-25 12:52:39 +0200 |
commit | 7875170f01991a1d28cfe284cc7075630cd69055 (patch) | |
tree | 39466da11bdd2deabc85afce3190e137f7e4706a /src/resolve/resolvectl.c | |
parent | 157306439e941ef920e05b065d5e5c083dc100aa (diff) | |
download | systemd-7875170f01991a1d28cfe284cc7075630cd69055.tar.gz |
resolvectl: Only strip ifname suffixes when being resolvconf
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.
Diffstat (limited to 'src/resolve/resolvectl.c')
-rw-r--r-- | src/resolve/resolvectl.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/src/resolve/resolvectl.c b/src/resolve/resolvectl.c index 23f4ff1077..7d13ed3905 100644 --- a/src/resolve/resolvectl.c +++ b/src/resolve/resolvectl.c @@ -104,18 +104,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(); @@ -138,6 +131,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]; |