blob: 2f3e776aa08c8112d3456698cccc2a21635e0e6f [file] [log] [blame]
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08001systemd-239: fixes for the compatibility interface
2
3[No upstream tracking] -- https://github.com/systemd/systemd/issues/9423
4
5resolvconf-compat: use compat_main() when called as `resolvconf`,
6since the interface is closer to that of `systemd-resolve`.
7
8Use a heap allocated string to set arg_ifname, since a stack allocated
9one would be lost after the function returns. (This last one broke the
10case where an interface name was suffixed with a dot, such as in
11`resolvconf -a tap0.dhcp`.)
12
13Tested:
14 $ build/resolvconf -a nonexistent.abc </etc/resolv.conf
15 Unknown interface 'nonexistent': No such device
16
17Upstream-Status: Backport [https://github.com/systemd/systemd/commit/5a01b3f35d7b6182c78b6973db8d99bdabd4f9c3]
18bug: 9423
19Signed-off-by: Simon Ausserlechner <simon.ausserlechner@siemens.com>
20
21diff --git a/src/resolve/resolvconf-compat.c b/src/resolve/resolvconf-compat.c
22index d7e68003e..072345894 100644
23--- a/src/resolve/resolvconf-compat.c
24+++ b/src/resolve/resolvconf-compat.c
25@@ -53,6 +53,8 @@ static int parse_nameserver(const char *string) {
26
27 if (strv_push(&arg_set_dns, word) < 0)
28 return log_oom();
29+
30+ word = NULL;
31 }
32
33 return 0;
34@@ -202,7 +204,7 @@ int resolvconf_parse_argv(int argc, char *argv[]) {
35
36 dot = strchr(argv[optind], '.');
37 if (dot) {
38- iface = strndupa(argv[optind], dot - argv[optind]);
39+ iface = strndup(argv[optind], dot - argv[optind]);
40 log_debug("Ignoring protocol specifier '%s'.", dot + 1);
41 } else
42 iface = argv[optind];
43diff --git a/src/resolve/resolvectl.c b/src/resolve/resolvectl.c
44index e96c13fea..e9e395e3e 100644
45--- a/src/resolve/resolvectl.c
46+++ b/src/resolve/resolvectl.c
47@@ -3092,7 +3092,7 @@ int main(int argc, char **argv) {
48 goto finish;
49 }
50
51- if (streq(program_invocation_short_name, "systemd-resolve"))
52+ if (STR_IN_SET(program_invocation_short_name, "systemd-resolve", "resolvconf"))
53 r = compat_main(argc, argv, bus);
54 else
55 r = native_main(argc, argv, bus);
56--
572.11.0
58