Commit graph

23218 commits

Author SHA1 Message Date
Thomas Haller 105d0d56d3 build: link libnm/liblibnm.la with udev library
libnm/liblibnm.la compiles "libnm/nm-device.c" and "libnm/nm-client.c",
both include libudev.h.

Let's explicitly link this library with libudev.
2019-05-22 20:04:08 +02:00
Thomas Haller aff1d66b81 Revert "libnm: don't assert for success of g_dbus_error_register_error()"
Now that unit tests no longer dynamically link against libnm/libnm.la,
and statically against the same code, we can enable this assertion
again.

This reverts commit 7a0e347b38.
2019-05-22 20:04:08 +02:00
Thomas Haller 6b7264e4aa build/meson: introduce libnm/liblibnm.la as static library for libnm/libnm.la
Same as done for autotools.
2019-05-22 20:04:08 +02:00
Thomas Haller 09557fa69d build: introduce libnm/liblibnm.la as static library for libnm/libnm.la
We have "src/libNetworkManager.la" which is an intermediate static
library containing everything that ends up in "src/NetworkManager".

Likewise, add "libnm/liblibnm.la" to be the static library that contains
everything from "libnm/libnm.la".

The point of these libraries is to tie everything together that is used
by "src/NetworkManager" and "libnm/libnm.la" so that it also can be used
by unit-tests. Thereby, the unit tests will link statically against the
code of libnm. The problem is that the unit tests also want to access
internal functionality of libnm that is not accessible when dynamically
linking.

In part, this new library replaces "libnm/libnm-utils.la". The previous
name was confusing, because to us everything is an "utils", and it's
unclear what the purpose of that library was. Now the purpose should be
a bit clearer: liblibnm.la is a step before libnm.la, similar to what
libNetworkManager.la is to NetworkManager.
2019-05-22 20:04:08 +02:00
Thomas Haller 57e21dc889 build: style cleanups of Makefile.am 2019-05-22 20:04:08 +02:00
Thomas Haller 2946d07085 shared: implement _nm_utils_monotonic_timestamp_initialized() in "nm-logging-stub.c" 2019-05-22 20:04:08 +02:00
Lubomir Rintel 4c78434a0b Revert "Do not manage Docker bridge interfaces"
The docker bridges are no special -- just regular externally created
bridges.

This reverts commit 0ce7327550.
2019-05-21 09:40:53 +02:00
Lubomir Rintel f3f8e21bd3 contrib/checkpatch: properly determine the commit id boundary
It doesn't have to be at the end of line, there may be more words
following.

Fixes: d66a1ace23 ('contrib/checkpatch: avoid command injection in checkpatch.pl script')
2019-05-20 16:31:52 +02:00
Beniamino Galvani 008a4b4215 team: don't kill teamd for external devices
The teamd instance must not be killed if the device was externally
activated.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/158
https://bugzilla.redhat.com/show_bug.cgi?id=1693142
2019-05-20 14:54:07 +02:00
Beniamino Galvani 95cc384377 core: merge branch 'bg/add-activate-fail-rh1667874'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/144
https://bugzilla.redhat.com/show_bug.cgi?id=1667874
2019-05-20 14:50:47 +02:00
Beniamino Galvani 58db61545d device: don't wait udev for devices created by us
If we created a software interface it is because we already decided
that it should be managed, and so there is no point in waiting udev to
check that the interface is not udev-unmanaged.

We still wait udev for software interfaces created externally.
2019-05-20 14:49:59 +02:00
Beniamino Galvani d33c995d45 manager: relax condition when checking for duplicate ACs
An active connection started by user could be queued in state UNKNOWN
which means the device hasn't started activating yet. Eventually it
will, and we don't want to cancel the user activation because of an
internal autoconnection attempt.
2019-05-20 13:57:35 +02:00
Beniamino Galvani 831f079e55 device: use variable for platform in realize_start_setup() 2019-05-20 13:57:35 +02:00
Lubomir Rintel ff2d0f5add manager: don't allow femoving a device without traversing proper states
There was a special case for ensuring that the device's configuration
doesn't disappear when some factory is too late at recognizing the
device is just a component of another one.

It was always a bad idea. If the device already had an active
connection (such as for a generated default wired connection), it would
remain around, with a dangling reference to the device.

