Commit Graph

17197 Commits

Author SHA1 Message Date
Thomas Haller
f93fbc76ec device: avoid assertion in nm_device_get_supplicant_timeout() for Wi-Fi connection
... without 802-1x setting.

    NetworkManager[27913]: <trace> [1487689965.7156] device[0x555555bc0060] (wlp3s0): powersave is set to 3
    NetworkManager[27913]: <info>  [1487689965.7156] Config: added 'ssid' value 'xxx'
    NetworkManager[27913]: <info>  [1487689965.7156] Config: added 'scan_ssid' value '1'
    NetworkManager[27913]: <info>  [1487689965.7156] Config: added 'bssid' value 'xxx'
    NetworkManager[27913]: <info>  [1487689965.7157] Config: added 'key_mgmt' value 'WPA-PSK'
    NetworkManager[27913]: <info>  [1487689965.7157] Config: added 'psk' value '<hidden>'
    NetworkManager[27913]: <debug> [1487689965.7157] sup-iface[0x555555be0010,wlp3s0]: assoc[0x555555ebd800]: starting association...
    NetworkManager[27913]: nm_device_get_supplicant_timeout: assertion 's_8021x' failed

    (gdb) bt
    ...
    #3  0x00007ffff4c70419 in g_return_if_fail_warning (log_domain=log_domain@entry=0x55555577610e "NetworkManager", pretty_function=pretty_function@entry=0x5555557725e0 <__func__.44436> "nm_device_get_supplicant_timeout", expression=expression@entry=0x5555557725bb "s_8021x") at gmessages.c:2536
    #4  0x000055555568af3a in nm_device_get_supplicant_timeout (self=0x555555bc0060 [NMDeviceWifi]) at src/devices/nm-device.c:12963
    #5  0x00007fffe88d7f1e in act_stage2_config (device=<optimized out>, reason=0x7fffffffe000) at src/devices/wifi/nm-device-wifi.c:2651
    #6  0x00005555556879f1 in activate_stage2_device_config (self=0x555555bc0060 [NMDeviceWifi]) at src/devices/nm-device.c:4320
    #7  0x000055555566876b in activation_source_handle_cb (self=self@entry=0x555555bc0060 [NMDeviceWifi], family=family@entry=2) at src/devices/nm-device.c:4060
    #8  0x000055555566882e in activation_source_handle_cb4 (user_data=user_data@entry=0x555555bc0060) at src/devices/nm-device.c:3997
    #9  0x00007ffff4c658e7 in g_idle_dispatch (source=0x555555e228c0, callback=0x555555668820 <activation_source_handle_cb4>, user_data=0x555555bc0060) at gmain.c:5545
    #10 0x00007ffff4c68e52 in g_main_dispatch (context=0x555555a214d0) at gmain.c:3203
    #11 0x00007ffff4c68e52 in g_main_context_dispatch (context=context@entry=0x555555a214d0) at gmain.c:3856
    #12 0x00007ffff4c691d0 in g_main_context_iterate (context=0x555555a214d0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3929
    #13 0x00007ffff4c694f2 in g_main_loop_run (loop=0x555555a1a750) at gmain.c:4125
    #14 0x00005555555821fe in main (argc=<optimized out>, argv=<optimized out>) at src/main.c:423

Fixes: 07570e245a
2017-02-21 16:21:02 +01:00
Thomas Haller
8406455b4d ifcfg: drop strlen() call from svEscape() 2017-02-21 15:47:43 +01:00
Thomas Haller
c9f6cb9fe4 ifcfg: some refactoring of reader using vGetValueStr()/vGetValue_cp() 2017-02-21 15:43:03 +01:00
Thomas Haller
ccbfda5c08 ifcfg: complete shvar API with svGetValue_cp() and svGetValueStr()
Add svGetValue_cp() and svGetValueStr() for completeness.

Currently, we mostly use svGetValueStr_cp(), which I think is wrong
because for most cases we should instead not ignore empty values -- that
is, svGetValue_cp() would be a better choice.

Also, I think that the non *_cp() API should be preferred in many cases
because it avoids cloning the value in many cases. The API is not
necessarily less favorable either:

    gs_free char *value = NULL;

    value = svGetValue_cp (s, key);
    if (value)
        ...

vs.

    gs_free char *value_to_free = NULL;
    const char *value;

    value = svGetValue (s, key, &value_to_free);
    if (value)
        ...

Add the two missing variants, so that future code can use what fits
best, not following undesired practices because seemingly there is
no alternative.
2017-02-21 15:30:23 +01:00
Thomas Haller
c0c9b3dbcd ifcfg/trivial: rename svGetValueString() to svGetValueStr_cp()
We have

 - svGetValue()
    - returns the original string
    - avoids copying the string unless necessary

 - svGetValueStr_cp() (formerly svGetValueString())
    - returns the original string, unless it is empty ""
    - always clones the string

