Commit graph

11102 commits

Author SHA1 Message Date
Lubomir Rintel
8f1631c679 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
(cherry picked from commit aa0e395530)
2018-10-09 20:23:59 +02:00
Beniamino Galvani
ce2d403530 device: don't remove routes when the interface is down
In update update_ext_ip_config() we remove from various internal
configurations those addresses and routes that were removed externally
by users.

When the interface is brought down, the kernel automatically removes
routes associated with it and so we should not consider them as
"removed by users".

Instead, keep them so that they can be restored when the interface
comes up again.

(cherry picked from commit f069c98cc9)
2018-10-08 18:10:26 +02:00
Beniamino Galvani
bd79e67c55 ip-config: add @intersect_routes argument to intersect functions
In some cases we want to intersect two IP configurations without
considering routes.

(cherry picked from commit 8f07b3ac4f)
2018-10-08 18:10:23 +02:00
Beniamino Galvani
81aaf0ff93 device: fix updating device information after link change
device_link_changed() can't use nm_device_update_from_platform_link()
to update the device private fields because the latter overwrites
priv->iface and priv->up, and so the checks below as:

  if (info.name[0] && strcmp (priv->iface, info.name) != 0) {

and:

  was_up = priv->up;
  priv->up = NM_FLAGS_HAS (info.n_ifi_flags, IFF_UP);
  ...
  if (priv->up && !was_up) {

never succeed.

Fixes: d7f7725ae8
(cherry picked from commit 46ed756112)
2018-10-08 18:10:17 +02:00
Beniamino Galvani
0b1ffdbdb5 core: improve nm_ip_config_dump()
Previously we had nm_ip{4,6}_config_dump() for debugging purposes, but
they were inconveniently printing to stdout and so the output was not
ordered in the journal.

Implement a unified nm_ip_config_dump() that logs through the usual
logging mechanism.

(cherry picked from commit 3b49d1075d)
2018-10-08 18:10:16 +02:00
Beniamino Galvani
8cbc08ce29 device: fix a wrong comparison
'i <= G_MAXINT' is always true.

(cherry picked from commit e3b9606b24)
2018-10-07 14:15:17 +02:00
Evgeny Vereshchagin
cd3aacefdd 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
(cherry picked from commit 7cb7cffc49)
2018-10-05 01:41:38 +02:00
Yu Watanabe
0cec1cb93e 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
(cherry picked from commit 484e92e17f)
2018-10-05 01:41:37 +02:00
Beniamino Galvani
4c9aa0ced0 build: meson: install ifcfg-rh files and directory
(cherry picked from commit 34ffd9fcab)
2018-10-02 10:02:32 +02:00
Beniamino Galvani
3711c31467 build: meson: fix computing NM exported symbols
The script didn't include all the symbols needed by plugins because
libNetworkManager.a, as built by meson, doesn't include symbols from
other static libraries that are linked in. Since we used
libNetworkManager.a to know which symbols are potentiall available
from NM, the result was an incomplete list.

Unfortunately, the only way to include the whole static library is to
create a dependency object and use 'link_whole', but this is only
available in meson >= 0.46. Since 'link_whole' is available for
executables in meson >= 0.40, create a fake executable and use that to
enumerate symbols.

Also add tests to check that plugins can be loaded correctly.

Fixes: dfa2a2b40c
(cherry picked from commit 19a718bc13)
2018-10-02 10:00:25 +02:00
Beniamino Galvani
f235d57a3a wifi: support hidden ssid in AP mode
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/48
(cherry picked from commit 5d97e76c7d)
2018-09-27 14:10:22 +02:00
Thomas Haller
0d32344781 wifi: log warning when active scanning for hidden networks
When there are profiles with wifi.hidden=yes, NetworkManager
will actively scan for these SSIDs. This makes the scan request
(and thus the user) recognizable and trackable.

It seems generally a bad idea to use hidden networks, as they
compromise either the privacy or usablity for the clients.

Log a (rate-limited) warning about this.

(cherry picked from commit 365079c09e)
2018-09-26 14:23:06 +02:00
Andrew Zaborowski
8cc306bba4 wifi/iwd: handle IWD Station interface disappearing
The net.connman.iwd.Station interface, unlike the Device interface, can
go away and come back when the device changes modes or goes DOWN and UP.
The GDbusProxy for the interface becomes invalid after the interface
disappeared and reappeared.  This would make the IWD backend stop
working after rfkill was used or after suspend/resume (provided the
suspend/resume events are detected, without them everything works and is
really fast too).

Redo the handling of the Powered property changes, corresponding to
device UP state, to get a new GDBusProxy when the Station interface
reappears.  Simplify some checks knowing that priv->can_scan implies for
example that the Station interface is present, and that priv->enabled
implies the NM device state is >= DISCONNECTED.

https://github.com/NetworkManager/NetworkManager/pull/211
(cherry picked from commit bfacd24f83)
2018-09-26 14:21:57 +02:00
Andrew Zaborowski
41b3c45699 wifi/iwd: don't change state in secrets callback
Also make sure the secrets request callback only send a reply to IWD and
the Connect method return callback executes the device state change to
"disconnected".

(cherry picked from commit 061913c588)
2018-09-26 14:21:01 +02:00
Andrew Zaborowski
b31d2ea02a wifi/iwd: actually wait for Connect() call return
state_changed (called when IWD signalled device state change) was
supposed to not change NM device state on connect success or failure and
instead wait for the DBus Connect() method callback but it would
actually still call nm_device_emit_recheck_auto_activate on failure so
refactor state_changed and network_connect_cb to make sure
the state change and nm_device_emit_recheck_auto_activate are only
called from network_connect_cb.

This fixes a race where during a switch from one network to another NM
would immediately start a new activation after state_changed and
network_connect_cb would then handle the Connect failure and mark the
new activation as failed.

(cherry picked from commit 44af62eb1f)
2018-09-26 14:21:01 +02:00
Andrew Zaborowski
0060b63782 wifi/iwd: don't save secrets in mirror NM connections
When creating the mirror 802.1x connections for IWD 802.1x profiles
set the NM_SETTING_SECRET_FLAG_NOT_SAVED flag on the secrets that
may at some point be requested from our agent.  The saved secrets could
not be used anyway because of our use of
NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW in
nm_device_iwd_agent_query.  But also try to respect whatever secret
caching policy has been configured in the IWD profile for those secrets,
IWD would be responsible for storing them if it was allowed in the
profile.

(cherry picked from commit e3aba12d14)
2018-09-26 14:21:01 +02:00
Andrew Zaborowski
9bc58e251c wifi/iwd: access Network objects through ObjectManager
In two places stop using g_dbus_proxy_new_* to create whole new
interface proxy objects for net.connman.iwd.Network as this will
normally have a huge overhead compared to asking the ObjectManager
client that we already have in NMIwdManager for those proxies.
dbus-monitor shows that for each network path returned by
GetOrderedNetworks () -- and we call it every 10 or 20 seconds and may
get many dozens of networks back -- gdbus would do the following each
time:
org.freedesktop.DBus.AddMatch("member=PropertiesChanged")
org.freedesktop.DBus.StartServiceByName("net.connman.iwd")
org.freedesktop.DBus.GetNameOwner("net.connman.iwd")
org.freedesktop.DBus.Properties.GetAll("net.connman.iwd.Network")
org.freedesktop.DBus.RemoveMatch("member=PropertiesChanged")

(cherry picked from commit fd1cfa6db4)
2018-09-26 14:21:01 +02:00
Frederic Danis
474cf75054 core: fix route metric set to -1 on DHCP renewal
The first DHCP renew after setting back Ethernet metric to default (-1)
applies a metric of 4294967295 (uint16 -1) instead of the default metric.

The route becomes:
  Kernel IP routing table
  Destination     Gateway         Genmask         Flags Metric Ref Use Iface
  0.0.0.0         0.0.0.0         0.0.0.0         U     700    0     0 ppp0
  0.0.0.0         192.168.19.193  0.0.0.0         UG    -1     0     0 eth0
  10.64.64.64     0.0.0.0         255.255.255.255 UH    0      0     0 ppp0
  10.64.64.64     0.0.0.0         255.255.255.255 UH    700    0     0 ppp0
  10.250.0.0      0.0.0.0         255.255.0.0     U     50     0     0 tun0
  192.168.19.0    0.0.0.0         255.255.255.0   U     100    0     0 eth0
  192.168.19.193  0.0.0.0         255.255.255.255 UH    100    0     0 eth0
  217.114.201.194 192.168.19.193  255.255.255.255 UGH   100    0     0 eth0

Route update traces:
  Sep 20 09:53:11.869027 tap-0FB1 NetworkManager[762]: <debug> libsystemd: DHCP CLIENT (0xfd5eaeb9): REQUEST (renewing)
  Sep 20 09:53:11.873766 tap-0FB1 NetworkManager[762]: <debug> libsystemd: DHCP CLIENT (0xfd5eaeb9): ACK
  Sep 20 09:53:11.873792 tap-0FB1 NetworkManager[762]: <debug> libsystemd: DHCP CLIENT (0xfd5eaeb9): lease expires in 1min 58s
  Sep 20 09:53:11.873800 tap-0FB1 NetworkManager[762]: <debug> libsystemd: DHCP CLIENT (0xfd5eaeb9): T2 expires in 1min 35s
  Sep 20 09:53:11.873808 tap-0FB1 NetworkManager[762]: <debug> libsystemd: DHCP CLIENT (0xfd5eaeb9): T1 expires in 50s
  Sep 20 09:53:11.873845 tap-0FB1 NetworkManager[762]: <debug> dhcp4 (eth0): client event 4
  Sep 20 09:53:11.873853 tap-0FB1 NetworkManager[762]: <debug> dhcp4 (eth0): lease available
  Sep 20 09:53:11.873881 tap-0FB1 NetworkManager[762]: <info>  dhcp4 (eth0):   address 192.168.19.100
  Sep 20 09:53:11.873890 tap-0FB1 NetworkManager[762]: <info>  dhcp4 (eth0):   plen 24
  Sep 20 09:53:11.873899 tap-0FB1 NetworkManager[762]: <info>  dhcp4 (eth0):   expires in 120 seconds
  Sep 20 09:53:11.873916 tap-0FB1 NetworkManager[762]: <info>  dhcp4 (eth0):   nameserver '192.168.19.193'
  Sep 20 09:53:11.873925 tap-0FB1 NetworkManager[762]: <info>  dhcp4 (eth0):   hostname 'TAPOFB1'
  Sep 20 09:53:11.873932 tap-0FB1 NetworkManager[762]: <info>  dhcp4 (eth0):   gateway 192.168.19.193
  Sep 20 09:53:11.874064 tap-0FB1 NetworkManager[762]: <info>  dhcp4 (eth0): state changed bound -> bound
  Sep 20 09:53:11.874082 tap-0FB1 NetworkManager[762]: <debug> device[0x558dc60b3140] (eth0): new DHCPv4 client state 1
  Sep 20 09:53:11.874535 tap-0FB1 NetworkManager[762]: <debug> device[0x558dc60b3140] (eth0): ip4-config: update (commit=1, new-config=0x558dc6110be0)
  Sep 20 09:53:11.874569 tap-0FB1 NetworkManager[762]: <debug> platform: address: adding or updating IPv4 address: 192.168.19.100/24 lft 120sec pref 120sec lifetime 237-0[120,120] dev 2 flags noprefixroute src unkn
  Sep 20 09:53:11.874626 tap-0FB1 NetworkManager[762]: <trace> platform-linux: event-notification: RTM_NEWADDR, flags 0, seq 141: 192.168.19.100/24 lft 120sec pref 120sec lifetime 237-237[120,120] dev 2 flags noprl
  Sep 20 09:53:11.874653 tap-0FB1 NetworkManager[762]: <debug> platform: signal: address 4 changed: 192.168.19.100/24 lft 120sec pref 120sec lifetime 237-237[120,120] dev 2 flags noprefixroute src kernel
  Sep 20 09:53:11.874671 tap-0FB1 NetworkManager[762]: <debug> device[0x558dc60b3140] (eth0): queued IP4 config change
  Sep 20 09:53:11.874699 tap-0FB1 NetworkManager[762]: <debug> platform-linux: do-add-ip4-address[2: 192.168.19.100/24]: success
  Sep 20 09:53:11.874723 tap-0FB1 NetworkManager[762]: <debug> platform: route: append     IPv4 route: 0.0.0.0/0 via 192.168.19.193 dev 2 metric 4294967295 mss 0 rt-src dhcp
  Sep 20 09:53:11.874778 tap-0FB1 NetworkManager[762]: <trace> platform-linux: event-notification: RTM_NEWROUTE, flags excl,create, seq 142: 0.0.0.0/0 via 192.168.19.193 dev 2 metric 4294967295 mss 0 rt-src rt-dhcl
  Sep 20 09:53:11.874809 tap-0FB1 NetworkManager[762]: <debug> platform: signal: route   4   added: 0.0.0.0/0 via 192.168.19.193 dev 2 metric 4294967295 mss 0 rt-src rt-dhcp scope global
  Sep 20 09:53:11.874846 tap-0FB1 NetworkManager[762]: <debug> platform-linux: do-add-ip4-route[0.0.0.0/0 via 192.168.19.193 dev 2 metric 4294967295 mss 0 rt-src rt-dhcp scope global]: success
  Sep 20 09:53:11.874867 tap-0FB1 NetworkManager[762]: <debug> platform: ip4-route: delete 0.0.0.0/0 via 192.168.19.193 dev 2 metric 100 mss 0 rt-src rt-dhcp scope global
  Sep 20 09:53:11.874904 tap-0FB1 NetworkManager[762]: <trace> platform-linux: event-notification: RTM_DELROUTE, flags 0, seq 143: 0.0.0.0/0 via 192.168.19.193 dev 2 metric 100 mss 0 rt-src rt-dhcp scope global
  Sep 20 09:53:11.874930 tap-0FB1 NetworkManager[762]: <debug> platform: signal: route   4 removed: 0.0.0.0/0 via 192.168.19.193 dev 2 metric 100 mss 0 rt-src rt-dhcp scope global
  Sep 20 09:53:11.874961 tap-0FB1 NetworkManager[762]: <debug> platform-linux: do-delete-ip4-route[0.0.0.0/0 via 192.168.19.193 dev 2 metric 100 mss 0 rt-src rt-dhcp scope global]: success
  Sep 20 09:53:11.874983 tap-0FB1 NetworkManager[762]: <trace> platform: ip4-dev-route: register 192.168.19.0/24 via 0.0.0.0 dev 2 metric 0 mss 0 rt-src rt-kernel scope link pref-src 192.168.19.100 (update)

https://mail.gnome.org/archives/networkmanager-list/2018-September/msg00020.html

Fixes: b9e6433a02
(cherry picked from commit 7d155757b1)
2018-09-21 08:41:58 +02:00
Lubomir Rintel
2ffcdb8efa settings/ifupdown/tests: avoid asserting on an array
char[] is not a char *; it can not go NULL.

  test-ifupdown.c:147:27: error: address of array 'n->name' will always evaluate
                                 to 'true' [-Werror,-Wpointer-bool-conversion]
                g_assert (b->name && n->name);
  test-ifupdown.c:156:27: error: address of array 'm->key' will always evaluate
                                 to 'true' [-Werror,-Wpointer-bool-conversion]
                        g_assert (k->key && m->key);

(cherry picked from commit b64ae759ad)
2018-09-19 15:31:00 +02:00
Thomas Haller
7f05debf99 connectivity: fix crash when removing easy-handle from curl callback
libcurl does not allow removing easy-handles from within a curl
callback.

That was already partly avoided for one handle alone. That is, when
a handle completed inside a libcurl callback, it would only invoke the
callback, but not yet delete it. However, that is not enough, because
from within a callback another handle can be cancelled, leading to
the removal of (the other) handle and a crash:

  ==24572==    at 0x40319AB: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==24572==    by 0x52DDAE5: Curl_close (url.c:392)
  ==24572==    by 0x52EC02C: curl_easy_cleanup (easy.c:825)
  ==24572==    by 0x5FDCD2: cb_data_free (nm-connectivity.c:215)
  ==24572==    by 0x5FF6DE: nm_connectivity_check_cancel (nm-connectivity.c:585)
  ==24572==    by 0x55F7F9: concheck_handle_complete (nm-device.c:2601)
  ==24572==    by 0x574C12: concheck_cb (nm-device.c:2725)
  ==24572==    by 0x5FD887: cb_data_invoke_callback (nm-connectivity.c:167)
  ==24572==    by 0x5FD959: easy_header_cb (nm-connectivity.c:435)
  ==24572==    by 0x52D73CB: chop_write (sendf.c:612)
  ==24572==    by 0x52D73CB: Curl_client_write (sendf.c:668)
  ==24572==    by 0x52D54ED: Curl_http_readwrite_headers (http.c:3904)
  ==24572==    by 0x52E9EA7: readwrite_data (transfer.c:548)
  ==24572==    by 0x52E9EA7: Curl_readwrite (transfer.c:1161)
  ==24572==    by 0x52F4193: multi_runsingle (multi.c:1915)
  ==24572==    by 0x52F5531: multi_socket (multi.c:2607)
  ==24572==    by 0x52F5804: curl_multi_socket_action (multi.c:2771)

Fix that, by never invoking any callbacks when we are inside a libcurl
callback. Instead, the handle is marked for completion and queued. Later,
we complete all queue handles separately.

While at it, drop the @error argument from NMConnectivityCheckCallback.
It was only used to signal cancellation. Let's instead signal that via
status NM_CONNECTIVITY_CANCELLED.

https://bugzilla.gnome.org/show_bug.cgi?id=797136
https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/1792745
https://bugzilla.opensuse.org/show_bug.cgi?id=1107197
https://github.com/NetworkManager/NetworkManager/pull/207

Fixes: d8a31794c8
(cherry picked from commit fa40fc6d76)
2018-09-17 18:23:10 +02:00
Thomas Haller
fe866fbeb3 libnm: drop API nm_connection_get_setting_{6lowpan,sriov,wpan}()
Note that NMSettingEthtool and NMSettingMatch don't have such
functions either.

We have API

  nm_connection_get_setting (NMConnection *, GType)
  nm_connection_get_setting_by_name (NMConnection *, const char *)

which can be used generically, meaning: the requested setting type
is an argument to the function. That is generally more useful and
flexible.

Don't add API which duplicates existing functionality and is (arguably)
inferiour. Drop it now. This is an ABI/API break for the current development
cycle where the 1.14.0 API is still unstable. Indeed it's already after
1.14-rc1, which is ugly. But it's also unlikely that somebody already uses
this API/ABI and is badly impacted by this change.

Note that nm_connection_get_setting() and nm_connection_get_setting_by_name()
are slightly inconvenient in C still, because they usually require a cast.
We should fix that by changing the return type to "void *". Such
a change may be possibly any time without breaking API/ABI (almost, it'd
be an API change when taking a function pointer without casting).

(cherry picked from commit a10156f516)
2018-09-14 16:30:51 +02:00
Thomas Haller
f71f9b54a8 vpn: disconnect signal handlers from proxy in NMVpnConnection::dispose()
We cannot be sure who holds a reference to the proxy, and
who is gonna call us back after the VPN connection instance
is destroyed.

(cherry picked from commit 6ebb9091d2)
2018-09-14 15:24:31 +02:00
Thomas Haller
011dd919fa vpn: fix assertion during "SecretsRequired" in unexpected state
Got this assertion:

    NetworkManager[12939]: <debug> [1536917977.4868] active-connection[0x563d8fd34540]: set state deactivated (was deactivating)
    ...
    NetworkManager[12939]: nm-openvpn[1106] <info>  openvpn[1132]: send SIGTERM
    NetworkManager[12939]: nm-openvpn[1106] <info>  wait for 1 openvpn processes to terminate...
    NetworkManager[12939]: nm-openvpn[1106] <warn>  openvpn[1132] exited with error code 1
    NetworkManager[12939]: <info>  [1536917977.5035] vpn-connection[0x563d8fd34540,2fdeaea3-975f-4325-8305-83ebca5eaa26,"my-openvpn-Red-Hat",0]: VPN plugin: requested secrets; state disconnected (9)
    NetworkManager[12939]: plugin_interactive_secrets_required: assertion 'priv->vpn_state == STATE_CONNECT || priv->vpn_state == STATE_NEED_AUTH' failed

Meaning. We should either ensure that secrets_required_cb() signal callback
is disconnected from proxy's signal, or we gracefully handle callbacks at
unexpected moments. Do the latter.

(cherry picked from commit 92344dd084)
2018-09-14 15:24:31 +02:00
Thomas Haller
d08530ac4b wifi: fix leaking fake AP in NMDeviceWifi's act_stage1_prepare()
Fixes: 96f40dcdcd
(cherry picked from commit ef61d7909f)
2018-09-13 16:28:55 +02:00
Beniamino Galvani
8309a7a696 dns: dnsmasq: avoid crash when no reverse domains exist
ip_data->domains.reverse can be NULL when the device is being removed
and has no IP configuration for a short moment.

Fixes: 6409e7719c

https://bugzilla.gnome.org/show_bug.cgi?id=797022
(cherry picked from commit f0c075f050)
2018-09-13 15:07:57 +02:00
Beniamino Galvani
7e1443746b build: rename DNSSEC_TRIGGER_SCRIPT to DNSSEC_TRIGGER_PATH
Rename the define for consistency, since the configure option is named
'dnssec-trigger'.

(cherry picked from commit 8e776955ee)
2018-09-13 14:35:32 +02:00
Beniamino Galvani
ec123d3bf4 build: meson: generate and use a linker script for NM binary
Generate the NetworkManager.ver link script to link the NM binary so
that unneeded symbol are unexported and can be dropped, reducing the
binary size.

Reported-by: Michael Biebl <biebl@debian.org>
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/33
(cherry picked from commit dfa2a2b40c)
2018-09-13 14:35:26 +02:00
Beniamino Galvani
6220bae2d3 ifcfg-rh: fix build with meson
The shared object was missing some files.

(cherry picked from commit bd556c8937)
2018-09-13 14:35:22 +02:00
Beniamino Galvani
b66607af95 build: remove check on dhcpcd version number
dhcpcd version 6, the first supporting IPv6, was released more than 5
years ago. Remove all checks on version number and IPv6 support.

(cherry picked from commit e0c49d7341)
2018-09-13 14:35:14 +02:00
Thomas Haller
7943b2bb2e platform/netlink: cleanup error number handling
Rename variables for the error number. Commonly the naming
is:

  - errno: the error number from <errno.h> itself
  - errsv: a copy of errno
  - nlerr: a netlink error number
  - err: an error code, but not a errno/errsv and not
      a netlink error number.

(cherry picked from commit f4de941d98)
2018-09-12 11:20:06 +02:00
Thomas Haller
b25e5625ac platform/trivial: adjust coding style in nm-netlink.c
(cherry picked from commit ac73c6f019)
2018-09-12 11:20:05 +02:00
Thomas Haller
a4c3ebed07 dhcp: abort DHCP on devices without MAC address early
Internal DHCPv4 client requires a valid MAC address for functioning.
Just always require a MAC address to start DHCP, both v4 and v6.

We have no MAC address for example on Layer3 devices like tun or wireguard.

Also, before "0a797bdc2a systemd/dhcp: fix assertion starting DHCP
client without MAC address", if we tired to start sd_dhcp_client without
setting a MAC address, an assertion was triggered.

(cherry picked from commit e8fa75ce06)
2018-09-12 10:40:28 +02:00
Thomas Haller
0a797bdc2a systemd/dhcp: fix assertion starting DHCP client without MAC address
An assertion in dhcp_network_bind_raw_socket() is triggered when
starting an sd_dhcp_client without setting setting a MAC address
first.

  - sd_dhcp_client_start()
    - client_start()
      - client_start_delayed()
        - dhcp_network_bind_raw_socket()

In that case, the arp-type and MAC address is still unset. Note that
dhcp_network_bind_raw_socket() already checks for a valid arp-type
and MAC address below, so we should just gracefully return -EINVAL.

Maybe sd_dhcp_client_start() should fail earlier when starting without
MAC address. But the failure here will be correctly propagated and
the start aborted.

See-also: https://github.com/systemd/systemd/pull/10054
(cherry picked from commit 34af574d58)
2018-09-12 10:40:07 +02:00
Thomas Haller
74ebb9a84d dhcp: return error reason from DHCP client start
(cherry picked from commit 1a4fe308e8)
2018-09-12 10:40:07 +02:00
Thomas Haller
d3ba511cce ppp: cleanup logging in impl_ppp_manager_set_ifindex()
It's enough that all code paths in impl_ppp_manager_set_ifindex() log exactly
one message. Also, give all messages the same prefix, so that it's clear where
they come from.

(cherry picked from commit 2a45c32e8c)
2018-09-12 09:46:28 +02:00
Thomas Haller
d3e0a0f9b3 ppp: downgrade warning about repeated SetIfindex calls from ppp plugin
In src/ppp/nm-pppd-plugin.c, it seems that pppd can invoke
phasechange(PHASE_RUNNING:) multiple times. Hence, the plugin
calls SetIfindex multiple times too. In nm-ppp-manager.c, we
want to make sure that the ifindex does not change after it
was set once. However, calling SetIfindex with the same ifindex
is not something worth warning. Just log a debug message and nothing.

Maybe the plugin should remember that it already set the ifindex,
and avoid multiple D-Bus calls. But it's unclear that that is desired.
For now, just downgrade the warning.

(cherry picked from commit 4a4439835d)
2018-09-12 09:46:28 +02:00
Thomas Haller
2f6af40cd5 ppp: avoid strncpy() in ppp plugin nm_phasechange()
strncpy() is deemed insecure, and it raises at least an eyebrow.
While it's save in this case, just avoid it.

(cherry picked from commit 4d11eba8c5)
2018-09-12 09:46:28 +02:00
Thomas Haller
7c50748dcc ppp-manager: avoid crash with nonexisting link in impl_ppp_manager_set_ifindex()
Fixes: dd98ada33f
(cherry picked from commit 30a469e0bb)
2018-09-11 21:40:12 +02:00
Frederic Danis
b3ca8abe38 ppp-manager: fix pppd not exiting correctly on modem hangup
When unplugging an USB 3G modem device, pppd does not exit correctly and
we have the following traces:

Sep 10 07:58:24.616465 ModemManager[1158]: <info>  (tty/ttyUSB0): released by device '/sys/devices/pci0000:00/0000:00:1c.0/0000:01:00.0/usb4/4-1'
Sep 10 07:58:24.620314 pppd[2292]: Modem hangup
Sep 10 07:58:24.621368 ModemManager[1158]: <info>  (tty/ttyUSB1): released by device '/sys/devices/pci0000:00/0000:00:1c.0/0000:01:00.0/usb4/4-1'
Sep 10 07:58:24.621835 ModemManager[1158]: <warn>  (ttyUSB1): could not re-acquire serial port lock: (5) Input/output error
Sep 10 07:58:24.621358 NetworkManager[1871]: <debug> ppp-manager: set-ifindex 4
Sep 10 07:58:24.621369 NetworkManager[1871]: <warn>  ppp-manager: can't change the ifindex from 4 to 4
Sep 10 07:58:24.623982 NetworkManager[1871]: <info>  device (ttyUSB0): state change: activated -> unmanaged (reason 'removed', sys-iface-state: 'removed')
Sep 10 07:58:24.624411 NetworkManager[1871]: <debug> kill child process 'pppd' (2292): wait for process to terminate after sending SIGTERM (15) (send SIGKILL in 1500 milliseconds)...
Sep 10 07:58:24.624440 NetworkManager[1871]: <debug> modem-broadband[ttyUSB0]: notifying ModemManager about the modem disconnection
Sep 10 07:58:24.626591 NetworkManager[1871]: <debug> modem-broadband[ttyUSB0]: notifying ModemManager about the modem disconnection
Sep 10 07:58:24.681016 NetworkManager[1871]: <warn>  modem-broadband[ttyUSB0]: failed to disconnect modem: GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: No such interface 'org.freedesktop.ModemManager1.Modem.Simple' on object at path /org/freedesktop/ModemManager1/Modem/0
Sep 10 07:58:26.126817 NetworkManager[1871]: <debug> kill child process 'pppd' (2292): process not terminated after 1502368 usec. Sending SIGKILL signal
Sep 10 07:58:26.128121 NetworkManager[1871]: <info>  device (ppp0): state change: disconnected -> unmanaged (reason 'unmanaged', sys-iface-state: 'removed')
Sep 10 07:58:26.135571 NetworkManager[1871]: <debug> kill child process 'pppd' (2292): terminated by signal 9 (1511158 usec elapsed)

This is due to nm-ppp-plugin waiting on SetIfIndex call until timeout,
which is longer than termination process timeout.

Calling g_dbus_method_invocation_return_value() on error fixes this.

Fixes: dd98ada33f

https://mail.gnome.org/archives/networkmanager-list/2018-September/msg00010.html
(cherry picked from commit e66e4d0e71)
2018-09-11 21:40:11 +02:00
Andrew Zaborowski
592ee02ea8 wifi/iwd: handle new GetOrderedNetworks() return type
The Station.GetOrderedNetworks dbus method's return type has changed in
IWD commit 0a42f63d42be903a46c595693884772c1c84d39f as the last incompatible
API change before IWD 0.8 (docs change was made earlier in
0453308134a3aadb6a2ec6a78ea642e19427704c) so that network names and
types are no longer included in the reply.  Expect this new reply
signature although still handle the old signature if we're using the
Device interface for IWD <= 0.7 compatibility.

It may be good idea to eventually pass the object manager instance from
nm-iwd-manager.c to nm-device-iwd.c to avoid using g_dbus_proxy_new_sync
and g_dbus_proxy_new_for_bus_sync in act_stage2_config, which possibly
generates a lot of DBus property queries.

https://github.com/NetworkManager/NetworkManager/pull/197
(cherry picked from commit 32506c8788)
2018-09-11 14:14:56 +02:00
Thomas Haller
8f9240de96 dhcp: fix leak in dhclient's dhclient_start()
Fixes: 5d6d5cd136
(cherry picked from commit c87faf07a1)
2018-09-10 14:38:20 +02:00
Thomas Haller
aee3bc0a33 device: mark wireguard devices as unmanaged
Later we want to fully support wireguard devices. Also,
possibly activating a generic profile in a wireguard device
would make sense.

Anyway, for the moment, just prevent that from happening
by explicitly marking the device as unmanaged.

(cherry picked from commit e3bd482329)
2018-09-10 11:13:49 +02:00
Thomas Haller
b8eb0e27b8 device: rename NM_UNMANAGED_LOOPBACK to NM_UNMANAGED_BY_TYPE
It is generally useful, not only for loopback. Rename.

(cherry picked from commit 045a36b33b)
2018-09-10 11:13:49 +02:00
Thomas Haller
c5c28481eb device: detect loopback device explicitly
Don't use NM_UNMANAGED_LOOPBACK for that.

(cherry picked from commit 3635f462b0)
2018-09-10 11:13:49 +02:00
Thomas Haller
544cf89d49 device: make device incompatible with profiles by default
Currently, NMDeviceWireguard does neither set connection_type_check_compatible
nor implement check_connection_compatible. That means, it appears to be compatible
with every connection profile, which is obviously wrong.

Allow devices not to implement check_connection_compatible() and avoid the issue
by rejecting profiles by default.

(cherry picked from commit baa0008313)
2018-09-10 11:13:49 +02:00
Andrew Zaborowski
7308ba2cb8 wifi/iwd: use the new 'Station' DBus interface
The following commit between IWD 0.7 and 0.8 splits the previous Device
interface into two interfaces with no functional changes:
https://git.kernel.org/pub/scm/network/wireless/iwd.git/commit/doc?id=0453308134a3aadb6a2ec6a78ea642e19427704c

Try using this new API but fall back to the old one if the State
property is found still on the Device interface.
2018-09-08 02:31:57 +02:00
Thomas Haller
c3808550eb shared: change nm_utils_strbuf_seek_end() handling truncated strings
Ok, I changed my mind.

The new behavior seems to make more sense to me. Not that it matters,
because we always use nm_utils_strbuf*() API with buffers that we expect
to be large enough to contain the result. And when truncation occurs,
we usually don't care much about it. That is, there is no code that
uses nm_utils_strbuf*() API and handles string truncation in particular.
2018-09-07 18:13:10 +02:00
Andrew Zaborowski
618568366d wifi/iwd: add new DBus interface name defines
New IWD DBus interfaces added before 0.4 and before 0.8
2018-09-07 15:18:56 +02:00
Andrew Zaborowski
436c2a1c8b wifi/iwd: use NM_IN_STRSET for strings
NM_IN_SET will only compare string pointers and isn't useful for
checking if nm_setting_wireless_get_mode (s_wifi) is infrastructure.

Fixes: 570e1fa75b
2018-09-07 15:18:56 +02:00
Andrew Zaborowski
910dc39cd3 wifi/iwd: fix leaking agent DBus objects
Make sure we free our IWD agent objects whenever we're freeing the
IWD Object Manager.  We're registering those objects on the same DBus
connection as the Object Manager so that they're visible to IWD, and
our only reference to that connection is through priv->object_manager
so even though the connection isn't changing when we free the object
manager and create a new one, we still need to free the agent object.
We could maybe keep a reference to the connection, but I'm not sure
there's any warranty that it doesn't get closed.  We could also use
nm_dbus_manager_get_connection (nm_dbus_manager_get ()) and only
register and free the agent once, since it happens to be the same
connection but it'd perhaps be a hack to rely on this.
2018-09-07 15:17:12 +02:00