Skip to content

Commit

Permalink
[vpnc] Fix internal option use to support BlockIPv6 option. JB#54607
Browse files Browse the repository at this point in the history
Read the "BlockIPv6" option separately out of the loop. VPNC does not
have support for the value and vpnc_opt for this is set as NULL.

Add support for more internal options where vpnc_opt is defined NULL.
Idea is to skip all of these when writing the configuration. This does
not prevent saving as cm_opt is used then.
  • Loading branch information
LaakkonenJussi committed Jun 11, 2021
1 parent 5b4ae24 commit a7b72e6
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions connman/vpn/plugins/vpnc.c
Expand Up @@ -65,7 +65,7 @@ enum {

struct {
const char *cm_opt;
const char *vpnc_opt;
const char *vpnc_opt; /* Set this NULL for internal options */
const char *vpnc_default;
int type;
bool cm_save;
Expand All @@ -91,7 +91,7 @@ struct {
{ "VPNC.SingleDES", "Enable Single DES", NULL, OPT_BOOLEAN, true },
{ "VPNC.NoEncryption", "Enable no encryption", NULL, OPT_BOOLEAN,
true },
{ "VPNC.BlockIPv6", "BlockIPv6", NULL, OPT_BOOLEAN, true},
{ "VPNC.BlockIPv6", NULL, NULL, OPT_BOOLEAN, true},
};

struct vc_private_data {
Expand Down Expand Up @@ -319,6 +319,10 @@ static int vc_write_config_data(struct vpn_provider *provider, int fd)
int i;

for (i = 0; i < (int)ARRAY_SIZE(vpnc_options); i++) {
/* Ignore all internal options. */
if (!vpnc_options[i].vpnc_opt)
continue;

opt_s = vpn_provider_get_string(provider,
vpnc_options[i].cm_opt);
if (!opt_s)
Expand All @@ -327,12 +331,6 @@ static int vc_write_config_data(struct vpn_provider *provider, int fd)
if (!opt_s)
continue;

if (g_strcmp0(opt_s, "VPNC.BlockIPv6") && !g_ascii_strcasecmp(
vpnc_options[i].vpnc_opt, "true")) {
block_ipv6 = true;
continue;
}

if (vpnc_options[i].type == OPT_STRING) {
if (write_option(fd,
vpnc_options[i].vpnc_opt, opt_s) < 0)
Expand All @@ -345,6 +343,8 @@ static int vc_write_config_data(struct vpn_provider *provider, int fd)

}

block_ipv6 = vpn_provider_get_boolean(provider, "VPNC.BlockIPv6",
false);
vpn_provider_set_supported_ip_networks(provider, true, !block_ipv6);

return 0;
Expand Down

0 comments on commit a7b72e6

Please sign in to comment.