Commit graph

8925 commits

Author SHA1 Message Date
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
Beniamino Galvani
436eec6083 ifcfg-rh: support 802-1x.phase1-auth-alg 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
Beniamino Galvani
f37e183442 device: apply the mtu property of gsm and cdma settings 2017-02-20 09:18:25 +01:00
Thomas Haller
35d4e8f7a0 device/wifi: fix #if check for more-logging
Fixes: ae158bf178
2017-02-19 19:15:17 +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
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
Thomas Haller
e3a489180b wifi: check for invalid BSSID in nm_wifi_ap_update_from_properties()
In nm_wifi_ap_new_from_properties(), we checked that the BSSID is valid
and bailed out otherwise. Since we call nm_wifi_ap_update_from_properties()
on a created BSSID, we should ensure there too that an update does not cause
the address to become invalid.

In the unlikely case where an update would change a previously valid address
to an invalid one, we would ignore the update.

Thus, move the check for addresses inside nm_wifi_ap_update_from_properties().
2017-02-17 14:41:26 +01:00
Thomas Haller
29a53b1cd7 supplicant: merge NEW_BSS signal with BSS_UPDATED
Before, the NEW_BSS signal was not careful to emit the signal only when the BSS
is seen for the first time. Consequently, supplicant_iface_new_bss_cb() checked
whether it already knows about the new BSS.

Merge NEW_BSS and BSS_UPDATED. Now we emit BSS_UPDATED when either the
BSS is new or changed.

Also, in supplicant_iface_new_bss_cb() (now supplicant_iface_bss_updated_cb())
no longer constructs an @ap instance if we have a @found_ap.

In some situations there can be a value of having a separate ADD signal.
But only when there the consumers care, and if the consumers can trust that
ADD is not just an UPDATE. The only consumer doesn't care and it not not be
trusted, so merge the signals.
2017-02-17 14:41:26 +01:00
Thomas Haller
c47026715e supplicant: cleanup network when cancelling "AddNetwork" request
If the assoc-request is cancelled while an "AddNetwork" request is
pending, we must cleanup the added network when the request succeeds.

The issue can also happen when NetworkManager shuts down and exits
the mainloop. This scenario is unsolved as the cleanup action
"RemoveNetwork" has no chance to run.

"AddBlob" works differently in that blogs are added with a specific name,
not like "AddNetwork", where a new D-Bus path is created. Maybe we should
also cleanup blobs that were added by us, but currently we don't.
2017-02-17 14:41:26 +01:00
Thomas Haller
dce13b6f11 supplicant: remove unused return value from nm_supplicant_interface_request_scan()
It cannot fail, remove code that anticipates a failure of request-scan.
2017-02-17 14:41:26 +01:00
Thomas Haller
da34034b95 supplicant: use nm_clear_g_cancellable() helper 2017-02-17 14:41:26 +01:00
Thomas Haller
e16bf4f3db supplicant/trivial: move code around 2017-02-17 14:41:26 +01:00
Thomas Haller
66c45d0fdc supplicant: rework nm_supplicant_interface_set_config() to invoke result callback
Instead of having a NM_SUPPLICANT_INTERFACE_CONNECTION_ERROR signal to notify
about failures during AddNetwork/SelectNetwork, accept a callback to report
success/failure.

Thereby, rename nm_supplicant_interface_set_config() to
nm_supplicant_interface_assoc().

The async callback is guaranteed to:

 - be invoked exactly once, signalling success or failure
 - always being invoked asyncronously.

The pending request can be (synchronously) cancelled via
nm_supplicant_interface_disconnect() or by disposing the
interface instance. In those cases the callback will be invoked
too, with error code cancelled/disposing.
2017-02-17 14:41:26 +01:00
Thomas Haller
324cf7ce82 ifcfg-rh: reuse file-suffix from NMSetting8021xSchemeVtable
Keyfile writer computes the file extension and only uses
the file suffix from the vtable.

Do that for ifcfg-rh too. No change in behavior.
2017-02-17 14:24:34 +01:00
Thomas Haller
7a21ae3e77 keyfile: reuse NMSetting8021xSchemeVtable in NMKeyfileWriteTypeDataCert 2017-02-17 14:24:34 +01:00
Thomas Haller
199524e426 ifnet: merge ObjectType with NMSetting8021xSchemeVtable in ifnet parser
ifnet has two extra instances @p12_type/@phase2_p12_type, that only
differed from @pk_type/@phase2_pk_type by their suffix.

