Skip to content

Commit

Permalink
vpn-provider: Support all true/false options in vpn_provider_get_boolean
Browse files Browse the repository at this point in the history
[vpn-provider] Support all true/false opts boolean set. JB#53542

Support also "yes" and "1" values for true boolean, similarly support
"no" and "0" for false boolean in vpn_provider_get_boolean(). VPNs using
PPPD do support all these strings for boolean values as strings.
  • Loading branch information
LaakkonenJussi committed Apr 27, 2021
1 parent a7aecf1 commit 28e3e34
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions connman/vpn/vpn-provider.c
Expand Up @@ -2923,10 +2923,14 @@ bool vpn_provider_get_boolean(struct vpn_provider *provider, const char *key,
if (!setting || !setting->value)
return default_value;

if (!g_strcmp0(setting->value, "true"))
if (!g_strcmp0(setting->value, "true") ||
!g_strcmp0(setting->value, "yes") ||
!g_strcmp0(setting->value, "1"))
return true;

if (!g_strcmp0(setting->value, "false"))
if (!g_strcmp0(setting->value, "false") ||
!g_strcmp0(setting->value, "no") ||
!g_strcmp0(setting->value, "0"))
return false;

return default_value;
Expand Down

0 comments on commit 28e3e34

Please sign in to comment.