Commit Graph

21088 Commits

Author SHA1 Message Date
Thomas Haller
14aefa1d7f clients: implement dcb priorities as int property 2017-05-23 13:37:10 +02:00
Thomas Haller
e086cf1887 clients: add value_infos for int getter
This allows to implement a pretty alias for numbers,
like "default" for 0.
2017-05-23 13:37:10 +02:00
Thomas Haller
b6d9bdcee8 clients: combine int property setters
Instead of having 3 implementations for setting an int (int, uint, int64), combine
them. Also, make them more configurable by allowing to specify min/max/base, outside
of GParamSpec.
2017-05-23 13:37:10 +02:00
Thomas Haller
35d6802724 clients: add validate_fcn for string property 2017-05-23 13:37:10 +02:00
Thomas Haller
6c4b12418b clients: implement macsec.mode property as enum 2017-05-23 13:37:10 +02:00
Thomas Haller
bd180e489d clients: implement macsec.validation property as enum 2017-05-23 13:37:10 +02:00
Thomas Haller
ebdc7a6ce7 clients: implement proxy.method property as enum 2017-05-23 13:37:10 +02:00
Thomas Haller
772225f8cf clients: implement ip-tunnel.mode property as enum 2017-05-23 13:37:10 +02:00
Thomas Haller
c55561d303 clients: implement connection.autoconnect-slaves property as enum 2017-05-23 13:37:10 +02:00
Thomas Haller
8c87a4b8a8 clients: replace nmc_string_to_int() by _nm_utils_ascii_str_to_int64() 2017-05-23 13:37:10 +02:00
Thomas Haller
1e5c5bd4a6 clients: cleanup parse_ip_route 2017-05-23 13:37:10 +02:00
Thomas Haller
5183399744 clients: cleanup parse_ip_address 2017-05-23 13:37:10 +02:00
Thomas Haller
9a3e35cc0e clients: don't use nmc_string_to_int_base() and nmc_string_to_uint_base() util
They are redundant.
2017-05-23 13:37:10 +02:00
Thomas Haller
1371116ea2 clients: implement wireless.mac-address-randomization property as enum 2017-05-23 13:37:10 +02:00
Thomas Haller
cc79b1a554 clients: implement wired.wake-on-lan property as enum 2017-05-23 13:37:10 +02:00
Thomas Haller
d48998b4e8 clients: implement tun.mode property as enum 2017-05-23 13:37:10 +02:00
Thomas Haller
3341e89e7c clients: implement macvlan.mode property as enum 2017-05-23 13:37:10 +02:00
Thomas Haller
5a98837b23 clients/trivial: whitespace 2017-05-23 13:37:10 +02:00
Thomas Haller
22e39edd2a cli: fix handling 802-1x.password-raw
https://bugzilla.gnome.org/show_bug.cgi?id=782836
2017-05-23 13:34:55 +02:00
Thomas Haller
d76c190dc7 clients: fix appending integer to result in nmc_property_set_bytes() 2017-05-23 13:27:24 +02:00
Beniamino Galvani
30393ee236 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
2017-05-23 13:27:24 +02:00
Lubomir Rintel
0aa2e0bad3 bluetooth: unhook adapter properties callback when the adapter vanishes
https://bugzilla.redhat.com/show_bug.cgi?id=1454654
2017-05-23 11:33:15 +02:00
Lubomir Rintel
30d06b2253 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
2017-05-22 17:14:06 +02:00
Thomas Haller
a2663803c3 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.
2017-05-22 14:01:07 +02:00
Francesco Giudici
7c2ecaa4e0 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.
2017-05-22 12:05:51 +02:00
Beniamino Galvani
6389d637a7 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
2017-05-21 15:51:27 +02:00
Thomas Haller
5b4cf8f762 wifi: reject WPS PSK secret with non-UTF-8 characters (part 2)
We must reject '\0' characters inside the PSK as well.

