connman removes FallbackNameservers at startup

2015-10-30 Thread Yevhen Kyriukha
Hello,

I noticed an issue with FallbackNameservers.
When connman starts on system boot it tries to connect to name servers
that are specified in FallbackNameservers. But NIC is usually not
ready by that moment and connman removes name servers with message:

Failed to connect to server 8.8.8.8

So when I run ./list-services script I do not see Nameservers that was
specified.

-- 
Regards,
Yevhen
___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[RFC 4/5] src: Add tmpfiles.d support for resolv.conf

2015-10-30 Thread Patrik Flykt
Add tmpfiles.d support for unconditionally creating a symlink from
[/var]/run/connman/resolv.conf to /etc/resolv.conf.

To keep the same behavior as before, the configuration file is
installed to tmpfiles.d. If /etc/resolv.conf behavior needs to be
specified differently by a distribution, do not install the
tmpfiles.d configuration file.
---
 Makefile.am| 17 +
 configure.ac   |  8 
 scripts/connman_resolvconf.conf.in |  1 +
 3 files changed, 22 insertions(+), 4 deletions(-)
 create mode 100644 scripts/connman_resolvconf.conf.in

diff --git a/Makefile.am b/Makefile.am
index 96abab7..95082c1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -63,9 +63,11 @@ endif
 
 if SYSTEMD
 systemdunitdir = @SYSTEMD_UNITDIR@
-
 systemdunit_DATA = src/connman.service
 
+tmpfilesdir = @SYSTEMD_TMPFILESDIR@
+nodist_tmpfiles_DATA = scripts/connman_resolvconf.conf
+
 if VPN
 systemdunit_DATA += vpn/connman-vpn.service
 endif
@@ -153,7 +155,8 @@ vpn_connman_vpnd_LDFLAGS = -Wl,--export-dynamic \
-Wl,--version-script=$(srcdir)/vpn/vpn.ver
 endif
 
-BUILT_SOURCES = $(local_headers) src/builtin.h $(service_files) scripts/connman
+BUILT_SOURCES = $(local_headers) src/builtin.h $(service_files) \
+   scripts/connman scripts/connman_resolvconf.conf
 
 if VPN
 BUILT_SOURCES += vpn/builtin.h
@@ -386,7 +389,8 @@ EXTRA_DIST += doc/overview-api.txt doc/behavior-api.txt \
doc/connman.8.in doc/connman-vpn.8.in
 
 EXTRA_DIST += src/main.conf \
-   src/eduroam.config
+   src/eduroam.config \
+   scripts/connman_resolvconf.conf.in
 
 MANUAL_PAGES += doc/connmanctl.1 doc/connman.conf.5 \
doc/connman-service.config.5 doc/connman-vpn.conf.5 \
@@ -457,7 +461,8 @@ do_subst = $(AM_V_GEN)$(SED) \
-e 's,[@]sysconfdir[@],$(sysconfdir),g' \
-e 's,[@]storagedir[@],$(storagedir),g' \
-e 's,[@]vpn_storagedir[@],$(vpn_storagedir),g' \
-   -e 's,[@]localstatedir[@],$(localstatedir),g'
+   -e 's,[@]localstatedir[@],$(localstatedir),g' \
+   -e 's,[@]runstatedir[@],$(runstatedir),g'
 
 %.1 : %.1.in
$(AM_V_at)$(MKDIR_P) $(dir $@)
@@ -479,6 +484,10 @@ scripts/connman: scripts/connman.in Makefile
$(AM_V_at)$(MKDIR_P) $(dir $@)
$(do_subst) < $< > $@
 
+scripts/connman_resolvconf.conf: scripts/connman_resolvconf.conf.in
+   $(AM_V_at)$(MKDIR_P) $(dir $@)
+   $(do_subst) < $< > $@
+
 include/connman/version.h: include/version.h
$(AM_V_at)$(MKDIR_P) include/connman
$(AM_V_GEN)$(LN_S) $(abs_top_builddir)/$< $@
diff --git a/configure.ac b/configure.ac
index 51482cb..b51d6b3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -254,6 +254,14 @@ if (test -n "${path_systemdunit}"); then
 fi
 AM_CONDITIONAL(SYSTEMD, test -n "${path_systemdunit}")
 
