Commit Graph

21553 Commits

Author SHA1 Message Date
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
Lennart Poettering
05872d554f dhcp6: reduce whitespace a bit
(cherry picked from commit 990668aa4cf04ea1c05791af97b1c05080378016)
2018-10-27 22:03:01 +02:00
Lennart Poettering
2dddf5924a dhcp6: split assert_return() to be more debuggable when hit
(cherry picked from commit 3c290c03167cf9334cb419035587ff3057940eee)
2018-10-27 22:03:01 +02:00
Lennart Poettering
d49a036afe dhcp6: constify things where we can
(cherry picked from commit e0a18b74a3b54bd9383b827139cea0df606e4378)
2018-10-27 22:03:01 +02:00
Li Song
915c2f675a sd-dhcp: remove unreachable route after rebinding return NAK
(cherry picked from commit cc3981b1272b9ce37e7d734a7b2f42e84acac535)
2018-10-27 22:03:01 +02:00
Yu Watanabe
83f849ae79 sd-dhcp6: drop empty 'error' label
(cherry picked from commit aae1fa5cc8a49e5071c7e089b186f52bac0da613)
2018-10-27 22:03:01 +02:00
Yu Watanabe
50403cccee sd-dhcp6: make dhcp6_option_parse_domainname() not store empty domain
This improves performance of fuzzer.
C.f. oss-fuzz#11019.

(cherry picked from commit 3c72b6ed4252e7ff5f7704bfe44557ec197b47fa)
2018-10-27 22:03:01 +02:00
Yu Watanabe
1990a3efab sd-dhcp6: do not update serverid when ENOMEM
(cherry picked from commit 33d367589581a9f46fe291181ef2b30b812e5cb3)
2018-10-27 22:03:01 +02:00
Yu Watanabe
a7137ce0ce sd-dhcp6: coding style cleanups
(cherry picked from commit da07cf358231caca214da5d4f161b06e713586be)
2018-10-27 22:03:01 +02:00
Yu Watanabe
373cbfc8c6 sd-dhcp6: fix argument and error handling of dhcp6_option_parse_status()
(cherry picked from commit 91c43f3978fa7c8341550b9ca279e460ba7e74e6)
2018-10-27 22:03:01 +02:00
Yuri Chornoivan
60dda78b74 po: update Ukrainian (uk) translation (#36)
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/36
2018-10-26 12:34:31 +02:00
Thomas Haller
085b769729 man: clarify udev property "NM_UNMANAGED" in man NetworkManager 2018-10-26 09:06:45 +02:00
Thomas Haller
f120bbc7a8 libnm/vpn: merge branch 'th/read-vpn-plugins-tests'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/30
2018-10-25 16:37:43 +02:00
Thomas Haller
9bc33a687e libnm: fix endless loop in nm_vpn_service_plugin_read_vpn_details()
Previously, a "DONE\n" was required to break the loop.
2018-10-25 16:37:35 +02:00
Thomas Haller
21f94e9265 libnm/tests: add test for nm_vpn_service_plugin_read_vpn_details() 2018-10-25 16:37:35 +02:00
Thomas Haller
6dcc0999a6 shared/tests: add NMTST_EXPECT_LIBNM_WARNING() macro 2018-10-25 16:37:35 +02:00
Thomas Haller
50e092a967 build: add configure check for having memfd_create() API 2018-10-25 16:37:35 +02:00
Thomas Haller
ec37e18c64 libnm: fix crash in activate_info_complete() when cancelling
We must disconnect ActivateInfo before invoking callbacks.

Otherwise, it can happen that the callee cancels the cancellable,
which in turn enters activate_info_complete() again, and leads
to a crash.

https://bugzilla.redhat.com/show_bug.cgi?id=1642625
2018-10-25 15:29:55 +02:00
Thomas Haller
ac90593cc2 man: fix "no-auto-default" state dir in NetworkManager.conf manual
Quote from `man NetworkManager.conf`:

  When the default wired connection is deleted or saved to a new
  persistent connection by a plugin, the device is added to a list in the
  file /run/NetworkManager/no-auto-default.state to prevent creating
  the default connection for that device again.

"/run" is obviously wrong. Fix it.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/33
2018-10-25 15:24:38 +02:00
Beniamino Galvani
d9e931acaf client: tests: avoid mixing stdout and stderr output on failure
On failure the self.fail() message often appears in the middle of the
diff between expected/actual output, making it hard to read. Since
print() output goes to stdout (which is buffered) and self.fail() to
stderr (which is not), flush stdout before printing the failure
message to ensure the two don't mix.
2018-10-25 14:52:35 +02:00
Thomas Haller
f8fed7dd52 checkpatch: complain about XXX markers in code
We have a few source code tags like "TODO" and "FIXME".
"XXX" is not intended to be merged, it is for marking
places in code while still working on it.
2018-10-25 11:20:10 +02:00
Thomas Haller
168e8b9b6f build: fix check-docs.sh for out-of-tree builds
Fixes: 7a59cd2744
2018-10-25 11:08:39 +02:00
Thomas Haller
cacd3be1a9 build: merge branch 'fix-bashism-in-tools-check-docs-sh'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/35
2018-10-25 09:45:16 +02:00
Thomas Haller
7a59cd2744 docs: rework check-docs test script
Try to make check-docs.sh script more readable.

Also, previously the script would check that one side was a subset
of the other side. Tighten this check up, now both sides of the
comparison must agree and yield the same lines.
2018-10-25 09:40:53 +02:00
Michael Biebl
e11ee4582a docs: fix bashism in tools/check-docs.sh
[thaller@redhat.com: fixed issue in original patch]
2018-10-25 08:00:40 +02:00
Beniamino Galvani
1408ffd9f6 build: fix ibft option in create-exports-NetworkManager.sh 2018-10-24 22:10:31 +02:00
Beniamino Galvani
587e0e37b2 build: merge branch 'bg/issue65'
ibft-related build fixes.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/65
2018-10-24 22:03:57 +02:00
Thomas Haller
0677b51549 build: enable ibft plugin for make dist-check 2018-10-24 21:43:17 +02:00
Thomas Haller
b660a41c7c build: fix build_clean.sh script to enable ibft
autotools build has/had a bug, where ibft test files would only be disted
if the ibft plugin was enabled.

Regardless of that, `build_clean.sh --release` is our suggested way to
create a release tarball. It should always enable the ibft plugin.

It didn't do so, due to a bug.
2018-10-24 21:43:17 +02:00
Beniamino Galvani
bc6071aed6 build: unconditionally dist ibft test files
Even if ibft support is disabled, test files should be included in
distribution.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/65
2018-10-24 21:05:29 +02:00
Lubomir Rintel
25f625b4fc shared/vpn-plugin-utils: load the editor from the same place as plugin
If passed a relative path, load the editor .so from the same directory
as the plugin .so. This is useful for development, as it allows running
the editor plugin from the build tree conveniently.

https://github.com/NetworkManager/NetworkManager/pull/242
2018-10-24 15:12:43 +02:00
Lubomir Rintel
cb28719e3a shared/vpn-plugin-utils: change the domain of errors
I suppose NM_VPN_PLUGIN_ERROR is slightly less wrong than
NM_CONNECTION_ERROR here. Shall have no practical implications anyway.
2018-10-24 15:12:43 +02:00
Thomas Haller
b1571e687e build/meson: merge branch 'esrevinu/master'
https://bugzilla.gnome.org/show_bug.cgi?id=797324
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/68

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/26
2018-10-24 10:19:02 +02:00