Commit Graph

15579 Commits

Author SHA1 Message Date
Thomas Haller
e108f1cfaf shared: add nm_strcmp_p() utils macro 2016-06-15 10:32:31 +02:00
Thomas Haller
ccc1be34ee libnm: backport symbols nm_setting_ip_config_get_dns_priority to libnm_1_2_4
Commit bdd0e7fec0 which added symbol
nm_setting_ip_config_get_dns_priority to libnm_1_4_0 was backported
to nm-1-2 in commit ad1cdcf6571da23e3197b09f1b4b14d23b8899d1.

Add the backported symbol to master to allow seemless upgrading
from 1.2.4 to 1.4.0.
2016-06-10 11:37:39 +02:00
Thomas Haller
4e6f466fd3 all: merge branch 'th/assert-expr-strings-bgo767296'
https://bugzilla.gnome.org/show_bug.cgi?id=767296
2016-06-09 12:17:34 +02:00
Thomas Haller
00f58adb16 build: remove assertion messages in non-debug build
Assertions like g_assert*() and g_return_*() contain the stringified
test expression. This string ends up in the binary and increases its
size.

We usually don't have failing assertions. These string are a waste,
instead the file and line number shall suffice.

It reduces the striped size of the NetworkManager binary from 2500k
to 2392k, that is -108k, -4.3%.

This changes

 - "g_assert (1 == 2);"
   from: NetworkManager:ERROR:source.c:347:some_function: assertion failed: (1 == 2)
   to:   NetworkManager:ERROR:source.c:347:<unknown-fcn>: assertion failed: (<dropped>)

 - "g_return_if_fail (1 == 2);"
   from: (process:21024): NetworkManager-CRITICAL **: some_function: assertion '1 == 2' failed
   to:   (process:21024): NetworkManager-CRITICAL **: ((source.c:347)): assertion '<dropped>' failed

When doing a non-debug build, those string are now removed. Debug-builds
can be enabled by setting --with-more-assert=$LEVEL to larger then zero.

https://bugzilla.gnome.org/show_bug.cgi?id=767296
2016-06-09 12:03:39 +02:00
Thomas Haller
fa973afa19 tests: add macro NMTST_G_RETURN_MSG for expecting g_return*() failures
A failure to g_return*() by default prints a g_critical() with stringifing the
condition. Add a macro NMTST_G_RETURN_MSG() that reproduces that line to more
accurately match the failure message.
2016-06-09 12:03:39 +02:00
Beniamino Galvani
21bdb82555 platform: tests: skip already used macvtap ifindexes
In old kernel versions the creation of a macvtap can fail if its
ifindex is already used by a macvtap in another namespace, because of
a conflict in sysfs entries generation [1].

Try to detect this situation in platform tests and skip an ifindex if
already in use.

[1] http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=17af2bce88d31e65ed73d638bb752d2e13c66ced
2016-06-07 14:44:30 +02:00
Beniamino Galvani
ff3cd5aaf5 dns: merge branch 'bg/dnsmasq-rdns-bgo767174'
https://bugzilla.gnome.org/show_bug.cgi?id=767174
2016-06-07 11:45:06 +02:00
Beniamino Galvani
6c5a5c9f2a dns: remove nm-dns-utils.c and nm-dns-utils.h
The functions in the two files seem to belong to nm-dns-dnsmasq.c as
nobody else is using them.
2016-06-07 11:20:09 +02:00
Beniamino Galvani
ae763642d8 dns: add reverse DNS IPv6 entries to dnsmasq
https://bugzilla.gnome.org/show_bug.cgi?id=767174
2016-06-07 11:20:09 +02:00
Beniamino Galvani
4d1e7dc23c dns: add CIDR reverse DNS IPv4 entries to dnsmasq
When a reverse DNS entry must be added to dnsmasq, instead of
considering IP addresses as classful use the prefix to compute one or
more "in-addr.arpa" according to CIDR rules.

https://bugzilla.gnome.org/show_bug.cgi?id=767174
2016-06-07 10:52:50 +02:00
Thomas Haller
24430e4b07 contrib/rpm: don't enable sanitizer for debug build
There are valid failures, for which sanitizer would kill
NetworkManager:

  audit[1380]: AVC avc:  denied  { setrlimit } for  pid=1380 comm="NetworkManager" scontext=system_u:system_r:NetworkManager_t:s0 tcontext=system_u:system_r:NetworkManager_t:s0 tclass=process permissive=0
  NetworkManager[1380]: ==1380==ERROR: AddressSanitizer setrlimit() failed 13

Disable sanitizer to make debug builds working again, at least for now.
2016-06-07 09:15:26 +02:00
Thomas Haller
b769b4dfcb tests: use absolute path for certs test directory
Allows to run the test without first switching directory
  ./libnm-core/tests/test-secrets
2016-06-06 16:35:23 +02:00
Thomas Haller
2822f92434 clients: fix wrong assertion _assert_format_int()
Fixes: 466bf2f633
2016-06-06 14:21:42 +02:00
Thomas Haller
b8b68e212d build: disable warning "-Wformat-y2k"
https://bugzilla.gnome.org/show_bug.cgi?id=767207
2016-06-06 14:07:23 +02:00
Thomas Haller
fa6b1070fc Revert "build: fix autogen.sh for builddir != srcdir"
This breaks build with older versions of gtkdocize that don't understand
yet --srcdir.

This reverts commit ed7ee64d4e.
2016-06-06 13:52:57 +02:00
Thomas Haller
2dc0ee29f6 clients: fix compilation without NM_MORE_ASSERTS
It would render _assert_format_int() unused and warn.

Fixes: 466bf2f633
2016-06-06 13:12:50 +02:00
Bastien Nocera
ed7ee64d4e build: fix autogen.sh for builddir != srcdir
https://bugzilla.gnome.org/show_bug.cgi?id=767207
2016-06-06 12:35:35 +02:00
Thomas Haller
348e505b3a macros: add macro _nm_printf() for function attribute 2016-06-05 12:22:01 +02:00
Thomas Haller
466bf2f633 build: avoid compiler warnings about non-constant format strings (-Wformat-nonliteral) 2016-06-05 12:22:01 +02:00
Beniamino Galvani
b1e267cd8a build: merge branch 'bg/asan-bgo761429'
https://bugzilla.gnome.org/show_bug.cgi?id=761429
2016-06-03 22:47:09 +02:00
Beniamino Galvani
9aad9022e8 libnm-util: skip linking test when address sanitizer is enabled
The linking test causes a crash to check whether libnm and libnm-util
are both linked. If abrt or systemd-coredump are enabled, the core
dump processing will take a long time when the address sanitizer is
enabled, due to the huge process address space. It seems a good choice
to disable the test when NM was compiled with -fsanitize=address.
2016-06-03 22:19:38 +02:00
Beniamino Galvani
01540cf1d3 build: add options to compile with address/undefined sanitizers
This adds two new options to the configure scripts to compile NM,
clients and libraries with the address and undefined-behavior
sanitizers available in recent GCC versions. Clang is not supported at
moment.
2016-06-03 22:19:38 +02:00
Beniamino Galvani
b5efd22c14 ifupdown/tests: fix memory leaks
Fix memory leaks in tests for the ifupdown plugin and re-enable valgrind.
2016-06-03 22:19:38 +02:00
Beniamino Galvani
963b72bccb ifnet: fix memory leaks
Fix memory leaks in ifnet plugin and tests, and re-enable valgrind for
tests.
2016-06-03 22:19:38 +02:00
Beniamino Galvani
74a0e74d12 platform/tests: fix memory leaks 2016-06-03 22:19:38 +02:00
Beniamino Galvani
b5daaf43bc build: configure.ac: always set -fno-strict-aliasing
We break the aliasing rules in the code, and thus the flag should
always be enabled to prevent wrong optimizations, even without
--enable-more-warnings.
2016-06-03 22:19:37 +02:00
Beniamino Galvani
76eca6aca9 build: configure.ac: replace NM_COMPILER_FLAG with CC_CHECK_FLAG_APPEND 2016-06-03 22:19:37 +02:00
Beniamino Galvani
54b873a475 build: import attributes.m4 from systemd
It contains useful macros for determining compiler support for
flags/attributes. We already similar macros in compiler_options.m4,
but the plan is to replace them.
2016-06-03 22:19:37 +02:00
Dan Williams
6725962f83 build: add -Wformat-nonliteral to --enable-more-warnings flags
New with gcc 6.0.
2016-06-03 11:05:05 -05:00
Thomas Haller
87a1360505 dns: merge branch 'th/rc-manager-file-follow'
https://github.com/NetworkManager/NetworkManager/pull/7
2016-06-03 12:21:16 +02:00
Thomas Haller
bcb88d540e dns: minor fix of logging with unset dns mode
With
  [main]
  #dns=

we would see in the log:
  dns-mgr: init: dns=(null), rc-manager=symlink

Instead, it should be
  dns-mgr: init: dns=default, rc-manager=symlink

Also, we should avoid logging NULL values with "%s", although
glib's printf is fine with that.
2016-06-03 12:20:37 +02:00
Thomas Haller
4711867915 dns: update detection of immutable resolv.conf
Before, we would first check whether the file is immuable before
parsing main.rc-manager setting. That means, if you configured

  [main]
  dns=default
  rc-manager=unmanged

we would still first try to detect whether the file is immutable.
The result of course is only minor, e.g. showing up in logging
as rc-manager=immutable instead of rc-manager=unmanged.
Also, an immutable resolv.conf would suppress a warning about
a bogus rc-manager setting.

Also, when selecting rc-manager=symlink and resolv.conf is a symlink
to an immutable file, we don't actually care about that. The reason is,
that if the link-target is not /var/run/NetworkManager/resolv.conf,
we anyway wouldn't modify the file.

The effect of this change is pretty minor, now in logging you would see:
  dns-mgr: init: dns=default, rc-manager=symlink
  dns-mgr: update-resolv-conf: write internal file /var/run/NetworkManager/resolv.conf succeeded but don't update /etc/resolv.conf as it points to /some/where/else
instead of
  dns-mgr: init: dns=default, rc-manager=immutable
  dns-mgr: update-resolv-conf: write internal file /var/run/NetworkManager/resolv.conf succeeded

Which feels slightly more right.

Note that symlinks cannot have file attributes.
2016-06-03 12:18:47 +02:00
Thomas Haller
718fd22436 dns: follow resolv.conf if it is a symlink for 'rc-manager=file'
Until before 1.2.0, NetworkManager would always write resolv.conf as file, but
if /etc/resolv.conf was a symlink, it would follow the link instead of
replacing it with a file ([1], [2]).

With 1.2.0, we initially dropped that behavior and added a new 'rc-manager=none'
which writes resolv.conf to /var/run/NetworkManager and symlinks resolv.conf [3].
In case resolv.conf being already a symlink to another target, it would
not be replaced [4].
Later, we added 'rc-manager=file', which always writes /etc/resolv.conf as
file [5].

With 1.4.0, we will rename 'rc-manager=none' to 'rc-manager=symlink' [6].

This commit now fixes 'rc-manager=file' to restores the pre-1.2 behavior
and follow symlinks.

[1] 5761e328b8
[2] https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/324233
[3] 4805be2ed2
[4] 583568e12f
[5] 288799713d
[6] cd6a469668

https://github.com/NetworkManager/NetworkManager/pull/7
2016-06-03 11:50:02 +02:00
Thomas Haller
9418f81528 dns: refactor logging statements to use _rc_manager_to_string()
Reuse _rc_manager_to_string() to stringify the rc-manager mode.
Also fix typo "rc-managed=file".
2016-06-03 10:31:07 +02:00
Thomas Haller
2ca21e150a configure/trivial: prettify "if" in configure.ac 2016-06-03 10:27:07 +02:00
Thomas Haller
d66b5e79c7 core: reuse common static string buffer in nm_utils_dnsmasq_status_to_string()
Instead of declaring our local string buffer @buffer,
reuse nm_utils_to_string_buffer_init().

https://github.com/NetworkManager/NetworkManager/pull/8
2016-06-03 09:24:45 +02:00
Michael Biebl
fe7d12a010 systemd: add Documentation to service files
Reference the nm-online and NetworkManager man page in the corresponding
service files.

https://www.freedesktop.org/software/systemd/man/systemd.unit.html#Documentation=

https://bugzilla.gnome.org/show_bug.cgi?id=767168
2016-06-02 21:27:14 +02:00
Michael Biebl
c8199b7de0 systemd: use RemainAfterExit=yes for NetworkManager-wait-online.service
RemainAfterExit=yes is typically used for Type=oneshot services.
systemd-networkd-wait-online.service uses it, so we should as well.

See
https://www.freedesktop.org/software/systemd/man/systemd.service.html#RemainAfterExit=
https://www.freedesktop.org/software/systemd/man/systemd.service.html#Type=

https://bugzilla.gnome.org/show_bug.cgi?id=767170
2016-06-02 20:59:10 +02:00
Thomas Haller
aa04e04c83 libnm/tests: fix memleak in test test_nm_utils_check_valid_json()
Fixes: 82f8a54854
2016-06-02 10:01:58 +02:00
Thomas Haller
5dea2efd9e contrib/rpm: add Requires to exact wwan version for NetworkManager-bluetooth subpackage
rpmdiff complains:

  Subpackage NetworkManager-bluetooth on aarch64 x86_64 ppc64 ppc64le s390x
  consumes library libnm-wwan.so()(64bit) from subpackage NetworkManager-wwan
  but does not have explicit package version requirement.
  Please add Requires: NetworkManager-wwan = %{version}-%{release} to
  NetworkManager-bluetooth in the specfile to avoid the need to test
  interoperability between the various combinations of old and new subpackages.

And indeed, device plugins don't have a stable API/ABI, and requires
exact NetworkManager and wwan versions. This was already enforced implicitly,
because all device plugins require the same exact NetworkManager version.
2016-06-02 09:44:37 +02:00
Thomas Haller
d91f3b35d7 auth: fix get_permissions() D-Bus call for settings-modify-global-dns 2016-06-01 22:04:37 +02:00
Thomas Haller
431c70832d dns,config: merge branch 'th/dns-reload-bgo766996'
https://bugzilla.gnome.org/show_bug.cgi?id=766996
2016-06-01 19:06:43 +02:00
Thomas Haller
8e54cfdb27 all: move NM_AUTH_PERMISSION_* defines to "nm-common-macros.h" header 2016-06-01 19:06:35 +02:00
Thomas Haller
ed551a4633 shared: add "nm-common-macros.h" header
Shared headers are all project-wide and internal API.
Currently we have the following:

General purpose:

  - shared/gsystem-local-alloc.h: header-only, allocation macros
  - shared/nm-dbus-compat.h: header-only, D-Bus related defines
  - shared/nm-glib.h: header-only, glib compatibility defines
  - shared/nm-macros-internal.h: header-only, utils
  - shared/nm-shared-utils.[hc]: source and header, utils
  - shared/nm-test*.[hc]: source and header, libnm testing utils

Special to NetworkManager repository:

  - shared/nm-version-macros.h.in: header-only, version macros
  - shared/nm-default.h: header-only, default-include

Now we add "shared/nm-common-macros.h" which is header-only, but non
general purpose.

I am running low on good names, considering all the shared/core/macros
utils headers. Still, I think "nm-common-macros.h" is appropriate.
2016-06-01 19:06:35 +02:00
Thomas Haller
2c411e9070 config: cleanup includes 2016-06-01 19:06:35 +02:00
Thomas Haller
02034cead3 config: unify logging line when reloading configuration
Also when config_data changes, the logging line should start with
"config: signal" like it does in the other cases.
2016-06-01 19:06:35 +02:00
Thomas Haller
ca5028e608 config: fix ignoring internal [.config] section
The [.config] section is configuration about the configuration file itself,
it should not be merged.

Properly ignore the [.config] section before merging the configuration
file.
2016-06-01 19:06:34 +02:00
Thomas Haller
0acee97220 config,dns: support Reload flags to specify that only parts should be reloaded
Support 3 new flags for Reload:

  - 0x01 (CONF): reload the configuration from disk
  - 0x02 (DNS_RC): write DNS configuration to resolv.conf
  - 0x04 (DNS_FULL): restart DNS plugin

Omitting all flags is the same as reloading everything, thus SIGHUP.
2016-06-01 19:06:34 +02:00
Thomas Haller
1d0e0eeffd manager: add Reload() D-Bus command
Add new Reload D-Bus command to reload NetworkManager configuration.

For now, this is like sending SIGHUP to the process. There are several
advantages here:

  - it is guarded via PolicyKit authentication while signals
    can only be sent by root.

  - the user can wait for the reload to be complete instead of sending
    an asynchronous signal. For now, we operation completes after
    nm_config_reload() returns, but later we could delay the response
    further until specific parts are fully reloaded.

  - SIGHUP reloads everything including re-reading configuration from
    disk while SIGUSR1 reloads just certain parts such as writing out DNS
    configuration anew.
    Now, the Reload command has a flags argument which is more granular
    in selecting parts which are to be reloaded. For example, via
    signals the user can:

      1) send SIGUSR1: this writes out the DNS configuration to
         resolv.conf and possibly reloads other parts without
         re-reading configuration and without restarting the DNS plugin.
      2) send SIGHUP: this reloads configuration from disk,
         writes out resolv.conf and restarts the DNS plugin.

    There is no way, to only restart the DNS plugin without also reloading
    everything else.
2016-06-01 19:06:34 +02:00
Thomas Haller
8913585397 libnm: implement missing NM_AUTH_PERMISSION_SETTINGS_MODIFY_GLOBAL_DNS 2016-06-01 19:06:34 +02:00