[PATCH v2 1/2] ntp: Fix potentially leaked addrinfo memory
by Peter Meerwald-Stadler
getaddrinfo() allocates a linked list of addrinfo structures;
in case family != AF_NET and != AF_INET6, the list is not feeded
freeaddrinfo() can be moved before the if-statement so that
the list is always freed
CID 1352476
---
src/ntp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/ntp.c b/src/ntp.c
index 9b1bb4f..3da1018 100644
--- a/src/ntp.c
+++ b/src/ntp.c
@@ -486,6 +486,7 @@ static void start_ntp(char *server)
family = info->ai_family;
memcpy(×erver_addr, info->ai_addr, info->ai_addrlen);
+ freeaddrinfo(info);
memset(&in6addr, 0, sizeof(in6addr));
if (family == AF_INET) {
@@ -503,7 +504,6 @@ static void start_ntp(char *server)
connman_error("Family is neither ipv4 nor ipv6");
return;
}
- freeaddrinfo(info);
DBG("server %s family %d", server, family);
--
2.7.4
5 years, 10 months
Add speed information to services
by Blanquicet-Melendez Jose (MM)
Hi everyone,
Nowadays most of the smartphones and laptops (Windows and Linux) provide the link speed information to the users, either to allow them to choose the most suitable network to connect to as well as (After having got connected) to show the current link speed. Unfortunately, this is something not provided by ConnMan yet.
Looking at the information we have inside ConnMan to implement such a feature, we found that we already have everything to do this. First of all, wpa_supplicant provides the list of BSS supported rates from which we could know if a BSS supports "b", "g" or "a", to distinguish between "g" or "a" we can just check the band for dual-band APs cases.
After that, the only missing information is to know whether "n" and "ac" are also supported, to do that we could take advantage of the IEs provided by the wpa_supplicant, there we just would have to check the presence of the VHT and HT capabilities.
Finally, by combining information from BSSs using the same SSID we would be able to provide speed information supported by each service: "a", "b", "g", "n" and "ac".
What do you think, would it be interesting? We would like to implement this feature and propose it to the community; any suggestion is welcome!
Regards,
Jose Blanquicet
________________________________
VISITA IL NOSTRO NUOVO SITO WEB! - VISIT OUR NEW WEB SITE! www.magnetimarelli.com
Confidential Notice: This message - including its attachments - may contain proprietary, confidential and/or legally protected information and is intended solely for the use of the designated addressee(s) above. If you are not the intended recipient be aware that any downloading, copying, disclosure, distribution or use of the contents of the above information is strictly prohibited.
If you have received this communication by mistake, please forward the message back to the sender at the email address above, delete the message from all mailboxes and any other electronic storage medium and destroy all copies.
Disclaimer Notice: Internet communications cannot be guaranteed to be safe or error-free. Therefore we do not assure that this message is complete or accurate and we do not accept liability for any errors or omissions in the contents of this message.
5 years, 10 months
[PATCH 1/3] Use AC_USE_SYSTEM_EXTENSIONS
by Ross Burton
Instead of using #define _GNU_SOURCE in some source files which causes problems
when building with musl as more files need the define, simply use
AC_USE_SYSTEM_EXTENSIONS in configure.ac to get it defined globally.
---
configure.ac | 1 +
gdhcp/client.c | 1 -
plugins/tist.c | 1 -
src/backtrace.c | 1 -
src/inet.c | 1 -
src/log.c | 1 -
src/ntp.c | 1 -
src/resolver.c | 1 -
src/rfkill.c | 1 -
src/stats.c | 1 -
src/timezone.c | 1 -
tools/stats-tool.c | 1 -
tools/tap-test.c | 1 -
tools/wispr.c | 1 -
vpn/plugins/vpn.c | 1 -
15 files changed, 1 insertion(+), 14 deletions(-)
diff --git a/configure.ac b/configure.ac
index 6e66ab3..bacf5ec 100644
--- a/configure.ac
+++ b/configure.ac
@@ -20,6 +20,7 @@ AC_SUBST(abs_top_srcdir)
AC_SUBST(abs_top_builddir)
AC_LANG_C
+AC_USE_SYSTEM_EXTENSIONS
AC_PROG_CC
AM_PROG_CC_C_O
diff --git a/gdhcp/client.c b/gdhcp/client.c
index fbb40ab..3aeb089 100644
--- a/gdhcp/client.c
+++ b/gdhcp/client.c
@@ -23,7 +23,6 @@
#include <config.h>
#endif
-#define _GNU_SOURCE
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
diff --git a/plugins/tist.c b/plugins/tist.c
index ad5ef79..cc2800a 100644
--- a/plugins/tist.c
+++ b/plugins/tist.c
@@ -23,7 +23,6 @@
#include <config.h>
#endif
-#define _GNU_SOURCE
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
diff --git a/src/backtrace.c b/src/backtrace.c
index 6a66c0a..4dbdda8 100644
--- a/src/backtrace.c
+++ b/src/backtrace.c
@@ -24,7 +24,6 @@
#include <config.h>
#endif
-#define _GNU_SOURCE
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
diff --git a/src/inet.c b/src/inet.c
index 69ded19..81d92c2 100644
--- a/src/inet.c
+++ b/src/inet.c
@@ -25,7 +25,6 @@
#include <config.h>
#endif
-#define _GNU_SOURCE
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
diff --git a/src/log.c b/src/log.c
index 9bae4a3..f7e82e5 100644
--- a/src/log.c
+++ b/src/log.c
@@ -23,7 +23,6 @@
#include <config.h>
#endif
-#define _GNU_SOURCE
#include <stdio.h>
#include <unistd.h>
#include <stdarg.h>
diff --git a/src/ntp.c b/src/ntp.c
index dd246eb..db8ae96 100644
--- a/src/ntp.c
+++ b/src/ntp.c
@@ -23,7 +23,6 @@
#include <config.h>
#endif
-#define _GNU_SOURCE
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
diff --git a/src/resolver.c b/src/resolver.c
index fbe4be7..ef61f92 100644
--- a/src/resolver.c
+++ b/src/resolver.c
@@ -23,7 +23,6 @@
#include <config.h>
#endif
-#define _GNU_SOURCE
#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
diff --git a/src/rfkill.c b/src/rfkill.c
index 2bfb092..af49d12 100644
--- a/src/rfkill.c
+++ b/src/rfkill.c
@@ -23,7 +23,6 @@
#include <config.h>
#endif
-#define _GNU_SOURCE
#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
diff --git a/src/stats.c b/src/stats.c
index 26343b1..cfcdc94 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -23,7 +23,6 @@
#include <config.h>
#endif
-#define _GNU_SOURCE
#include <errno.h>
#include <sys/mman.h>
#include <sys/types.h>
diff --git a/src/timezone.c b/src/timezone.c
index e346b11..8e91267 100644
--- a/src/timezone.c
+++ b/src/timezone.c
@@ -23,7 +23,6 @@
#include <config.h>
#endif
-#define _GNU_SOURCE
#include <errno.h>
#include <stdio.h>
#include <fcntl.h>
diff --git a/tools/stats-tool.c b/tools/stats-tool.c
index b076478..428d94b 100644
--- a/tools/stats-tool.c
+++ b/tools/stats-tool.c
@@ -22,7 +22,6 @@
#include <config.h>
#endif
-#define _GNU_SOURCE
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
diff --git a/tools/tap-test.c b/tools/tap-test.c
index fdc098a..57917f5 100644
--- a/tools/tap-test.c
+++ b/tools/tap-test.c
@@ -23,7 +23,6 @@
#include <config.h>
#endif
-#define _GNU_SOURCE
#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
diff --git a/tools/wispr.c b/tools/wispr.c
index d5f9341..e56dfc1 100644
--- a/tools/wispr.c
+++ b/tools/wispr.c
@@ -23,7 +23,6 @@
#include <config.h>
#endif
-#define _GNU_SOURCE
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
diff --git a/vpn/plugins/vpn.c b/vpn/plugins/vpn.c
index 9a42385..479c3a7 100644
--- a/vpn/plugins/vpn.c
+++ b/vpn/plugins/vpn.c
@@ -23,7 +23,6 @@
#include <config.h>
#endif
-#define _GNU_SOURCE
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
--
2.8.1
5 years, 10 months
Not sure how to fix this bug
by Thomas Green
In connman 1.33 I have come up with an interesting scenario, and am not sure how to fix it. The easiest way to duplicate it is to plug my wired connection into a switch that is turned on, but does -not- have the uplink cable plugged in. After the DHCP request fails, there is some (random?) address assigned (169.254.x.x). At that point the uplink cable on the switch is plugged in. When a DHCP solicitation is sent again, and an answer is received, connman gets the information, but does not send the new nameserver information. Attached is a copy of the debug log I have, and at about line 149 you see where the nameservers are saved. But after that, they are all used internally, but my application does not get a PropertyChanged signal indicating the change.
It seems to me it would be a quick fix but I'm not sure where is the best place to do it.
Thank you for your help
Tom
5 years, 10 months
[PATCH 1/2] ntp: Fix potentially leaked addrinfo
by Peter Meerwald-Stadler
CID 1352476
---
src/ntp.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/ntp.c b/src/ntp.c
index 9b1bb4f..bb15792 100644
--- a/src/ntp.c
+++ b/src/ntp.c
@@ -477,15 +477,15 @@ static void start_ntp(char *server)
hint.ai_socktype = SOCK_DGRAM;
hint.ai_flags = AI_NUMERICHOST | AI_PASSIVE;
ret = getaddrinfo(server, NULL, &hint, &info);
-
if (ret) {
connman_error("cannot get server info");
return;
}
family = info->ai_family;
-
memcpy(×erver_addr, info->ai_addr, info->ai_addrlen);
+ freeaddrinfo(info);
+
memset(&in6addr, 0, sizeof(in6addr));
if (family == AF_INET) {
@@ -503,7 +503,6 @@ static void start_ntp(char *server)
connman_error("Family is neither ipv4 nor ipv6");
return;
}
- freeaddrinfo(info);
DBG("server %s family %d", server, family);
--
2.7.4
5 years, 10 months
[PATCH 1/3] docs: update manager-api.txt to include BrowserOnly Key
by Atul Anand
It has been documented that we are adding a new dict key BrowserOnly
on PACrunner DBus interface.
---
doc/manager-api.txt | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/doc/manager-api.txt b/doc/manager-api.txt
index 9e6209d..0e0b7aa 100644
--- a/doc/manager-api.txt
+++ b/doc/manager-api.txt
@@ -60,6 +60,12 @@ Methods object CreateProxyConfiguration(dict settings)
Interface name like "wlan0" etc. to provide
consistent results for myIpAddress function.
+ boolean BrowserOnly [optional]
+
+ If this value is set, proxy configuration will
+ be used for only browser schemes. If no Key is
+ received PACrunner assumes FALSE by default.
+
array{string} Domains [optional]
Domain names and IP range for which this proxy
--
2.5.5
5 years, 10 months
/etc/resolv.conf disable overwrite
by Moberg, Patrik
Hello,
Is there anyway to tell Connman not to overwrite /etc/resolv.conf in version 1.33?
I am starting Connman with --nodnsproxy.
Cheers,
Patrik Moberg
5 years, 10 months
[PATCH] connman.service: Use ProtectSystem=true to allow writing /etc/localtime
by Philip Withnall
Setting the timezone requires unlinking and relinking /etc/localtime,
so
we need /etc to be mounted read–write. This means that commit dc8f151e
has to be softened to ProtectSystem=true rather than
ProtectSystem=full. This mounts most of the filesystem as read-only,
apart from /etc, which is read–write.
Signed-off-by: Philip Withnall <philip.withnall(a)collabora.co.uk>
---
src/connman.service.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/connman.service.in b/src/connman.service.in
index 57eaaf9..d5d6d44 100644
--- a/src/connman.service.in
+++ b/src/connman.service.in
@@ -15,7 +15,7 @@ ExecStart=@sbindir@/connmand -n
StandardOutput=null
CapabilityBoundingSet=CAP_KILL CAP_NET_ADMIN CAP_NET_BIND_SERVICE
CAP_NET_RAW CAP_SYS_TIME CAP_SYS_MODULE
ProtectHome=true
-ProtectSystem=full
+ProtectSystem=true
[Install]
WantedBy=multi-user.target
--
2.5.5
5 years, 10 months
[PATCH] Pull pacrunner forward to mozjs24
by Jeremy Linton
Mozjs185 is getting really old and unsupported. Newer versions
of the mozjs JSAPI are C++ based. Start the conversion to more recent
JSAPI's by updating pacrunner to use mozjs24 which is a common version
being used by a number of distributions. It also happens to be the first
C++ only version of JSAPI.
Signed-off-by: Jeremy Linton <jeremy.linton(a)arm.com>
---
Makefile.am | 6 +++---
configure.ac | 4 ++--
plugins/{mozjs.c => mozjs.cpp} | 36 +++++++++++++++++++-----------------
3 files changed, 24 insertions(+), 22 deletions(-)
rename plugins/{mozjs.c => mozjs.cpp} (82%)
diff --git a/Makefile.am b/Makefile.am
index ee84b75..21a602d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -31,7 +31,7 @@ endif
if MOZJS
js_sources = src/js_funcs.c
builtin_modules += mozjs
-builtin_sources += plugins/mozjs.c
+builtin_sources += plugins/mozjs.cpp
builtin_cflags += @MOZJS_CFLAGS@
builtin_libadd += @MOZJS_LIBS@
endif
@@ -137,7 +137,7 @@ unit_test_pacrunner_LDADD += @CURL_LIBS@
endif
if MOZJS
-unit_test_pacrunner_SOURCES += plugins/mozjs.c
+unit_test_pacrunner_SOURCES += plugins/mozjs.cpp
unit_test_pacrunner_LDADD += @MOZJS_LIBS@ @PTHREAD_LIBS@
@@ -145,7 +145,7 @@ noinst_PROGRAMS += unit/test-mozjs
unit_test_mozjs_SOURCES = unit/test-mozjs.c src/pacrunner.h \
src/proxy.c src/manual.c src/download.c \
- src/js.c plugins/mozjs.c $(js_sources)
+ src/js.c plugins/mozjs.cpp $(js_sources)
unit_test_mozjs_LDADD = @MOZJS_LIBS@ @GLIB_LIBS@ @PTHREAD_LIBS@
endif
diff --git a/configure.ac b/configure.ac
index 42a64a9..d2fc8f8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -76,8 +76,8 @@ AM_CONDITIONAL(DUKTAPE, test "${enable_duktape}" = "yes")
AC_ARG_ENABLE(mozjs, AC_HELP_STRING([--enable-mozjs],
[enable Mozilla Javascript plugin support]))
if (test "${enable_mozjs}" = "yes"); then
- PKG_CHECK_MODULES(MOZJS, mozjs185, dummy=yes,
- AC_MSG_ERROR(Mozilla Javascript >= 1.8 is required))
+ PKG_CHECK_MODULES(MOZJS, mozjs-24, dummy=yes,
+ AC_MSG_ERROR(Mozilla Javascript >= 24 is required))
AC_SUBST(MOZJS_CFLAGS)
AC_SUBST(MOZJS_LIBS)
fi
diff --git a/plugins/mozjs.c b/plugins/mozjs.cpp
similarity index 82%
rename from plugins/mozjs.c
rename to plugins/mozjs.cpp
index a923203..843b2fa 100644
--- a/plugins/mozjs.c
+++ b/plugins/mozjs.cpp
@@ -34,8 +34,10 @@
#include <jsapi.h>
#pragma GCC diagnostic error "-Wredundant-decls"
+extern "C" {
#include "pacrunner.h"
#include "js.h"
+}
static pthread_mutex_t mozjs_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -43,11 +45,12 @@ struct pacrunner_mozjs {
struct pacrunner_proxy *proxy;
JSContext *jsctx;
JSObject *jsobj;
+ JSAutoCompartment *jsac;
};
-static JSBool myipaddress(JSContext *jsctx, uintN argc, jsval *vp)
+static JSBool myipaddress(JSContext *jsctx, unsigned argc, jsval *vp)
{
- struct pacrunner_mozjs *ctx = JS_GetContextPrivate(jsctx);
+ struct pacrunner_mozjs *ctx = (pacrunner_mozjs *)JS_GetContextPrivate(jsctx);
char address[NI_MAXHOST];
DBG("");
@@ -68,9 +71,9 @@ static JSBool myipaddress(JSContext *jsctx, uintN argc, jsval *vp)
return JS_TRUE;
}
-static JSBool dnsresolve(JSContext *jsctx, uintN argc, jsval *vp)
+static JSBool dnsresolve(JSContext *jsctx, unsigned argc, jsval *vp)
{
- struct pacrunner_mozjs *ctx = JS_GetContextPrivate(jsctx);
+ struct pacrunner_mozjs *ctx = (pacrunner_mozjs *)JS_GetContextPrivate(jsctx);
char address[NI_MAXHOST];
jsval *argv = JS_ARGV(jsctx, vp);
char *host = JS_EncodeString(jsctx, JS_ValueToString(jsctx, argv[0]));
@@ -97,10 +100,10 @@ static JSBool dnsresolve(JSContext *jsctx, uintN argc, jsval *vp)
static JSClass jscls = {
"global", JSCLASS_GLOBAL_FLAGS,
- JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
+ JS_PropertyStub, JS_DeletePropertyStub, JS_PropertyStub,
JS_StrictPropertyStub,
- JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
+ JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, NULL,
+ JSCLASS_NO_OPTIONAL_MEMBERS
};
static JSRuntime *jsrun;
@@ -115,7 +118,7 @@ static int create_object(struct pacrunner_proxy *proxy)
if (!script)
return 0;
- ctx = g_malloc0(sizeof(struct pacrunner_mozjs));
+ ctx = (pacrunner_mozjs *)g_malloc0(sizeof(struct pacrunner_mozjs));
ctx->proxy = proxy;
ctx->jsctx = JS_NewContext(jsrun, 8 * 1024);
@@ -126,12 +129,10 @@ static int create_object(struct pacrunner_proxy *proxy)
JS_SetContextPrivate(ctx->jsctx, ctx);
__pacrunner_proxy_set_jsctx(proxy, ctx);
-#if JS_VERSION >= 185
- ctx->jsobj = JS_NewCompartmentAndGlobalObject(ctx->jsctx, &jscls,
- NULL);
-#else
- ctx->jsobj = JS_NewObject(ctx->jsctx, &jscls, NULL, NULL);
-#endif
+ JS::CompartmentOptions compart_opts;
+ compart_opts.setVersion(JSVERSION_LATEST);
+ ctx->jsobj = JS_NewGlobalObject(ctx->jsctx, &jscls, NULL, compart_opts);
+ ctx->jsac = new JSAutoCompartment(ctx->jsctx, ctx->jsobj);
if (!JS_InitStandardClasses(ctx->jsctx, ctx->jsobj))
pacrunner_error("Failed to init JS standard classes");
@@ -152,13 +153,14 @@ static int create_object(struct pacrunner_proxy *proxy)
static int mozjs_clear_proxy(struct pacrunner_proxy *proxy)
{
- struct pacrunner_mozjs *ctx = __pacrunner_proxy_get_jsctx(proxy);
+ struct pacrunner_mozjs *ctx = (pacrunner_mozjs *)__pacrunner_proxy_get_jsctx(proxy);
DBG("proxy %p ctx %p", proxy, ctx);
if (!ctx)
return -EINVAL;
+ delete ctx->jsac;
JS_DestroyContext(ctx->jsctx);
__pacrunner_proxy_set_jsctx(proxy, NULL);
@@ -180,7 +182,7 @@ static int mozjs_set_proxy(struct pacrunner_proxy *proxy)
static char * mozjs_execute(struct pacrunner_proxy *proxy, const char *url,
const char *host)
{
- struct pacrunner_mozjs *ctx = __pacrunner_proxy_get_jsctx(proxy);
+ struct pacrunner_mozjs *ctx = (pacrunner_mozjs *)__pacrunner_proxy_get_jsctx(proxy);
JSBool result;
jsval rval, args[2];
char *answer, *g_answer;
@@ -229,7 +231,7 @@ static int mozjs_init(void)
{
DBG("");
- jsrun = JS_NewRuntime(8 * 1024 * 1024);
+ jsrun = JS_NewRuntime(8 * 1024 * 1024, JS_USE_HELPER_THREADS);
return pacrunner_js_driver_register(&mozjs_driver);
}
--
2.9.2
5 years, 10 months
An question for "ServicesChanged"
by Zheng, Wu
Hi upstream,
To get the wifi services list from the "ServicesChanged" signal of net.connman.Manager ,
I meet an question.
1. If the connman find the new services,
the connman will send the all items of services via the "ServicesChanged" signal of net.connman.Manager.
2. If the connman find the existed services with the services' items changed,
the connman will not send the items of services via the "ServicesChanged" signal of net.connman.Manager.
the user only gets the "ServicesChanged" signal of net.connman.Manager and not get the services' items.
The root cause is that in the function of "service_append_added_foreach",
only the services' items of "services_notify->add" is added to the "ServicesChanged" signal of net.connman.Manager.
If the services have exist, the services can't be added to "services_notify->add".
Therefore, any items' modification of the existed services can't be sent to the user via the "ServicesChanged" signal of net.connman.Manager.
Is it right?
If so, the user only use the "GetProperties" of "net.connman.Manager" to get the items of existed services
when the user get the "ServicesChanged" signal of net.connman.Manager.
Best Regards
Zheng Wu
5 years, 10 months