[PATCH v0 0/2] OpenVPN logging
by Daniel Wagner
From: Daniel Wagner <daniel.wagner(a)bmw-carit.de>
Hi,
I am debugging some network setups here and found out that we don't
log anything from OpenVPN which is pretty sad. Let's fix this.
cheers,
daniel
Daniel Wagner (2):
openvpn: Fix stdout/stderr forwarding from deamon
openvpn: Add verbose flag
vpn/plugins/openvpn.c | 49 ++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 44 insertions(+), 5 deletions(-)
--
2.5.5
4 years, 3 months
[PATCH] technology: avoid redundant saving to the file system
by Yusuke Nakamura
Even if OfflineMode is the same as before, Connman always saves
to the file system. This patch makes Connman to save OfflineMode
only when it is actually changed in order to avoid redundant data
writing.
---
src/technology.c | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/src/technology.c b/src/technology.c
index 660af52..0fc2cb2 100644
--- a/src/technology.c
+++ b/src/technology.c
@@ -444,15 +444,31 @@ bool __connman_technology_get_offlinemode(void)
static void connman_technology_save_offlinemode(void)
{
GKeyFile *keyfile;
+ GError *error = NULL;
+ bool offlinemode;
keyfile = __connman_storage_load_global();
- if (!keyfile)
+
+ if (!keyfile) {
keyfile = g_key_file_new();
+ g_key_file_set_boolean(keyfile, "global",
+ "OfflineMode", global_offlinemode);
- g_key_file_set_boolean(keyfile, "global",
+ __connman_storage_save_global(keyfile);
+ }
+ else {
+ offlinemode = g_key_file_get_boolean(keyfile, "global",
+ "OfflineMode", &error);
+
+ if (error || offlinemode != global_offlinemode) {
+ g_key_file_set_boolean(keyfile, "global",
"OfflineMode", global_offlinemode);
+ if (error)
+ g_clear_error(&error);
- __connman_storage_save_global(keyfile);
+ __connman_storage_save_global(keyfile);
+ }
+ }
g_key_file_free(keyfile);
--
1.7.9.5
4 years, 3 months
[PATCH] rfkill: Open /dev/rfkill read-only if we are only reading from it
by Slava Monich
---
src/rfkill.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/rfkill.c b/src/rfkill.c
index 2bfb092..d9bed4d 100644
--- a/src/rfkill.c
+++ b/src/rfkill.c
@@ -196,7 +196,7 @@ int __connman_rfkill_init(void)
DBG("");
- fd = open("/dev/rfkill", O_RDWR | O_CLOEXEC);
+ fd = open("/dev/rfkill", O_RDONLY | O_CLOEXEC);
if (fd < 0) {
connman_error("Failed to open RFKILL control device");
return -EIO;
--
1.9.1
4 years, 3 months
[PATCH] timezone: Add support for setting timezone using timedated
by Philip Withnall
If we are running under systemd, the ProtectSystem key in our .service
file prevents us from writing to /etc/localtime. Instead, set the
timezone by using org.freedesktop.timedate1 over D-Bus, if it is
available. If it is not available, fall back to /etc/localtime.
Signed-off-by: Philip Withnall <philip.withnall(a)collabora.co.uk>
---
src/timezone.c | 213 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 210 insertions(+), 3 deletions(-)
diff --git a/src/timezone.c b/src/timezone.c
index e346b11..c74bfdd 100644
--- a/src/timezone.c
+++ b/src/timezone.c
@@ -38,11 +38,46 @@
#include <glib.h>
#include "connman.h"
+#include "gdbus.h"
#define ETC_LOCALTIME "/etc/localtime"
#define ETC_SYSCONFIG_CLOCK "/etc/sysconfig/clock"
#define USR_SHARE_ZONEINFO "/usr/share/zoneinfo"
+/* See https://www.freedesktop.org/wiki/Software/systemd/timedated/ for
+ * reference. */
+#define TIMEDATED_SERVICE "org.freedesktop.timedate1"
+#define TIMEDATED_INTERFACE TIMEDATED_SERVICE
+#define TIMEDATED_PATH "/org/freedesktop/timedate1"
+
+static GDBusClient *timedated_client = NULL;
+static GDBusProxy *timedated_proxy = NULL;
+static gchar *timedated_timezone = NULL;
+
+static void timedate_property_changed(GDBusProxy *proxy, const char *name,
+ DBusMessageIter *iter, void *user_data)
+{
+ DBG("Property %s", name);
+
+ if (g_str_equal(name, "Timezone")) {
+ const char *str;
+
+ if (!iter) {
+ g_dbus_proxy_refresh_property(proxy, name);
+ return;
+ }
+
+ if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_STRING)
+ return;
+
+ dbus_message_iter_get_basic(iter, &str);
+ g_free(timedated_timezone);
+ timedated_timezone = g_strdup(str);
+
+ DBG("Timezone set to %s", timedated_timezone);
+ }
+}
+
static char *read_key_file(const char *pathname, const char *key)
{
struct stat st;
@@ -226,7 +261,36 @@ static char *find_origin(void *src_map, struct stat *src_st,
return NULL;
}
-char *__connman_timezone_lookup(void)
+/* Query the timezone from org.freedesktop.timedate1. */
+static char *__connman_timezone_lookup_dbus(void)
+{
+ DBusMessageIter iter;
+ const char *str;
+
+ DBG("");
+
+ /* If timedated_timezone is set, we have been notified of the timezone
+ * previously. */
+ if (timedated_proxy && timedated_timezone)
+ return timedated_timezone;
+
+ /* Not connected to the D-Bus service? */
+ if (!timedated_proxy)
+ return NULL;
+
+ /* Query D-Bus and update the cache. */
+ if (!g_dbus_proxy_get_property(timedated_proxy, "Timezone", &iter))
+ return NULL;
+ dbus_message_iter_get_basic(&iter, &str);
+
+ g_free(timedated_timezone);
+ timedated_timezone = g_strdup(str);
+
+ return g_strdup(timedated_timezone);
+}
+
+/* Look up the timezone from /etc/sysconfig/clock or /etc/localtime. */
+static char *__connman_timezone_lookup_filesystem(void)
{
struct stat st;
void *map;
@@ -284,6 +348,20 @@ done:
return zone;
}
+char *__connman_timezone_lookup(void)
+{
+ char *timezone;
+
+ DBG("");
+
+ /* Try D-Bus first; then fall back to the filesystem. */
+ timezone = __connman_timezone_lookup_dbus();
+ if (timezone)
+ return timezone;
+
+ return __connman_timezone_lookup_filesystem();
+}
+
static int write_file(void *src_map, struct stat *src_st, const char *pathname)
{
struct stat st;
@@ -311,7 +389,53 @@ static int write_file(void *src_map, struct stat *src_st, const char *pathname)
return 0;
}
-int __connman_timezone_change(const char *zone)
+static void timezone_change_dbus_cb(DBusMessage *message, void *user_data)
+{
+ const char *zone = user_data;
+
+ if (dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_ERROR) {
+ const char *dbus_error = dbus_message_get_error_name(message);
+
+ DBG("zone %s %s", zone, dbus_error);
+ } else {
+ DBG("zone %s success", zone);
+ }
+}
+
+static void timezone_change_dbus_append(DBusMessageIter *iter,
+ void *user_data)
+{
+ const char *zone = user_data;
+ dbus_bool_t user_interaction = FALSE;
+
+ /* The second parameter is user_interaction — whether polkit should ask
+ * for credentials interactively if necessary. We do not want that.
+ *
+ * The polkit action controlling this is:
+ * org.freedesktop.timedate1.set-timezone. */
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &zone);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &user_interaction);
+}
+
+/* Set the timezone using org.freedesktop.timedate1. */
+static int __connman_timezone_change_dbus(const char *zone)
+{
+ /* Are we connected to the D-Bus service? */
+ if (!timedated_proxy)
+ return -ENOENT;
+
+ DBG("zone %s", zone);
+
+ if (!g_dbus_proxy_method_call(timedated_proxy, "SetTimezone",
+ timezone_change_dbus_append, timezone_change_dbus_cb,
+ g_strdup(zone), g_free))
+ return -EIO;
+
+ return -EINPROGRESS;
+}
+
+/* Set the timezone by overwriting /etc/localtime. */
+static int __connman_timezone_change_filesystem(const char *zone)
{
struct stat st;
char *map, pathname[PATH_MAX];
@@ -345,6 +469,23 @@ int __connman_timezone_change(const char *zone)
return err;
}
+int __connman_timezone_change(const char *zone)
+{
+ int err;
+
+ DBG("");
+
+ /* Try D-Bus first; then fall back to the filesystem. This order is
+ * important, as if we are running under systemd, /etc will be mounted
+ * read-only (due to the ProtectSystem key in our .service file), and
+ * hence only org.freedesktop.timedate1 can be used. */
+ err = __connman_timezone_change_dbus(zone);
+ if (err >= 0 || err == -EINPROGRESS)
+ return 0;
+
+ return __connman_timezone_change_filesystem(zone);
+}
+
static guint inotify_watch = 0;
static gboolean inotify_data(GIOChannel *channel, GIOCondition cond,
@@ -402,7 +543,45 @@ static gboolean inotify_data(GIOChannel *channel, GIOCondition cond,
return TRUE;
}
-int __connman_timezone_init(void)
+static int __connman_timezone_init_dbus(void)
+{
+ DBusConnection *connection;
+ int err = -EIO;
+
+ DBG("");
+
+ /* Try connecting to org.freedesktop.timedate1 first. If that fails,
+ * try /etc/localtime as a fallback. */
+ connection = connman_dbus_get_connection();
+
+ timedated_client = g_dbus_client_new(connection, TIMEDATED_SERVICE,
+ TIMEDATED_PATH);
+ if (!timedated_client)
+ goto error;
+
+ timedated_proxy = g_dbus_proxy_new(timedated_client, TIMEDATED_PATH,
+ TIMEDATED_INTERFACE);
+ if (!timedated_proxy)
+ goto error;
+
+ g_dbus_proxy_set_property_watch(timedated_proxy,
+ timedate_property_changed, NULL);
+
+ dbus_connection_unref(connection);
+
+ return 0;
+error:
+ if (timedated_client) {
+ g_dbus_client_unref(timedated_client);
+ timedated_client = NULL;
+ }
+
+ dbus_connection_unref(connection);
+
+ return err;
+}
+
+static int __connman_timezone_init_filesystem(void)
{
GIOChannel *channel;
char *dirname;
@@ -443,6 +622,21 @@ int __connman_timezone_init(void)
return 0;
}
+int __connman_timezone_init(void)
+{
+ int err;
+
+ DBG("");
+
+ /* Try connecting to org.freedesktop.timedate1 first. If that fails,
+ * try /etc/localtime as a fallback. */
+ err = __connman_timezone_init_dbus();
+ if (err >= 0)
+ return err;
+
+ return __connman_timezone_init_filesystem();
+}
+
void __connman_timezone_cleanup(void)
{
DBG("");
@@ -451,4 +645,17 @@ void __connman_timezone_cleanup(void)
g_source_remove(inotify_watch);
inotify_watch = 0;
}
+
+ if (timedated_proxy) {
+ g_dbus_proxy_unref(timedated_proxy);
+ timedated_proxy = NULL;
+ }
+
+ if (timedated_client) {
+ g_dbus_client_unref(timedated_client);
+ timedated_client = NULL;
+ }
+
+ g_free(timedated_timezone);
+ timedated_timezone = NULL;
}
--
2.7.4
4 years, 3 months
Do not lose wpa_supplicant interface configuration
by Jose Blanquicet
Hi,
Currently, each time ConnMan removes wpa_s interfaces at runtime the
configuration indicated in that file is lost. It was because wpa_s did
not expose the configuration file path in order to allow ConnMan to
recreate interfaces with the same configuration they were initially
created. In order to solve this we proposed a patch to wpa_s community
(b44d9c760fda85797187f1d0e97be47ed0182ed6), that patch aims to expose
the configuration file path as an D-Bus interface property. It was
recently applied and now ConnMan has the possibility to recreate
interfaces with the correct configuration file path, to solve the
following issues, (If someone knows other cases please let us know):
1. Enable/Disable WiFi: All wpa_s interfaces are removed, and config
information is lost.
2. Tethering: When enabling, the selected wpa_s interface is removed
and recreated with the bridge "tether". Also when disabling, again the
tethering wpa_s interface is removed and recreated without bridge.
After the tethering enable the config information is lost.
3. ConnMan turns off: All wpa_s interfaces are removed, and config
information is lost.
We are working on a patch to use this new property in order to not
lose the wpa_s interface configuration. To do this, we definitely need
to store this value before removing the interface and use it later
when recreating. We would like to discuss here on how and where store
this information in ConnMan:
1. Enable/Disable WiFi: Neither wifi nor device structs are removed,
so the path can be easily stored in any of these two structs.
2. Tethering: Both wifi and device structs are removed. We think that
could be a good idea to use a temporal struct inside Technology's
struct where we store the interface name or index and the config file
path of the tethering interface when tethering is disabling and then
pass this info again to wifi plugin when interface is re-detected and
will be re-created. There should not be problems because there is only
one tethering interface at a time per technology: anyone can confirm?
Please any feedback is appreciated.
3. ConnMan turns off: Due to ConnMan removes all wpa_s intefaces when
turning off, wpa_s remains almost useless and wpa_s cannot be used
neither from wpa_cli, because it will not communicate to wpa_s if it
has no interface registered. One idea could be then to close also
wpa_s.
Please everybody feel free to comment and make suggestions.
Regards,
Jose Blanquicet
4 years, 3 months
[PATCH 0/3] Move pacrunner to mozjs38
by Jeremy Linton
This set builds on the previous set moving pacrunner
to mozj24. This set fixes some general memory leaks/bugs
then moves pacrunner to mozjs38.
Jeremy Linton (3):
Fix test-mozjs memory leak
Fix unclean shutdown with proxy_disable
Pull mozjs forward to mozjs38
configure.ac | 4 +--
plugins/mozjs.cc | 87 ++++++++++++++++++++++++++++---------------------------
src/proxy.c | 4 ++-
unit/test-mozjs.c | 19 +++++++-----
4 files changed, 62 insertions(+), 52 deletions(-)
--
2.9.2
4 years, 3 months
A couple of question regarding tethering
by Jose Blanquicet
Hi,
I have three quick questions for tethering:
1. If I am not wrong, the return value when setting up an AP in
technology.c:set_tethering() can only be either 0, -EINPROGRESS or
-EOPNOTSUPP. Why it was implemented in such a way? This implementation
prevents to forward any occurred error in driver->set_tethering()
function.
2. There is a specific reason to continue trying to call
set_tethering() on others drivers after one of them has already
replied 0 or -EINPROGRESS? Why do not simply break the loop and
return?
3. Are we sure tethering.c:__connman_tethering_set_enabled() will
always complete successfully? I would prefer to add a return value to
this function and also to connman_technology_tethering_notify() in
order to check that all the operations done inside
__connman_tethering_set_enabled (Create the bridge and start/configure
DHCP server) have finished successfully before indicating tethering
was enabled and recreating the interface (Bridged with "tether") in
wifi.c:sta_remove_callback(). In fact, I would suggest to try to call
connman_technology_tethering_notify() before removing the wifi
interface. Does it make sense for you?
As you could see I mostly referred to wifi technology (plugin),
however this new return value could also be used by other technologies
supporting tethering (bluetooth, gadget, ethernet).
Regards,
Jose Blanquicet
4 years, 3 months
[PATCH 0/8] Connman changes for Android.
by Naveen Singh
These are the set of 8 patches required for connman to compile
for android.
Patch 1 - Detect Android in configure.ac
Patch 2 - Remove hard check for ns_initparse in configure.ac
Patch 3 - Add the local definition of ns_* functions in connman
Patch 4 - Add libraries based on build
Patch 5 - Get rid of definitions of in6_ifreq and in6_pktinfo
Patch 6 - Add the definition of ether_arp in connman for Android
Patch 7 - Adding android specific code in gweb/gresolv.c
Patch 8 - Include android header file to get definition of MAXDNSSRCH
Naveen Singh (8):
configure.ac: Introduce the notion of android
configure.ac: Remove hard check of ns_initparse
resolver: Adding ns_parse.c for android compilation
Makefile.am:libresolv.so and librt.so to be included only in Linux
build
Removing the definition of in6_ifreq and in6_pktinfo
struct ether_arp definition is missing in bionic
gweb/gresolv.c: Adding android specific code in gresolv.c
resolver: MAXDNSSRCH definition for android
Makefile.am | 12 ++-
configure.ac | 25 ++++-
gdhcp/client.c | 15 +++
gdhcp/common.c | 2 +-
gdhcp/common.h | 8 --
gdhcp/ipv4ll.c | 19 ++++
gweb/gresolv.c | 17 +++-
gweb/ns_parse.c | 279 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/inet.c | 6 --
src/resolver.c | 3 +
10 files changed, 364 insertions(+), 22 deletions(-)
create mode 100644 gweb/ns_parse.c
--
2.8.0.rc3.226.g39d4020
4 years, 3 months
PreferredTechonologies for 'ready' services
by Maxime CHEVALLIER
Hi all,
Following up on my previous post [1], I found this in the documentation
:
The doc 'connman.conf.5.in' specifies, for PreferredTechnologies :
"A service of a preferred technology type in state 'ready' will get the
default route when compared to another preferred type further down
the
list with state 'ready' or with a non-preferred type"
However this does not seem to be true :
The 'service_compare' function in src/service.c doesn't take the
PreferredTechnologies list into account when sorting services.
In my case ( cellular and ethernet 'ready', but never 'online' ), this
prevents me from having the 'cellular' technology as the default
service,
ethernet always goes back to the top of the list after a while :
my /etc/connman/main.conf :
[General]
PreferredTechnologies=cellular,ethernet
Output of connmanctl services 30 seconds after booting :
*AR Wired ethernet_0010025f0148_p00_cable
*AR DATA ONLY (F SFR) cellular_000000000000072_context1
*Ac Wired ethernet_0010025f0148_cable
I was wondering if this was a wrong description in the documentation,
or
if this was an actual missing check in the implementation.
I can work on a patch if needed, but that would be great if you can
confirm that this is an actual issue, and not me misinterpreting the
doc or the code.
Best regards,
Maxime Chevallier
[1] : https://lists.01.org/pipermail/connman/2016-September/020900.html
4 years, 4 months
[PATCH] gsupplicant: Fix memory leak
by Jose Blanquicet
Memory allocated to store Wi-Fi Display information needs to be freed.
The number of lost blocks is proportional to the number of found peers.
The following valgrind report was got when there were two peers in range:
==10427== 18 bytes in 2 blocks are definitely lost in loss record 48 of 181
==10427== at 0x4C2CC70: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==10427== by 0x4E85668: g_malloc0 (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
==10427== by 0x423C7C: peer_property (supplicant.c:2926)
==10427== by 0x42983C: supplicant_dbus_property_foreach (dbus.c:145)
==10427== by 0x429951: property_get_all_reply (dbus.c:184)
==10427== by 0x514A501: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.7.6)
==10427== by 0x514D730: dbus_connection_dispatch (in /lib/x86_64-linux-gnu/libdbus-1.so.3.7.6)
==10427== by 0x483C8F: message_dispatch (mainloop.c:72)
==10427== by 0x4E7FCE4: g_main_context_dispatch (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
==10427== by 0x4E80047: g_main_context_iterate.isra.24 (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
==10427== by 0x4E80309: g_main_loop_run (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
==10427== by 0x41001C: main (main.c:706)
---
gsupplicant/supplicant.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index 0a3815d..7200041 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -764,6 +764,7 @@ static void remove_peer(gpointer data)
g_free(peer->path);
g_free(peer->name);
g_free(peer->identifier);
+ g_free(peer->widi_ies);
g_free(peer);
}
--
1.9.1
4 years, 4 months