Commit Graph

17858 Commits

Author SHA1 Message Date
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
Beniamino Galvani
a21b8882cc 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
2017-05-16 11:37:41 +02:00
Beniamino Galvani
36e97f5d7b 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
2017-05-16 11:37:11 +02:00
Thomas Haller
ae81216ae0 merge: cli pager 2017-05-15 23:25:14 +02:00
Lubomir Rintel
7c24a2cb39 cli: allow the GNU option format
$ nmcli --fields=all c
  Error: Option '-fields=all' is unknown, try 'nmcli -help'.

What a shame. Let's fix this.
2017-05-15 19:19:49 +02:00
Thomas Haller
f8316a536c device: merge branch 'th/device-carrier-wait-rh1450444'
https://bugzilla.redhat.com/show_bug.cgi?id=1450444
2017-05-15 17:40:31 +02:00
Thomas Haller
9f874d166d device: fix delaying startup complete waiting for carrier
platform: signal: link changed: 2: eth0 <DOWN;broadcast,multicast> mtu ...
    ...
    device[0x7f90c29c64d0] (eth0): bringing up device
    ...
    platform: signal: link changed: 2: eth0 <UP,LOWER_UP;broadcast,multicast,up,running,lowerup> mtu ...
    ...
    device (eth0): link connected
    ...
    device[0x7f90c29c64d0] (eth0): add_pending_action (2): 'carrier wait'

Note how we schedule the pending action 'carrier-wait', although the device
already has carrier. That means, the pending action will not be removed
until timeout, 5 seconds later.

Avoid scheduling 'carrier-wait' if we already have carrier.

However, don't just add the pending action 'carrier-wait' only during
nm_device_bring_up(). Instead, always schedule the carrier_wait timeout.
This gives a grace period during which we keep setting 'carrier-wait' whenever
we have no carrier. This should prevent two cases:
  - during nm_device_bring_up() the platform state might not yet have
    caught up. If we don't add the pending action there, we will add
    it a moment later when carrier goes away.
  - bringing the interface up might cause carrier to get lost for a
    moment (flapping). If that happens within the timeout, also add the
    pending action.
2017-05-15 17:38:59 +02:00
Thomas Haller
02bb4ce7eb device: cleanup nm_device_set_carrier_from_platform()
nm_device_set_carrier_from_platform() is only called from two places.

- both check for NM_DEVICE_CAP_CARRIER_DETECT, so move that check
  inside the function.
- drop the logging in realize_start_setup(). nm_device_set_carrier() already
  does logging.
- always set the fake carrier in nm_device_set_carrier_from_platform().
  For the fake carrer, we anyway expect it to be already TRUE in most
  case, so usually this should have no effect.
  Also emit a property changed signal. That is necessary to refresh the
  D-Bus property.
2017-05-15 17:38:47 +02:00
Thomas Haller
7e472b4eb3 device: rename and minor refactoring of check_carrier()
The name should mirror what we already have: nm_device_set_carrier().
Also, move the code closer to nm_device_set_carrier() and refactor
it a bit.
2017-05-15 17:38:47 +02:00
Thomas Haller
eaba285375 device: downgrade logging messages about (non) pending action
Adding/Removing a pending action with assert_not_yet_pending/
assert_is_pending means that we expect that no action is taken.

Downgrade the logging level in those cases to <trace>.
2017-05-15 17:38:47 +02:00
Thomas Haller
6c5d883a4b device: minor cleanup of carrier_disconnected_action_cancel() 2017-05-15 17:38:47 +02:00
Thomas Haller
a07c6255a0 device/trivial: rename functions related to "carrier" 2017-05-15 17:38:47 +02:00
Thomas Haller
5a7374d8be device: don't call virtual function carrier_changed() directly
Don't give the subclass the ability to override the parents
behavior. The parent implementation is not intended to allow
for that. Instead, restrict the flexibility of how the virtual
function integrates with the larger picture. That means, the
virtual function is only called at one place, and there is only
one implementation in NMDeviceEthernet (and it doesn't really
matter whether the implementation chains up the parent implementation
or not).
2017-05-15 17:38:47 +02:00
Lubomir Rintel
24c079e4b2 cli: spawn a pager when running on a terminal
This makes it a lot more convenient to deal with long outputs (such as
"nmcli c show id ...").

