Commit graph

21392 commits

Author SHA1 Message Date
Thomas Haller
cec7ade86c wwan: don't assume DNS info is always available for IPv6
See also "5df024f57a wwan: don't assume DNS info is always available"
which does the same for IPv4.
2018-10-12 00:00:43 +02:00
Beniamino Galvani
c0fc85f3c4 cli: check we have an active connection before showing hint
If the activation fails even before the active connection instance is
created, we get the following:

 $ nmcli connection up vpn1
 libnm-CRITICAL **: nm_active_connection_get_connection: assertion 'NM_IS_ACTIVE_CONNECTION (connection)' failed
 nmcli-CRITICAL **: active_connection_hint: assertion 'connection' failed
 Error: Connection activation failed: Not authorized to control networking.

Check that we have an active connection before showing the hint.

Fixes: bc6c042d54
2018-10-11 18:40:54 +02:00
Thomas Haller
c925b72e1f wifi/iwd: merge branch 'balrog-kun/iwd-ap-adhoc'
https://github.com/NetworkManager/NetworkManager/pull/221
2018-10-11 16:07:45 +02:00
Andrew Zaborowski
b3dad27a4a wifi/iwd: use KnownNetwork DBus properties on Network objects
Instead of walking through the list all known networks and comparing
name & SSIDs to judge whether a network is an IWD KnownNetwork, look at
the Network.KnownNetwork pre-IWD-0.8 property.
2018-10-11 16:07:15 +02:00
Andrew Zaborowski
2fff4e14b4 wifi/iwd: always update can_connect in state_changed
Ensure priv->can_connect is up to date on IWD state changed.  If we
exited the function early priv->can_connect would sometimes be wrongly
TRUE and we'd start a new autoconnect too early after IP configuration
had failed for example.
2018-10-11 16:07:15 +02:00
Andrew Zaborowski
979c632e11 wifi/iwd: add Ad-hoc mode support 2018-10-11 16:07:15 +02:00
Andrew Zaborowski
a6f13d3c69 wifi/iwd: add AP mode support
Handle AP mode connections by setting the Mode property on IWD's Device
interface to "ap" (which will make the Station interface go away, the
Powered property -- normally controlled by set_enabled -- to switch to
FALSE and back to TRUE, and then the AccessPoint interface to appear)
and then calling the AccessPoint.Start method.  This is all done in the
CONFIG phase in NM.  We also attempt to always set Mode back to
"station" and wait for the Station interface to reappear before going to
the NM DISCONNECTED state.  All this complicates the code a little.

While making the necessary changes simplify a lot of the checks which
are implied by other things we've checked already, for example
priv->can_scan and priv->can_connect can now only be TRUE when device is
powered up and in station mode (Station interface is present) so we can
skip other checks.  Also assume that check_connection_compatible has
been called before other methods are called so we can skip multiple
connection mode checks and checks that a IWD KnownNetwork exsists for
EAP connections.

act_stage1_prepare and act_stage2_config now borrow more code from
nm-device-wifi.c because both backend now handle multiple modes.
2018-10-11 16:07:15 +02:00
Andrew Zaborowski
6e95029b09 wifi/iwd: use nm_utils_error_is_cancelled consistently
Use nm_utils_error_is_cancelled instead of checking
g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED), set
consider_is_disposing false.  Also use the DBUS_INTERFACE_PROPERTIES
macro.
2018-10-11 16:07:15 +02:00
Andrew Zaborowski
6e1935eb21 wifi/iwd: free variants returned by g_dbus_proxy_call_finish
Make sure we g_variant_unref() the values returned from
g_dbus_proxy_call_finish.  In get_ordered_networks_cb also make sure we
don't access the NMDeviceIwd data until after we know the call has not
been cancelled.  Switch from _nm_dbus_proxy_call_finish to
g_dbus_proxy_call_finish where we don't care about the variant type
returned.
2018-10-11 16:07:15 +02:00
Andrew Zaborowski
178af02678 wifi: skip nm_platform_wifi_get_capabilities/get_mode for IWD backend
Only call nm_platform_wifi_get_capabilities and
nm_platform_wifi_get_mode with the wpa_supplicant backend.  They're used
to initialize the wireless-capabilities property and to skip creating
NMDevices for interfaces in unknown wifi mode which IWD handles already.
2018-10-11 16:07:15 +02:00
Andrew Zaborowski
7a6d5ab5a2 wifi/iwd: set capabilities property based on IWD support
Parse the Adapter.SupportedModes dbus property and set the
gobject property wireless-capabilities based on that.
2018-10-11 16:07:15 +02:00
Thomas Haller
6e41d79067 ndisc: merge branch 'th/ndisc-fixes'
https://github.com/NetworkManager/NetworkManager/pull/219
2018-10-11 14:51:08 +02:00
Thomas Haller
98ec56c670 ndisc: always emit changed signal if an ndisc parameter changes
Note how the nm_ndisc_add_*() return a boolean to indicate whether
anything changes. That is taken to decide whether to emit a changed
signal.