Fixes: ac436dc2c4
2017-05-20 13:05:07 +02:00
Thomas Haller
d5c857307e wifi: properly handle floating GVariant in supplicant_iface_wps_credentials_cb()
g_variant_new_parsed() returns a floating reference. Later, we pass
the floating reference to nm_settings_connection_new_secrets(),
but don't transfer ownership.

That might not be a bug (I didn't check), but it requires that
nm_settings_connection_new_secrets() does not take a reference
to the secrets variant.

Convert the floating reference to a real reference to avoid
this dangerous pattern.

Fixes: 0eb7617504
2017-05-19 19:36:26 +02:00
Thomas Haller
ac436dc2c4 wifi: reject WPS PSK secret with non-UTF-8 characters
We pack the PSK byte array in a GVariant of type string,
hence all characters must be valid UTF-8.

Maybe we should do something more sophisticated but let's
just ignore such pass phrases.

Fixes: 0eb7617504
2017-05-19 19:36:10 +02:00
Beniamino Galvani
af8aac9b54 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
2017-05-19 17:44:09 +02:00
Thomas Haller
5a67130e15 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
2017-05-19 14:52:03 +02:00
Thomas Haller
733160c862 build: don't install intermediate library libnm/libnm-utils.la
Fixes: 8df944c7e4
2017-05-19 14:13:41 +02:00
Thomas Haller
9d2cdb80e6 libnm: merge branch 'th/sanitize-non-utf8-rh1443114-pt2'
https://bugzilla.redhat.com/show_bug.cgi?id=1443114
2017-05-19 13:13:17 +02:00
Thomas Haller
e255ad2a03 libnm: move fixup_desc_string() to nm-libnm-utils.c 2017-05-19 12:45:45 +02:00
Thomas Haller
8df944c7e4 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".
2017-05-19 12:45:45 +02:00
Thomas Haller
72104ea10a libnm: ignore phrases in fixup device description only when delimited by space 2017-05-19 12:45:45 +02:00
Thomas Haller
12c881ad40 libnm: fix device description in fixup_desc_string()
Fixes: b9e9f76165
2017-05-19 12:45:45 +02:00
Francesco Giudici
f867f20ab8 device: remove useless check and var
with the rework in commit #87a3df2e572ed47b5f76f6d1cad63ce622296e21
the check of the return value of _device_activate () is no more needed.
Remove useless check and var.
2017-05-19 10:08:56 +02:00
Thomas Haller
dfd72a623e 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
2017-05-19 09:46:39 +02:00
Thomas Haller
b9e9f76165 libnm: UTF-8 sanitize strings from UDev in NMDevice 2017-05-19 09:46:08 +02:00
Thomas Haller
0870906540 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.
2017-05-19 09:46:08 +02:00
Thomas Haller
df6d27b33a 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().
2017-05-19 09:46:08 +02:00
Thomas Haller
e216d5eac0 device: make UDI property construct-only 2017-05-19 09:46:08 +02:00
Thomas Haller
5eac18b58d device: fix setting device's UDI property
Fixes: e8139f56c2
2017-05-19 09:46:08 +02:00
Thomas Haller
c15eae92c0 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.
2017-05-19 09:46:08 +02:00
Thomas Haller
9594ee6e69 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
2017-05-19 09:46:08 +02:00
Thomas Haller
41e7fca597 build: enable -Wlogical-op and -Wshift-negative-value compiler warning 2017-05-18 18:21:27 +02:00
Thomas Haller
aaefa2b07f wifi: fix check for PSK for new WPS credentials
src/devices/wifi/nm-device-wifi.c:1855:20: error: logical ‘or’ of collectively exhaustive tests is always true [-Werror=logical-op]
      if (psk_len >= 8 || psk_len <= 63) {
                       ^~

Fixes: 0eb7617504
2017-05-18 18:21:27 +02:00
Thomas Haller
225f7e8602 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.
2017-05-18 14:51:06 +02:00
Beniamino Galvani
1e78f50b8e 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
2017-05-17 09:46:22 +02:00