Commit graph

16752 commits

Author SHA1 Message Date
Thomas Haller
023bceb41c device/wifi: ensure consistent timestamp for dumping Wi-Fi AP
When we dump a list of APs, determine one timestamp for "now",
instead of re-evaluating it every time.

This ensures that all APs are printed with the same understanding
of the current timestamp.

(cherry picked from commit 5e4d13271c)
2017-02-10 14:47:18 +01:00
Thomas Haller
1272f3cc04 device/wifi: log scanning related messages with LOGD_WIFI instead of LOGD_WIFI_SCAN
LOGD_WIFI_SCAN is there to avoid flodding the log with continous scan
results. It should not be used for messages related to scheduling scan
requests.

This is especially important, because LOGD_WIFI_SCAN domain is not
included in LOGD_DEFAULT.

(cherry picked from commit d5657d003c)
2017-02-10 14:47:18 +01:00
Thomas Haller
36196b5a82 device/wifi: refactor logging of Wi-Fi AP by preserving logging context of device
The _LOGD() macros of NMDeviceWifi print a logging context for each
line, that is, they add a prefix with the device name.

Replace nm_wifi_ap_dump() by nm_wifi_ap_to_string() and let device
log a message about the AP.

Also, update the format for printing the AP. Now, all fields are
separated by space.

(cherry picked from commit d98fa31ddd)
2017-02-10 14:47:18 +01:00
Thomas Haller
8b455abab2 device: cleanup handling queued state change in NMDevice
- no longer bother clearing .state and .reason when the .id
  field is unset. The fields just don't matter and no user
  accesses these fields when the glib source id is not set.
- unify logging and give them all a prefix "queue-state[%s, %s, %u]: ".
- drop nm_device_queued_state_peek(), it only had one caller,
  thus inline the trivial check.
- make nm_device_queued_state_clear() a static function
  queued_state_clear()
- rename queued_set_state() to queued_state_set().

(cherry picked from commit 96b167cd97)
2017-02-10 14:47:18 +01:00
Thomas Haller
57111e356d device/trivial: reorder defines in "nm-device.c"
Reorder code to be like in other source files:
- first includes and generic defines
- then various helper structs
- then GObject related declarations, with first signal and property
  enums, then the private data, then the G_DEFINE_TYPE() itself.
- finally, forward declarations for functions.

(cherry picked from commit f97d8b86fb)
2017-02-10 14:47:18 +01:00
Thomas Haller
dc7e984422 device: change hw_addr_type field to bitfield type
We don't want to waste a full "int" size to store the @hw_addr_type
in NMDevicePrivate. Previously, that was hacked around by using guint8.

Now, instead use a bitfield which has the right type.

(cherry picked from commit cac0738723)
2017-02-10 14:47:18 +01:00
Thomas Haller
e61e872574 device: inline device helper structs QueuedState and PingInfo
These two structs are only used at exactly one place: as the type
for a field in NMDevicePrivate.

Having additional structs (that are only used at one place) only
add noise. Also, there are already prior-acts of using unnamed
structs in NMDevicePrivate in case of structs that only serve
to group/namespace a set of fields.

(cherry picked from commit 5151a6071f)
2017-02-10 14:47:18 +01:00
Thomas Haller
b1be460863 device: prepend pending actions list
The order doesn't matter, so prepend instead of append new items
to the pending-actions list.

(cherry picked from commit e347d96596)
2017-02-10 14:47:18 +01:00
Thomas Haller
aebff6a1ac device: don't clone pending-action string
All callers either use a static @action argument or keep a clone
of the string that lives as long as the action is pending. So,
save cloning the string.

(cherry picked from commit 3bc1e02adf)
2017-02-10 14:47:18 +01:00
Thomas Haller
78eaabf98f device: implement queued_state_to_string() via NM_UTILS_LOOKUP_STR_DEFINE_STATIC()
(cherry picked from commit 8ac14b5400)
2017-02-10 14:47:18 +01:00
Thomas Haller
9822299d41 device: refactor pending-action strings as named defines
(cherry picked from commit e234673a4a)
2017-02-10 14:47:18 +01:00
Thomas Haller
3a438a1431 device: queue recheck-available before removing "wait for supplicant" pending action
While we still recheck-available, we want to queue a pending action to block
startup-complete. However, we have to queue that before removing the pending
action for "wait for supplicant".

  <debug> [...] device[0x563abbcca400] (wlp2s0): remove_pending_action (0): 'waiting for supplicant'
  <info>  [...] manager: startup complete
  <debug> [...] device[0x563abbcca400] (wlp2s0): add_pending_action (1): 'queued state change to disconnected'