Previously, we would not consider all fields which are exposed
as public API.

Note that nm-ip6-config.c would care about the lifetime of NMNDiscAddress.
For that, nm_ndisc_add_address() would correctly consider a change of
the lifetime as relevant. So, this was for the most part not broken.
However, for example nm_ndisc_add_route() would ignore changes to the
gateway.

Always signal changes if anything changes at all. It's more correct
and robust.
2018-10-11 05:56:18 +02:00
Thomas Haller
4f78d82fcd ndisc/trivial: move code 2018-10-11 05:56:18 +02:00
Thomas Haller
d444fcde34 ndisc: abort handling IO in event_ready() if we are unable to switch namespace
It should never happen that we are unable to switch the namespace.
However, in case it does, we cannot just return G_SOURCE_CONTINUE,
because we will just endlessly trying to process IO without actually
reading from the socket.

This shouldn't happen, but the instance is hosed and something is
very wrong. No longer handle the socket to avoid an endless loop.
2018-10-11 05:56:18 +02:00
Thomas Haller
9aa628cedb ndisc: keep NMNDisc instance alive while processing IO in event_ready()
event_ready() calls ndp_callall_eventfd_handler(), which invokes
our own callback, which may invoke change notification.

At that point, it's not guaranteed that the signal handler won't
destroy the ndisc instance, which means, the "struct ndp" gets destroyed
while invoking callbacks. That's bad, because libndp is not robust
against that.

Ensure the object stays alive long enough.
2018-10-11 05:56:18 +02:00
Thomas Haller
1f856b7cb3 ndisc: first reschedule timeout before invoking change event in check_timestamps()
It's just ugly to invoke external code in the middel of an operation.
You never know, whether the handler won' unref the ndisc instance.
2018-10-11 05:56:18 +02:00
Thomas Haller
8de09bb119 keyfile/tests: drop unused variables
Fixes: e886e5364e
2018-10-10 12:38:33 +02:00
Thomas Haller
c295d45a3b platform/netlink: fix overrun in attribute iteration in nla_ok()
See-also: 123dc07bcc
See-also: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1045b03e07d85f3545118510a587035536030c1c
2018-10-10 12:04:27 +02:00
Thomas Haller
82652c1415 cli: merge branch 'th/cli-drop-some-global'
https://github.com/NetworkManager/NetworkManager/pull/225
2018-10-10 09:57:17 +02:00
Thomas Haller
86502bef9c cli: don't needlessly cast function pointer for rl_attempted_completion_function 2018-10-10 09:55:45 +02:00
Thomas Haller
5d684597c4 cli: don't access global nm_cli variable from nmc_setting_set_property() 2018-10-10 09:55:45 +02:00
Thomas Haller
99d3b6930b cli: don't use global variable nm_cli in nmc_terminal_spawn_pager()
print_required_fields() still accesses the global variable.
We can only move the uses of globals up the call-stack, one
bit at a time.
2018-10-10 09:55:45 +02:00
Thomas Haller
411243c654 cli: don't use global nm_cli in nmc_readline_*()
Globals are bad. Don't let nmc_readline_helper() access
nm_cli.

Instead, pass nmc_config along. nmc_config albeit being
a complex struct, is much more begning:

  - the configuration nmc_config is initialized early on
    and afterwards immutable.
  - it only contains simple fields, which affect the behavior.
  - it's not a global. While passing around the complex configuration
    struct, it is clear that all callpaths don't access additional
    global information.
