vpn: Accept also "true" or "1" as a boolean value
authorJukka Rissanen <jukka.rissanen@linux.intel.com>
Wed, 22 Aug 2012 08:28:01 +0000 (11:28 +0300)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Thu, 23 Aug 2012 11:20:10 +0000 (14:20 +0300)
Currently user is able to set the boolean VPN config value
only by setting the variable to "yes". This is not very
intuitive so accept also the value of "true" or "1".

plugins/l2tp.c
plugins/pptp.c
plugins/vpnc.c

index 5a655e630533f24d35214aa8dbf10c1c57ef9f91..39c961810993989c1b17fc64b113d6068fd75a00 100644 (file)
@@ -285,7 +285,9 @@ static ssize_t l2tp_write_bool_option(int fd,
        ssize_t ret = 0;
 
        if (key != NULL && value != NULL) {
-               if (strcmp(value, "yes") == 0) {
+               if (strcasecmp(value, "yes") == 0 ||
+                               strcasecmp(value, "true") == 0 ||
+                               strcmp(value, "1") == 0) {
                        buf = g_strdup_printf("%s\n", key);
                        ret = full_write(fd, buf, strlen(buf));
 
index 9db1b896f7471ac257841c342b5995246357244b..365bde7cdf5361349db975ebc33d11e211cb56ce 100644 (file)
@@ -225,7 +225,9 @@ static void pptp_write_bool_option(struct connman_task *task,
                                const char *key, const char *value)
 {
        if (key != NULL && value != NULL) {
-               if (strcmp(value, "yes") == 0)
+               if (strcasecmp(value, "yes") == 0 ||
+                               strcasecmp(value, "true") == 0 ||
+                               strcmp(value, "1") == 0)
                        connman_task_add_argument(task, key, NULL);
        }
 }
index fea1c15c984729c1523206383dac474dbd0a30ba..6b7a02be8d2bd447151c16ad1587d0c660b1366e 100644 (file)
@@ -194,7 +194,9 @@ static ssize_t write_bool_option(int fd, const char *key, const char *value)
        ssize_t ret = 0;
 
        if (key != NULL && value != NULL) {
-               if (strcmp(value, "yes") == 0) {
+               if (strcasecmp(value, "yes") == 0 ||
+                               strcasecmp(value, "true") == 0 ||
+                               strcmp(value, "1") == 0) {
                        buf = g_strdup_printf("%s\n", key);
                        ret = full_write(fd, buf, strlen(buf));