But as the suffix field as unused, we can drop that entirely.
2017-02-17 14:24:34 +01:00
Thomas Haller
01b8520447 ifcfg-rh: merge ObjectType with NMSetting8021xSchemeVtable in ifcfg-rh writer 2017-02-17 14:24:34 +01:00
Thomas Haller
6627fef1a6 ifcfg-rh: refactor duplicate ObjectType instance to handle PKCS#12 types
If one property has multiple ways to be handled, we should not create
two ObjectType instances, instead let the ObjectType have enough
information to act accordingly.
2017-02-17 14:24:34 +01:00
Thomas Haller
a77e6f1f5d ifcfg-rh: refactor ObjectType structs to make it more similar to NMSetting8021xSchemeVtable 2017-02-17 14:24:34 +01:00
Lubomir Rintel
eda2ddb8c6 supplicant: set PIN for objects on PKCS#11 tokens 2017-02-17 14:24:34 +01:00
Lubomir Rintel
e599e96572 ifcfg-rh: add support for certificate passwords 2017-02-17 14:24:34 +01:00
Lubomir Rintel
70b370f52c ifcfg-rh: support the pkcs11 scheme for certs/keys
The PKCS#11 URIs start with the "pkcs11:" scheme. There's a slight
possiblity of a clash with file names relative to the ifcfg file, but
that's probably is unlikely enough the leave us not worried.

The alteratives are probably more horrible (using a different key, or
using a separate key for the scheme alone) and it's already simple
enough to avoid a clash by using an absolute file name.
2017-02-17 14:24:34 +01:00
Thomas Haller
4898e2f686 settings: make "ready"/"flags" property read-only
and "filename" construct-only.
2017-02-17 11:09:39 +01:00
Thomas Haller
9e5319dbc0 core: use define for atomic-section-prefix setting for NMConfig
main() should pass the same atomic-section-prefix setting to it's
NMConfig instances. Currently both are NULL, but make it a define
to make this explicit.

Also, make static array @default_values const and sanitize value
when setting PROP_ATOMIC_SECTION_PREFIXES property.
2017-02-17 11:08:29 +01:00
Thomas Haller
a8f0d88596 ifcfg: ensure ipv4.method is not "disabled" when reading IP addresses from alias files
When the main ifcfg file contains no IP addresses, the method
will be "disabled". Later, when reading IP addresses for the
aliases, we must ensure that the method is manual.

Otherwise, validation fails with

  ip.addresses: this property is not allowed for method=disabled
2017-02-16 21:55:40 +01:00
Lubomir Rintel
53a00b8198 checkpoint: drop a redundant assignment 2017-02-16 18:12:47 +01:00
Lubomir Rintel
4752ef20d6 wifi: error check nla_parse_nested()
Makes coverity happy.
2017-02-16 18:12:46 +01:00
Lubomir Rintel
9b1c6e9497 tests: drop a dead case branch
It seems to annoy coverity.
2017-02-16 18:12:45 +01:00
Lubomir Rintel
07bf4151ba manager: retrigger the connectivity check if we loose a default route
Update the connectivity state if we go from CONNECTED_GLOBAL to
CONNECTED_LOCAL. It will likely fail immediately (unless there's a default
route we're not aware of or the check URL is routable locally), keeping the
Connectivity property up-to-date.
2017-02-16 15:44:28 +01:00
Thomas Haller
15177a34be dns: change behavior for "rc-manager=symlink" to preserve "/etc/resolv.conf" as file
The purpose of "rc-manager=symlink" is so that the administrator can point
the "/etc/resolv.conf" as a symlink to a certain file, and thus indicating
that a certain component is responsible to manage resolv.conf, while others
should stay away from it.
For example, systemd-resolved never touches "/etc/resolv.conf", but
expects the admin to setup the symlink appropriately. It also recognizes
whether the symlink points to it's own resolv.conf in /run or to another
component.

Previously, "rc-manager=symlink" would always replace a regular file
with a symlink to "/var/run/NetworkManager/resolv.conf". Only if
"/etc/resolv.conf" is already a symlink somewhere else, NM would not
touch it. This with the exception that if "/etc/resolv.conf" points to
"/var/run/NetworkManager/resolv.conf", it would replace the symlink
with the same link to raise inotify events.

Change behavior so if "/etc/resolv.conf" is already a regular file, keep
it as file.
This means, if you have multiple components that don't care, everybody
can write the "/etc/resolv.conf" (as file) and there is no clear
expressed responsibility.
It was wrong that NetworkManager would convert the file to a symlink,
this should be reserved to the admin. Instead, NetworkManager should
accept that the intent is unspecified and preserve the regular file.
It's up to the admin to replace the symlink to somewhere else (to keep
NM off), or to point it to "/var/run/NetworkManager/resolv.conf", to show
the explicit intent.

The wrong behavior causes dangling symlinks when somebody disables
NetworkManager for good.

