mirror of
https://github.com/systemd/systemd.git
synced 2024-10-31 07:51:21 +03:00
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.
This commit is contained in:
parent
157306439e
commit
7875170f01
@ -211,7 +211,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;
|
||||
|
||||
|
@ -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];
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user