Commit graph

21499 commits

Author SHA1 Message Date
Thomas Haller
d49e88f716 Revert "keyfile: drop with_extension argument from _internal_write_connection()"
For upstream, we changed behavior here. However, I think certain
downstream don't want to do that, and revert patch "d37ad15f12 keyfile:
also add ".nmconnection" extension when writing keyfiles in /etc".

For that to make easier, keep the upstream sources closer to what
was. Revert.

This reverts commit e93d8cdb74.
2018-10-23 13:46:14 +02:00
Thomas Haller
6978558e8c contrib: adjust NM-log for changes to platform logging
Fixes: 8f107f5c00
2018-10-23 12:03:59 +02:00
Thomas Haller
43955828c0 wifi/iwd: merge branch 'balrog-kun/iwd-fixes' (#236)
https://github.com/NetworkManager/NetworkManager/pull/236
2018-10-23 11:33:16 +02:00
Andrew Zaborowski
7f5957c8a7 wifi/iwd: check priv->dbus_obj in is_available
is_available would recently return true after IWD had disconnected
if a connection was active because it would check that
priv->dbus_station_proxy was non-NULL (i.e. that the DBus interface was
still visible, which it wasn't) but that check would be overridden
if the NMDevice state was activated.  Now require priv->dbus_obj to be
non-NULL, which would even be enough on its own although I'm leaving the
previous check there too to catch potential IWD states we don't support
in which priv->dbus_station_proxy is NULL without an active connection.
2018-10-23 11:32:28 +02:00
Andrew Zaborowski
75d53cc9fc wifi/iwd: add a sanity check for duplicate Networks on DBus
Sanity check networks received from the Station.GetOrderedNetworks()
DBus method.  Duplicates shouldn't happen but the code should be safe
against bogus data received over DBus.  There was a recent bug in a
library used by IWD causing occasional duplicates to be returned which
would cause invalid memory accesses reported by valgrind in NM because
g_hash_table_insert would free what we passed as the key.
2018-10-23 11:32:28 +02:00
Andrew Zaborowski
5c9a33f021 wifi/iwd: start a scan immediately after device appears
Start a new scan with 0 delay after a device goes into the disconnected
state, goes UP or freshly appears on DBus instead of waiting 10 seconds.
2018-10-23 11:32:28 +02:00
Andrew Zaborowski
bea6c40367 wifi/iwd: handle forgetting connection profiles
Watch for connection-removed events and delete corresponding IWD network
configs if found.  This mainly changes anything for 802.1X networks
where the deleted NM connections might annoyingly re-appear after a
restart.  For PSK networks though it'll make IWD forget the password
which, until now, would be remembered by IWD even if it was removed or
changed in the NM profile, which is a bug.

This is still fragile because we don't handle "connection-updated"
events so the data->mirror_connection pointer for a known network record
may after some time point to an NMSettingsConnection with a different
SSID or security type and there are corner cases where the IWD-side
profile will not be forgotten.  At least I'm trying to make sure we
don't crash and don't wrongly remove any IWD profile which could also be
annoying for complicated EAP configs.
2018-10-23 11:32:28 +02:00
Andrew Zaborowski
b98f269b91 wifi/iwd: print warning if known network exists in interface-added
Something is possibly wrong with the DBus signal handling if a newly
added KnownNetwork interface already has an entry in
priv->known_networks, but since we handle this case add a warning and
update the GDBusProxy pointer for that existing entry.
2018-10-23 11:32:28 +02:00
Andrew Zaborowski
ba52c4ea0a wifi/iwd: return existing connection from mirror_8021x_connection
interface_added expects mirror_8021x_connection() to return the pointer to
the existing connection if one exists, and NULL on error, rather than
NULL if a conneciton exists.  While touching that, add logic to return
specifically a connection with EAP method set to 'external' if one
exists even though this should not affect any other logic we have
currently.
2018-10-23 11:32:28 +02:00
Andrew Zaborowski
a9d1aaf090 wifi/iwd: use nm_act_request_get_secrets if no PSK for AP found
Some internal logic causes the secrets in a connection to be
occasionally moved to NMSettingConnection's priv->system_secrets after a
connection attempt so we need to use nm_act_request_get_secrets to get
them added to the device's settings connection and applied connection if
the PSK is missing during an AP or AdHoc mode activation (in
infrastructure mode we already do secret requests though they're cached
by IWD in most cases).

The common steps for the PSK available and unavailable scenarios is moved
from act_stage2_config to act_set_mode.
2018-10-23 11:32:28 +02:00
Andrew Zaborowski
21fc18cc33 wifi/iwd: skip creating a GVariant for DBus calls with no params
g_dbus_proxy_call and other GDBus function can accept a NULL as the
method call parameters.
2018-10-23 11:32:28 +02:00
Andrew Zaborowski
9dc1611f37 wifi/iwd: use g_variant_lookup in property change handlers
This simplifies the code by using g_variant_lookup.  In this handler
where we parse more than one property this is probably slower although
the number of string comparisons will be the same.
2018-10-23 11:32:28 +02:00
Thomas Haller
9edc4f0c2f core,libnm: merge branch 'th/setting-hash'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/29
2018-10-23 11:12:22 +02:00
Thomas Haller
4047633225 libnm: hash settings in NMConnection by gtype
NMConnection keeps a list (hash table) of all settings.

There are two lookup methods to find a setting in a connection:

  - nm_connection_get_setting() by GType
  - nm_connection_get_setting_by_name() by name

Note, that nm_connection_get_setting_by_name() first converts the
name to a GType, and then looks up the setting by GType.

But then, nm_connection_get_setting() would again convert the GType to
the type name, and hash the name. That is pointless, just index by GType
directly.

Maybe, using a hash table is anyway overkill because commonly there are
only a handful of settings in a connection. Regardless of that, change
the hashing.
2018-10-23 11:07:23 +02:00
Thomas Haller
4f27164148 core: don't cast return value of nm_device_get_applied_setting() 2018-10-23 10:47:01 +02:00
Thomas Haller
af48af4671 device: return void pointer from nm_device_get_applied_setting()
Literally ever use of nm_device_get_applied_setting() requires a
cast. Just don't.
2018-10-23 10:47:01 +02:00
Thomas Haller
56ac630893 keyfile: merge branch 'th/keyfile-filename-utils'
https://github.com/NetworkManager/NetworkManager/pull/239
2018-10-23 10:42:24 +02:00
Thomas Haller
83acb40a86 keyfile: move and rename NM_CONFIG_KEYFILE_PATH_DEFAULT define 2018-10-23 10:37:33 +02:00
Thomas Haller
e93d8cdb74 keyfile: drop with_extension argument from _internal_write_connection()
For non-test code, we always passed TRUE.

For test code, setting with_extension is fine too, so drop the
argument.
2018-10-23 10:37:33 +02:00
Thomas Haller
c4a9f44aff initrd: use keyfile util for creating filename 2018-10-23 10:37:33 +02:00
Thomas Haller
c36b5236b6 keyfile/trivial: rename keyfile related functions
NM_CONFIG_KEYFILE_PATH_IN_MEMORY is now called NMS_KEYFILE_PATH_NAME_RUN.
This name seems odd in the current context, it will be more suitable
when we also have NMS_KEYFILE_PATH_NAME_LIB (for /usr/lib).
2018-10-23 10:36:18 +02:00
Thomas Haller
410664967b keyfile: move keyfile utilities from src/ to libnm-core/
These utilities are concerned with valid file names (as NetworkManager
daemon requires it). This is relevant for everybody who wants to write
keyfile files directly. Hence, move it to libnm-core. Still as internal
API.
2018-10-23 10:36:07 +02:00
Thomas Haller
61717cc575 initrd: use cleanup attribute and return early from output_conn() 2018-10-23 10:36:07 +02:00
Thomas Haller
71c3483ac4 core: merge branch 'th/file-is-in-path'
https://github.com/NetworkManager/NetworkManager/pull/238
2018-10-23 10:32:53 +02:00
Thomas Haller
3c58fc1122 core: use nm_utils_file_is_in_path() for checking paths
For one, re-use the helper function instead of re-implementing
the check at multiple places.

Also, with this duplicate path separators are accepted.
2018-10-23 10:32:53 +02:00
Thomas Haller
f90b3adc15 core: add nm_utils_file_is_in_path() for checking paths
Add a helper function for the common check whether a file is
inside a path. Also, this function handles special cases like
repeated file separators. However, as it is still entirely text
based, it also cannot recognize if two (literally) different
paths reference the same inode/file.
2018-10-23 10:32:53 +02:00
Thomas Haller
9dce4a426b systemd: fix handling special cases kill_dots and path_simplify()
Previously, paths like ".", "./", ./." would all result in an
empty path. That is wrong, one dot must be kept.

afbae3e9f2
2018-10-23 10:32:53 +02:00
Thomas Haller
eece5aff09 core: add "nm-sd-utils.h" to access system internal helper
We have a fork of a lot of useful systemd helper code.
However, until now we shyed away from using it aside from
the bits that we really need.

That means, although we have some really nice implementations
in our source-tree, we didn't use them. Either we were missing
them, or we had to re-implement them.

Add "nm-sd-utils.h" header to very carefully make internal
systemd API accessible to the rest of core.

This is not intended as a vehicle to access all of internal
API. Instead, this must be used with care, and only a hand picked
selection of functions must be exposed. Use with caution, but where it
makes sense.
2018-10-23 10:32:53 +02:00
Beniamino Galvani
d0a99176a7 initrd: cmdline-reader: fix setting uint properties
Previously a uint property was assigned with a guint64 value, which
has a different size. Fix this and add a warning when the read value
can't be converted.

Fixes: ecc074b2f8

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/66
2018-10-23 09:09:42 +02:00
Lubomir Rintel
7c7e4cf134 ndisc: mark a keep-alive variable unused
Fixed build with clang:

  src/ndisc/nm-lndp-ndisc.c:494:27: error: unused variable 'ndisc_keep_alive' [-Werror,-Wunused-variable]
        gs_unref_object NMNDisc *ndisc_keep_alive = g_object_ref (ndisc);
                                 ^
Fixes: 9aa628cedb
2018-10-22 18:23:46 +02:00
Thomas Haller
301d703bc3 checkpatch: quote variable in "checkpatch-feature-branch.sh" 2018-10-22 18:21:41 +02:00
Lubomir Rintel
f577f719cc merge: branch 'lr/auth-dialog'
https://github.com/NetworkManager/NetworkManager/pull/173
2018-10-22 18:17:18 +02:00
Lubomir Rintel
5a0d67f739 clients/secret-agent-simple: support auth helpers
This makes it possible to utilize agents in the "external UI" mode
instead of hardcoded handling of VPN secrets requests.

Ideally this would be turned into a library so that nm-applet can share
the code, but figuring out the right API might be a non-trivial
undertaking.
2018-10-22 18:15:25 +02:00
Lubomir Rintel
f42c3d6653 service-plugin: add a warning here and there
We're basically rather careless when parsing the auth-dialog protocol.
Let's add some warning so we get an early alert when something's wrong.
2018-10-22 18:15:25 +02:00
Lubomir Rintel
3dfb72b926 service-plugin: allow continuations in the auth-dialog protocol
Equals sign was picked as a continuation character arbitratily.
It would simplify parsing, if we cared.

  DATA_KEY=some-key
  DATA_VAL=string
  =continued after a line break
  SECRET_KEY=key names
  =can have
  =continuations too
  SECRET_VAL=value
  DONE
2018-10-22 18:15:25 +02:00
Thomas Haller
669bd33022 contrib/rpm: don't depend NetworkManager-ovs package on openvswitch on RHEL
On RHEL, openvswitch package is not in the base set of packages. Hence,
we cannot depend NetworkManager-ovs package on openvswitch.

This isn't really a problem, because NetworkManager's OVS plugin must
anyway behave graceful when openvswich service is not running or not
available. It only means, that a user who wants to use the OVS plugin
needs to explicitly install the openvswitch package.

https://bugzilla.redhat.com/show_bug.cgi?id=1629178
https://bugzilla.redhat.com/show_bug.cgi?id=1633190
2018-10-22 16:34:51 +02:00
Thomas Haller
43b28e06ed test/meson: increase timeout for some tests
During gitlab-ci, some tests may take a long time. Increase
the default timeout.
2018-10-22 16:16:52 +02:00
Thomas Haller
924a895a1a checkpatch: support ranges for "checkpatch-feature-branch.sh"
Improve "checkpatch-feature-branch.sh" to support accepting
range as argument.
2018-10-22 14:09:47 +02:00
Thomas Haller
8d6d7c48f9 core/trivial: fix whitespace 2018-10-22 14:03:11 +02:00
Thomas Haller
948abdb84d platform/tests: extend timeout for link-linux tests with meson
Our gitlab CI sometimes takes a long time with the
"/link/create-many-links/1000" test.
2018-10-22 13:42:20 +02:00
Thomas Haller
4543785438 checkpatch: fix "checkpatch-feature-branch.sh" for master branch
The main purpose of "checkpatch-feature-branch.sh" is to test all
patches of a feature branch. When we run the script against master
(or nm-1-*), then there is no feature branch.

Previously, the script would just error out.

That is not very useful, in particular as we call this from gitlab-ci,
which also runs on master.

Instead, in that case, test the HEAD.
2018-10-22 13:35:20 +02:00
Thomas Haller
31f13acdc9 gitlab: merge branch 'th/gitlab-ci'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/25
2018-10-22 13:21:36 +02:00
Thomas Haller
a0a0824564 gitlab: add .gitlab-ci.yml for gitlab CI
See-also: https://docs.gitlab.com/ee/ci/yaml/
2018-10-22 13:19:15 +02:00
Thomas Haller
369446eae6 checkpatch: add "contrib/scripts/checkpatch-feature-branch.sh" script
This takes current HEAD branch, and finds all the commits what
are not on master or one of the nm-1-* branches, and runs
checkpatch.pl on each.

The use is to run checkpatch.pl on all patches of a feature
branch.
2018-10-22 13:19:15 +02:00
Thomas Haller
a487d34fc4 contrib: make "contrib/fedora/REQUIRED_PACKAGES" executable script
It will be called by .gitlab-ci.yml to install the packages.
2018-10-22 13:19:15 +02:00
Jan Alexander Steffens (heftig)
e0b168d6a8 meson: Fix platform tests
All platform tests were run twice with the `linux` platform, instead of
`fake` and `linux`, as expected.
2018-10-22 13:19:15 +02:00
Thomas Haller
581be6b8d2 platform/tests: fix test-nmp-object when running on system without udev
Fix the test, to check that the nmp-object was deleted. It is
no longer visible and no longer alive.
2018-10-22 13:19:15 +02:00
Thomas Haller
cfc0565604 platform/tests: don't compare dangling pointer in "test-nmp-object.c"
This wouldn't even dereference the dangling pointer, but
merely comparing it for pointer equality. Still, it's actually
undefined behavior. Avoid it.
2018-10-22 13:17:53 +02:00
Sven Schwermer
1913a4d259 ppp: check ppp status against correct type
ppp_status is of type NMPPPStatus whereas PHASE_RUNNING is pppd's type.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/28
2018-10-22 10:53:16 +02:00
Beniamino Galvani
2ee2305ed8 cli: fix memory leak 2018-10-22 08:43:44 +02:00