This effectively reverts commit 5ad69cb29b ('core: remove child devices
without deconfiguring them (bgo #738479)'). It's okay to do so, because
we now wouldn't deconfigure the device upon its removal anyway.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/151/
2019-05-20 12:50:01 +02:00
Thomas Haller eebcbfae75 dhcp: store dhclient's pid file in "/var/run/NetworkManager" instead of "/var/run"
The pid-file is private to NetworkManager. It should reside in NetworkManager's
run directory instead of "/var/run".

I don't think that changing this location can break existing uses. Why
would somebody outside of NetworkManager care about this file?

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/157
2019-05-20 11:52:31 +02:00
Thomas Haller b18cda2671 all: merge branch 'th/rename-tests'
Rename tests so that they have unique names.

meson requires that the build executables have unique names (at least,
older versions). Hence, we used to name the test binary different from
the source file ("libnm-test-general" vs. "test-general.c").

The tests should be named "*/tests/test-*", and the source file should
have the same name as the test executable.

Rename the sources so that the names are unique.
2019-05-19 15:55:41 +02:00
Thomas Haller 1da7dfc408 gitignore: merge gitignore files
For the most part, we only have one main .gitignore file.

There were a few nested files, merge them into the main file.

I find it better to have only one gitignore file, otherwise the
list of ignored files is spread out through the working directory.
2019-05-19 14:41:21 +02:00
Thomas Haller 5c0dd32622 src/tests: rename core's "test-general*" to "test-core*" 2019-05-19 14:41:00 +02:00
Thomas Haller fbe2fdd167 libnm/tests: rename libnm's "test-general" to "test-libnm" 2019-05-19 14:41:00 +02:00
Thomas Haller 0c7bc1a5d9 clients/tests: rename clients/common's "test-general" to "test-clients-common" 2019-05-19 14:00:16 +02:00
Thomas Haller c99bbc99b0 wifi/tests: rename Wi-Fi's "test-general" to "test-devices-wifi"
We already have 4 other tests that are named "test-general". Rename.
2019-05-19 11:28:53 +02:00
Thomas Haller d27f6b9d0a keyfile/tests: rename core's "test-keyfile" to "test-keyfile-settings"
We already have "libnm-core/tests/test-keyfile.c" from which we build
"test-keyfile".

Our test binaries should be named the following:

- "*/tests/test-*"

- the test binary "*/tests/test-*" should be build from a source file
  "*/tests/test-*.c". Meaning: the source's and executable's name should
  correspond.

- test binaries should be named uniquely. Also, because older meson
  versions don't like having the same binary name more than once.

Rename to avoid the duplicate name.
2019-05-19 11:25:59 +02:00
Thomas Haller a80c199e9e gitignore: move ignored libnm-glib/libnm-util files to the bottom of the .gitignore
The bottom contains the tombstones for files that we ignored in
the past, but no longer actually have. Move the lines.
2019-05-19 11:23:23 +02:00
Patrick J. Volkerding e1df17e0ac hostname-manager: use fqdn for persistent hostname on Slackware
This will be the default for Slackware 15.0 and on.

This should be safe for both master and 1.12.x stable branch, as
no existing Slackware releases are expected to run NM-1.12.x or
later.

Signed-off-by: Robby Workman <rworkman@slackware.com>

https://mail.gnome.org/archives/networkmanager-list/2019-May/msg00011.html
2019-05-19 10:45:07 +02:00
Thomas Haller 041aa3d605 platform/tests: rename platform's "test-general.c"
Older versions of meson don't like building multiple artifacts
with the same name (even if they are in different directories). We
have multiple tests called "test-general.c", and it would be natural
to compile a test binary of the same name.

  Meson encountered an error in file src/tests/meson.build, line 14, column 2:
  Tried to create target "test-general", but a target of that name already exists.

It's generally a bad idea to have in our source tree multiple files with the
same name. Rename the test.

Fixes: 16cd84d346 ('build/meson: rename platform tests to use same name as autotools'):
2019-05-18 11:37:47 +02:00
Thomas Haller 5e11d4bf1f gitlab-ci: disable valgrind on Fedora 30 and Fedora 31 depending on glib2 package
Valgrind is known to report many false positives with certain glib2
versions. Workaround that by disabling it based on the installed
package version.

See-also: https://bugzilla.redhat.com/show_bug.cgi?id=1710417
See-also: https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/155
2019-05-18 11:37:35 +02:00
Thomas Haller faf55eb2f8 ci: merge branch 'th/gitlab-ci-valgrind'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/155
2019-05-18 10:54:33 +02:00
Thomas Haller 6d76a0974e gitlab-ci: run unit tests under valgrind in gitlab-ci
On Ubuntu 16.04 (trusty) valgrind fails due to rdrand being advertised
but not implemented.

Work around that by installing valgrind from Ubuntu 18.04 (bionic) via
the "contrib/scripts/nm-ci-install-valgrind-in-ubuntu1604.sh" script.
2019-05-18 09:58:52 +02:00
Thomas Haller 16cd84d346 build/meson: rename platform tests to use same name as autotools
First of all, all file names in our source-tree should be unique. We should
not have stuff like "libnm-core/tests/test-general.c" and "src/tests/test-general.c".
The problem here are the C source files, and consequently also the test
binaries have duplicate names. We should avoid that in general. However,
our binaries should have a matching name with the C source. If
"test-general.c" is not good enough, that needs renaming. Not building
"platform-test-general" out of it.

On the other hand, all our tests should have a filename "*/tests/test-*", like
they do for autotools.

Rename the meson platform tests.

It's also important because "tools/run-nm-test.sh" relies on the test
name to workaround valgrind warnings.
2019-05-17 21:47:04 +02:00
Thomas Haller e966f942cc build: merge branch 'th/build-runstatedir'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/145
2019-05-17 21:34:02 +02:00
Thomas Haller 0cbef232c9 contrib/rpm: set runstatedir to "/run" instead of "/var/run"
Do so on all RHEL/Fedora releases. They all use systemd, and it's the right
choice for all of them.
2019-05-17 21:33:36 +02:00
Thomas Haller 921b7eb716 configure: add --with-runstatedir option to configure
Nowadays, it's adivisable to use "/run" instead of "/var/run" ([1]). This is because
"/var" might not be mounted in early boot, during shutdown, or during rescue mode.

Autoconf 2.70 will add an option --runstatedir ([2], [3]). However, the latest
autoconf release is 2.69 from April 2012, so this might take a while longer. Note
that some distributions patched their autoconf 2.69 to support --runstatedir [4],
but not Fedora.

See also [5], [6] for when we added support for autoconf 2.70's
"--runstatedir".

Add a "--with-runstatedir" option that we can use. Note that this
overwrites autoconf's "--runstatedir" (should it be supported). That
makes sense, because this way the user can set the option regardless of
whether autoconf supports "--runstatedir".

For example, Xen did something similar [7].

Meson currently does not support this either. I will not add a
workaround, because there is hope that it will be eventually fixed [8].
Also, autotools is still our default way for building. There is a
NetworkManager issue about this ([9]), which is still unfixed.

[1] http://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch03s15.html
[2] https://www.gnu.org/prep/standards/html_node/Directory-Variables.html
[3] https://lists.gnu.org/archive/html/bug-autoconf/2013-09/msg00000.html
[4] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=759647
[5] https://bugzilla.gnome.org/show_bug.cgi?id=737139
[6] commit cd3c52a24d ('build: support runstatedir configure option')
[7] https://patchwork.kernel.org/patch/9576621/
[8] https://github.com/mesonbuild/meson/issues/4141
[9] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/24
2019-05-17 21:32:44 +02:00
Thomas Haller b32ad2344e session-monitor: use "/run/ConsoleKit/database" instead of "/var/run/ConsoleKit/database"
There should be no difference in pratice. But we should not mention "/var/run"
as /var might not be mounted in early boot or rescue environment. Of course,
in those cases ConsoleKit is not running either. But still...
2019-05-17 21:24:18 +02:00
Thomas Haller 6a89f6c368 trivial: fix code comment mentioning "/var/run/NetworManager" to refer to "/run" 2019-05-17 21:24:18 +02:00
Thomas Haller 10688e3d88 tests: use "/run" instead of "/var/run" 2019-05-17 21:24:18 +02:00
Thomas Haller 80c0dab9c7 contrib/rpm: reword comment in NetworkManager.conf
This change is a bit annoying, because we package "NetworkManager.conf" file in
our RPM. So, upon package upgrade, rpm will note that a new config file should
be installed and thus will leave ".rpmnew" files.

Also, don't mention "/var/run". It should really be just "/run" because
"/var" might not be mounted in early boot/initrd or in rescue environment.
2019-05-17 21:24:18 +02:00
Thomas Haller ad142e1945 build: remove duplicate and unused RUNDIR define 2019-05-17 21:24:18 +02:00
Thomas Haller 5c3f5a846e dhcp/dhcpcd: fix location of PID file for dhcpcd
"RUNDIR" is set to "$runstatedir/NetworkManager". That is not correct,
we must use "$runstatedir".

I don't understand how this could have ever worked. Commit e2ecf5b808
('dhcp: dhcpcd uses a fixed path for PID files') seems to address this issue,
but already then "RUNDIR" was set to "$(localstatedir)/run/NetworkManager".
2019-05-17 21:24:18 +02:00
Thomas Haller 2edf18376f logging: merge branch 'th/logging-syslog-facility'
https://bugzilla.redhat.com/show_bug.cgi?id=1709741

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/147
2019-05-17 21:16:00 +02:00
Thomas Haller f8cbf06a77 logging: use stack allocated string buffer to constuct NM_LOG_DOMAINS field
NM_LOG_DOMAINS is a comma-separated list of the selected logging domains.

As the number of all logging domains is fixed at compile-time, the maximum
length of the buffer is known.

  $ git grep $'^\t{ LOGD_' | sed 's/.*"\(.*\)" .*/\1/' | xargs | sed 's/  */,/g' | sed 's/^/NM_LOG_DOMAINS=/'
  NM_LOG_DOMAINS=PLATFORM,RFKILL,ETHER,WIFI,BT,MB,DHCP4,DHCP6,PPP,WIFI_SCAN,IP4,IP6,AUTOIP4,DNS,VPN,SHARING,SUPPLICANT,AGENTS,SETTINGS,SUSPEND,CORE,DEVICE,OLPC,INFINIBAND,FIREWALL,ADSL,BOND,VLAN,BRIDGE,DBUS_PROPS,TEAM,CONCHECK,DCB,DISPATCH,AUDIT,SYSTEMD,VPN_PLUGIN,PROXY

Note that the static buffer "_all_logging_domains_to_str" is known
to be large enough to contain these domain names (it's even longer,
as it also contains "ALL", "IP", and "DHCP" alises). We can use that
to define the array of suitable size.
2019-05-17 21:12:38 +02:00
Thomas Haller 9cddb9f8bd logging: use static buffer in nm_logging_all_domains_to_string()
Don't create a heap allocated GString to hold the static
result of nm_logging_all_domains_to_string().

Instead, use a static buffer of the exactly required size.

The main reason to do this, is to get the exact size of
"_all_logging_domains_to_str" buffer. This is the upper
boundary for the size of a string buffer to hold all domain
names.
We will need that boundary in the next commit. The attractive
thing here is that we will have a unit-test failure if this
boundery no longer matches (--with-more-asserts). That means,
this boundary is guarded by unit tests and we don't accidentally
get it wrong when the domains change.

Also, take care to initialize the buffer in a thread-safe manner.
It's easy enough to get right, so there is no excuse for having
non-thread-safe code in logging.
2019-05-17 21:12:38 +02:00
Thomas Haller cc2553e871 logging: don't misuse SYSLOG_FACILITY field in journal
Syslog's "facility" is a well defined thing and must be
one of a few well-known numbers. Don't re-use it for our
own purposes.

Fixes: 1b808d3b25 ('logging: add native systemd-journald support to nm-logging')

https://bugzilla.redhat.com/show_bug.cgi?id=1709741
2019-05-17 21:12:38 +02:00
Thomas Haller 467ac96dd1 logging: use char pointer for iov_free in _nm_log_impl() 2019-05-17 21:09:20 +02:00
Thomas Haller 138c187376 logging: fix stack overflow in logging for iov_data array
This overflow could only happen when we would try to log a message
with "NM_DEVICE=", "NM_CONNECTION=", and more than 8 logging domains
(_NUM_MAX_FIELDS_SYSLOG_FACILITY - 2).

The latter is never the case. While we sometimes log messages with
more than one logging domain, there are no logging statements that
use most as 8 different logging domains. So, this overflow is not
actually reachable from current code (I think).

Fixes: ed552c732c ('logging: log device and connection along with the message'):
2019-05-17 21:08:34 +02:00
Thomas Haller 87f3c50f48 wwan: minor cleanup for owns_port() to return early
I find

    for (i = 0; i < n_ports && !owns; i++)
        owns = ...

hard to read.

If the condition is satisfied, we can just return the result right
away.
2019-05-17 17:50:16 +02:00
Thomas Haller 4a10feec16 ci: merge branch 'th/randomize-tests-for-gitlab-ci'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/125
2019-05-17 13:46:37 +02:00
Thomas Haller 70487d9ff8 ci: randomize tests during our CI
This affects gitlab-ci and travis-ci, which both run this script.
2019-05-17 13:30:14 +02:00
Jonas DOREL 13be449296 doc: replace "Split DNS" with "Conditional Forwarding"
Split DNS usually refers to "Split Horizon DNS" whereas "Conditional
Forwarding" is specifically for what the documentation describes.

[thaller@redhat.com: rewrote commit message]

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/143
2019-05-17 12:08:45 +02:00
Thomas Haller ac14ebb322 CONTRIBUTING: explain how assertions work for us 2019-05-16 17:38:07 +02:00
Thomas Haller 03ab1466bd dhcp: use g_return_if_fail() instead of g_assert() in nm_dhcp_client_start_timeout() 2019-05-16 17:01:15 +02:00