Commit Graph

21585 Commits

Author SHA1 Message Date
Thomas Haller
a0efc69f46 man: fix generate settings-docs.h text for 'ipv4.dns-priority'
Fixes: 207a9a2223
2018-11-13 14:07:10 +01:00
Thomas Haller
207a9a2223 man: document global connection default for "ipv4.dns-priority"
... and "ipv6.dns-priority".

Fixes: 77ded12da4
2018-11-13 13:49:02 +01:00
Thomas Haller
17f9801e07 man: clarify blocking autoconnect during nmcli connection down
Manually disconnecting a profile of course blocks autoconnect of the
same profile. Otherwise, the profile would likely re-activate right
away, which is clearly against the users intention. If the users just
want to re-activate the profile, they should issue `nmcli connection up`
instead, with does a full down and up cycle.

This is more interesting for profiles that have 'connection.multi-connect'
set to 'multiple'. Would you expect that manually deactivating such a
profile blocks autoconnect of the profile on all devices? Maybe
yes, maybe not. Currently that is indeed the case and autoconnect gets
blocked regardless of multi-connect.
2018-11-13 13:48:10 +01:00
Thomas Haller
37e47fbdab build: avoid header conflict for <linux/if.h> and <net/if.h> with "nm-platform.h"
In the past, the headers "linux/if.h" and "net/if.h" were incompatible.
That means, we can either include one or the other, but not both.
This is fixed in the meantime, however the issue still exists when
building against older kernel/glibc.

That means, including one of these headers from a header file
is problematic. In particular if it's a header like "nm-platform.h",
which itself is dragged in by many other headers.

Avoid that by not including these headers from "platform.h", but instead
from the source files where needed (or possibly from less popular header
files).

Currently there is no problem. However, this allows an unknowing user to
include <net/if.h> at the same time with "nm-platform.h", which is easy
to get wrong.
2018-11-12 16:02:35 +01:00
Thomas Haller
45e54840db build: merge branch 'th/build-libnm-shared'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/43
2018-11-12 13:16:02 +01:00
Thomas Haller
70c4e49cf6 build: create intermediate libraries of shared/nm-utils
Previously we would compile source files from shared/nm-utils
multiple times. That not only slows down compilation, but it makes it
confusing which project require exactly what.

Most of the files in shared/nm-utils are a mixed bag of utility
functions. Just build one libnm-utils-base library. Since the linker
will throw away unused parts, there is no problem that not every user
of libnm-utils-base needs everything.

Also add libnm-utils-udev, which cannot be part of libnm-utils-base as
it has an additional dependency on libudev.
2018-11-12 13:13:40 +01:00
Thomas Haller
06ccf3a64d build: move code for shared libs in Makefile.am around
Let's sort the code by the dependencies. The shared/ projects
have the least dependencies. Move to the beginning.
2018-11-12 13:12:15 +01:00
Corentin Noël
201c153e25 libnm: fix GObject Introspection annotations for functions returning a GPtrArray
The GPtrArray owns the element so it is a (transfer full).

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/46
2018-11-12 12:05:19 +01:00
Thomas Haller
16c9e89c3f dns: merge branch 'resolv-search-increase'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/47
2018-11-12 11:58:38 +01:00
Kyle Walker
3f2cc579e7 dns: remove the resolv.conf 6 entry limit
The resolv.conf used to have a limit of 6 entries for the search option.
With later versions of glibc, this limit has been removed. As a result,
remove the limit here so that all search entries set will be applied to the
resolv.conf. If there is a limit imposed by older versions of glibc, it
should be imposed there as opposed to within NetworkManager.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/80

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/47
2018-11-12 11:56:47 +01:00
Thomas Haller
49c11a44e4 dns: avoid truncation of searches list due to 256 char limit in glibc
Before glibc 2.26, glibc's resolver would only honor 6 search entries
and a character limit of 256. This was lifted recently ([1], [2], [3]).

We also lift this limitation in NetworkManager ([4], [5]).