I think the behavior svGetValueStr*() of coercing "" to NULL is wrongly
used in most places. We should better handle "" like any other value,
not treat it as unset.

That would require another function svGetValue_cp(), which is like svGetValue()
but always copies the string. Rename svGetValueString() so that there is a place
for names like

  - svGetValue_cp()
  - svGetValueStr()

Also rename svSetValueString() to svSetValueStr().
2017-02-21 12:34:36 +01:00
Thomas Haller
d37c77234f ifcfg: set error for failure reading unrecognized connection in connection_from_file_full() 2017-02-21 12:17:30 +01:00
Thomas Haller
9b8e56180f ifcfg: don't g_strstrip() value in read_dcb_bool_array()
Ifcfg reader now properly handles escaping and quoting. We don't
need to stip whitespace, if somebody explicitly configures

  prop=" value"

it is a configuration error.
2017-02-21 12:17:30 +01:00
Thomas Haller
b1c8c9cbaf ifcfg: return early on error using cleanup attributes in reader 2017-02-21 12:17:30 +01:00
Thomas Haller
19c9d1bafd ifcfg: add nm_auto_shvar_file_close cleanup macro 2017-02-21 11:46:23 +01:00
Beniamino Galvani
7e79e913ad merge: branch 'bg/802-1x-auth-timeout-bgo723084'
Make the 802.1x authentication timeout configurable to allow a faster
fallback to other connections.

https://bugzilla.gnome.org/show_bug.cgi?id=723084
2017-02-21 09:34:23 +01:00
Thomas Haller
8588630c26 settings: log changes to NMSettingsConnection's autoconnect_retries 2017-02-21 09:18:53 +01:00
Beniamino Galvani
4a6fd0e83e device: honor the connection.autoconnect-retries for 802.1X
NMDeviceEthernet and NMDeviceMacsec implement their own retry policy
for connection using 802.1X, and consider the credentials wrong when
the authentication fails for 3 times. In such case, they also disable
autoconnection for the device by setting the state reason NO_SECRETS.

This means that it's not possible at the moment to choose how many
times the authentication will be retried since they don't use the
standard reconnection logic.

Change NMDeviceEthernet and NMDeviceMacsec to use the number of
retries from connection.autoconnect-retries instead of a hardcoded
value to decide how many times the authentication must be restarted.
2017-02-21 09:18:53 +01:00
Beniamino Galvani
07570e245a device: add support for 802-1x.auth-timeout
Use the per-connection authentication timeout for 802.1X Ethernet,
MACsec and Wi-Fi connections. In case the value is not defined, fall
back to the global one.
2017-02-21 09:18:53 +01:00
Beniamino Galvani
556a46959f ifcfg-rh: add support for 802-1x.auth-timeout property 2017-02-21 09:18:53 +01:00
Beniamino Galvani
9a215d332b cli: add support for 802-1x.auth-timeout property 2017-02-21 09:18:53 +01:00
Beniamino Galvani
078bd7b1a9 libnm-core: add auth-timeout property to the 802.1x setting
The property can be used to tune the authentication timeout. It's
especially useful to speed up the failure in case the port doesn't
support 802.1X and make NM try a different, non-authenticated
connection.
2017-02-21 09:18:53 +01:00
Thomas Haller
9952280d40 ifcfg: don't check for empty string after svGetValueString()
svGetValueString() precisely filters out empty strings. No need to
check for that afterwards.
2017-02-21 01:17:41 +01:00
Thomas Haller
601700dedf ifcfg: stack-allocate tag for DNS value lookup 2017-02-21 00:57:38 +01:00
Thomas Haller
03eab8bf92 ifcfg: return binary address from read_ip4_address()
This allows us to avoid cloning the string at several places.
2017-02-21 00:53:56 +01:00
Thomas Haller
e824dd34f0 build: fix type on Makefile.am
Fixes: 3cc00dd550
2017-02-21 00:37:48 +01:00
Thomas Haller
3cc00dd550 ifcfg: also read DEFROUTE and GATEWAY from alias files
Also accept DEFROUTE and GATEWAY when they are defined in
alias files -- provided, that they are not yet defined
in the main ifcfg file.
2017-02-20 23:18:36 +01:00
Thomas Haller
de42bde695 ifcfg: refactor creation of numered tag lables to use stack allocated buffer
and use gs_free attribute and return-early on error.
2017-02-20 19:43:52 +01:00
Lubomir Rintel
ff46158d9e tui: generate names for bonds, teams and bridges
This makes it more likely that the user will end up with a master
connection that has connection.interface-name property. This makes it
possible for ifcfg plugin to specify the master in the for of device
name (as opposed to UUID) for compatibility with the legacy network
tooling.

This is equivalent to what nmcli does.

