Skip to content

Commit

Permalink
[openvpn] Ignore all options without value set to false. JB#54606
Browse files Browse the repository at this point in the history
Ignore the options which have no value and are set to false to comply
with the set value for the option. These options are either set or not
set, so treat them as booleans.

Move "BlockIPv6" use to later to be used directly from provider values.

Require OpenVPN 2.5.2 since "--block-ipv6" is implemented in version
2.5 and above. The option is used only at run-time.
  • Loading branch information
LaakkonenJussi committed Jun 14, 2021
1 parent e3a2a62 commit 643cdf4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
20 changes: 12 additions & 8 deletions connman/vpn/plugins/openvpn.c
Expand Up @@ -365,6 +365,14 @@ static int task_append_config_data(struct vpn_provider *provider,
if (!ov_options[i].ov_opt)
continue;

/*
* In case the option is without value, i.e. a boolean toggle
* then ignore the value when option is disabled.
*/
if (!ov_options[i].has_value && !vpn_provider_get_boolean(
provider, ov_options[i].cm_opt, false))
continue;

option = vpn_provider_get_string(provider,
ov_options[i].cm_opt);
if (!option)
Expand All @@ -374,23 +382,19 @@ static int task_append_config_data(struct vpn_provider *provider,
* If the AuthUserPass option is "-", provide the input
* via management interface
*/
if (!strcmp(ov_options[i].cm_opt, "OpenVPN.AuthUserPass") &&
!strcmp(option, "-"))
if (!g_strcmp0(ov_options[i].cm_opt, "OpenVPN.AuthUserPass") &&
!g_strcmp0(option, "-"))
option = NULL;

/* Handle BlockIPv6 internally */
if (!strncmp(ov_options[i].cm_opt, "OpenVPN.BlockIPv6", 17)) {
block_ipv6 = true;
continue;
}

if (connman_task_add_argument(task,
ov_options[i].ov_opt,
ov_options[i].has_value ? option : NULL) < 0)
return -EIO;

}

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

return 0;
Expand Down
2 changes: 1 addition & 1 deletion rpm/connman.spec
Expand Up @@ -131,7 +131,7 @@ This package provides OpenVPN VPN plugin for connman.
Summary: Connection Manager OpenConnect VPN plugin
Requires: %{name} = %{version}-%{release}
Requires: %{name}-vpn-scripts
Requires: openconnect
Requires: openconnect >= 2.5.2

%description plugin-vpn-openconnect
This package provides OpenConnect VPN plugin for connman.
Expand Down

0 comments on commit 643cdf4

Please sign in to comment.