Commit graph

17482 commits

Author SHA1 Message Date
Thomas Haller
cd8f3cf09f tests: work around coverity false-positives
(cherry picked from commit c7c47575ce)
2017-06-02 20:21:11 +02:00
Thomas Haller
38fbdc8118 supplicant: work-around coverify false-positive for check_return: g_async_initable_init_finish()
NetworkManager-1.8.0/src/supplicant/nm-supplicant-interface.c:232: check_return: Calling "g_async_initable_init_finish" without checking return value (as is done elsewhere 7 out of 8 times).

(cherry picked from commit 6f1ea8b8ee)
2017-06-02 20:21:11 +02:00
Thomas Haller
2574393f08 supplicant/tests: work-around coverify false-positive in test
NetworkManager-1.8.0/src/supplicant/tests/test-supplicant-config.c:528: check_return: Calling "nm_setting_802_1x_set_ca_cert" without checking return value (as is done elsewhere 13 out of 16 times).

(cherry picked from commit 7087956870)
2017-06-02 20:21:11 +02:00
Thomas Haller
e984d9eb36 connectivity: fix scheduling periodic connectivity checks
commit a955639 (connectivity: don't do periodic checks on interval=0)
broke scheduling connectivity checks.

That is because the timer is on only scheduled if
nm_connectivity_check_enabled(), which in turn only returns TRUE
if curl_mhandle is set. However, nm_connectivity_init() would only
initialize curl_mhandle after update_config(), missing to schedule
the periodic task.

https://mail.gnome.org/archives/networkmanager-list/2017-May/msg00076.html

Fixes: a95563996f
(cherry picked from commit f1eb1619f1)
2017-06-02 19:42:44 +02:00
Francesco Giudici
1618717170 connectivity: fix typo in error message
(cherry picked from commit 7a2c31a54a)
2017-06-02 19:42:40 +02:00
Thomas Haller
8db2ca661f libnm: fix rejecting NMSettingVlan with id >= 4095
Without it, clients can wrongly create VLan settings with
ID 4095, which triggers assertions in NetworkManager.

Fixes: 8715d61437
(cherry picked from commit 159cd4836f)
2017-05-30 18:17:08 +02:00
Thomas Haller
b2ab1f4b61 tui: use nm_streq0() in nmt_connect_connection_list_get_connection()
(cherry picked from commit 3443f25001)
2017-05-30 14:46:54 +02:00
Arnaud Lefebvre
cc36b9f6eb nmtui connect: avoid segfault when iface is not found
https://github.com/NetworkManager/NetworkManager/pull/21
(cherry picked from commit 1fcbb69ae2)
2017-05-30 14:46:53 +02:00
Thomas Haller
47ebca23e3 ifcfg-rh: merge branch 'th/ifcfg-netmask-legacy-rh1445414' (partial backport)
https://bugzilla.redhat.com/show_bug.cgi?id=1445414

(cherry picked from commit 70c0f7965d)
2017-05-30 13:44:56 +02:00
Thomas Haller
92a277dc6f ifcfg-rh: fix preserving NETMASK key in write_ip4_setting()
To support legacy scripts, we want to write out the NETMASK
key whenever the ifcfg file has a NETMASK key previously.
Note, that we anyway always write the relevant PREFIX key.
The NETMASK is redundant, only there to help legacy scripts.

That was broken, because we would svUnsetValue("NETMASK") before
checking whether the NETMASK key is present.

Also, when saving a connection to ifcfg-rh file that was created
by other tools, we might mix up the numbering. E.g. we never
write out IPADDR0. Hence, turn on legacy mode whenever the ifcfg-rh
file has any key starting with "NETMASK".

(cherry picked from commit 844bf3d1a2)
2017-05-30 13:44:04 +02:00
Thomas Haller
7ebc132864 ifcfg-rh/tests: add test for reading NETMASK property
(cherry picked from commit ba05819c89)
2017-05-30 11:20:23 +02:00
Thomas Haller
85aa450e94 build: sort filenames in Makefile.am alphabetically
(cherry picked from commit 371b761680)
2017-05-30 11:20:09 +02:00
Thomas Haller
3dfddc18a5 ifcfg-rh: add svFindFirstKeyWithPrefix() function
During backporting manually patched to use GList instead of CList.

(cherry picked from commit e9d960740a)
2017-05-30 11:17:44 +02:00
Thomas Haller
2bf3d590ce ifcfg-rh: fix writing NETMASK in write_ip4_setting()
(cherry picked from commit efd462d946)
2017-05-30 11:12:35 +02:00
Lubomir Rintel
f2eba65dd5 po: fix line ending in Japan translation
(cherry picked from commit 9d1bf05eda)
2017-05-29 17:41:17 +02:00
Lubomir Rintel
452ec2956b po: import Japanese translation
From Red Hat translators. The master translation updated via Zanata.

https://bugzilla.redhat.com/show_bug.cgi?id=1382625
2017-05-29 17:11:49 +02:00
Francesco Giudici
2c0865db25 device: when setting back a device to managed, update internal sys state
Otherwise a device which was set as unmanaged (updated to the REMOVED
internal sys-state) will never update its own sys-state if later set
back as managed.
Manage either when setting explictly the device to managed either when
just upping a connection on an unmanaged device.

(cherry picked from commit adbf383628)
2017-05-26 16:10:26 +02:00
Francesco Giudici
3c7c273836 device: add the internal interface state to the state change log message
(cherry picked from commit 55b8ba4ddc)
2017-05-26 16:10:18 +02:00
Beniamino Galvani
3fefef8594 core: add configuration flag to choose slaves activation order
Commits 39d0559d9a ("platform: sort links by name instead of
ifindex") and 529a0a1a7f ("manager: sort slaves to be autoconnected
by device name") changed the order of activation of slaves. Introduce
a system-wide configuration property to preserve the old behavior.

https://bugzilla.redhat.com/show_bug.cgi?id=1452585
(cherry picked from commit 31656a066b)
2017-05-24 15:59:58 +02:00
Beniamino Galvani
6110b11235 device: release removed devices from master on cleanup
On cleanup, unconditionally release a device from its master if the
link is missing or it doesn't have a master, otherwise the master
would later try to release the slave, hitting the following assertion:

 "nm_platform_link_release: assertion 'slave > 0' failed"
  #0  g_logv
  #1  g_log
  #2  g_return_if_fail_warning
  #3  nm_platform_link_release
  #4  release_slave
  #5  nm_device_master_release_one_slave
  #6  slave_state_changed
  #7  ffi_call_unix64
  #8  ffi_call
  #9  g_cclosure_marshal_generic
  #10 g_closure_invoke
  #11 signal_emit_unlocked_R
  #12 g_signal_emit_valist
  #14 _set_state_full
  #15 nm_device_state_changed
  #16 nm_device_unrealize
  #17 _platform_link_cb_idle
  #18 g_main_context_dispatch
  #19 g_main_context_dispatch
  #20 g_main_context_iterate
  #21 g_main_loop_run
  #22 main

Fixes: 9e8218f99a

https://bugzilla.redhat.com/show_bug.cgi?id=1448907
(cherry picked from commit 3355a2823b)
2017-05-24 13:44:46 +02:00
Thomas Haller
58b15abfb1 contrib/rpm: allow building devel RPMs without debug enabled
Since commit 1afbf948a0,
"build: use different defaults for snapshot builds",
configure would enable debugging options if the version
number is odd.

Hence, on the master branch it was no longer possible to
build an RPM without debugging enabled. Especially,

  ./contrib/fedora/rpm/build_clean.sh -g -W debug

would not work as one would expect.

(cherry picked from commit 22ad5422cf)
2017-05-24 10:35:21 +02:00
Thomas Haller
fb4b5001ac contrib/rpm: add option to build package with sanitizer
(cherry picked from commit 07036d731a)
2017-05-24 10:35:20 +02:00
Thomas Haller
06d3c95e4f clients: fix appending integer to result in nmc_property_set_bytes()
(cherry picked from commit d76c190dc7)
2017-05-23 16:10:46 +02:00
Beniamino Galvani
cc6c9468fc clients: fix setter for 802-1x.password-raw
The property is a GBytes, not a GByteArray.

https://bugzilla.gnome.org/show_bug.cgi?id=782836
(cherry picked from commit 30393ee236)
2017-05-23 16:00:33 +02:00
Lubomir Rintel
7851f1c595 bluetooth: unhook adapter properties callback when the adapter vanishes
https://bugzilla.redhat.com/show_bug.cgi?id=1454654
(cherry picked from commit 0aa2e0bad3)
2017-05-23 11:39:21 +02:00
Lubomir Rintel
390cfec792 device: capture the IP6 configuration on the IP interface
Fixes a crash with Bluetooth devices where the device is the BlueZ
device and iface stays 0 while the IP interface is the actual BNEP link.

https://bugzilla.gnome.org/show_bug.cgi?id=782545
(cherry picked from commit 30d06b2253)
2017-05-22 17:14:43 +02:00
Thomas Haller
54203d986f shared: refactor nm_utils_is_power_of_two() to return false for 0
Returning TRUE for zero makes no sense. Obviously, zero is not a power
of two.

Also, the function is used to check whether a number has only one bit
(flag) set, so, an alternative name would be "has-one-bit-set", which
also should return FALSE for zero. All callers didn't really care for
the previous meaning "has-at-most-one-bit-set".

This also avoids the issue of checking (x >= 0), which causes
-Wtype-limits warnings for unsigned types. Which was avoided
by doing (x == 0 || x > 0), which caused -Wlogical-op warning,
which then was avoided (x == 0 || (x > 0 && 1)). Just don't.

(cherry picked from commit a2663803c3)
2017-05-22 14:03:08 +02:00
Francesco Giudici
4f45f04d0f build: work around GCC -Wlogical-op for "nm_utils_is_power_of_two" macros
We recently added -Wlogical-op in our build process
(commit #41e7fca59762dc928c9d67b555b1409c3477b2b0).
Seems that old versions of gcc (4.8.x) will hit that warning with our
implementation of our "nm_utils_is_power_of_two" and
"test_nm_utils_is_power_of_two_do" macros.
Fool it just adding an always TRUE check.

(cherry picked from commit 7c2ecaa4e0)
2017-05-22 14:03:07 +02:00
Beniamino Galvani
4b6955095b device: fix capture of device config in ipX_config_merge_and_apply()
Use nm_device_get_ip_ifindex() to obtain the right ifindex for the
device. Fixes the following:

 nm_platform_ip4_address_get_all: assertion 'ifindex > 0' failed
 #0  _g_log_abort () from target:/lib64/libglib-2.0.so.0
 #1  g_logv () from target:/lib64/libglib-2.0.so.0
 #2  g_log () from target:/lib64/libglib-2.0.so.0
 #3  nm_platform_ip4_address_get_all (self=self@entry=0x1181020, ifindex=ifindex@entry=0) at src/platform/nm-platform.c:2640
 #4  nm_ip4_config_capture (platform=0x1181020, ifindex=ifindex@entry=0, capture_resolv_conf=capture_resolv_conf@entry=0) at src/nm-ip4-config.c:271
 #5  ip4_config_merge_and_apply (self=self@entry=0x1254a70, config=config@entry=0x0, commit=commit@entry=1) at src/devices/nm-device.c:5447
 #6  activate_stage5_ip4_config_commit (self=0x1254a70) at src/devices/nm-device.c:8299
 #7  activation_source_handle_cb (self=0x1254a70, family=family@entry=2) at src/devices/nm-device.c:4421
 #8  activation_source_handle_cb4 (user_data=<optimized out>) at src/devices/nm-device.c:4358
 #9  g_idle_dispatch () from target:/lib64/libglib-2.0.so.0
 #10 g_main_context_dispatch () from target:/lib64/libglib-2.0.so.0
 #11 g_main_context_iterate.isra () from target:/lib64/libglib-2.0.so.0
 #12 g_main_loop_run () from target:/lib64/libglib-2.0.so.0
 #13  main (argc=<optimized out>, argv=<optimized out>) at src/main.c:435

Fixes: a21b8882cc
(cherry picked from commit 6389d637a7)
2017-05-21 15:59:25 +02:00
Beniamino Galvani
cb5ba08f00 ifcfg-rh: omit empty next hop for routes in legacy format
Don't add "via (null)" if the next hop is missing.

https://bugzilla.redhat.com/show_bug.cgi?id=1452648
(cherry picked from commit af8aac9b54)
2017-05-19 17:45:46 +02:00
Thomas Haller
da2a02138d build: don't link static libraries multiple times
libnm-core.a should only be linked once in libnm.so. Previously,
it was linked twice, once as part of libnm-utils.a and once
directly in libnm.so.

Fixes: 8df944c7e4
(cherry picked from commit 5a67130e15)
2017-05-19 14:54:19 +02:00
Thomas Haller
23b5bdd843 build: don't install intermediate library libnm/libnm-utils.la
Fixes: 8df944c7e4
(cherry picked from commit 733160c862)
2017-05-19 14:14:45 +02:00
Thomas Haller
ac8e47f325 libnm: merge branch 'th/sanitize-non-utf8-rh1443114-pt2'
https://bugzilla.redhat.com/show_bug.cgi?id=1443114

(cherry picked from commit 9d2cdb80e6)
2017-05-19 13:17:10 +02:00
Thomas Haller
ea0fd21428 libnm: move fixup_desc_string() to nm-libnm-utils.c
(cherry picked from commit e255ad2a03)
2017-05-19 13:15:50 +02:00
Thomas Haller
1ebac60d22 libnm: add testable libnm/nm-libnm-utils.c file
Previously, internal parts of libnm were not testable.
Instead, add "libnm/nm-libnm-utils.c" and "libnm/libnm-utils.la"
to contain code that can be statically linked with a new
test "libnm/tests/test-general".

(cherry picked from commit 8df944c7e4)
2017-05-19 13:15:50 +02:00
Thomas Haller
aa60b77146 libnm: ignore phrases in fixup device description only when delimited by space
(cherry picked from commit 72104ea10a)
2017-05-19 13:15:50 +02:00
Thomas Haller
c22075dc98 libnm: fix device description in fixup_desc_string()
Fixes: b9e9f76165
(cherry picked from commit 12c881ad40)
2017-05-19 13:15:50 +02:00
Thomas Haller
71eb7b5c1e all: merge branch 'th/sanitize-non-utf8-rh1443114'
https://bugzilla.redhat.com/show_bug.cgi?id=1443114
https://bugzilla.redhat.com/show_bug.cgi?id=1451160
https://bugzilla.redhat.com/show_bug.cgi?id=1451286

(cherry picked from commit dfd72a623e)
2017-05-19 10:07:48 +02:00
Thomas Haller
d7b184d992 libnm: UTF-8 sanitize strings from UDev in NMDevice
(cherry picked from commit b9e9f76165)
2017-05-19 10:07:14 +02:00
Thomas Haller
3a96772918 device: sanitze UTF-8 values for D-Bus
ip link add name $'d\xccf\\c' type dummy

Use nm_utils_str_utf8safe_escape() to sanitize non UTF-8 sequences
before exposing them on D-Bus. The operation can be reverted client
side via nm_utils_str_utf8safe_unescape() or simply g_strcompress().

Note that this preserves all valid UTF-8 sequences as-is, with exception
of the backslash escape character and ASCII control characters. Thus, this
is a change in behavior for strings that contain such characters.

Note that nmcli is not changed to somehow unescape the string before
printing. As the string is not valid UTF-8 (or contains ASCII characters
that need escaping), they are not printable as-is, so unescaping before
printing makes little sense.

(cherry picked from commit 0870906540)
2017-05-19 10:07:14 +02:00
Thomas Haller
52105f27df shared: add nm_utils_str_utf8safe_*() API to sanitize UTF-8 strings
Use C-style backslash escaping to sanitize non-UTF-8 strings.
The functions are compatible with glib's g_strcompress() and
g_strescape().

The difference is only that g_strescape() escapes all non-printable,
non ASCII character as well, while nm_utils_str_utf8safe_escape()
-- depending on the flags -- preserves valid UTF-8 sequence except
backslash.

The flags allow to optionally escape ASCII control characters and
all non-ASCII (valid UTF-8) characters. But the option to preserve
valid UTF-8 (non-ASCII) characters verbatim, is what distinguishes
from g_strescape().

(cherry picked from commit df6d27b33a)
2017-05-19 10:07:14 +02:00
Thomas Haller
c3b180198f device: make UDI property construct-only
(cherry picked from commit e216d5eac0)
2017-05-19 10:07:14 +02:00
Thomas Haller
4ae14d3677 device: fix setting device's UDI property
Fixes: e8139f56c2
(cherry picked from commit 5eac18b58d)
2017-05-19 10:07:14 +02:00
Thomas Haller
822282754d libnm: don't cunescape \x00 encoding in nm_udev_utils_property_decode()
UDev never creates such invalid escape sequences. Anyway,
we cannot accept a NUL character at this point. Just take
the ill escape verbatim -- it should never happen anyway.

(cherry picked from commit c15eae92c0)
2017-05-19 10:07:14 +02:00
Thomas Haller
5eb11aa8ec libnm: fix unterminated NUL string when parsing UDev properties
This can result in trailing garbage (which fails UTF-8 validation
checks) or even worse, in read-out-of-bounds.

Fixes: 6808bf8195

https://bugzilla.redhat.com/show_bug.cgi?id=1443114
https://bugzilla.redhat.com/show_bug.cgi?id=1451160
https://bugzilla.redhat.com/show_bug.cgi?id=1451286
(cherry picked from commit 9594ee6e69)
2017-05-19 10:07:14 +02:00
Thomas Haller
29c86eda62 contrib/rpm: drop explicit dependency on libnl3 package
We already get a library dependency on

    libnl-3.so.200()(64bit)
    libnl-3.so.200(libnl_3)(64bit)

Drop the explicit package dependency, leaving only the
BuildRequires.

Also, all recent versions of libnl3 implement library versioning.

(cherry picked from commit 225f7e8602)
2017-05-19 09:14:23 +02:00
Thomas Haller
48e6a014e0 build: enable -Wlogical-op and -Wshift-negative-value compiler warning
(cherry picked from commit 41e7fca597)
2017-05-19 09:14:11 +02:00
Beniamino Galvani
bf28e0845f device: fix crash in ip6_config_merge_and_apply()
nm_ip6_config_capture() returns NULL for slaves. Fixes the following:

 nm_ip6_config_new_cloned: assertion 'NM_IS_IP6_CONFIG (src)' failed

 #0 g_logv () at /lib64/libglib-2.0.so.0
 #1 g_log () at /lib64/libglib-2.0.so.0
 #2 nm_ip6_config_new_cloned (src=0x0) at src/nm-ip6-config.c:2272
 #3 ip6_config_merge_and_apply (self=self@entry=0x200d8f0, commit=commit@entry=1) at src/devices/nm-device.c:6192
 #4 nm_device_bring_up (self=self@entry=0x200d8f0, block=block@entry=1, no_firmware=no_firmware@entry=0x0) at src/devices/nm-device.c:10369
 #5 _hw_addr_set (self=self@entry=0x200d8f0, addr=addr@entry=0x2095ea0 "6A:1C:00:2A:68:7C", operation=operation@entry=0x64f8ba "set", detail=detail@entry=0x67369d "restore") at src/devices/nm-device.c:13225
 #6 nm_device_hw_addr_set (self=self@entry=0x200d8f0, addr=addr@entry=0x2095ea0 "6A:1C:00:2A:68:7C", detail=detail@entry=0x67369d "restore", set_permanent=set_permanent@entry=0) at src/devices/nm-device.c:13255
 #7 release_slave (device=0x200d8f0, slave=0x1ef2990, configure=<optimized out>) at src/devices/nm-device-bond.c:463
 #8 nm_device_master_release_one_slave (self=self@entry=0x200d8f0, slave=slave@entry=0x1ef2990, configure=1, reason=reason@entry=NM_DEVICE_STATE_REASON_CONNECTION_REMOVED) at src/devices/nm-device.c:2041
 #9 slave_state_changed (slave=0x1ef2990, slave_new_state=NM_DEVICE_STATE_DEACTIVATING, slave_old_state=NM_DEVICE_STATE_ACTIVATED, reason=NM_DEVICE_STATE_REASON_CONNECTION_REMOVED, self=0x200d8f0)
     at src/devices/nm-device.c:3366
 ...

Fixes: a21b8882cc
(cherry picked from commit 1e78f50b8e)
2017-05-17 09:52:53 +02:00
Beniamino Galvani
bf5407992f device: update external configuration before commit
If the platform signaled that the external configuration changed (and
thus update_ipX_config() is scheduled) and we are doing a commit of
the new configuration, update priv->ext_ipX_config. Without this, the
commit will remove addresses added externally but not yet captured in
the external configuration.

https://bugzilla.redhat.com/show_bug.cgi?id=1449873
(cherry picked from commit a21b8882cc)
2017-05-16 11:42:48 +02:00
Beniamino Galvani
cbf5a776f7 dhcp: don't add route to DHCP4 server
This basically reverts commit 31fe84e467 "core: Add host route for
DHCP4 server if outside assigned subnet (bgo #721767)" because the
additional route added by NM does more harm than good.

First, the code does not consider routes pushed by the server and thus
it can add a route conflicting with the ones from the network
administrator.

Second, there is no specification on what a DHCP client should do when
the server is not reachable via unicast, and adding arbitrary logic
into the client is likely to break things in specific cases. If
network administrators want to make the DHCP server reachable from a
client in a different subnet, they should push proper routes with the
lease.

In any case, if the DHCP server is not reachable through unicast,
before the lease expiration (after timeout T2) the client will resort
to broadcast and so there won't be any network disruption; the renewal
will only happen at a later time.

Fixes: 31fe84e467

https://bugzilla.redhat.com/show_bug.cgi?id=1448987
(cherry picked from commit 36e97f5d7b)
2017-05-16 11:42:47 +02:00