Send connman mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.01.org/mailman/listinfo/connman
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of connman digest..."


Today's Topics:

   1. Re: VLAN configuration support (Justin Maggard)
   2. Re: duplicate entries in /etc/resolv.conf (Daniel Wagner)
   3. Re: VLAN configuration support (Daniel Wagner)
   4. [PATCH] plugins: Build dynamically loadable VPN plugins
      (Jussi Laakkonen)
   5. [PATCH] vpn: Rename openconnect-script to vpn-script.
      (Jussi Laakkonen)
   6. [PATCH 0/5] VPN settings and configurable VPN privileges
      (Jussi Laakkonen)
   7. [PATCH 1/5] vpn: Move settings from main.c to vpn-settings.c
      (Jussi Laakkonen)


----------------------------------------------------------------------

Message: 1
Date: Sun, 28 Apr 2019 23:51:06 -0700
From: Justin Maggard <[email protected]>
To: Daniel Wagner <[email protected]>
Cc: "Langlois, Maxime" <[email protected]>,
        "[email protected]" <[email protected]>
Subject: Re: VLAN configuration support
Message-ID:
        <CAKgsxVRP8MnVxMrsMhu=-4dzwVd=em-ebcpuslmwjcdp5vo...@mail.gmail.com>
Content-Type: text/plain; charset="UTF-8"

On Mon, Apr 15, 2019 at 11:27 PM Daniel Wagner <[email protected]> wrote:
>
> Hi Maxime,
>
> On 4/4/19 10:25 PM, Langlois, Maxime wrote:
> > would love to contribute! However I haven't planned that extra time for
> > diving into the connman source code... and deadlines being what they
> > are, I might have to move to an alternative :(
>
> Fair enough. Anyway, you should plan some time to fix/maintain any open
> source project you choose. There is no free lunch.
>
> The change isn't too hard to implement and test. I'll do it in the
> coming days.
>
> > Decision is not yet made though, as I still have other things to
> > evaluate. Our networking requirements are quite complex and I'm still
> > trying to figure every bits and pieces!
>
> Sure :)
>
> > If it ever occurs that I retain the connman solution, I certainly might
> > submit the patches.
>
> That is good to hear!
>
> Thanks,
> Daniel