(cherry picked from commit 252e95c113)
2017-02-10 14:47:18 +01:00
Thomas Haller
45ac6d8c12 device: add pending-action "recheck-available"
Startup-complete means that all devices have settled in a state
and no further activation is pending. When we have a recheck-available
scheduled, we clearly should not yet declare startup-complete.

Add a new pending-action "recheck-available" to avoid:

  <info>  [1485520408.3920] device (wlp2s0): supplicant interface state: starting -> ready
  <debug> [1485520408.3920] device[0x563abbcca400] (wlp2s0): remove_pending_action (0): 'waiting for supplicant'
  <info>  [1485520408.3920] manager: startup complete
  <debug> [1485520408.3924] device[0x563abbcca400] (wlp2s0): add_pending_action (1): 'queued state change to disconnected'

(cherry picked from commit 11744b090e)
2017-02-10 14:47:18 +01:00
Thomas Haller
e3dc1a0cc5 core: use define for GObject property name NM_SUPPLICANT_INTERFACE_SCANNING
grep-ing for '\<scanning\>' yields 42 hits under src. But only 2 are actual
references to the "scanning" GObject property of NMDeviceWifi.

Use a #define with a unique name where we mean NMDeviceWifi's property.

(cherry picked from commit 95a95b3e48)
2017-02-10 14:47:17 +01:00
Thomas Haller
256bfe54e7 build: allow configuring path to binutils's nm tool during build
`nm` is used by "tools/create-exports-NetworkManager.sh" script.
Alloc configuring an explicit path during configure.

  BINUTILS_NM=/usr/bin/nm ./configure

(cherry picked from commit 8bc88bcc7c)
2017-02-08 17:01:04 +01:00
Beniamino Galvani
acf9a5c699 platform: fix detection of primary/secondary addresses
ip4_addr_subnets_is_secondary() should fill the list of addresses in
the same subnet also when returning FALSE, because
nm_platform_ip4_address_sync() uses it.

Fixes: 2f68a50041
(cherry picked from commit a347962831)
2017-02-08 15:10:30 +01:00
Beniamino Galvani
b6a34b9c39 core: fix nm_utils_file_set_contents() handling of -1 length
nm_utils_file_set_contents() must compute the content size when
@length is -1.

Fixes: 21358edc54
(cherry picked from commit 0a0893280b)
2017-02-08 12:41:53 +01:00
Thomas Haller
d2d7a0aafc nm-online: fix wrong assertion failure during nm-online
_return() assigns the return value @retval and asserts that
currently no return-value is assigned -- in order not to overwrite
a once set value.

That requires, that we call _return() and exit the main-loop right
away, without possibility to call _return() again.

However, during client_properties_changed() we easily might
receive the "notify" signal multiple times, and thus call
quit_if_connected() and _return() multiple times. That would
lead to a wrong assertion failure.

Avoid that, by disconnecting the signal handler once we reach
_return().

Fixes: f7875a42b0
(cherry picked from commit ec91f950b8)
2017-02-07 19:44:04 +01:00
Thomas Haller
7ada0e0bc3 device/wifi: drop messing with wpa-supplicant's support for MAC address randomization
We no longer use wpa_supplicant for MAC address randomization. Instead, NetworkManager
handles it on it's own. It is actually important that supplicant does not interfere
when setting the MAC address of the device.

The code was only in effect when supplicant has a PreassocMacAddr property.
As this is a recent feature, the left-over code wasn't noticed until now.

https://mail.gnome.org/archives/networkmanager-list/2017-February/msg00003.html

Fixes: 767abfa690
(cherry picked from commit 0cb85f161e)
2017-02-07 14:39:13 +01:00
Beniamino Galvani
a0149376f6 bond: fix crash in update_connection()
The value read from sysfs can be NULL.

Fixes: 2324410a75
(cherry picked from commit 0683ad5db2)
2017-02-07 11:13:20 +01:00
Thomas Haller
64242f5e6a build: merge branch 'th/build-warn-wextra'
(cherry picked from commit 029784b1cc)
2017-02-06 19:43:01 +01:00
Thomas Haller
053bc1de9e build: reorder flags in "m4/compiler_options.m4"
Mostly sort alphabetically, but
  - keep -Wextra first
  - move "-Wno-*" flags to the end

