diff options
| author | Michael Biebl <biebl@debian.org> | 2019-11-06 20:46:28 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2019-11-06 20:46:28 +0100 |
| commit | 515e1311d22086215e182f18a4529f24660ca4c3 (patch) | |
| tree | 5b1d21eeceaa57d233d46ddfeeca5e0c1fc8b8a3 /src/dhcp/nm-dhcp-dhclient-utils.c | |
| parent | 790e3946f0274a272fdda4d8697ce31a757a48d2 (diff) | |
| parent | 9c642eac191ef0dce49855d8da0a9e9af18d5113 (diff) | |
Update upstream source from tag 'upstream/1.20.6'
Update to upstream version '1.20.6' with Debian dir 93035bdc0e2b22e7410d6c70c55a21648f836a2f
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)) |