However, older glibc versions would just truncate the string at 255
characters. In particular, it would not only tuncate the list to 6
entries, but the entry which crosses the 256th character boundary would
be mangled. Avoid that, by adding spaces.

[1] https://sourceware.org/ml/libc-alpha/2017-08/msg00010.html
[2] https://sourceware.org/bugzilla/show_bug.cgi?id=19569
[3] https://sourceware.org/bugzilla/show_bug.cgi?id=21475
[4] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/47
[5] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/80
2018-11-12 11:56:47 +01:00
Thomas Haller
60cd93612f dns/tests: add test for writing resolv.conf 2018-11-12 11:52:49 +01:00
Thomas Haller
1c338861c4 dns: make strv arguments of create_resolv_conf() const 2018-11-12 11:47:04 +01:00
Thomas Haller
a15756d990 shared: add NM_MAKE_STRV() macro 2018-11-12 11:47:04 +01:00
Thomas Haller
763cb8d486 ci: use common script for tests on travis and gitlab
For one, it's not unreasonable that we want to run the same
tests both for gitlab and travis.

Move the actual tests into a script, which is called by both
CI environments.

We still can do something different, based on the environment.
The advantage here is, that the common part will be shared, and
the places where we differ can easily be spot.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/44
2018-11-12 11:29:37 +01:00
Beniamino Galvani
570c41aae4 rpm: disable ebpf support on RHEL
The ebpf syscall doesn't work on RHEL even if the linux/bpf.h header
is available: let's explicitly disable it.

On Fedora explicitly enable eBPF instead of autodetecting it.
2018-11-09 11:36:25 +01:00
Beniamino Galvani
38299a1d78 build: meson: fix wrong man page link
Fixes: 98b4a19a53

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/78
2018-11-08 10:21:58 +01:00
Lubomir Rintel
395c385b9b libnm-core: don't serialize synthetic properties in nm_setting_to_string()
Fixes: f957ea2b34

https://github.com/NetworkManager/NetworkManager/pull/245
2018-11-07 15:36:44 +01:00
Lubomir Rintel
32857a093b modemu: fall back to a virtual bus
This allows us to somehow work with no PCI (or USB for that matter), such
as some virtual machines. Old ModemManager doesn't like this though, but
there doesn't seem to be a way around it.

https://github.com/NetworkManager/NetworkManager/pull/246
2018-11-07 14:50:21 +01:00
Lubomir Rintel
bbb1a36020 modemu: fix subsystem hash endianness
Tested on a really really big endian IBM POWER. Also turn an accompanying
comment into a slightly more sensible one.

https://github.com/NetworkManager/NetworkManager/pull/246
2018-11-07 14:50:18 +01:00
Lubomir Rintel
adc0150e7f rpm: add a bundled(systemd) provide
Required by Fedora Packaging Standards [1] and also really useful.

[1] https://fedoraproject.org/wiki/Bundled_Libraries?rd=Packaging:Bundled_Libraries#Requirement_if_you_bundle

https://github.com/NetworkManager/NetworkManager/pull/247
2018-11-07 14:46:11 +01:00
Beniamino Galvani
7747c8d8ae ofono: fix crash when disconnecting
Fixes: 9b935fad9b
2018-11-06 10:38:35 +01:00
Beniamino Galvani
f330b198b1 modem: fix crash when disconnecting
Fixes: 9b935fad9b
2018-11-06 10:27:34 +01:00
Beniamino Galvani
c7371ff441 man: merge branch 'bg/man'
Some small improvements to man pages and program help

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/41
2018-11-05 09:40:26 +01:00
Beniamino Galvani
c7edb34eb9 cli: add --rescan option to help output 2018-11-05 09:32:20 +01:00
Beniamino Galvani
15d722b70c nm-online: sort options in man page and program help 2018-11-05 09:32:20 +01:00
Beniamino Galvani
e107d3b593 cli: display double-dash long options in help
We support all of these:

 nmcli -v
 nmcli -version
 nmcli --version