https://bugzilla.redhat.com/show_bug.cgi?id=1369091
2017-02-20 16:07:43 +01:00
Thomas Haller
a184c25cb9 merge branch 'th/8021x-auth-flags-tls-disable-bgo765059'
https://bugzilla.gnome.org/show_bug.cgi?id=765059
2017-02-20 14:11:55 +01:00
Beniamino Galvani
436eec6083 ifcfg-rh: support 802-1x.phase1-auth-alg 2017-02-20 14:06:14 +01:00
Beniamino Galvani
bb72409e9f cli: support 802-1x.phase1-auth-flags 2017-02-20 14:06:14 +01:00
Thomas Haller
2a11c57c4e libnm/wifi: rework NMSetting8021xAuthFlags to explicitly disable TLS version
The wpa_supplicant API supports to enable/disable each TLS version
individually, or leave it at the default. Currently, the default
means to enable a TLS version, thus, the only meaningful option
for the momemnt means to explicitly disable it.

In the future, supplicant may disable options by default, and
the inverse option can become interesting to configure
"tls_disable_tlsv1_0=0". When that happens, we can solve it by
adding another flag NM_SETTING_802_1X_AUTH_FLAGS_TLS_1_0_ENABLE.

Change the previous behavior of the NMSetting8021xAuthFlags.
Previously, when not specifying TLS_DISABLE_DEFAULT, all
options were unspecified. On the other hand, when specifying
a single TLS disable flag, all versions were explicitly enabled
or disabled.

Instead, change the meaning of the disable flags. When present,
it explicitly disables an option. But it does not explicitly enable
it.
2017-02-20 14:06:14 +01:00
Leorize
8ce60a302a supplicant: allows disabling select TLS versions on phase 1 authentication
Some AAA servers have issues interoperating with select TLS versions,
which wpa_supplicant negotiates by default.

This commit allows disabling troubling versions of TLS so that
connecting to broken authentication servers could be possible.
2017-02-20 14:06:14 +01:00
Leorize
e3a9f1b32a libnm-core/8021x: add phase1-auth-flags configuration items 2017-02-20 13:45:32 +01:00
Thomas Haller
1525b44714 utils: support unknown numeric values in nm_utils_enum_to_str() and nm_utils_enum_from_str()
- for nm_utils_enum_to_str(), whenever encounter a numeric value
  that has no expression as enum/flag, encode the value numerically.
  For enums, encode it as decimal. For flags, encode it as hexadecimal
  (with 0x prefix).
  Also check that an existing value_nick cannot be wrongly interpreted
  as a integer, and if they would, encode them instead as integers only.

- Likewise, in nm_utils_enum_from_str() accept numerical values
  and for nm_utils_enum_get_values() return enum nicks that look
  like numeric values in their numeric form only.

- In nm_utils_enum_from_str(), don't use g_strsplit(), but clone the
  string only once and manipulate it inplace.

- Accept '\n' and '\r' as additional delimiters for flags.

- For consistency, also return an err_token for enum types. If the caller
  doesn't care about that, he should simply not pass the out-argument.
2017-02-20 13:45:32 +01:00
Beniamino Galvani
8950d18362 libnm-core: add _nm_utils_enum_to_str_full()
Unfortunately nm_utils_enum_to_str() doesn't allow to specify the
separator between enum values. Since the function is public API and
can't be modified now, add a new internal function which accepts the
separator as argument.
2017-02-20 13:45:32 +01:00
Beniamino Galvani
4d3ec516bd libnm-core: add missing transfer annotation for nm_utils_enum_to_str() 2017-02-20 13:44:08 +01:00
Beniamino Galvani
8b11c976ba merge: branch 'bg/wwan-mtu-rh1388613'
Add a MTU property to GSM and CDMA connections.

https://bugzilla.redhat.com/show_bug.cgi?id=1388613
2017-02-20 09:30:09 +01:00
Beniamino Galvani
27a52989e3 cli: support the cdma.mtu property 2017-02-20 09:18:25 +01:00
Beniamino Galvani
c51232f940 cli: support the gsm.mtu property 2017-02-20 09:18:25 +01:00
Beniamino Galvani
f37e183442 device: apply the mtu property of gsm and cdma settings 2017-02-20 09:18:25 +01:00
Beniamino Galvani
65837f5fff libnm-core: add mtu property to cdma setting 2017-02-20 09:18:16 +01:00
Beniamino Galvani
5d09183922 libnm-core: add mtu property to gsm setting 2017-02-20 09:18:16 +01:00
Thomas Haller
35d4e8f7a0 device/wifi: fix #if check for more-logging
Fixes: ae158bf178
2017-02-19 19:15:17 +01:00
Beniamino Galvani
5ae3db7515 libnm: disconnect signal from D-Bus proxies on dispose
https://bugzilla.gnome.org/show_bug.cgi?id=778615
2017-02-18 10:24:26 +01:00
Thomas Haller
ae158bf178 device/wifi: silence some logging for AP changes
We log updates of the Wi-Fi AP with a separate logging domain LOGD_WIFI_SCAN.
However, there is ony "update" message that is triggered every 6 seconds, which
becomes especially verbose.

