diff options
| author | Sebastien Bacher <seb128@ubuntu.com> | 2020-01-07 16:53:57 +0100 |
|---|---|---|
| committer | Sebastien Bacher <seb128@ubuntu.com> | 2020-01-07 16:56:18 +0100 |
| commit | 5035d260cb1cde38bfdc732e0d1ff8b3ca78135c (patch) | |
| tree | 1433995e753effc7cfa4f63266691bdc8b5ad6b3 /src/dhcp/nm-dhcp-dhclient-utils.c | |
| parent | 21add8edb7927d06f038208fd6271202063d5293 (diff) | |
| parent | 121343423a2e75e15e16988e664a8b32a629f2ba (diff) | |
Merge tag 'debian/1.20.6-1'
network-manager Debian release 1.20.6-1
Diffstat (limited to 'src/dhcp/nm-dhcp-dhclient-utils.c')
| -rw-r--r-- | src/dhcp/nm-dhcp-dhclient-utils.c | 43 |
1 files changed, 32 insertions, 11 deletions
diff --git a/src/dhcp/nm-dhcp-dhclient-utils.c b/src/dhcp/nm-dhcp-dhclient-utils.c index bf3df399..98f8c13a 100644 --- a/src/dhcp/nm-dhcp-dhclient-utils.c +++ b/src/dhcp/nm-dhcp-dhclient-utils.c @@ -304,11 +304,13 @@ nm_dhcp_dhclient_create_config (const char *interface, if (orig_contents) { gs_free const char **lines = NULL; gsize line_i; - int nest = 0; + nm_auto_free_gstring GString *blocks_stack = NULL; + guint blocks_skip = 0; gboolean in_alsoreq = FALSE; gboolean in_req = FALSE; char intf[IFNAMSIZ]; + blocks_stack = g_string_new (NULL); g_string_append_printf (new_contents, _("# Merged from %s\n\n"), orig_path); intf[0] = '\0'; @@ -326,19 +328,38 @@ nm_dhcp_dhclient_create_config (const char *interface, if (in_req) { /* pass */ } else if (strchr (p, '{')) { - nest++; - if ( !intf[0] - && NM_STR_HAS_PREFIX (p, "interface")) - if (read_interface (p, intf, sizeof (intf))) - continue; + if ( NM_STR_HAS_PREFIX (p, "lease") + || NM_STR_HAS_PREFIX (p, "alias") + || NM_STR_HAS_PREFIX (p, "interface") + || NM_STR_HAS_PREFIX (p, "pseudo")) { + /* skip over these blocks, except 'interface' when it + * matches the current interface */ + blocks_skip++; + g_string_append_c (blocks_stack, 'b'); + if ( !intf[0] + && NM_STR_HAS_PREFIX (p, "interface")) { + if (read_interface (p, intf, sizeof (intf))) + continue; + } + } else { + /* allow other blocks (conditionals) */ + if (!strchr (p, '}')) /* '} else {' */ + g_string_append_c (blocks_stack, 'c'); + } } else if (strchr (p, '}')) { - if (nest) - nest--; - intf[0] = '\0'; - continue; + if (blocks_stack->len > 0) { + if (blocks_stack->str[blocks_stack->len - 1] == 'b') { + g_string_truncate (blocks_stack, blocks_stack->len - 1); + nm_assert(blocks_skip > 0); + blocks_skip--; + intf[0] = '\0'; + continue; + } + g_string_truncate (blocks_stack, blocks_stack->len - 1); + } } - if (nest && !intf[0]) + if (blocks_skip > 0 && !intf[0]) continue; if (intf[0] && !nm_streq (intf, interface)) |