+AC_ARG_WITH([tmpfilesdir], AC_HELP_STRING([--with-tmpfilesdir=DIR],
+   [path to systemd tmpfiles.d directory]), [path_tmpfiles=${withval}],
+   [path_tmpfiles="`$PKG_CONFIG --variable=tmpfilesdir systemd`"])
+if (test -n "${path_tmpfiles}"); then
+   SYSTEMD_TMPFILESDIR="${path_tmpfiles}"
+   AC_SUBST(SYSTEMD_TMPFILESDIR)
+fi
+
 PKG_CHECK_MODULES(XTABLES, xtables >= 1.4.11, dummy=yes,
AC_MSG_ERROR(Xtables library is required))
 AC_SUBST(XTABLES_CFLAGS)
diff --git a/scripts/connman_resolvconf.conf.in 
b/scripts/connman_resolvconf.conf.in
new file mode 100644
index 000..e47dc07
--- /dev/null
+++ b/scripts/connman_resolvconf.conf.in
@@ -0,0 +1 @@
+L+ /etc/resolv.conf- - - - @runstatedir@/connman/resolv.conf
-- 
2.1.4

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[RFC 5/5] scripts: Handle link to resolv.conf in init script

2015-10-30 Thread Patrik Flykt
Add init script functionality to create a symlink by default from
[/var]/run/connman/resolv.conf to /etc/resolv.conf.
---
 scripts/connman.in | 4 
 1 file changed, 4 insertions(+)

diff --git a/scripts/connman.in b/scripts/connman.in
index 1692b95..9cc5895 100644
--- a/scripts/connman.in
+++ b/scripts/connman.in
@@ -9,6 +9,10 @@ if [ -f @sysconfdir@/default/connman ] ; then
. @sysconfdir@/default/connman
 fi
 
+if [ "HANDLE_RESOLVCONF" != "no" ] ; then
+ln -sf @runstatedir@/connman/resolv.conf /etc/
+fi
+
 set -e
 
 do_start() {
-- 
2.1.4

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[RFC 2/5] build: Use runstatedir instead of deriving it from localstatedir

2015-10-30 Thread Patrik Flykt
With $(runstatedir) being defined, use it instead of $(localstatedir)/run.
---
 Makefile.am | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 4319c4c..96abab7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -161,8 +161,8 @@ endif
 
 CLEANFILES = src/connman.conf $(BUILT_SOURCES) $(service_files)
 
-statedir = $(localstatedir)/run/connman
-vpn_statedir = $(localstatedir)/run/connman-vpn
+statedir = $(runstatedir)/connman
+vpn_statedir = $(runstatedir)/connman-vpn
 
 if VPN
 vpn_plugindir = $(libdir)/connman/plugins-vpn
-- 
2.1.4

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[RFC 0/5] Move resolv.conf to /run/connman

2015-10-30 Thread Patrik Flykt

Hi,

One of the features asked every now and then is how to keep ConnMan from
always writing resolv.conf. This RFC patch set makes ConnMan write its
resolv.conf file into [/var]/run/connman and unconditionally set up links
by default to this file from /etc/resolv.conf.

Patch 3/5 changes ConnMan to create the [/var]/run/connman directory and
always write resolv.conf to this location. In order to keep compatibility
with previous versions, patch 4/5 implements tmpfiles.d support to
unconditionally create the symlink to /etc when using systemd. Likewise,
the init script is updated in patch 5/5 with similar functionality, should
someone use that startup method.

In order to be a bit future-proof, the first patch introduces the
$(runstatedir) variable in a compatible manner, as the variable will
appear starting with automake 2.70. The two invocations of
$(localstatedir)/run are updated to use $(runstatedir) in patch 2/5.


Please review and comment,

   Patrik



Patrik Flykt (5):
  build: Define runstatedir
  build: Use runstatedir instead of deriving it from localstatedir
  resolver: Create STATEDIR and use it when writing resolv.conf
  src: Add tmpfiles.d support for resolv.conf
  scripts: Handle link to resolv.conf in init script

 .gitignore |  2 ++
 Makefile.am| 21 +++--
 configure.ac   | 12 
 m4/configmake.m4   | 15 +++
 scripts/connman.in |  4 
 scripts/connman_resolvconf.conf.in |  1 +
 src/main.c |  6 ++
 src/resolver.c |  2 +-
 8 files changed, 56 insertions(+), 7 deletions(-)
 create mode 100644 m4/configmake.m4
 create mode 100644 scripts/connman_resolvconf.conf.in

-- 
2.1.4

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[RFC 3/5] resolver: Create STATEDIR and use it when writing resolv.conf

2015-10-30 Thread Patrik Flykt
Create STATEDIR [/var]/run/connman and unconditionally write resolv.conf
to this directory.
---
 src/main.c | 6 ++
 src/resolver.c | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/main.c b/src/main.c
index e46fa7b..6cf6bc8 100644
--- a/src/main.c
+++ b/src/main.c
@@ -623,6 +623,12 @@ int main(int argc, char *argv[])
perror("Failed to create storage directory");
}
 