The implementation is essentially jacked from systemd. The bugs are
mine.
2017-05-15 17:23:51 +02:00
Francesco Giudici
23bc781063 all/trivial: fix few comment typos 2017-05-15 15:52:21 +02:00
Thomas Haller
234bc0adcf cli: fix use-after-free in _get_fcn_gobject_enum()
Fixes: ddfff04a45
2017-05-15 15:16:22 +02:00
Lubomir Rintel
6fde475b27 cli: shorten setting names to aliases in "nmcli c show" connection list
This basically uses "wifi" in place of "802-11-wireless" and analogously
for other setting types that have aliases unless a --terse option was
specified.

Apart from looking nicer it makes the default output less wide,
hopefully avoiding line breaks on 80 column terminals in basic use
cases.
2017-05-15 14:46:05 +02:00
Lubomir Rintel
efafc98147 merge: branch 'lr/wps2'
https://bugzilla.gnome.org/show_bug.cgi?id=781336
2017-05-15 13:00:13 +02:00
Lubomir Rintel
1194641afe dbus/secret-agent: add a flag indicating WPS PBC is active
The agents may used this to learn that WPS PBC enrollment is active and
suggest that user pushes a button on the router instead of supplying a
network key.
2017-05-15 12:59:55 +02:00
Lubomir Rintel
2899bb3429 cli: add support for the WPS property 2017-05-15 12:59:55 +02:00
Lubomir Rintel
99c112a493 ifcfg-rh: save/restore WPS properties 2017-05-15 12:59:55 +02:00
Lubomir Rintel
0eb7617504 wifi: attempt a WPS enroll when secrets are missing
If the supplicant returns the credentials, update the PSK in the
connection and disable further WPS enrollment attempts.
2017-05-15 12:59:55 +02:00
Lubomir Rintel
f87912326c settings-connection: all method to internally supply new secrets
It's sort of a very very lightweight version of get_secrets_done_cb()
that allows as to add secrets to the connection that didn't come from
the agent manager.
2017-05-15 12:59:55 +02:00
Lubomir Rintel
5c80571006 wifi/ap: maintain the WPS flags
Exposure of this property on D-Bus would be useful for the GUIs to encourage
the users to enter a PIN or push a button.

We'll also use it to decide whether a connection will initiate WPS
enrollment unless the user overrides the default.
2017-05-15 12:59:55 +02:00
Lubomir Rintel
a3040bf92f wifi/ap: add flags accessor
The wifi device will inspect this to decide whether to initiate a WPS enrollment
unless the user overrides the default.
2017-05-15 12:59:55 +02:00
Lubomir Rintel
1d15e9c6de supplicant-interface: add support for WPS enrollment 2017-05-15 12:59:55 +02:00
Lubomir Rintel
e6f95b50c8 setting-wireless: add wps-method property
This property will be used to decide if it makes sense to attempt a WPS
enrollment on connection activation.
2017-05-15 12:59:55 +02:00
Lubomir Rintel
36b6bbdae3 dbus: add WPS methods to AP flags
Will be used to indicate WPS method discovered to be supported by the
access point.
2017-05-15 12:59:55 +02:00
Lubomir Rintel
63836f3945 ifcfg-rh: don't skip 802-11-security if there's no WPA-PSK 2017-05-15 12:59:55 +02:00
Thomas Haller
fb2ef01d85 contrib: update fedora's REQUIRED_PACKAGES list 2017-05-15 12:40:32 +02:00
Thomas Haller
d875df5ab4 device: simplify check for ready slaves 2017-05-14 09:52:18 +02:00