Commit graph

21328 commits

Author SHA1 Message Date
Thomas Haller
16bde2d1ec dhcp: log client-id of DHCP instance
(cherry picked from commit 2af1dc1d28)
2018-11-14 14:17:34 +01:00
Thomas Haller
5dc8a14576 libnm: cleanup _nm_utils_hexstr2bin*() helper
Add 3 variants of _nm_utils_hexstr2bin*():

  - _nm_utils_hexstr2bin_full(), which takes a preallocated
    buffer and fills it.
  - _nm_utils_hexstr2bin_alloc() which returns a malloc'ed
    buffer
  - _nm_utils_hexstr2bin_buf(), which fills a preallocated
    buffer of a specific size.

(cherry picked from commit be6c7fa5f6)
2018-11-14 14:17:34 +01:00
Thomas Haller
2a8bef4454 all: drop _nm_utils_bin2hexstr()
We already have nm_utils_bin2hexstr() and _nm_utils_bin2hexstr_full().
This is confusing.

  - nm_utils_bin2hexstr() is public API of libnm. Also, it has
    a last argument @final_len to truncate the string at that
    length.
    It uses no delimiter and lower-case characters.

  - _nm_utils_bin2hexstr_full() does not do any truncation, but
    it has options to specify a delimiter, the character case,
    and to update a given buffer in-place. Also, like
    nm_utils_bin2hexstr() and _nm_utils_bin2hexstr() it can
    allocate a new buffer on demand.

  - _nm_utils_bin2hexstr() would use ':' as delimiter and make
    the case configurable. Also, it would always allocate the returned
    buffer.

It's too much and confusing. Drop _nm_utils_bin2hexstr() which is internal
API and just a wrapper around _nm_utils_bin2hexstr_full().

(cherry picked from commit b537c0388a)
2018-11-14 14:17:34 +01:00
Thomas Haller
f4973558dc libnm: return output buffer from _nm_utils_bin2hexstr_full()
It's just more convenient, as it allows better chaining.

Also, allow passing %NULL as @out buffer. It's clear how
large the output buffer must be, so for convenience let the
function (optionally) allocate a new buffer.

This behavior of whether to
  - take @out, fill it, and return @out
  - take no @out, allocate new buffer, fill and and return it
is slightly error prone. But it was already error prone before, when
it would accept an input buffer without explicit buffer length. I think
this makes it more safe, because in the common case the caller can avoid
pre-allocating a buffer of the right size and the function gets it
right.

(cherry picked from commit 21df8d38ef)
2018-11-14 14:17:34 +01:00
Thomas Haller
cc93cf46ad all/trivial: rename hexstr<>bin conversion functions
"bin2str" and "str2bin" are not very clear. These strings are
hex-strings. Rename.

(cherry picked from commit 6714440669)
2018-11-14 14:17:34 +01:00
Thomas Haller
68d1f1cee8 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

(cherry picked from commit 6651915e69)
2018-11-14 12:40:06 +01:00
Thomas Haller
b2722219e7 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.

(cherry picked from commit 7a46ccff00)
2018-11-14 12:38:05 +01:00
Thomas Haller
9ac4bdb501 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
(cherry picked from commit b9eb264efe)
2018-11-14 12:38:05 +01:00
Thomas Haller
e2d777ff13 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.

(cherry picked from commit 35cecd32fd)
2018-11-14 12:38:05 +01:00
Thomas Haller
9672ea128e 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.

(cherry picked from commit 5f4d8ffa79)
2018-11-14 12:38:05 +01:00
Thomas Haller
cffb82e102 libnm: merge branch 'th/uuid'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/38

(cherry picked from commit 506eb47386)
2018-11-14 10:55:35 +01:00
Thomas Haller
0e3f35edeb libnm: add nm_utils_uuid_is_null() helper
(cherry picked from commit 01239e99d7)
2018-11-14 10:51:44 +01:00
Thomas Haller
b9d2503843 libnm: add nm_utils_uuid_generate_from_string_bin() function
(cherry picked from commit 4db431191c)
2018-11-14 10:51:44 +01:00
Thomas Haller
9da5c5989e 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.

(cherry picked from commit 070a4d9355)
2018-11-14 10:51:44 +01:00
Thomas Haller
91745d0ae9 libnm/tests: add more tests for generating UUIDs
The expected values are checked with python's uuid module
and OSSP uuid.

(cherry picked from commit 2ce5347e4d)
2018-11-14 10:51:44 +01:00
Thomas Haller
1a1d1bf7f3 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.

(cherry picked from commit c150b0fa29)
2018-11-14 10:51:44 +01:00
Thomas Haller
9a710e5108 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()".

(cherry picked from commit 88b081fce4)
2018-11-14 10:51:44 +01:00
Thomas Haller
9db9b00c33 dns: merge branch 'resolv-search-increase'
https://bugzilla.redhat.com/show_bug.cgi?id=1648009
https://bugzilla.redhat.com/show_bug.cgi?id=1649704
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/47

(cherry picked from commit 16c9e89c3f)
2018-11-14 10:47:55 +01:00
Kyle Walker
3ce19034fa 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
(cherry picked from commit 3f2cc579e7)
2018-11-14 10:38:57 +01:00
Thomas Haller
dfce87b2b7 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