Suppress this one and only log it when compiled --with-more-logging. And then
only log with level LOGL_TRACE, so the user still can filter this one out.
2017-02-17 20:32:42 +01:00
Thomas Haller
2c9ef8cf2e shared: move NMSetting8021xSchemeVtable to "shared/nm-setting-metadata.h" 2017-02-17 19:52:13 +01:00
Thomas Haller
c79e84368a all: add new "shared/nm-setting-metadata.h" file
"shared/nm-setting-metadata.h" will contain data structures
to handle NM setting properties in a generic way.

For now, this is internal API, but shared between libnm-core (which
extends to libnm, NetworkManager, device-plugins, settings-plugins),
and nmcli.

Related: https://bugzilla.gnome.org/show_bug.cgi?id=732292
2017-02-17 19:51:53 +01:00
Thomas Haller
fe6204ffc7 device/wifi: merge branch 'th/device-wifi-wait-for-scan-bgo770938'
https://bugzilla.gnome.org/show_bug.cgi?id=770938
https://bugzilla.gnome.org/show_bug.cgi?id=777831
2017-02-17 19:25:41 +01:00
Thomas Haller
2ab2254dd7 device/wifi: block autoconnect while scanning is in progress
We should only start autoconnecting after the scan is complete.
Otherwise, we might activate a shared connection or pick a
connection based on an incomplete scan list.

https://bugzilla.gnome.org/show_bug.cgi?id=770938
2017-02-17 14:41:27 +01:00
Thomas Haller
6eaded9071 device: add get_autoconnect_allowed() virtual function
It allows derived classes to override the autoconnect-allowed
state.

We already have

- NM_DEVICE_AUTOCONNECT property, which is two parts:
  - NMDevicePrivate::autoconnect_user, which is settable via
    D-Bus by the use, to allow the device to autoconnect.
  - NMDevicePrivate::autoconnect_intern, which is set by
    internal decision.
- NM_DEVICE_AUTOCONNECT_ALLOWED signal, where other devices can
  subscribe to block autoconnect. Currently that is only used
  by NMDeviceOlpcMesh.

These two make up for nm_device_autoconnect_allowed().

Add another way to allow derived classes to disable autoconnect
temporarily. This could also be achieved by having the device
subscribe to NM_DEVICE_AUTOCONNECT_ALLOWED of self, or by adding
a signal slot. But a plain function pointer seems easier.
2017-02-17 14:41:27 +01:00
Thomas Haller
2f9166e6b9 device: separately handle NMDevice's autoconnect by user and internal decision
The NMDevice's autoconnect property is settable via D-Bus and is is
also modified by internal decision, like when no PIN is available.

Certain internal actions cause clearing the internal autoconnect flag,
but they should not override the user desicion.

For example, when NM awaks from sleep it would reenable autoconnect,
but it should not reenable it for devices where the user explicitly
said that autoconnect is to be disabled.

Similarly, activating a device alone is not yet an instruction to
re-enable autoconnect. If the user consciously disables autoconnect,
it should stay enabled. On the other hand, activating a device should
reenable autoconnect if it was blocked by internal decision.

We need to track these two flags separately, and set them accordingly.
2017-02-17 14:41:27 +01:00
Thomas Haller
257484e7ba wifi: also show the NM D-Bus path for the Wi-Fi AP in nm_wifi_ap_to_string() 2017-02-17 14:41:27 +01:00
Thomas Haller
c9dc0eba65 wifi: only react on AP update signal when there are actual changes
Since we emit BSS_UPDATED signal before SCAN_DONE, it is very likely
that nothing actually changed. This clutters the logs with update
messages.

Also move the added/removed logging messages inside ap_add_remove().
We would call ap_add_remove() at several places without logging the
change.
2017-02-17 14:41:27 +01:00
Thomas Haller
e0f9677018 supplicant: delay SCAN_DONE signal until all BSS are initialized
We initialize the BSS asyncronously. Don't declare SCAN_DONE
until all BSS are up.

Otherwise, especially during the very first scan we declare SCAN_DONE
when having no BSS yet. This wrongly removes the pending action
"wifi-scan", while "autoconnect" cannot happen as there are not BSS
yet. Thus we declare "startup-complete" too early.

Another issue is that we may start autoconnecting with an incomplete
scan list, and thus pick a non-preferred connections.

https://bugzilla.gnome.org/show_bug.cgi?id=777831
2017-02-17 14:41:26 +01:00