+   if (mkdir(STATEDIR, S_IRUSR | S_IWUSR | S_IXUSR |
+   S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) < 0) {
+   if (errno != EEXIST)
+   perror("Failed to create storage directory");
+   }
+
umask(0077);
 
main_loop = g_main_loop_new(NULL, FALSE);
diff --git a/src/resolver.c b/src/resolver.c
index 6a64938..9db2756 100644
--- a/src/resolver.c
+++ b/src/resolver.c
@@ -130,7 +130,7 @@ static int resolvfile_export(void)
 
old_umask = umask(022);
 
-   fd = open("/etc/resolv.conf", O_RDWR | O_CREAT | O_CLOEXEC,
+   fd = open(STATEDIR"/resolv.conf", O_RDWR | O_CREAT | O_CLOEXEC,
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (fd < 0) {
err = -errno;
-- 
2.1.4

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[RFC 1/5] build: Define runstatedir

2015-10-30 Thread Patrik Flykt
Provide an m4 macro defining runstatedir as $(localstatedir)/var. This
applies to automake versions < 2.70.
---
 .gitignore   |  2 ++
 configure.ac |  4 
 m4/configmake.m4 | 15 +++
 3 files changed, 21 insertions(+)
 create mode 100644 m4/configmake.m4

diff --git a/.gitignore b/.gitignore
index bbb44c3..74acd7c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,6 +24,8 @@ missing
 stamp-h1
 autom4te.cache
 test-driver
+m4/
+!m4/configmake.m4
 
 connman.pc
 include/connman
diff --git a/configure.ac b/configure.ac
index 69c0eeb..51482cb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,8 @@
 AC_PREREQ(2.60)
 AC_INIT(connman, 1.30)
 
+AC_CONFIG_MACRO_DIR([m4])
+
 AM_INIT_AUTOMAKE([foreign subdir-objects color-tests])
 AC_CONFIG_HEADERS([config.h])
 
@@ -31,6 +33,8 @@ m4_ifdef([AC_LIBTOOL_TAGS], [AC_LIBTOOL_TAGS([])])
 AC_DISABLE_STATIC
 AC_PROG_LIBTOOL
 
+gl_CONFIGMAKE_PREP
+
 AC_ARG_ENABLE(optimization, AC_HELP_STRING([--disable-optimization],
[disable code optimization through compiler]), [
if (test "${enableval}" = "no"); then
diff --git a/m4/configmake.m4 b/m4/configmake.m4
new file mode 100644
index 000..ef78ebe
--- /dev/null
+++ b/m4/configmake.m4
@@ -0,0 +1,15 @@
+# configmake.m4 serial 2
+dnl Copyright (C) 2010-2015 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+# gl_CONFIGMAKE_PREP
+# --
+AC_DEFUN([gl_CONFIGMAKE_PREP],
+[
+  dnl Added in autoconf 2.70
+  if test "x$runstatedir" = x; then
+AC_SUBST([runstatedir], ['${localstatedir}/run'])
+  fi
+])
-- 
2.1.4

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


Re: ConnMan doesn't clear rfkill softblock when Wi-Fi plugged in after start-up

2015-10-30 Thread Patrik Flykt
On Fri, 2015-10-30 at 12:28 +1100, Craig McQueen wrote:
> Consider this pre-condition:
> 
> * ConnMan is configured for Wi-Fi enabled and tethered.
> * USB Wi-Fi device is not plugged in.
> * Linux rfkill softblock is enabled for wlan.

ConnMan follows the external softblock state. So if something else
enabled rfkill on WiFi, ConnMan should have disabled the technology at
this point. Please verify the state of WiFi technology at this point.

> Now, consider this scenario:
> 
> * ConnMan was not running.
> * USB Wi-Fi device is plugged in.
> * ConnMan is started.
> 
> In that scenario, ConnMan detects the Wi-Fi technology, enables it,
> turns off the rfkill softblock for wlan, and starts tethering. Good!

When ConnMan starts it will know that its last technology state for WiFi
was 'enabled' and therefore disables rfkill on startup.

> Now consider this alternative scenario:
> 
> * ConnMan is running.
> * USB Wi-Fi device is plugged in.
> 
> In this scenario, ConnMan detects the Wi-Fi technology, but doesn't
> enable it because of the rfkill softblock for wlan.

If this starts from the precondition above, we have all of the following
events taking place:
- ConnMan was started
- rfkill enabled for wifi by some external entity
- ConnMan updates technology to 'disabled' in response
- USB WiFi device plugged in
- Nothing happens as the technology is disabled

If this is the scenario, please check that WiFi got disabled after
rfkill was enabled for WiFi.

> In this second scenario, I would wish for ConnMan to turn off the
> rfkill softblock for wlan (since it is configured for Wi-Fi enabled
> and tethered), and start tethering. What code change would be needed
> to achieve that?

ConnMan follows external settings of rfkill events, see above.

Cheers,

Patrik


___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


Re: Wi-Fi service won't auto-connect when Ethernet is already present

2015-10-30 Thread Patrik Flykt
On Fri, 2015-10-30 at 14:18 +1100, Craig McQueen wrote:
> I'm using ConnMan v1.30 on a BeagleBone Black based system. I've got a
> USB Wi-Fi device, as well as Ethernet.
> 
> Is it possible to configure ConnMan so that it will auto-connect Wi-Fi
> even if it's got an Ethernet connection? Ethernet would still be
> "preferred" in the sense of having the default route. But I want Wi-Fi
> to always connect if an auto-connect service is available, even while
> Ethernet is present.

No. ConnMan will autoconnect a newly detected WiFi only if wifi is a
more preferred technology than the already connected ethernet.

> If Wi-Fi connects while Ethernet is unplugged, then later Ethernet is
> plugged in, then they can both be connected at the same time, which is
> good.

Yes. Ethernet is more preferred than WiFi, so it will be selected as the
interface with the default route. As it is more preferred than WiFi, it
will be automatically connected.

But as it is ethernet, it's also a bit special. It will always be
connected on a cable plug-in as documented in doc/service-api.txt,
Connect() method call.

> But if Ethernet connects first, and the USB Wi-Fi device is plugged in
> later, then it won't auto-connect to the configured Wi-Fi service, and
> I wish it would.

WiFi won't autoconnect as ethernet is more preferred than wifi by
default.

> I've read the "Preferred Technologies" section of the ConnMan web site
> documentation page. It sounds as though there are twists indeed. Can
> the "Preferred Technologies" feature be disabled? I tried putting in
> my /etc/connman/main.conf:
> 
> PreferredTechnologies =
> 
> But that didn't seem to make a difference.

That restores the default behavior, which is the order in which the
services are sorted - and presented in ServicesChanged() signals -
according to connected state, favorite and technology type. With
everything being equal, the default sorting based on technologies is in
src/service.c, service_compare(), and is ethernet, wifi, cellular,
bluetooth, vpn and gadget.

Cheers,

Patrik


___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman