Commit graph

8466 commits

Author SHA1 Message Date
Thomas Haller
274de2555b build/trivial: rename VALGRIND_RULES in Makefile.am to NM_LOG_COMPILER 2016-10-19 15:26:30 +02:00
Thomas Haller
5424e3a063 keyfile: disable permission checks of keyfile for tests
The tests were checking that the keyfiles had permission
0600 and there was a check-local target to prepare the permissons
of the tests.

That is inconvenient, and it is unexpected to have a check-local
target for such a case.

Also, the tests were not testing that keyfile reader would
bail out on invalid permissions. So just skip the check for
testing.
2016-10-19 15:26:30 +02:00
Thomas Haller
068dd41df9 platform/tests: relax assertion in software_add
Avoid failure

    NMPlatformSignalAssert: test-link.c:146, software_add(): failure to accept signal one time: link-changed-changed ifindex 15 (2 times received)
2016-10-19 15:23:49 +02:00
Beniamino Galvani
956f0be2f9 platform: fix lifetime check 2016-10-18 16:48:27 +02:00
Beniamino Galvani
628cc8a057 arping: fix error handling when starting probe
We didn't check the return value of g_spawn_async() and added a watch
on a potentially zero pid.
2016-10-18 16:48:27 +02:00
Lubomir Rintel
2c43862b2d platform/tests: don't attempt to mount anything to /sys/devices
More recent kernels won't allow that in userns when /sys itself
is read-only.
2016-10-17 15:45:59 +02:00
Lubomir Rintel
0acdcc348c Revert "platform/tests: skip root tests when we can't mount /sys/devices"
This was plain stupid. We don't care about sysfs being writable or
anything *before* entering the namespace.

This reverts commit 15a26d6192.
2016-10-17 15:45:59 +02:00
Beniamino Galvani
a67bdbc331 core: handle the autoconnect-retries property 2016-10-16 12:56:09 +02:00
Beniamino Galvani
f63e28b147 ifcfg-rh: support the autoconnect-retries property 2016-10-16 12:56:09 +02:00
Beniamino Galvani
92a8cfac69 core: introduce default logging macros 2016-10-14 15:57:43 +02:00
Beniamino Galvani
89bcf50f61 platform: avoid unaligned access to link stats on 64bit architectures
The undefined behavior sanitizer complains with:

platform/nm-linux-platform.c:1482:31: runtime error: member access within misaligned address 0x61a000016fac for type 'struct rtnl_link_stats64', which requires 8 byte alignment
0x61a000016fac: note: pointer points here
  bc 00 17 00 bf 05 00 00  00 00 00 00 bf 05 00 00  00 00 00 00 b5 68 02 00  00 00 00 00 b5 68 02 00
              ^
platform/nm-linux-platform.c:1483:29: runtime error: member access within misaligned address 0x61a000016fac for type 'struct rtnl_link_stats64', which requires 8 byte alignment
0x61a000016fac: note: pointer points here
  bc 00 17 00 bf 05 00 00  00 00 00 00 bf 05 00 00  00 00 00 00 b5 68 02 00  00 00 00 00 b5 68 02 00
              ^
platform/nm-linux-platform.c:1484:31: runtime error: member access within misaligned address 0x61a000016fac for type 'struct rtnl_link_stats64', which requires 8 byte alignment
0x61a000016fac: note: pointer points here
  bc 00 17 00 bf 05 00 00  00 00 00 00 bf 05 00 00  00 00 00 00 b5 68 02 00  00 00 00 00 b5 68 02 00
              ^
platform/nm-linux-platform.c:1485:29: runtime error: member access within misaligned address 0x61a000016fac for type 'struct rtnl_link_stats64', which requires 8 byte alignment
0x61a000016fac: note: pointer points here
  bc 00 17 00 bf 05 00 00  00 00 00 00 bf 05 00 00  00 00 00 00 b5 68 02 00  00 00 00 00 b5 68 02 00
              ^

That's because the pointer returned by nla_data() is only
32bit-aligned and using it to access structure members can cause
issues on some 64bit architectures.

Use the unaligned_read_ne64() macro to access the structure members.

https://bugzilla.gnome.org/show_bug.cgi?id=772605
2016-10-14 11:16:13 +02:00
Thomas Haller
c7853a1415 build: add extra dependencies for linker-version-script for NetworkManager and libnm.so 2016-10-14 10:33:30 +02:00
Beniamino Galvani
0539725aef supplicant: fix cancellation of interface association
The @assoc_cancellable was never initialized and thus ineffective; fix
this.

Furthermore, we only cancel it in nm_supplicant_interface_disconnect()
as we expect that clients call the function before destroying the
interface. Don't assume this and also cancel it in dispose().

https://bugzilla.redhat.com/show_bug.cgi?id=1383628
2016-10-14 09:32:48 +02:00
Thomas Haller
510626bf74 ip-config: cleanup integer types for nm_ip4_config_get_num_*() 2016-10-14 06:18:43 +02:00
Thomas Haller
5253ab0d0d dns/resolved: don't repeatedly call nm_ip4_config_get_num_*() to iterate config 2016-10-14 06:09:11 +02:00
Thomas Haller
878ed77c6b dns/resolved: fix style issues 2016-10-14 05:55:31 +02:00
Sjoerd Simons
c4864ba63f dns/resolved: adjust link domain settings
Make link domain settings more conventional. If an IP Config only has no
search entries, use domains for search instead otherwise ignore domains.

Also on connections which are never the default, setup the
search/domains as routing-only meaning that only dns queries for those
domains will be done on this link. Prevents quering DNS information for
on-vpn host with other namservers and using the VPN DNS server for host
not on the VPN.

This is also fixes issues with a recent change in systemd-resolved where
links with a routing domain will only be used for those domains, which
meant that the previous strategry with a typical ip configuration (no
search only domains) resulted in no usable name resolution.

Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>

https://bugzilla.gnome.org/show_bug.cgi?id=772343
2016-10-14 05:40:53 +02:00
Thomas Haller
92f4185575 devices/build: use one linker-script-devices.ver for all device plugins 2016-10-13 21:36:06 +02:00
Thomas Haller
757d06800e dhcp/build: add linker version script for nm-dhcp-helper binary 2016-10-13 21:33:33 +02:00
Thomas Haller
569d28f573 iface-helper/build: don't link nm-iface-helper with -rdynamic / -export-dynamic
Since nm-iface-helper doesn't dlopen any library, it seems not necessary
to link with -rdynamic.
2016-10-13 21:33:33 +02:00
Thomas Haller
401f6c2b8c iface-helper/build: add linker version script 2016-10-13 21:33:33 +02:00
Thomas Haller
e95090d303 settings/build: add linker version script for settings plugins 2016-10-13 21:33:33 +02:00
Thomas Haller
b171fbc9ca build: explicitly whitelist symbols in NetworkManager binary
- this allows the linker to drop unused symbols via link-time optimization
  or with --gc-sections:

    git clean -fdx
    ./autogen.sh --enable-ld-gc --enable-ifcfg-rh --enable-ifupdown \
        --enable-ifnet --enable-ibft --enable-teamdctl --enable-wifi \
        --with-modem-manager-1 --with-ofono --with-more-asserts \
        --with-more-logging
    make -j20
    strip ./src/NetworkManager

  gives 2822840 vs. 2625960 bytes (-7%).

- this also gives more control over the symbols that are used by the
  plugins. Yes, it means if you modify a plugin to use a new symbols,
  you have to extend NetworkManager.ver file.
  You can run the script to create the version file:

    $ ./tools/create-exports-NetworkManager.sh update

  but be sure that your current configuration enables all plugins
  and debugging options to actually use all symbols that are in use.

- If you compile with certain plugins enabled, you could theoretically
  re-compile NetworkManager to expose less symbols. Try:

    $ ./tools/create-exports-NetworkManager.sh build

- note that we have `make check` tests to ensure that all used
  symbols of the plugins can be found. So, it should not be possible
  to accidentally forget to expose a symbol.
2016-10-13 21:33:33 +02:00
Thomas Haller
76a057b4ec build: always include subdir wifi/tests regardless of ENABLE_TESTS
Like done for all other device plugins.
2016-10-13 21:33:33 +02:00
Thomas Haller
9f5b80d215 build: don't guard check-local with "if ENABLE_TESTS"
We should enable tests by default, probably we even should drop
the configure flags to enable tests and just always build them.

Anyway, at this point there is no use in guarding check-local
with a check for ENABLE_TESTS. A user who does't want to run
the tests, should just not call `make check`.
2016-10-13 21:33:33 +02:00
Thomas Haller
38d669d5ee build: move check_so_symbols for settings plugins to parent makefile
Like for the device plugins, check_so_symbols is called from the
Makefile of the plugin itself, not from tests/Makefile.am.

Just keep it consistent.
2016-10-13 21:33:33 +02:00
Thomas Haller
cc78d89796 build: fix check_local for wifi plugin 2016-10-13 21:33:33 +02:00
Beniamino Galvani
034f07787d pacrunner: accept NULL interface name
Pacrunner uses the interface information to implement a myIpAddress()
function which returns the first IPv4 address of the interface
associated to a proxy. That function doesn't deal with multiple
addresses per interface, and so in case of a VPN which configures
addresses on the parent interface (e.g. IPsec), we currently pass a
NULL interface. That is correct, but triggers the following assertion:

GLib-CRITICAL **: g_variant_new_variant: assertion 'value != NULL' failed
 #0  g_logv () from target:/lib64/libglib-2.0.so.0
 #1  g_log () from target:/lib64/libglib-2.0.so.0
 #2  g_variant_new_string () from target:/lib64/libglib-2.0.so.0
 #3  nm_pacrunner_manager_send (self=0xab3230, iface=iface@entry=0x0, proxy_config=proxy_config@entry=0xc83470, ip4_config=ip4_config@entry=0x7f66b4002710, ip6_config=ip6_config@entry=0x0) at nm-pacrunner-manager.c:334
 #4  _set_vpn_state (self=self@entry=0xd0c120, vpn_state=vpn_state@entry=STATE_ACTIVATED, reason=reason@entry=NM_VPN_CONNECTION_STATE_REASON_NONE, quitting=quitting@entry=0) at vpn-manager/nm-vpn-connection.c:571
 #5  dispatcher_pre_up_done (call_id=<optimized out>, user_data=<optimized out>) at vpn-manager/nm-vpn-connection.c:460
 #6  dispatcher_done_cb (proxy=0x988870, result=<optimized out>, user_data=0xae1740) at nm-dispatcher.c:444

Ignore the interface parameter when it's NULL.
2016-10-13 17:39:56 +02:00
Beniamino Galvani
db9589f0ce session-monitor: fix parsing of ConsoleKit database
The section name is "Session", not "CkSession".  Restore the correct
value, changed by commit 0de60b300e ("session: merge
nm-session-monitor-* modules").

Fixes: 0de60b300e

https://bugzilla.gnome.org/show_bug.cgi?id=772640
2016-10-13 09:40:36 +02:00
Beniamino Galvani
0e7f834a6f session-monitor: use logging macros
Use logging macros and also, print the session tracking method during
startup for debugging purposes.
2016-10-13 09:40:14 +02:00
Beniamino Galvani
21358edc54 core: introduce and use nm_utils_file_set_contents()
In some places we use g_file_set_contents() after a umask() to limit
the permissions of the created file. Unfortunately if the containing
directory has a default ACL the umask will be ignored and the new file
will have a mode equal to the default ACL (since g_file_set_contents()
opens the file with mode 0666).

Calling a chmod() after the file gets created is insecure (see commit
60b7ed3bdc) and so the only solution seems to be to reimplement
g_file_set_contents() and accept a mode as parameter.

We already had similar functions in the tree, consolidate them into a
new generic utility function.

https://bugzilla.gnome.org/show_bug.cgi?id=769702
2016-10-12 14:54:57 +02:00
Thomas Haller
a4110d6d4d build: drop deleted nm-atm-manager.h header file from Makefile.am
Fixes: 4d37f7a1e9
2016-10-12 11:59:04 +02:00
Thomas Haller
97d3b07753 ifcfg-rh/build: fix build error due to line-break in Makefile.am
Fixes: dd4ce10c92
2016-10-11 12:12:25 +02:00
Thomas Haller
2c26e3e7f9 device: make registration of internal device-factories more explicit
Internal device types are a static thing. Let's not do a
constructor function to register the device factory.

This gets rid of all attribute((constructor)) functions inside
NetworkManager core. That is desired, because we don't want to
run code before main(). For example, at that point logging is
not yet initialized, but with code that runs before main() it
is hard to ensure that we don't log anything yet.
2016-10-11 11:57:43 +02:00
Thomas Haller
92b7cb2161 device: rename internal device factories
Instead of NMBondFactory, call it NMBondDeviceFactory.
2016-10-11 11:46:30 +02:00
Thomas Haller
18660604aa device: make NMDeviceFactory a class instead of an interface
An interface would make sense to allow the actual device-factory to inherit
from another type.

However, glib interfaces make code much harder to follow and less
efficient. The device factory shall be a very simple type with meta data
about supported device types and the ability to create device instances.
There is no need to make this an interface implementation, instead just
let the factories inherit from NM_TYPE_DEVICE_FACTORY directly.
2016-10-11 11:45:14 +02:00
Thomas Haller
05e6d155ba device: minor cleanup of nm-device-factory.c 2016-10-11 11:43:16 +02:00
Thomas Haller
051bcd9f1c ifcfg-rh: hide shvarFile struct 2016-10-11 11:37:46 +02:00
Thomas Haller
29f7688da5 ifcfg-rh: avoid copying and unescaping current line when unsetting value 2016-10-11 11:37:46 +02:00
Thomas Haller
b00ee52ab3 ifcfg-rh/trivial: move code in shvar.c 2016-10-11 11:37:46 +02:00
Thomas Haller
96846352de ifcfg-rh: minor cleanups in writer 2016-10-11 11:37:46 +02:00
Thomas Haller
0ed009f236 ifcfg-rh: use svUnsetValue()
sed 's/^\(\t\+\)svSetValue (\([a-z]\+\), \("[^"]*"\|[*a-z_0-9A-Z]\+\(\(->\|.\)[a-z0-9A-Z_]\+\)\), NULL, \(FALSE\|TRUE\));$/\1svUnsetValue (\2, \3);/g' src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c -i
2016-10-11 11:37:46 +02:00
Thomas Haller
491b6027ba ifcfg-rh: add svUnsetValue() 2016-10-11 11:37:46 +02:00
Thomas Haller
b3b0cb0b17 ifupdown: rename files to "nms-ifupdown-*" 2016-10-11 11:37:46 +02:00
Thomas Haller
1eac4f3e60 ifnet: rename files to "nms-ifnet-*" 2016-10-11 11:37:46 +02:00
Thomas Haller
dd4ce10c92 settings/build: build and use libnms-*-core.la library
Don't have the test recompile parts of the settings plugin.
Instead, build one core library that is used both by the test
and the settings plugin.

Advantage: might save some compilation time, but more importantly: the
test use the same object code then NetworkManager itself, avoiding
different behavior due to compilation flags.
2016-10-11 11:37:46 +02:00
Thomas Haller
eab8b06d8b ifcfg-rh/tests: merge test-ifcfg-rh-utils into test-ifcfg-rh
We don't need need separate unit tests for basic tests that can
just run in the same test-run. If you really need to run only
a particular set of tests, try
  ./src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh -p /settings/plugins/ifcfg-rh/utils

Results in less compilation (time), and less binaries to test during
`make check`.
2016-10-11 11:37:46 +02:00
Thomas Haller
254f892c9c ifcfg-rh: rename files 2016-10-11 11:37:46 +02:00
Thomas Haller
d18e71f35a ibft/build: cleanup Makefile.am to build one core library from ibft plugin
Instead of having the tests re-compile "nms-ibft-reader.c".
2016-10-11 11:37:46 +02:00
Thomas Haller
68f33a846e ibft: rename function names for ibft plugin 2016-10-11 11:37:46 +02:00