Change the help output to display the first and last versions for
options, since they are the most common ones for command line tools.
2018-11-05 09:32:20 +01:00
Beniamino Galvani
d76ac490f5 cli: sort options in man page and program help
Options are displayed in a random order, sort them.
2018-11-05 09:32:20 +01:00
Beniamino Galvani
9958df36e5 tests/cli: merge branch 'bg/issue39'
Wait for all wifi scans to finish before displaying the 'nmcli device
wifi list' result, and other fixes.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/39
2018-11-02 17:05:50 +01:00
Beniamino Galvani
5ba301f4eb tests: simulate old LastScan wifi value in test-networkmanager-service.py
In this way clients will randomly find that the AP list is older than
30 seconds and they will issue a new scan.
2018-11-02 14:56:40 +01:00
Beniamino Galvani
5665f67bae cli/tests: fix output on failure 2018-11-02 14:56:40 +01:00
Beniamino Galvani
a985efaf93 cli: fix memory leaks 2018-11-02 14:56:40 +01:00
Beniamino Galvani
c0138cdb35 cli: wait for all wifi scans to finish before displaying the result
Otherwise devices are displayed in a inconsistent order.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/39
2018-11-02 14:56:40 +01:00
Thomas Haller
6651915e69 dhcp: merge branch 'th/dhcp-match-spec'
https://bugzilla.redhat.com/show_bug.cgi?id=1640494

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/40
2018-11-01 11:18:05 +01:00
Thomas Haller
7a46ccff00 contrib/rpm: add "00-server-dhcp-client-id.conf"
While this is packaged in "NetworkManager-config-server.rpm"
sub-package, it's not in "00-server.conf" file. The reason
is that a convenient way to disable configuration from
"/usr/lib/NetworkManager/conf.d", is by putting a (possibly empty)
file into /etc directory with the same name. If the sub-package
only provides one large "00-server.conf" file, this is no longer
possible at a granular level.
2018-11-01 11:17:12 +01:00
Thomas Haller
b9eb264efe device: add "dhcp-plugin" match spec for device
The need for this is the following:

"ipv4.dhcp-client-id" can be specified via global connection defaults.
In absence of any configuration in NetworkManager, the default depends
on the DHCP client plugin. In case of "dhclient", the default further
depends on /etc/dhcp.

For "internal" plugin, we may very well want to change the default
client-id to "mac" by universally installing a configuration
snippet

    [connection-use-mac-client-id]
    ipv4.dhcp-client-id=mac

However, if we the user happens to enable "dhclient" plugin, this also
forces the client-id and overrules configuration from /etc/dhcp. The real
problem is, that dhclient can be configured via means outside of NetworkManager,
so our defaults shall not overwrite defaults from /etc/dhcp.

With the new device spec, we can avoid this issue:

    [connection-dhcp-client-id]
    match-device=except:dhcp-plugin:dhclient
    ipv4.dhcp-client-id=mac

This will be part of the solution for rh#1640494. Note that merely
dropping a configuration snippet is not yet enough. More fixes for
DHCP will follow. Also, bug rh#1640494 may have alternative solutions
as well. The nice part of this new feature is that it is generally
useful for configuring connection defaults and not specifically for
the client-id issue.

Note that this match spec is per-device, although the plugin is selected
globally. That makes some sense, because in the future we may or may not
configure the DHCP plugin per-device or per address family.

https://bugzilla.redhat.com/show_bug.cgi?id=1640494
2018-11-01 11:17:12 +01:00
Thomas Haller
35cecd32fd core/tests: allow temporarily suppressing logging during tests
Often, during tests we want to assert against the logged messages.
In fact, most tests enable assertions for all logging and enforce
them with g_test_assert_expected_messages(). So, this is common.

However, sometimes it can be cumbersome to understand which logging
lines will be produced. For example, the next commits will call
nm_dhcp_manager_get() during the tests, which initializes NMDhcpManager
and logs a message which plugin was selected (or an additional warning,
if the selected plugin was not found). The availability of the DHCP plugin
depends on searching the path for "/usr/bin/dhclient", so from testing code
it's hard to determine what will be logged.