(cherry picked from commit 4a72c121ed)
2017-02-06 19:42:43 +01:00
Thomas Haller
bbb827b4b3 build: enable -Wextra warning
(cherry picked from commit 5120205f98)
2017-02-06 19:42:43 +01:00
Thomas Haller
54584cb3ab build: fix -Wold-style-declaration warnings
libnm-core/nm-setting-bond.c:502:1: error: ‘static’ is not at beginning of declaration [-Werror=old-style-declaration]
     const static struct {
     ^~~~~

    In file included from clients/cli/common.c:32:0:
    ./clients/common/nm-vpn-helpers.h:27:1: error: ‘typedef’ is not at beginning of declaration [-Werror=old-style-declaration]
     } typedef VpnPasswordName;
    ^

(cherry picked from commit cb365b33f3)
2017-02-06 19:42:43 +01:00
Thomas Haller
edf6f0b600 build: fix -Wignored-qualifiers warnings
./src/nm-config-data.h:163:1: error: 'const' type qualifier on return type has no effect [-Werror,-Wignored-qualifiers]
    const guint nm_config_data_get_connectivity_interval (const NMConfigData *config_data);
    ^~~~~~

(cherry picked from commit e68cc17f43)
2017-02-06 19:42:43 +01:00
Thomas Haller
cdf862f048 shared: fix -Wtype-limits warning in nm_glib_check_version() macro
Fix it by converting the macro to an inline function. It's anyway
nicer.

    $ make src/src_libNetworkManagerBase_la-main-utils.lo
      CC       src/src_libNetworkManagerBase_la-main-utils.lo
    In file included from ./shared/nm-utils/nm-macros-internal.h:29:0,
                     from ./shared/nm-default.h:178,
                     from src/main-utils.c:22:
    src/main-utils.c: In function ‘nm_main_utils_setup_signals’:
    ./shared/nm-utils/nm-glib.h:144:36: error: comparison of unsigned expression >= 0 is always true [-Werror=type-limits]
                  && glib_micro_version >= (micro))))
                                        ^
    src/main-utils.c:82:6: note: in expansion of macro ‘nm_glib_check_version’
      if (nm_glib_check_version (2, 36, 0)) {
          ^~~~~~~~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors
    Makefile:12312: recipe for target 'src/src_libNetworkManagerBase_la-main-utils.lo' failed

(cherry picked from commit 1a190b9038)
2017-02-06 19:42:43 +01:00
Thomas Haller
d6625d5111 settings: drop redundant range check from NMSettingBridgePort::verify()
priv->path_cost and priv->priority can only be set as GObject properties,
which already does the same range check. Hence, the checks are never reached.

This also avoids a compiler warning:

    libnm-core/nm-setting-bridge-port.c: In function ‘verify’:
    libnm-core/nm-setting-bridge-port.c:132:22: error: comparison is always false due to limited range of data type [-Werror=type-limits]
      if (priv->path_cost > BR_MAX_PATH_COST) {
                          ^

(cherry picked from commit 31c0c66c0e)
2017-02-06 19:42:43 +01:00
Thomas Haller
afa249e277 build: merge branch 'th/build-gcc7-warnings'
(cherry picked from commit 77140cafe3)
2017-02-06 18:04:31 +01:00
Thomas Haller
7c5a4c6842 build: enable -Wimplicit-fallthrough warning from gcc7
(cherry picked from commit 4b9cebd8ad)
2017-02-06 17:54:45 +01:00
Thomas Haller
23d9fbb858 systemd: backport fall-through comments for -Wimplicit-fallthrough warning 2017-02-06 17:54:45 +01:00
Thomas Haller
4603ce7ad0 all: cleanup switch fall-through comments for -Wimplicit-fallthrough warning
The -Wimplicit-fallthrough=3 warning is quite flexible of accepting
a fall-through warning.

Some comments were missing or not detected correctly.

Thereby, also change all other comments to follow the exact
same pattern.

(cherry picked from commit 7c6c8f0d8b)
2017-02-06 17:54:45 +01:00
Thomas Haller
55852df7c8 build: disable -Wformat-truncation warning
The warning seems questionable and overly strict.
For now, just disable it to allow building with gcc7.

    src/systemd/src/basic/time-util.c: In function ‘format_timespan’:
    src/systemd/src/basic/time-util.c:509:46: error: ‘%0*lu’ directive output between 1 and 2147483648 bytes may cause result to exceed ‘INT_MAX’ [-Werror=format-truncation=]
                                                  "%s"USEC_FMT".%0*"PRI_USEC"%s",
                                                  ^~~~
    src/systemd/src/basic/time-util.c:509:60: note: format string is defined here
                                                  "%s"USEC_FMT".%0*"PRI_USEC"%s",
    src/systemd/src/basic/time-util.c:509:46: note: directive argument in the range [0, 18446744073709551614]
                                                  "%s"USEC_FMT".%0*"PRI_USEC"%s",
                                                  ^~~~

https://mail.gnome.org/archives/networkmanager-list/2017-February/msg00001.html
(cherry picked from commit 705e63a292)
2017-02-06 17:54:45 +01:00
Thomas Haller
c453b46b9c m4/compiler_options.m4: add line breaks for compiler options to check
No change in behavior.

(cherry picked from commit 6bd9f5361f)
2017-02-06 17:43:09 +01:00
Thomas Haller
3a4c9676da systemd: fix memleak in dhcp6_option_parse_domainname
https://github.com/systemd/systemd/pull/5114
419eaa8f8d
(cherry picked from commit c2d0b9eec0)
2017-02-06 14:09:54 +01:00
Thomas Haller
d1fb96207e systemd: fix memleak in dhcp6_lease_set_domains
https://github.com/systemd/systemd/pull/5113
0b75a95ace
(cherry picked from commit 7cd2dfabec)
2017-02-06 14:09:53 +01:00
Mickaël Thomas
4f58ff5d37 nm-online: fix countdown to not show 0 seconds until finished
When using nm-online -t N, the countdown shows "0s" during the last second.

The countdown value should be rounded up so that "0s" is only shown when the
timeout is actually elapsed.

https://bugzilla.gnome.org/show_bug.cgi?id=778093
(cherry picked from commit 5216754b1e)
2017-02-03 00:11:59 +01:00
Beniamino Galvani
05342d1178 libnm-core: return NULL from _nm_utils_slist_to_strv for empty lists
The function is used, among others, in the get_property() of many
objects to return a boxed strv from a list. The default value for a
boxed strv property is NULL, but _nm_utils_slist_to_strv() returns a
pointer to an array with zero elements when the list is empty.

Change the function to return NULL if the input list is empty.

(cherry picked from commit 660bb1a48f)
2017-02-02 14:05:07 +01:00
Thomas Haller
45847ccee0 nm-online: refactor and fix nm-online
Moving nm-online to async init introduced various issues:
- with a timeout of zero, nm-online would terminate with failure
  before initializing the NMClient instance.
- add a timeout for safeguarding the async creation of NMClient
- fix adding trailing newline for the progress bar.

While at it, refactor:
- use defines for the exit codes
- don't use exit(), but instead always properly quit the mainloop
  and cleanup all resources.
- in non-quiet mode, print the result [online] or [offline] at
  the end.

Fixes: c5f17a97ea

https://bugzilla.gnome.org/show_bug.cgi?id=777914
(cherry picked from commit f7875a42b0)
2017-02-02 11:24:43 +01:00
Thomas Haller
1125ed9eed nm-online: fix division-by-zero with zero timeout
$ nm-online -t 0
  Floating point exception (core dumped)

Fixes: c5f17a97ea

https://bugzilla.gnome.org/show_bug.cgi?id=777914
(cherry picked from commit 34acecf544)
2017-01-31 11:06:04 +01:00
Lubomir Rintel
5d22a96d1d cli: add missing NULL-check
Only the connection down operation is cancellable, the other actions are not.

Fixes: 73b560c215
(cherry picked from commit 7399cf3b16)
2017-01-29 14:22:45 +01:00
Lubomir Rintel
e0ed5a0c3f contrib/rpm: don't recreate files that make install installs
(cherry picked from commit cc1491401f)
2017-01-29 14:22:44 +01:00
Lubomir Rintel
9f6dfc0763 contrib/rpm: don't own the legacy VPN directory
The plugins should own it instead.

(cherry picked from commit a1464f0cfa)
2017-01-29 14:22:43 +01:00
Lubomir Rintel
2fa71901f5 build: install all necessary directories
(cherry picked from commit d9ebd31d40)
2017-01-29 14:22:43 +01:00
Lubomir Rintel
c8540ec75e build: don't install /run files
They're volatile and created during runtime.

(cherry picked from commit b4e1d4794e)
2017-01-29 14:22:42 +01:00
Thomas Haller
38cef9de7a build: add missing GLIB_CFLAGS for compiling adsl device plugin
(cherry picked from commit cd267cceed)
2017-01-29 12:25:16 +01:00
Thomas Haller
157b6d0ec4 libnm-core: clear wifi.mac-address-randomization when unsetting wifi.cloned-mac-address
When a client clears wifi.cloned-mac-address, he clearly also want
to clear the deprected wifi.mac-address-randomization property.

Do that automatically in libnm.

https://mail.gnome.org/archives/networkmanager-list/2017-January/msg00060.html
(cherry picked from commit 7f63c875f9)
2017-01-28 17:19:33 +01:00
Thomas Haller
491ccd9d64 ifcfg-rh: fix interpreting missing MAC_ADDRESS_RANDOMIZATION as permanent address
With commit 4f6c91d696, we aimed to
enable mac-address-randomization by default for Wi-Fi. That however
is not possible by default because it breaks various scenarios.
Also, later wifi.mac-address-randomization was deprecated in favor
of wifi.cloned-mac-address setting.

Both wifi.mac-address-randomization and wifi.cloned-mac-address support
global default values, so it is wrong to read a missing
MAC_ADDRESS_RANDOMIZATION setting as "NEVER" -- which due to
normalization also results in cloned-mac-address=permanent.

See also commit 46d53e1101 which does
something similar for keyfile.

This bug also prevents a user from clearing the cloned-mac-address:

  $ nmcli connection show "$CONN"
  ...
  802-11-wireless.cloned-mac-address:        permanent
  802-11-wireless.mac-address-randomization: never
  ...
  $ nmcli connection modify "$CONN: wifi.cloned-mac-address ''
  # ^ takes no effect

As workaround, you also need to clear mac-address-randomization:

  $ nmcli connection modify "$CONN: wifi.cloned-mac-address '' \
          wifi.mac-address-randomization default

https://mail.gnome.org/archives/networkmanager-list/2017-January/msg00060.html
(cherry picked from commit 27cba47957)
2017-01-28 16:06:37 +01:00
James McCoy
6419d24620 nm-online: return from quit_if_connected after setting retval
c5f17a97ea changed nm-online to determine
the status asynchronously, however this introduced a regression with
"nm-online -x -q" when there is connectivity.

        if (   state == NM_STATE_CONNECTED_LOCAL
            || state == NM_STATE_CONNECTED_SITE
            || state == NM_STATE_CONNECTED_GLOBAL) {
            data->retval = 0;
            g_main_loop_quit (data->loop);
        }
    }
    if (data->exit_no_nm && (state != NM_STATE_CONNECTING)) {
        data->retval = 1;
        g_main_loop_quit (data->loop);
    }

After setting data->retval = 0 in the "state is connected" branch, the
function falls through to the "exit_no_nm and !connecting" branch,
overwriting data->retval.  This causes "nm-online -x -q" to incorrectly
report an offline state.

Adding an explicit "return;" after any state where data->retval is set
ensures that the value isn't overwritten before main() uses it.

Fixes: c5f17a97ea

https://mail.gnome.org/archives/networkmanager-list/2017-January/msg00058.html
(cherry picked from commit dbd365c3f9)
2017-01-28 10:54:54 +01:00
Lubomir Rintel
c758622f46 cli: avoid use-after free on connection deletion
If the connection spontaneously disappears (perhaps along with the whole
daemon on crash) while we're deleting it, then the removal callback
would free up the context structure the delete operation is using.

Let's cancel the in-flight delete operations so that they won't touch
the structure after it's gone.

(cherry picked from commit 73b560c215)
2017-01-27 13:34:16 +01:00
Lubomir Rintel
c1628a098b manager: avoid an extra path to ac translation
The ac might already be unexported which would lead to a crash.
In any case, it's just unnecessary.

(cherry picked from commit 1db6b01b2f)
2017-01-27 13:34:16 +01:00