(cherry picked from commit 49c11a44e4)
2018-11-14 10:38:57 +01:00
Thomas Haller
b78a0ebcb1 dns/tests: add test for writing resolv.conf
(cherry picked from commit 60cd93612f)
2018-11-14 10:38:54 +01:00
Thomas Haller
4515d36fa1 dns: make strv arguments of create_resolv_conf() const
(cherry picked from commit 1c338861c4)
2018-11-14 10:37:41 +01:00
Thomas Haller
5fe1728d1f shared: add NM_MAKE_STRV() macro
(cherry picked from commit a15756d990)
2018-11-14 10:36:15 +01:00
Thomas Haller
ce88f7c404 dns: fix creating resolv.conf content
g_string_new_len() allocates the buffer with length
bytes. Maybe it should be obvious (wasn't to me), but
if a init argument is given, that is taken as containing
length bytes.

So,

    str = g_string_new_len (init, len);

is more like

    str = g_string_new_len (NULL, len);
    g_string_append_len (str, init, len);

and not (how I wrongly thought)

    str = g_string_new_len (NULL, len);
    g_string_append (str, init);

Fixes: 95b006c244
(cherry picked from commit 511709c54d)
2018-11-14 10:35:54 +01:00
Thomas Haller
23d9a5218a dns: refactor create_resolv_conf() to use GString for constructing content
(cherry picked from commit 95b006c244)
2018-11-14 10:35:40 +01:00
Corentin Noël
7d5cce2e10 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
(cherry picked from commit 201c153e25)
2018-11-12 13:04:09 +01:00
Lubomir Rintel
bc80722484 libnm-core: don't serialize synthetic properties in nm_setting_to_string()
Fixes: f957ea2b34

https://github.com/NetworkManager/NetworkManager/pull/245
(cherry picked from commit 395c385b9b)
2018-11-07 15:43:23 +01:00
Beniamino Galvani
468591805a 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
(cherry picked from commit 9958df36e5)
2018-11-02 17:08:06 +01:00
Beniamino Galvani
9b0735f6fd 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.

(cherry picked from commit 5ba301f4eb)
2018-11-02 17:07:43 +01:00
Beniamino Galvani
d1afd1c420 cli/tests: fix output on failure
(cherry picked from commit 5665f67bae)
2018-11-02 17:07:41 +01:00
Beniamino Galvani
e22602096f cli: fix memory leaks
(cherry picked from commit a985efaf93)
2018-11-02 17:07:40 +01:00
Beniamino Galvani
c1bf574ea5 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
(cherry picked from commit c0138cdb35)
2018-11-02 17:07:39 +01:00
Thomas Haller
ba83251bba systemd: merge branch 'CVE-2018-15688' into nm-1-14 2018-10-29 14:31:39 +01:00
Lennart Poettering
fc230dca13 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)
(cherry picked from commit 01ca2053bb)
2018-10-28 18:46:10 +01:00
Li Song
cb77290a69 sd-dhcp: remove unreachable route after rebinding return NAK
(cherry picked from commit cc3981b1272b9ce37e7d734a7b2f42e84acac535)
(cherry picked from commit 915c2f675a)
2018-10-28 18:46:10 +01:00
Yu Watanabe
f11f5abb1a 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)
(cherry picked from commit 50403cccee)
2018-10-28 18:46:10 +01:00
Yu Watanabe
0e93fd895d sd-dhcp6: fix argument and error handling of dhcp6_option_parse_status()
(cherry picked from commit 91c43f3978fa7c8341550b9ca279e460ba7e74e6)
(cherry picked from commit 373cbfc8c6)
2018-10-28 18:46:10 +01:00
Yu Watanabe
91fb1673d5 dhcp6: fix buffer size checking
(cherry picked from commit cb1bdeaf56852275e6b0dd1fba932bb174767f70)
2018-10-28 18:46:10 +01:00
Yu Watanabe
157094abd8 sd-dhcp-lease: fix memleaks
(cherry picked from commit e2975f854831d08a25b4f5eb329b6d04102e115f)
2018-10-28 18:37:27 +01:00
Thomas Haller
2c6fafad7a 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
(cherry picked from commit ec37e18c64)
2018-10-25 15:31:18 +02:00
Thomas Haller
0ec52f6dec build: fix check-docs.sh for out-of-tree builds
Fixes: 7a59cd2744

(cherry picked from commit 168e8b9b6f)
2018-10-25 11:11:03 +02:00
Thomas Haller
a0157f8628 build: merge branch 'fix-bashism-in-tools-check-docs-sh'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/35

(cherry picked from commit cacd3be1a9)
2018-10-25 09:49:32 +02:00
Thomas Haller
679fa18e34 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.

(cherry picked from commit 7a59cd2744)
2018-10-25 09:49:13 +02:00
Michael Biebl
ff7d3fd3d6 docs: fix bashism in tools/check-docs.sh
[thaller@redhat.com: fixed issue in original patch]

(cherry picked from commit e11ee4582a)
2018-10-25 09:49:12 +02:00
Beniamino Galvani
a9f907bfa7 build: merge branch 'bg/issue65'
ibft-related build fixes.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/65
(cherry picked from commit 587e0e37b2)
2018-10-24 22:14:09 +02:00
Beniamino Galvani
3d7b6ac8f9 build: fix ibft option in create-exports-NetworkManager.sh
(cherry picked from commit 1408ffd9f6)
2018-10-24 22:13:30 +02:00
Thomas Haller
036d49b398 build: enable ibft plugin for make dist-check
(cherry picked from commit 0677b51549)
2018-10-24 22:07:30 +02:00
Thomas Haller
dd76fe3ccd 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.

(cherry picked from commit b660a41c7c)
2018-10-24 22:07:29 +02:00
Beniamino Galvani
c56a3b6c11 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
(cherry picked from commit bc6071aed6)
2018-10-24 22:07:27 +02:00
Lubomir Rintel
5e8d7bfbd1 release: bump version to 1.14.5 (development) 2018-10-24 10:03:52 +02:00