Instead, add a way to temporarily disable logging during testing.
2018-10-31 13:47:17 +01:00
Thomas Haller
5f4d8ffa79 core/tests: allow to reset singleton instantiations for testing
Most singletons can only be instantiated once (unless NM_DEFINE_SINGLETON_ALLOW_MULTIPLE
is defined). Otherwise, an assertion will be triggered if the singleton is destroyed
and another instance is requested.

For testing, we want to create multiple singleton instances and being able to reset
the singleton getter. Add a function for that.
2018-10-31 11:40:37 +01:00
Thomas Haller
506eb47386 libnm: merge branch 'th/uuid'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/38
2018-10-31 11:36:48 +01:00
Thomas Haller
01239e99d7 libnm: add nm_utils_uuid_is_null() helper 2018-10-31 11:34:31 +01:00
Thomas Haller
4db431191c libnm: add nm_utils_uuid_generate_from_string_bin() function 2018-10-31 11:34:31 +01:00
Thomas Haller
070a4d9355 libnm: add support for SHA1 based version 5 UUIDs
The entire point of using version 3/5 UUIDs is to generate
stable UUIDs based on a string. It's usually important that
we don't change the UUID generation algorithm later on.

Since we didn't have a version 5 implementation, we would always
resort to the MD5 based version 3. Version 5 is recommended by RFC 4122:

   o  Choose either MD5 [4] or SHA-1 [8] as the hash algorithm; If
      backward compatibility is not an issue, SHA-1 is preferred.

Add a version 5 implementation so we can use it in the future.

All test values are generated with python's uuid module or OSSP uuid.
2018-10-31 11:34:31 +01:00
Thomas Haller
2ce5347e4d libnm/tests: add more tests for generating UUIDs
The expected values are checked with python's uuid module
and OSSP uuid.
2018-10-31 09:43:31 +01:00
Thomas Haller
c150b0fa29 libnm/trivial: rename uuid type VARIANT3 to VERSION3
In RFC 4122, this is called "version 3", not "variant 3". While for
UUIDs there is also a concept of "variants", that is something else.

Fix naming.
2018-10-31 09:41:12 +01:00
Thomas Haller
88b081fce4 libnm: expose UUID utils as internal API
We link against libuuid.so, but it was entirely internal to
libnm-core. We only exposed UUIDs in string form.

Add API to also handle UUIDs in binary form.

Note that libuuid already defines a type "uuid_t". However,
don't use it and instead use our own typedef NMUuid.
Reasons:

  - uuid.h should be internal to libnm-core (nm-utils.c specifically),
    and not be used by or exposed it other parts of the code.

  - uuid_t is a typedef for a guchar[16] array. Typedefs
    for arrays are confusing, because depending on whether
    it's an automatic variable or a pointer in a function argument,
    they behave differently regarding whether to take their address
    or not and usage of "sizeof()".
2018-10-31 09:41:12 +01:00
Thomas Haller
3648c58bc5 systemd: merge branch systemd into master 2018-10-28 09:31:31 +01:00
Thomas Haller
5437448a64 systemd: update code from upstream (2018-10-27)
This is a direct dump from systemd git.

======

SYSTEMD_DIR=../systemd
COMMIT=e6b538d06680857fb25e2a6da94fc416bb2340f5

(
  cd "$SYSTEMD_DIR"
  git checkout "$COMMIT"
  git reset --hard
  git clean -fdx
)

git ls-files :/src/systemd/src/ \
             :/shared/nm-utils/unaligned.h | \
  xargs -d '\n' rm -f

nm_copy_sd() {
    mkdir -p "./src/systemd/$(dirname "$1")"
    cp "$SYSTEMD_DIR/$1" "./src/systemd/$1"
}

nm_copy_sd_shared() {
    mkdir -p "./shared/nm-utils/"
    cp "$SYSTEMD_DIR/$1" "./shared/nm-utils/${1##*/}"
}