2018-10-10 09:55:45 +02:00
Thomas Haller
0be65a4b78 cli: don't pass complex info argument to active_connection_hint()
Untangle the amount or agruments passed to active_connection_hint().
2018-10-10 09:55:45 +02:00
Lubomir Rintel
aa0e395530 devices/olpc: correct the signal handler arguments
Commit 631ca806 ("devices/wifi: flip meaning of scanning allowed
signal") added a "periodic" argument, but the OLPC companion handler was
not adjusted. Fix it now.

https://github.com/NetworkManager/NetworkManager/pull/222

Fixes: 631ca80692
2018-10-09 20:07:02 +02:00
Beniamino Galvani
09d0e5590c cli: fix memory leak
activate_connection_editor_cb() must free @info and unref the device.
2018-10-09 09:58:27 +02:00
Beniamino Galvani
d091cbdc2f cli: fix cleanup after activation from editor
progress_activation_editor_cb() is called multiple times every 120
milliseconds and it must free resources only the last time.

Fixes: f0a2686545

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/51
2018-10-09 09:58:27 +02:00
Beniamino Galvani
17a942b458 libnm-core: fix other int comparisons in team setting
I forgot to update them when applying commit 72b4541771.

Fixes: 72b4541771
2018-10-08 11:28:14 +02:00
Lubomir Rintel
fb2ae67da6 merge: branch 'lr/wpan-channel'
https://github.com/NetworkManager/NetworkManager/pull/209
2018-10-07 15:46:51 +02:00
Lubomir Rintel
c21b4c3d0a cli: add support for wpan.page and wpan.channel properties 2018-10-07 15:46:02 +02:00
Lubomir Rintel
bd6074095d devices/wpan: set channel on activation 2018-10-07 15:46:02 +02:00
Lubomir Rintel
0573656eeb platform/wpan: allow setting channel 2018-10-07 15:46:02 +02:00
Lubomir Rintel
ae38d43e66 core/setting-wpan: add page and channel properties 2018-10-07 15:46:02 +02:00
Lubomir Rintel
a745f0c952 core/setting-wpan: fix some whitespace errors 2018-10-07 15:46:02 +02:00
Lubomir Rintel
0d3c6072f5 contrib/checkpatch: remove the first character off a diff
Otherwise the leading whitespace checks won't work on patches.
2018-10-07 15:46:02 +02:00
Lubomir Rintel
587f006690 contrib/checkpatch: check some more whitespace trouble 2018-10-07 15:46:02 +02:00
Lubomir Rintel
1d57aefa41 contrib/checkpatch: correctly separate indentation across hunks 2018-10-07 15:46:02 +02:00
Beniamino Galvani
0cb5c4f611 merge: branch 'bg/covscan'
Some coverity fixes.

https://github.com/NetworkManager/NetworkManager/pull/220
2018-10-07 14:01:08 +02:00
Thomas Haller
72b4541771 libnm-core: fix int comparisons in team setting 2018-10-07 13:57:11 +02:00
Beniamino Galvani
d0f85092b9 libnm-core: remove unneeded comparisons
a_gendata and b_gendata cannot be NULL. This makes coverity happy.
2018-10-06 10:03:48 +02:00
Beniamino Galvani
e4154895ff shared/nm-utils: avoid a coverity warning
1. NetworkManager-1.14.0/shared/nm-utils/nm-shared-utils.c:1242: value_overwrite: Overwriting previous write to "ch" with value from "v".
 2. NetworkManager-1.14.0/shared/nm-utils/nm-shared-utils.c:1239: assigned_value: Assigning value from "++str[0]" to "ch" here, but that stored value is overwritten before it can be used.
 #  1237|   				if (ch >= '0' && ch <= '7') {
 #  1238|   					v = v * 8 + (ch - '0');
 #  1239|-> 					ch = (++str)[0];
 #  1240|   				}
 #  1241|   			}

Don't assign ch when it is going to be overwritten.
2018-10-06 10:03:48 +02:00
Beniamino Galvani
e3b9606b24 device: fix a wrong comparison
'i <= G_MAXINT' is always true.
2018-10-06 10:03:48 +02:00
Beniamino Galvani
9e43821e17 dispatcher: fix shellcheck warnings
Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.
And likewise, prefer [ p ] || [ q ] over [ p -o q ].

https://github.com/koalaman/shellcheck/wiki/SC2166
2018-10-06 10:03:48 +02:00
Beniamino Galvani
27ab932a49 libnm-core: use g_variant_type_equal() to compare variant types
Even if a direct pointer comparison should be fine, use the proper
function. GVariantType documentation says:

 "Two types may not be compared by value; use g_variant_type_equal()
 or g_variant_type_is_subtype_of()."

This also fixes coverity warnings.
2018-10-06 10:03:48 +02:00
Beniamino Galvani
9b04b871a0 libnm-core: fix coverity warning
3. NetworkManager-1.14.0/libnm-core/nm-utils.c:4944: var_compare_op: Comparing "str" to null implies that "str" might be null.
 4. NetworkManager-1.14.0/libnm-core/nm-utils.c:4958: var_deref_op: Dereferencing null pointer "str".
 #  4956|
 #  4957|   	/* do some very basic validation to see if this might be a JSON object. */
 #  4958|-> 	if (str[0] == '{') {
 #  4959|   		gsize l;
 #  4960|
2018-10-06 10:03:48 +02:00
Thomas Haller
4791782f46 systemd: merge branch systemd into master
https://github.com/NetworkManager/NetworkManager/pull/186
2018-10-05 01:24:08 +02:00
Thomas Haller
5f1ad6a482 systemd: comment out unused code in utf8.c
Unused code is nice, because on update we don't need to check
whether a patch affects behavior.

Mark code that is unused as such.
2018-10-05 01:00:32 +02:00
Evgeny Vereshchagin
7cb7cffc49 dhcp6: fix an off-by-one error in dhcp6_option_parse_domainname
==14==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60200055fa9c at pc 0x0000005458f1 bp 0x7ffc78940d90 sp 0x7ffc78940d88
READ of size 1 at 0x60200055fa9c thread T0
    #0 0x5458f0 in dhcp6_option_parse_domainname /work/build/../../src/systemd/src/libsystemd-network/dhcp6-option.c:555:29
    #1 0x54706e in dhcp6_lease_set_domains /work/build/../../src/systemd/src/libsystemd-network/sd-dhcp6-lease.c:242:13
    #2 0x53fce0 in client_parse_message /work/build/../../src/systemd/src/libsystemd-network/sd-dhcp6-client.c:984:29
    #3 0x53f3bc in client_receive_advertise /work/build/../../src/systemd/src/libsystemd-network/sd-dhcp6-client.c:1083:13
    #4 0x53d57f in client_receive_message /work/build/../../src/systemd/src/libsystemd-network/sd-dhcp6-client.c:1182:21
    #5 0x7f0f7159deee in source_dispatch /work/build/../../src/systemd/src/libsystemd/sd-event/sd-event.c:3042:21
    #6 0x7f0f7159d431 in sd_event_dispatch /work/build/../../src/systemd/src/libsystemd/sd-event/sd-event.c:3455:21
    #7 0x7f0f7159ea8d in sd_event_run /work/build/../../src/systemd/src/libsystemd/sd-event/sd-event.c:3512:21
    #8 0x531f2b in fuzz_client /work/build/../../src/systemd/src/fuzz/fuzz-dhcp6-client.c:44:9
    #9 0x531bc1 in LLVMFuzzerTestOneInput /work/build/../../src/systemd/src/fuzz/fuzz-dhcp6-client.c:53:9
    #10 0x57bec8 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/libfuzzer/FuzzerLoop.cpp:570:15
    #11 0x579d67 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool*) /src/libfuzzer/FuzzerLoop.cpp:479:3
    #12 0x57dc92 in fuzzer::Fuzzer::MutateAndTestOne() /src/libfuzzer/FuzzerLoop.cpp:707:19
    #13 0x580ca6 in fuzzer::Fuzzer::Loop(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, fuzzer::fuzzer_allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) /src/libfuzzer/FuzzerLoop.cpp:838:5
    #14 0x55e968 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/libfuzzer/FuzzerDriver.cpp:764:6
    #15 0x551a1c in main /src/libfuzzer/FuzzerMain.cpp:20:10
    #16 0x7f0f701a082f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
    #17 0x41e928 in _start (/out/fuzz-dhcp6-client+0x41e928)

https://github.com/systemd/systemd/pull/10200
b387d3c132
2018-10-05 00:44:27 +02:00
Yu Watanabe
484e92e17f dhcp6: check option length before reading values
Fixes oss-fuzz#10746
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=10746.

https://github.com/systemd/systemd/pull/10213
84452783b8
2018-10-05 00:38:09 +02:00