https://bugzilla.redhat.com/show_bug.cgi?id=1367551
2017-02-14 17:45:55 +01:00
Beniamino Galvani
f71e1379d6 dhcp: dhclient: reset the request list if conf file contains 'request'
After commit 2049e97d9e ("dhcp: refactor parsing of 'request' and
'also request' options") NM parses all the existing 'request' and
'also request' from the original configuration file and appends them
as 'also request' to avoid duplicates and conflicts.

So if the original file contains 'request x' (which means "request
only option x instead of builtin defaults"), we would translate it
into 'also request x', which appends the option to the builtin
defaults, causing duplicates in the DHCP request as dhclient seems not
smart enough to sanitize the list by itself.

To fix this, ensure that the request list is reset if the
configuration file contains a 'request'.

Fixes: 2049e97d9e

https://bugzilla.gnome.org/show_bug.cgi?id=778430
2017-02-14 11:29:05 +01:00
Thomas Haller
5a03de7051 wifi: introduce enum type NMSupplicantInterfaceState instead of plain int
Also change the signature of the NM_SUPPLICANT_INTERFACE_STATE signal,
to have three "int" type arguments. Thereby also fix the subscribers
to this signal that wrongly had type guint32, instead of guint
(which happens to be the same underlying type, so no real problem).

https://mail.gnome.org/archives/networkmanager-list/2017-February/msg00021.html
2017-02-14 09:47:05 +01:00
Thomas Haller
ed07de8667 platform: avoid printing "(null)" interface name during logging
Avoids:

    platform: link: setting up '(null)' (11)

Use nm_strquote_a() to quote the string if it is not NULL.
2017-02-10 17:31:16 +01:00
Thomas Haller
ecd3263e40 dns: fix shutdown to restore non-cached DNS config
The DNS manager and other singletons have the problem that
they are not properly destroyed on exit, that is, we leak
most of the instances. That should be eventually fixed and
all resources/memory should be released.

Anyway, fix the shutdown procedure by adding an explict command
nm_dns_manager_shutdown(). We should not rely on cleanup actions
to take place when the last reference is dropped, because then
we get complex interactions where we must ensure that everybody
drops the references at the right pointer.

Since the previous shutdown action was effectively never performed,
it is not quite clear what we actually want to do on shutdown.
For now, move the code to nm_dns_manager_stop(). We will see if
that is the desired behavior.
2017-02-10 15:26:45 +01:00
Thomas Haller
6ad8011e2d platform: use IFA_FLAGS name instead of numeric value
Originally, IFA_FLAGS might not have been present in the headers.
In the mean time, we explicitly define it outself to be "8".
2017-02-10 15:14:15 +01:00
Thomas Haller
95f9b0266c platform: unify logging messages about kernel support
Give them a common prefix.
2017-02-10 15:14:15 +01:00
Thomas Haller
6b03eacb34 platform: downgrade warning about failure to detect kernel support to debug
Also, as time goes by it is less likely to encounter a user
where the kernel has no support. The most likely reason nowadays
is that the user booted with "ipv6.disabled=1".

https://bugzilla.redhat.com/show_bug.cgi?id=1421019
2017-02-10 15:02:28 +01:00
Thomas Haller
ef6c393889 core: define a full sort order for nm_settings_connection_cmp_timestamp()
We want to have some guaranteed order when comparing different connections.
So, in case of equal timestamps, proceed with comparing more properties.

It makes sense to consider the autoconnect-priority next.
This is what get_existing_connection() needs, thus we no longer
need to pre-sort the list.
2017-02-10 14:43:24 +01:00
Thomas Haller
93f7ab2c54 core: consolidate sorting of connections by autoconnect/timestamp
NMPolicy's auto_activate_device() wants to sort by autoconnect-priority,
nm_utils_cmp_connection_by_autoconnect_priority() but fallback to the default
nm_settings_connection_cmp_default(), which includes the timestamp.

Extend nm_settings_connection_cmp_default() to consider the
autoconnect-priority as well. Thus change behavior so that
nm_settings_connection_cmp_default() is the sort order that
auto_activate_device() wants. That makes sense, as
nm_settings_connection_cmp_default() already considered the
ability to autoconnect as first. Hence, it should also honor
the autoconnect priority.

When doing that, rename nm_settings_connection_cmp_default()
to nm_settings_connection_cmp_autoconnect_priority().
2017-02-10 14:43:24 +01:00
Thomas Haller
a822132399 core: make nm_utils_cmp_connection_by_autoconnect_priority() more robust
Check for NULL and unexpected missing NMSettingConnection.
Be more forgiving and accept whatever is there when comparing
@a with @b.
2017-02-10 14:43:24 +01:00
Thomas Haller
b3b1793f3d core: refactor nm_manager_get_activatable_connections() to return an array
... instead of a GSList.
2017-02-10 14:43:24 +01:00