nm_copy_sd "src/basic/alloc-util.c"
nm_copy_sd "src/basic/alloc-util.h"
nm_copy_sd "src/basic/async.h"
nm_copy_sd "src/basic/env-util.c"
nm_copy_sd "src/basic/env-util.h"
nm_copy_sd "src/basic/escape.c"
nm_copy_sd "src/basic/escape.h"
nm_copy_sd "src/basic/ether-addr-util.c"
nm_copy_sd "src/basic/ether-addr-util.h"
nm_copy_sd "src/basic/extract-word.c"
nm_copy_sd "src/basic/extract-word.h"
nm_copy_sd "src/basic/fileio.c"
nm_copy_sd "src/basic/fileio.h"
nm_copy_sd "src/basic/fd-util.c"
nm_copy_sd "src/basic/fd-util.h"
nm_copy_sd "src/basic/fs-util.c"
nm_copy_sd "src/basic/fs-util.h"
nm_copy_sd "src/basic/hash-funcs.c"
nm_copy_sd "src/basic/hash-funcs.h"
nm_copy_sd "src/basic/hashmap.c"
nm_copy_sd "src/basic/hashmap.h"
nm_copy_sd "src/basic/hexdecoct.c"
nm_copy_sd "src/basic/hexdecoct.h"
nm_copy_sd "src/basic/hostname-util.c"
nm_copy_sd "src/basic/hostname-util.h"
nm_copy_sd "src/basic/in-addr-util.c"
nm_copy_sd "src/basic/in-addr-util.h"
nm_copy_sd "src/basic/io-util.c"
nm_copy_sd "src/basic/io-util.h"
nm_copy_sd "src/basic/list.h"
nm_copy_sd "src/basic/log.h"
nm_copy_sd "src/basic/macro.h"
nm_copy_sd "src/basic/mempool.h"
nm_copy_sd "src/basic/mempool.c"
nm_copy_sd "src/basic/parse-util.c"
nm_copy_sd "src/basic/parse-util.h"
nm_copy_sd "src/basic/path-util.c"
nm_copy_sd "src/basic/path-util.h"
nm_copy_sd "src/basic/prioq.h"
nm_copy_sd "src/basic/prioq.c"
nm_copy_sd "src/basic/process-util.h"
nm_copy_sd "src/basic/process-util.c"
nm_copy_sd "src/basic/random-util.c"
nm_copy_sd "src/basic/random-util.h"
nm_copy_sd "src/basic/refcnt.h"
nm_copy_sd "src/basic/set.h"
nm_copy_sd "src/basic/signal-util.h"
nm_copy_sd "src/basic/siphash24.h"
nm_copy_sd "src/basic/socket-util.c"
nm_copy_sd "src/basic/socket-util.h"
nm_copy_sd "src/basic/sparse-endian.h"
nm_copy_sd "src/basic/stat-util.c"
nm_copy_sd "src/basic/stat-util.h"
nm_copy_sd "src/basic/stdio-util.h"
nm_copy_sd "src/basic/string-table.c"
nm_copy_sd "src/basic/string-table.h"
nm_copy_sd "src/basic/string-util.c"
nm_copy_sd "src/basic/string-util.h"
nm_copy_sd "src/basic/strv.c"
nm_copy_sd "src/basic/strv.h"
nm_copy_sd "src/basic/time-util.c"
nm_copy_sd "src/basic/time-util.h"
nm_copy_sd "src/basic/umask-util.h"
nm_copy_sd_shared "src/basic/unaligned.h"
nm_copy_sd "src/basic/utf8.c"
nm_copy_sd "src/basic/utf8.h"
nm_copy_sd "src/basic/util.c"
nm_copy_sd "src/basic/util.h"
nm_copy_sd "src/libsystemd-network/arp-util.c"
nm_copy_sd "src/libsystemd-network/arp-util.h"
nm_copy_sd "src/libsystemd-network/dhcp6-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp6-lease-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp6-network.c"
nm_copy_sd "src/libsystemd-network/dhcp6-option.c"
nm_copy_sd "src/libsystemd-network/dhcp6-protocol.h"
nm_copy_sd "src/libsystemd-network/dhcp-identifier.c"
nm_copy_sd "src/libsystemd-network/dhcp-identifier.h"
nm_copy_sd "src/libsystemd-network/dhcp-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp-lease-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp-network.c"
nm_copy_sd "src/libsystemd-network/dhcp-option.c"
nm_copy_sd "src/libsystemd-network/dhcp-packet.c"
nm_copy_sd "src/libsystemd-network/dhcp-protocol.h"
nm_copy_sd "src/libsystemd-network/lldp-internal.h"
nm_copy_sd "src/libsystemd-network/lldp-neighbor.c"
nm_copy_sd "src/libsystemd-network/lldp-neighbor.h"
nm_copy_sd "src/libsystemd-network/lldp-network.c"
nm_copy_sd "src/libsystemd-network/lldp-network.h"
nm_copy_sd "src/libsystemd-network/network-internal.c"
nm_copy_sd "src/libsystemd-network/network-internal.h"
nm_copy_sd "src/libsystemd-network/sd-dhcp6-client.c"
nm_copy_sd "src/libsystemd-network/sd-dhcp6-lease.c"
nm_copy_sd "src/libsystemd-network/sd-dhcp-client.c"
nm_copy_sd "src/libsystemd-network/sd-dhcp-lease.c"
nm_copy_sd "src/libsystemd-network/sd-ipv4ll.c"
nm_copy_sd "src/libsystemd-network/sd-ipv4acd.c"
nm_copy_sd "src/libsystemd-network/sd-lldp.c"
nm_copy_sd "src/libsystemd/sd-event/sd-event.c"
nm_copy_sd "src/libsystemd/sd-id128/id128-util.c"
nm_copy_sd "src/libsystemd/sd-id128/id128-util.h"
nm_copy_sd "src/libsystemd/sd-id128/sd-id128.c"
nm_copy_sd "src/shared/dns-domain.c"
nm_copy_sd "src/shared/dns-domain.h"
nm_copy_sd "src/systemd/_sd-common.h"
nm_copy_sd "src/systemd/sd-dhcp6-client.h"
nm_copy_sd "src/systemd/sd-dhcp6-lease.h"
nm_copy_sd "src/systemd/sd-dhcp-client.h"
nm_copy_sd "src/systemd/sd-dhcp-lease.h"
nm_copy_sd "src/systemd/sd-event.h"
nm_copy_sd "src/systemd/sd-ndisc.h"
nm_copy_sd "src/systemd/sd-id128.h"
nm_copy_sd "src/systemd/sd-ipv4acd.h"
nm_copy_sd "src/systemd/sd-ipv4ll.h"
nm_copy_sd "src/systemd/sd-lldp.h"
2018-10-27 22:43:21 +02:00
Thomas Haller
ef7312a3ae systemd: merge branch 'systemd-dhcp6-fix'
Backport a series of upstream patches from systemd, related
to out-of-bounds heap write with DHCPv6.

On master, we anyway will do a full re-import of systemd code.
Cherry-pick individual patches first, to make backporting easier.

CVE-2018-15688
2018-10-27 22:33:07 +02:00
Lennart Poettering
58423902ce dhcp6: prefer offsetof() over sizeof() for structs with undefined sizes
This doesn't change anything in the generated source, but I think makes
semantically more sense, as these structures have undefined size, and we
only want to know the size up to the data field in these cases.

(cherry picked from commit 20b55f853847378b85561a4e299604d27b5cd25b)
2018-10-27 22:03:01 +02:00
Lennart Poettering
01ca2053bb dhcp6: make sure we have enough space for the DHCP6 option header
Fixes a vulnerability originally discovered by Felix Wilhelm from
Google.

CVE-2018-15688
LP: #1795921
https://bugzilla.redhat.com/show_bug.cgi?id=1639067

(cherry picked from commit 4dac5eaba4e419b29c97da38a8b1f82336c2c892)
2018-10-27 22:03:01 +02:00