VLAN support was added a few years ago
(https://git.kernel.org/pub/scm/network/connman/connman.git/commit/?id=f48ee4201c795c0cafc73279d2b61ef8e477b9ae).
At the time, I also posted a patch that would have Connman also
manager the creation and deletion of VLAN interfaces.

-Justin


------------------------------

Message: 2
Date: Mon, 29 Apr 2019 11:13:12 +0200
From: Daniel Wagner <[email protected]>
To: Doron Behar <[email protected]>
Cc: [email protected]
Subject: Re: duplicate entries in /etc/resolv.conf
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8

HI Doron,

On 28.04.19 18:12, Doron Behar wrote:
> Would it be possible if perhaps you'll kindly post the commit ids that
> fixed this when those will be ready? I'd love to build connman with
> those patches because this is kind of crucial for me.

Could you test these patches:

        [PATCH 0/2] Don't export duplicate entries in resolv.conf

Thanks,
Daniel


------------------------------

Message: 3
Date: Mon, 29 Apr 2019 11:16:49 +0200
From: Daniel Wagner <[email protected]>
To: Justin Maggard <[email protected]>
Cc: "[email protected]" <[email protected]>
Subject: Re: VLAN configuration support
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8

Hi Justin,

On 29.04.19 08:51, Justin Maggard wrote:
> VLAN support was added a few years ago
> (https://git.kernel.org/pub/scm/network/connman/connman.git/commit/?id=f48ee4201c795c0cafc73279d2b61ef8e477b9ae).
> At the time, I also posted a patch that would have Connman also
> manager the creation and deletion of VLAN interfaces.

Thanks for the pointer. The missing functionality is in the provisiong
code. Currently you can't write a provisioning file which matches on
device names, only on MAC addresses. This evening I should have time to
write the patch for this.

Thanks,
Daniel


------------------------------

Message: 4
Date: Mon, 29 Apr 2019 17:31:08 +0300
From: Jussi Laakkonen <[email protected]>
To: [email protected]
Subject: [PATCH] plugins: Build dynamically loadable VPN plugins
Message-ID: <[email protected]>

This commit fixes the issue of loading external (library) VPN plugins
using dlopen(). The vpn/plugins/vpn.c source should not be built with
external VPN plugins as vpn/plugins/vpn.c is regarded as a plugin. This
will cause undefined symbol erros when opening the .so using dlopen(),
since vpn.c uses functions defined only for local (builtin) use and are
cannot be accessed by plugins.

The vpn/plugins/vpn.c source must be included in vpn build sources if
there is a single VPN plugin to be built. Both builtin and external
VPN plugins require this. Otherwise, when there are no builtin VPN
plugins included in build, loading of the external plugins will fail as
the vpn/plugins/vpn.c would have never included in connman-vpnd.
---
 Makefile.plugins | 25 ++++++++++---------------
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/Makefile.plugins b/Makefile.plugins
index dce8b283..7e0bc779 100644
--- a/Makefile.plugins
+++ b/Makefile.plugins
@@ -63,16 +63,15 @@ builtin_modules += vpn
 builtin_sources += plugins/vpn.c
 
 if OPENCONNECT
+builtin_vpn_source = vpn/plugins/vpn.c vpn/plugins/vpn.h
 if OPENCONNECT_BUILTIN
 builtin_vpn_modules += openconnect
 builtin_vpn_sources += vpn/plugins/openconnect.c
-builtin_vpn_source = vpn/plugins/vpn.c vpn/plugins/vpn.h
 builtin_vpn_cflags += -DOPENCONNECT=\"@OPENCONNECT@\"
 else
 vpn_plugin_LTLIBRARIES += vpn/plugins/openconnect.la
 vpn_plugin_objects += $(plugins_openconnect_la_OBJECTS)
-vpn_plugins_openconnect_la_SOURCES = vpn/plugins/vpn.h vpn/plugins/vpn.c \
-                                               vpn/plugins/openconnect.c
+vpn_plugins_openconnect_la_SOURCES = vpn/plugins/openconnect.c
 vpn_plugins_openconnect_la_CFLAGS = $(plugin_cflags) \
                                        -DOPENCONNECT=\"@OPENCONNECT@\" \
                                        -DVPN_STATEDIR=\""$(vpn_statedir)"\" \
@@ -82,16 +81,15 @@ endif
 endif
 
 if OPENVPN
+builtin_vpn_source = vpn/plugins/vpn.c vpn/plugins/vpn.h
 if OPENVPN_BUILTIN
 builtin_vpn_modules += openvpn
 builtin_vpn_sources += vpn/plugins/openvpn.c
-builtin_vpn_source = vpn/plugins/vpn.c vpn/plugins/vpn.h
 builtin_vpn_cflags += -DOPENVPN=\"@OPENVPN@\"
 else
 vpn_plugin_LTLIBRARIES += vpn/plugins/openvpn.la
 vpn_plugin_objects += $(plugins_openvpn_la_OBJECTS)
-vpn_plugins_openvpn_la_SOURCES = vpn/plugins/vpn.h vpn/plugins/vpn.c \
-                                               vpn/plugins/openvpn.c
+vpn_plugins_openvpn_la_SOURCES = vpn/plugins/openvpn.c
 vpn_plugins_openvpn_la_CFLAGS = $(plugin_cflags) -DOPENVPN=\"@OPENVPN@\" \
                                        -DVPN_STATEDIR=\""$(vpn_statedir)"\" \
                                        -DSCRIPTDIR=\""$(build_scriptdir)"\"
@@ -100,16 +98,15 @@ endif
 endif
 
 if VPNC
+builtin_vpn_source = vpn/plugins/vpn.c vpn/plugins/vpn.h
 if VPNC_BUILTIN
 builtin_vpn_modules += vpnc
 builtin_vpn_sources += vpn/plugins/vpnc.c
-builtin_vpn_source = vpn/plugins/vpn.c vpn/plugins/vpn.h
 builtin_vpn_cflags += -DVPNC=\"@VPNC@\"
 else
 vpn_plugin_LTLIBRARIES += vpn/plugins/vpnc.la
 vpn_plugin_objects += $(plugins_vpnc_la_OBJECTS)
-vpn_plugins_vpnc_la_SOURCES = vpn/plugins/vpn.h vpn/plugins/vpn.c \
-                                               vpn/plugins/vpnc.c
+vpn_plugins_vpnc_la_SOURCES = vpn/plugins/vpnc.c
 vpn_plugins_vpnc_la_CFLAGS = $(plugin_cflags) -DVPNC=\"@VPNC@\" \
                                        -DVPN_STATEDIR=\""$(vpn_statedir)"\" \
                                        -DSCRIPTDIR=\""$(build_scriptdir)"\"
@@ -118,16 +115,15 @@ endif
 endif
 
 if L2TP
+builtin_vpn_source = vpn/plugins/vpn.c vpn/plugins/vpn.h
 if L2TP_BUILTIN
 builtin_vpn_modules += l2tp
 builtin_vpn_sources += vpn/plugins/l2tp.c
-builtin_vpn_source = vpn/plugins/vpn.c vpn/plugins/vpn.h
 builtin_vpn_cflags += -DL2TP=\"@L2TP@\"
 else
 vpn_plugin_LTLIBRARIES += vpn/plugins/l2tp.la
 vpn_plugin_objects += $(plugins_l2tp_la_OBJECTS)
-vpn_plugins_l2tp_la_SOURCES = vpn/plugins/vpn.h vpn/plugins/vpn.c \
-                                               vpn/plugins/l2tp.c
+vpn_plugins_l2tp_la_SOURCES = vpn/plugins/l2tp.c
 vpn_plugins_l2tp_la_CFLAGS = $(plugin_cflags) -DL2TP=\"@L2TP@\" \
                                        -DVPN_STATEDIR=\""$(vpn_statedir)"\" \
                                        -DSCRIPTDIR=\""$(build_scriptdir)"\"
@@ -136,16 +132,15 @@ endif
 endif
 
 if PPTP
+builtin_vpn_source = vpn/plugins/vpn.c vpn/plugins/vpn.h
 if PPTP_BUILTIN
 builtin_vpn_modules += pptp
 builtin_vpn_sources += vpn/plugins/pptp.c
-builtin_vpn_source = vpn/plugins/vpn.c vpn/plugins/vpn.h
 builtin_vpn_cflags += -DPPPD=\"@PPPD@\" -DPPTP=\"@PPTP@\"
 else
 vpn_plugin_LTLIBRARIES += vpn/plugins/pptp.la
 vpn_plugin_objects += $(plugins_pptp_la_OBJECTS)
-vpn_plugins_pptp_la_SOURCES = vpn/plugins/vpn.h vpn/plugins/vpn.c \
-                                               vpn/plugins/pptp.c
+vpn_plugins_pptp_la_SOURCES = vpn/plugins/pptp.c
 vpn_plugins_pptp_la_CFLAGS = $(plugin_cflags) -DPPPD=\"@PPPD@\" \
                                        -DPPTP=\"@PPTP@\" \
                                        -DVPN_STATEDIR=\""$(vpn_statedir)"\" \
-- 
2.20.1



------------------------------

Message: 5
Date: Mon, 29 Apr 2019 17:32:50 +0300
From: Jussi Laakkonen <[email protected]>
To: [email protected]
Subject: [PATCH] vpn: Rename openconnect-script to vpn-script.
Message-ID: <[email protected]>

The scripts/openconnect-script.c has nothing OpenConnect specific and is
also used by VPNC. Thus, renaming it to generic vpn-script.c clarifies
the purpose of the script.

Changed OpenConnect and VPNC plugins to use vpn-script. Modified
Makefile.plugins also to use the vpn-script..
---
 .gitignore                                     | 2 +-
 Makefile.plugins                               | 8 ++++----
 scripts/{openconnect-script.c => vpn-script.c} | 8 +++++---
 vpn/plugins/openconnect.c                      | 3 +--
 vpn/plugins/vpnc.c                             | 3 +--
 5 files changed, 12 insertions(+), 12 deletions(-)
 rename scripts/{openconnect-script.c => vpn-script.c} (95%)

diff --git a/.gitignore b/.gitignore
index b43336c9..3088a92f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -40,7 +40,7 @@ src/connman-wait-online.service
 src/connmand-wait-online
 plugins/connman.policy
 scripts/connman
-scripts/openconnect-script
+scripts/vpn-script
 scripts/openvpn-script
 scripts/connman_resolvconf.conf
 client/connmanctl
diff --git a/Makefile.plugins b/Makefile.plugins
index 122b2935..87bcc6fc 100644
--- a/Makefile.plugins
+++ b/Makefile.plugins
@@ -191,14 +191,14 @@ plugins_iospm_la_LDFLAGS = $(plugin_ldflags)
 endif
 
 if OPENCONNECT
-script_PROGRAMS += scripts/openconnect-script
+script_PROGRAMS += scripts/vpn-script
 
-scripts_openconnect_script_LDADD = @DBUS_LIBS@
+scripts_vpn_script_LDADD = @DBUS_LIBS@
 else
 if VPNC
-script_PROGRAMS += scripts/openconnect-script
+script_PROGRAMS += scripts/vpn-script
 
-scripts_openconnect_script_LDADD = @DBUS_LIBS@
+scripts_vpn_script_LDADD = @DBUS_LIBS@
 endif
 endif
 
diff --git a/scripts/openconnect-script.c b/scripts/vpn-script.c
similarity index 95%
rename from scripts/openconnect-script.c
rename to scripts/vpn-script.c
index 5e04144f..6e020e92 100644
--- a/scripts/openconnect-script.c
+++ b/scripts/vpn-script.c
@@ -54,9 +54,11 @@ static void append(DBusMessageIter *dict, const char 
*pattern)
        key = pattern;
        value = delim + 1;
 
-       /* We clean the environment before invoking openconnect, but
-          might as well still filter out the few things that get
-          added that we're not interested in */
+       /*
+        * We clean the environment before invoking openconnect/vpnc,
+        * but might as well still filter out the few things that get
+        * added that we're not interested in
+        */
        if (!strcmp(key, "PWD") || !strcmp(key, "_") ||
            !strcmp(key, "SHLVL") || !strcmp(key, "connman_busname") ||
            !strcmp(key, "connman_network"))
diff --git a/vpn/plugins/openconnect.c b/vpn/plugins/openconnect.c
index 8e74479f..4117471c 100644
--- a/vpn/plugins/openconnect.c
+++ b/vpn/plugins/openconnect.c
@@ -248,8 +248,7 @@ static int run_connect(struct vpn_provider *provider,
        connman_task_add_argument(task, "--syslog", NULL);
        connman_task_add_argument(task, "--cookie-on-stdin", NULL);
 
-       connman_task_add_argument(task, "--script",
-                                 SCRIPTDIR "/openconnect-script");
+       connman_task_add_argument(task, "--script", SCRIPTDIR "/vpn-script");
 
        connman_task_add_argument(task, "--interface", if_name);
 
diff --git a/vpn/plugins/vpnc.c b/vpn/plugins/vpnc.c
index af9dbe76..cd9ff688 100644
--- a/vpn/plugins/vpnc.c
+++ b/vpn/plugins/vpnc.c
@@ -298,8 +298,7 @@ static int vc_connect(struct vpn_provider *provider,
                connman_task_add_argument(task, "--ifmode", "tun");
        }
 
-       connman_task_add_argument(task, "--script",
-                               SCRIPTDIR "/openconnect-script");
+       connman_task_add_argument(task, "--script", SCRIPTDIR "/vpn-script");
 
        option = vpn_provider_get_string(provider, "VPNC.Debug");
        if (option)
-- 
2.20.1



------------------------------

Message: 6
Date: Mon, 29 Apr 2019 18:39:57 +0300
From: Jussi Laakkonen <[email protected]>
To: [email protected]
Subject: [PATCH 0/5] VPN settings and configurable VPN privileges
Message-ID: <[email protected]>

This set of commits moves the VPN configuration from vpn/main.c into
vpn/vpn-settings.c. The configuration is amended with the option to
define privileges using DAC (user, group and supplementary groups) for
the VPN binary started by VPN plugin.

Settings can be defined for all VPNs in CONFIGDIR/connman-vpn.conf
or separately for each VPN using the plugin name. For example, OpenVPN
configuration is in CONFIGDIR/vpn-plugins/openvpn.conf. Setting a
plugin specific configuration overrides main connman-vpn.conf settings.
If there is no configuration for some parameter set, the default value
is used and if the default value is also missing, nothing is done.
Documentation of this is added to connman-vpn.conf manual pages.

When registering a VPN (vpn_register()) vpn/plugins/vpn.c loads the
plugin specific config (struct vpn_plugin_data). If configuration
exists the returned content is used when connecting the VPN. Config is
loaded only once and is free'd when plugin calls vpn_unregister().

task.c is modified to support a custom task setup function and user
data for it when new task is to be created. This custom task setup
function is executed when the task is being run and the user data is
passed for it to process.

vpn/plugins/vpn.c utilizes this by defining vpn_task_setup() function
to be run at VPN start. This vpn_task_setup() takes the config and sets
group, supplementary groups and user for the VPN plugin binary (in this
order). setgid(), setgroups() and setuid() is used and CAP_SETGID and
CAP_SETUID are, therefore, required.

Setting up groups is a system specific problem, but in general,
following should work at least with OpenVPN:
User = <user for VPN>
Group = vpn
SupplementaryGroups = inet, net_admin


Jussi Laakkonen (5):
  vpn: Move settings from main.c to vpn-settings.c
  vpn: Add support for configurable user and groups in settings
  task: Add support for a custom setup function
  vpn: Run VPN plugin binaries with configurable privileges
  man: Document VPN config file privilege configuration in
    connman-vpn.conf

 Makefile.am                |   2 +-
 doc/connman-vpn.conf.5.in  |  34 ++++-
 include/task.h             |   6 +-
 src/task.c                 |  13 +-
 vpn/connman-vpn.service.in |   2 +-
 vpn/main.c                 |  68 +---------
 vpn/plugins/vpn.c          | 136 +++++++++++++++++++-
 vpn/vpn-settings.c         | 254 +++++++++++++++++++++++++++++++++++++
 vpn/vpn.h                  |  16 +++
 9 files changed, 460 insertions(+), 71 deletions(-)
 create mode 100644 vpn/vpn-settings.c

-- 
2.20.1



------------------------------

Message: 7
Date: Mon, 29 Apr 2019 18:39:58 +0300
From: Jussi Laakkonen <[email protected]>
To: [email protected]
Subject: [PATCH 1/5] vpn: Move settings from main.c to vpn-settings.c
Message-ID: <[email protected]>

Move VPN settings to vpn-settings.c.
---
 Makefile.am        |   2 +-
 vpn/main.c         |  68 ++----------------------------
 vpn/vpn-settings.c | 100 +++++++++++++++++++++++++++++++++++++++++++++
 vpn/vpn.h          |   5 +++
 4 files changed, 110 insertions(+), 65 deletions(-)
 create mode 100644 vpn/vpn-settings.c

diff --git a/Makefile.am b/Makefile.am
index 745bef05..77f5d8a8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -182,7 +182,7 @@ vpn_connman_vpnd_SOURCES = $(builtin_vpn_sources) 
$(backtrace_sources) \
                        vpn/vpn-ipconfig.c src/inet.c vpn/vpn-rtnl.c \
                        src/dbus.c src/storage.c src/ipaddress.c src/agent.c \
                        vpn/vpn-agent.c vpn/vpn-agent.h src/inotify.c \
-                       vpn/vpn-config.c
+                       vpn/vpn-config.c vpn/vpn-settings.c
 
 vpn_connman_vpnd_LDADD = gdbus/libgdbus-internal.la $(builtin_vpn_libadd) \
                                @GLIB_LIBS@ @DBUS_LIBS@ @GNUTLS_LIBS@ \
diff --git a/vpn/main.c b/vpn/main.c
index ee88aacd..133acd27 100644
--- a/vpn/main.c
+++ b/vpn/main.c
@@ -44,71 +44,10 @@
 
 #define CONFIGMAINFILE CONFIGDIR "/connman-vpn.conf"
 
-#define DEFAULT_INPUT_REQUEST_TIMEOUT 300 * 1000
-
 static GMainLoop *main_loop = NULL;
 
 static unsigned int __terminated = 0;
 
-static struct {
-       unsigned int timeout_inputreq;
-} connman_vpn_settings  = {
-       .timeout_inputreq = DEFAULT_INPUT_REQUEST_TIMEOUT,
-};
-
-static GKeyFile *load_config(const char *file)
-{
-       GError *err = NULL;
-       GKeyFile *keyfile;
-
-       keyfile = g_key_file_new();
-
-       g_key_file_set_list_separator(keyfile, ',');
-
-       if (!g_key_file_load_from_file(keyfile, file, 0, &err)) {
-               if (err->code != G_FILE_ERROR_NOENT) {
-                       connman_error("Parsing %s failed: %s", file,
-                                                               err->message);
-               }
-
-               g_error_free(err);
-               g_key_file_free(keyfile);
-               return NULL;
-       }
-
-       return keyfile;
-}
-
-static void parse_config(GKeyFile *config, const char *file)
-{
-       GError *error = NULL;
-       int timeout;
-
-       if (!config)
-               return;
-
-       DBG("parsing %s", file);
-
-       timeout = g_key_file_get_integer(config, "General",
-                       "InputRequestTimeout", &error);
-       if (!error && timeout >= 0)
-               connman_vpn_settings.timeout_inputreq = timeout * 1000;
-
-       g_clear_error(&error);
-}
-
-static int config_init(const char *file)
-{
-       GKeyFile *config;
-
-       config = load_config(file);
-       parse_config(config, file);
-       if (config)
-               g_key_file_free(config);
-
-       return 0;
-}
-
 static gboolean signal_handler(GIOChannel *channel, GIOCondition cond,
                                                        gpointer user_data)
 {
@@ -230,7 +169,7 @@ static GOptionEntry options[] = {
  */
 unsigned int connman_timeout_input_request(void)
 {
-       return connman_vpn_settings.timeout_inputreq;
+       return __vpn_settings_get_timeout_inputreq();
 }
 
 int main(int argc, char *argv[])
@@ -314,9 +253,9 @@ int main(int argc, char *argv[])
        __connman_dbus_init(conn);
 
        if (!option_config)
-               config_init(CONFIGMAINFILE);
+               __vpn_settings_init(CONFIGMAINFILE);
        else
-               config_init(option_config);
+               __vpn_settings_init(option_config);
 
        __connman_inotify_init();
        __connman_agent_init();
@@ -348,6 +287,7 @@ int main(int argc, char *argv[])
        __connman_inotify_cleanup();
        __connman_dbus_cleanup();
        __connman_log_cleanup(false);
+       __vpn_settings_cleanup();
 
        dbus_connection_unref(conn);
 
diff --git a/vpn/vpn-settings.c b/vpn/vpn-settings.c
new file mode 100644
index 00000000..40d2905a
--- /dev/null
+++ b/vpn/vpn-settings.c
@@ -0,0 +1,100 @@
+/*
+ *  ConnMan VPN daemon settings
+ *
+ *  Copyright (C) 2012-2013  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2018-2019 Jolla Ltd. All rights reserved.
+ *  Contact: [email protected]
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <connman/log.h>
+
+#include "vpn.h"
+
+#define DEFAULT_INPUT_REQUEST_TIMEOUT 300 * 1000
+
+static struct {
+       unsigned int timeout_inputreq;
+} connman_vpn_settings  = {
+       .timeout_inputreq               = DEFAULT_INPUT_REQUEST_TIMEOUT,
+};
+
+unsigned int __vpn_settings_get_timeout_inputreq()
+{
+       return connman_vpn_settings.timeout_inputreq;
+}
+
+static void parse_config(GKeyFile *config, const char *file)
+{
+       const char *group = "General";
+       GError *error = NULL;
+       int timeout;
+
+       if (!config)
+               return;
+
+       DBG("parsing %s", file);
+
+       timeout = g_key_file_get_integer(config, group,
+                       "InputRequestTimeout", &error);
+       if (!error && timeout >= 0)
+               connman_vpn_settings.timeout_inputreq = timeout * 1000;
+
+       g_clear_error(&error);
+}
+
+GKeyFile *__vpn_settings_load_config(const char *file)
+{
+       GError *err = NULL;
+       GKeyFile *keyfile;
+
+       keyfile = g_key_file_new();
+
+       g_key_file_set_list_separator(keyfile, ',');
+
+       if (!g_key_file_load_from_file(keyfile, file, 0, &err)) {
+               if (err->code != G_FILE_ERROR_NOENT) {
+                       connman_error("Parsing %s failed: %s", file,
+                                                               err->message);
+               }
+
+               g_error_free(err);
+               g_key_file_unref(keyfile);
+               return NULL;
+       }
+
+       return keyfile;
+}
+
+int __vpn_settings_init(const char *file)
+{
+       GKeyFile *config;
+
+       config = __vpn_settings_load_config(file);
+       parse_config(config, file);
+       if (config)
+               g_key_file_unref(config);
+
+       return 0;
+}
+
+void __vpn_settings_cleanup()
+{
+       return;
+}
diff --git a/vpn/vpn.h b/vpn/vpn.h
index 8bf86bd1..01e6aab1 100644
--- a/vpn/vpn.h
+++ b/vpn/vpn.h
@@ -116,3 +116,8 @@ char *__vpn_config_get_string(GKeyFile *key_file,
         const char *group_name, const char *key, GError **error);
 char **__vpn_config_get_string_list(GKeyFile *key_file,
         const char *group_name, const char *key, gsize *length, GError 
**error);
+
+int __vpn_settings_init(const char *file);
+void __vpn_settings_cleanup(void);
+GKeyFile *__vpn_settings_load_config(const char *file);
+unsigned int __vpn_settings_get_timeout_inputreq(void);
-- 
2.20.1



------------------------------

Subject: Digest Footer

_______________________________________________
connman mailing list
[email protected]
https://lists.01.org/mailman/listinfo/connman


------------------------------

End of connman Digest, Vol 42, Issue 26
***************************************

Reply via email to