Commit graph

21320 commits

Author SHA1 Message Date
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
Lubomir Rintel
66cad942f2 release: bump version to 1.14.4 2018-10-24 10:03:52 +02:00
Lubomir Rintel
8619214faa release: update NEWS 2018-10-24 10:03:52 +02:00
Taegil Bae
4f2c6dd264 meson: set RPATH for libnm_device_plugin_wwan.so
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/26
(cherry picked from commit 4b2dc8826d)
2018-10-24 09:59:46 +02:00
Taegil Bae
4ebe6f1e26 meson: set RPATH for libnm_device_plugin_bluetooth.so
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/26
(cherry picked from commit 82b8ef2252)
2018-10-24 09:59:44 +02:00
Michael Biebl
0ffb390bf3 settings/ifupdown: fix block_name typo in initialize()
In commit f0938948bc a typo creeped in and
"block->name" got replaced by "block_name". Variable block_name is used
for a different purpose and not initialized at this point.
As a result g_str_has_prefix crashes with a segfault.

Spotted by Bernhard Übelacker <bernhardu@mailbox.org>

Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=911621
Fixes: f0938948bc

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/31
(cherry picked from commit 8179b23d76)
2018-10-23 23:01:35 +02:00
Lubomir Rintel
576f0877f3 cli: initialize readline before installing the redisplay handler
Otherwise readline decides to initialize terminal handling at the first
readline call, and if that happens at the point it sees our
non-echoing rl_redisplay.

At that point, unless already intialized, readline wrongly convinces itself we
do our own handling of terminal peculiarities (such as cursor movement, or
erases).  We do not -- we merely wrap the stock rl_redisplay(), temporarily
hiding the actual characters.

The rl_initialize() in nmc_readline_echo()s fixes broken line editing in
password prompts that weren't preceded a previous non-password prompt.
The other one is there for consistency only. (I guess we should be
initializing readline before use anyway; although it seems to initialize
itself anyway if we fail to do so...)

https://github.com/NetworkManager/NetworkManager/pull/241
(cherry picked from commit 05d6c993dd)
2018-10-23 23:01:30 +02:00
Beniamino Galvani
2e5d0f3046 initrd: cmdline-reader: fix setting uint properties
Previously a uint property was assigned with a guint64 value, which
has a different size. Fix this and add a warning when the read value
can't be converted.

Fixes: ecc074b2f8

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/66
(cherry picked from commit d0a99176a7)
2018-10-23 13:24:42 +02:00
Beniamino Galvani
147081bd72 dhcp: dhclient: fix memory leak
Fixes: c263f5355c
(cherry picked from commit 0ba0f52cb7)
2018-10-23 09:10:06 +02:00