Commit Graph

22259 Commits

Author SHA1 Message Date
Thomas Haller
25a3825b51 libnm: fix duplicate free in nm_client_checkpoint_rollback()
#0  0x00007fffea7481e5 in _g_log_abort (breakpoint=1) at gmessages.c:554
    #1  0x00007fffea74951d in g_logv (log_domain=0x7fffea78e00e "GLib", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=args@entry=0x7fffffffcbb0)
        at gmessages.c:1371
    #2  0x00007fffea7496f3 in g_log
        (log_domain=log_domain@entry=0x7fffea78e00e "GLib", log_level=log_level@entry=G_LOG_LEVEL_CRITICAL, format=format@entry=0x7fffea798320 "%s: assertion '%s' failed")
        at gmessages.c:1413
    #3  0x00007fffea749f2d in g_return_if_fail_warning
        (log_domain=log_domain@entry=0x7fffea78e00e "GLib", pretty_function=pretty_function@entry=0x7fffea799d40 <__func__.4759> "g_atomic_ref_count_dec", expression=expression@entry=0x7fffea799ca1 "g_atomic_int_get (arc) > 0") at gmessages.c:2762
    #4  0x00007fffea754c12 in g_atomic_ref_count_dec (arc=arc@entry=0x5555558c5280) at grefcount.c:260
    #5  0x00007fffea7302c6 in g_hash_table_unref (hash_table=0x5555558c5240) at ghash.c:1101
    #6  0x00007fffea4b6dbc in clear_op_res (simple=0x55555587ed90 [GSimpleAsyncResult]) at gsimpleasyncresult.c:248
    #7  0x00007fffea4b6dbc in g_simple_async_result_finalize (object=0x55555587ed90 [GSimpleAsyncResult]) at gsimpleasyncresult.c:268
    #8  0x00007fffea67b949 in g_object_unref (_object=<optimized out>) at gobject.c:3346
    #9  0x00007fffea67b949 in g_object_unref (_object=0x55555587ed90) at gobject.c:3238
    #10 0x00007fffe95dea2d in checkpoint_rollback_cb (object=<optimized out>, result=<optimized out>, user_data=0x55555587ed90) at libnm/nm-manager.c:1584
    #11 0x00007fffea4ca834 in g_task_return_now (task=0x5555558b5c80 [GTask]) at gtask.c:1148
    #12 0x00007fffea4cb196 in g_task_return (task=0x5555558b5c80 [GTask], type=<optimized out>) at gtask.c:1206
    #13 0x00007fffea5096bb in reply_cb (connection=<optimized out>, res=<optimized out>, user_data=0x5555558b5c80) at gdbusproxy.c:2596
    #14 0x00007fffea4ca834 in g_task_return_now (task=0x5555558b5d50 [GTask]) at gtask.c:1148
    #15 0x00007fffea4cb196 in g_task_return (task=0x5555558b5d50 [GTask], type=<optimized out>) at gtask.c:1206
    #16 0x00007fffea4fdd4a in g_dbus_connection_call_done (source=<optimized out>, result=0x5555558b5e20, user_data=0x5555558b5d50) at gdbusconnection.c:5715
    #17 0x00007fffea4ca834 in g_task_return_now (task=0x5555558b5e20 [GTask]) at gtask.c:1148
    #18 0x00007fffea4ca86d in complete_in_idle_cb (task=task@entry=0x5555558b5e20) at gtask.c:1162
    #19 0x00007fffea73e97b in g_idle_dispatch (source=0x7fffdc04eb90, callback=0x7fffea4ca860 <complete_in_idle_cb>, user_data=0x5555558b5e20) at gmain.c:5620
    #20 0x00007fffea74206d in g_main_dispatch (context=0x5555557c8410) at gmain.c:3182
    #21 0x00007fffea74206d in g_main_context_dispatch (context=context@entry=0x5555557c8410) at gmain.c:3847
    #22 0x00007fffea742438 in g_main_context_iterate (context=0x5555557c8410, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3920
    #23 0x00007fffea742762 in g_main_loop_run (loop=0x55555584ed00) at gmain.c:4116

Fixes: c3efedf54b
2019-02-19 09:33:05 +01:00
Thomas Haller
c9244d28ae shared: add nm_g_type_find_implementing_class_for_property() helper
A helper method, only useful for printf debugging -- and thus
unused in the source-tree.

It is relatively cumbersome to lookup the GType that implements
a property. For example, for NMDeviceBond.driver, it should return
NMDevice (which implements the "driver" property).
2019-02-19 09:33:05 +01:00
Thomas Haller
fc9d661018 platform/wireguard: fix parsing WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL from netlink
Fixes: 0827d4c2e4
2019-02-18 15:10:07 +01:00
Thomas Haller
074103f92d all: merge branch 'th/c-list-move'
https://github.com/NetworkManager/NetworkManager/pull/298
2019-02-18 15:01:05 +01:00
Thomas Haller
9ae71bf555 all: use nm_c_list_move_*() helpers 2019-02-18 15:00:10 +01:00
Thomas Haller
a85318f8de shared: add nm_c_list_move_*() helpers 2019-02-18 15:00:10 +01:00
Beniamino Galvani
080f5ee76b ovs: merge branch 'bg/ovs-leaks'
https://github.com/NetworkManager/NetworkManager/pull/296
2019-02-17 19:39:19 +01:00
Beniamino Galvani
29984c07cd ovs: fix dispose()
input and output must be freed only when not NULL.

Also, ovsdb_disconnect() should do nothing if there is no client.

Fixes: 830a5a14cb
2019-02-17 19:39:08 +01:00
Beniamino Galvani
b92f2c9323 ovs: don't leak a GCancellable on connection failure
Every time we clear priv->client we should also clear the cancellable
or it will be leaked.

Fixes: 830a5a14cb
2019-02-17 19:39:08 +01:00
Beniamino Galvani
139b9974fa ovs: fix leak of json objects
Fixes: 830a5a14cb
2019-02-17 19:39:07 +01:00
Beniamino Galvani
8d9685ef98 ovs: use nm_auto_decref_json 2019-02-17 19:39:07 +01:00
Beniamino Galvani
5efa9ff348 shared: add nm_auto_decref_json 2019-02-17 19:39:07 +01:00
Thomas Haller
1423ad24c0 wifi/iwd: fix compiler warning about pointer cast in powered_changed()
../src/devices/wifi/nm-device-iwd.c: In function ‘powered_changed’:
    ../src/devices/wifi/nm-device-iwd.c:2336:15: warning: assignment from incompatible pointer type [enabled by default]
         interface = g_object_ref (priv->dbus_device_proxy);
                   ^
2019-02-17 11:14:08 +01:00
Thomas Haller
9a4cd1efd1 release: update NEWS 2019-02-15 18:40:41 +01:00
Thomas Haller
5923a30c43 settings/ifupdown: fix ifupdown plugin after merging eni_ifaces and connections hashes
The @eni_ifaces hash may now contain %NULL elements. They are only markers
for interface names, but are not actual connections.

They must be skipped.

Fixes: 6aa66426a4

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/124
2019-02-15 16:12:14 +01:00
Thomas Haller
c032690df2 all: merge branch 'th/various-for-wireguard-3'
https://github.com/NetworkManager/NetworkManager/pull/293
2019-02-14 08:00:55 +01:00
Thomas Haller
a3d4dea61f platform: print persistent-keepalive setting of WireGuard peers 2019-02-14 08:00:29 +01:00
Thomas Haller
153b41fa97 platform: add peer_flags argument to nm_platform_link_wireguard_change() 2019-02-14 08:00:29 +01:00
Thomas Haller
1e1b03c089 platform: add flags for setting individual WireGuard options of link 2019-02-14 08:00:29 +01:00
Thomas Haller
2ed01e2e34 platform: add change-flags argument to platform's link_wireguard_change()
We will need more flags.

WireGuard internal tools solve this by embedding the change flags inside
the structure that corresponds to NMPlatformLnkWireGuard. We don't do
that, NMPlatformLnkWireGuard is only for containing the information about
the link.
2019-02-14 08:00:29 +01:00
Thomas Haller
c3751a25a1 device: add mechanism to invoke act_stage2_config() function also for external/assume case
Usually, for external/assume we skip calling act_stage2_config().

Add a flag that allows the device to indicate that it always wants
to be called. This is useful, if the device wants to do some initialization
also for external/assume cases.
2019-02-14 08:00:29 +01:00
Thomas Haller
b45b087bbe device: split activate_stage2_device_config() steps for assumed/external check
Instead of performing a series of steps inside one check for
"!nm_device_sys_iface_state_is_external_or_assume (self)", perform
all steps individually (under the same check).

There is no change in behavior, but this is more logical to me.
We perform a series of steps, depending on condition. Each step
individually depends on a set of conditions, instead of checking
for a set of conditions and doing a series of independent steps.
2019-02-14 08:00:29 +01:00
Thomas Haller
afdf2a21df device: abort device activation if tc_commit() fails in stage2
After we change the device's state to NM_DEVICE_STATE_FAILED,
we must abort processing the current stage.

Fixes: e4bdb21909
2019-02-14 08:00:29 +01:00
Thomas Haller
6f35efe6fe policy: treat WireGuard devices as VPN for DNS
WireGuard devices are (will be) regular NMDevice implementations,
but NMDnsManager should treat them like VPN.

For that, reuse the device's type and nm_device_get_route_metric_default().
2019-02-14 08:00:29 +01:00
Thomas Haller
55ce9d9de9 clients/secret-agent: allow suppressing prompting the entry-id when requesting secrets
When asking for the preshared-key for WireGuard peers, the secret request
will be very verbose with redundant information. Allow suppressing the entry
id from the prompt.
2019-02-14 08:00:29 +01:00
Thomas Haller
ead7c00348 clients/secret-agent: split creation of secret-request data 2019-02-14 08:00:29 +01:00
Thomas Haller
a4f0bda6d4 clients/secret-agent: fail request_secrets_from_ui() if there are no secrets to be requested
From looking at the code above, this likely shouldn't actually happen.
2019-02-14 08:00:29 +01:00
Thomas Haller
6ef825d501 clients/secret-agent: keep setting-name in request-data
It's not really used, but we shouldn't just forget about it.

Currently, we fill requests only based on the connection-type, ignoring
the setting-name. I guess, the concept of requesting secrets for a setting
is utterly broken. But equally broken it is to just look at the connection
(type). At least, don't just throw parts of the request away but keep
it.
2019-02-14 08:00:29 +01:00
Thomas Haller
713e879d76 libnm: add NMSockAddrEndpoint API
NMSockAddrEndpoint is an immutable structure that contains the endpoint
string of a service. It also includes the (naive) parsing of the host and
port/service parts.

This will be used for the endpoint of WireGuard's peers. But since endpoints
are not something specific to WireGuard, give it a general name (and
purpose) independent from WireGuard.

Essentially, this structure takes a string in a manner that libnm
understands, and uses it for node and service arguments for
getaddrinfo().

NMSockAddrEndpoint allows to have endpoints that are not parsable into
a host and port part. That is useful because our settings need to be
able to hold invalid values. That is for forward compatibility (server
sends a new endpoint format) and for better error handling (have
invalid settings that can be constructed without loss, but fail later
during the NMSetting:verify() step).
2019-02-14 08:00:29 +01:00
Thomas Haller
d93845e2c2 libnm: add internal _nm_utils_secret_flags_validate() util 2019-02-14 08:00:29 +01:00
Thomas Haller
28c53ea37e libnm/trivial: rename NM_SETTING_SECRET_FLAG_ALL flag (formerly NM_SETTING_SECRET_FLAGS_ALL)
It should mirror the naming pattern of the flags.
2019-02-14 08:00:29 +01:00
Thomas Haller
99ae5322c9 shared: add macros for initializing NMSecretPtr 2019-02-13 16:03:23 +01:00
Thomas Haller
2fa7a7c20b shared: make nm_streq() and nm_streq0() inline functions
There is no advantage in having these as macros. Make them
inline functions, compiler should be able to decide that they
are in fact inlinable.

Also, don't call g_strcmp0() for nm_streq0(). It means we first
have to call glib function, only to call a glibc function. No need
for this abstraction.
2019-02-13 16:03:23 +01:00
Thomas Haller
4fab0d09a5 shared: add NM_STR_HAS_SUFFIX()
Contrary to g_str_has_suffix(), it exploits the fact the the suffix length
is known at compile time. No need to call a glib function, to find out what
we already know, to call strcmp().

Instead just calculate the string length and call memcmp().
2019-02-13 16:03:23 +01:00
Thomas Haller
d216e2f305 libnm: fix usage of nm_streq() macro
Yes, C has a preprocessor and nm_streq() currently is a macro.

Still, macros should very much behave like regular functions.
For example, no unexpected side-effects aside what a regular function
would have, evaluating all arguments exactly once, or no side-effects
w.r.t. the order in which arguments are evaluated.

In some cases, we deviate from that for good reasons. For example
NM_IN_SET() may not evaluate all arguments. _LOGD() may not evaluate
any arguments, and NM_UTILS_LOOKUP_STR_DEFINE() is not a function-like
macro at all.

Still, that is not the case here. We avoid to misuse macros to write
code that does not look like C.
2019-02-13 16:03:23 +01:00
Thomas Haller
2c881b8064 wifi-p2p: merge branch 'th/wifi-p2p-wait-supplicant-fix'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/80
2019-02-13 16:01:12 +01:00
Thomas Haller
27169047c5 wifi-p2p: add FIXME comment for handling group_owner in NMDeviceWifiP2P 2019-02-13 16:01:03 +01:00
Thomas Haller
3c989f30d6 wifi-p2p: rework setting pending action waiting for supplicant
Previously, we might have a pending action 'waiting-for-supplicant'
registered, although the device was not waiting:

    <info>  [1549611177.5815] device (wlan0): supplicant interface state: starting -> ready
    <debug> [1549611177.5816] device[0x55d1781ae5d0] (p2p-dev-wlan0): P2P: Releasing WPA supplicant interfaces.
    <debug> [1549611177.5816] device[0x55d1781ae5d0] (p2p-dev-wlan0): P2P: WPA supplicant management interface changed to /fi/w1/wpa_supplicant1/Interfaces/1.
    <trace> [1549611177.5816] device[0x55d1781ae5d0] (p2p-dev-wlan0): remove_pending_action (0): 'waiting-for-supplicant' not pending (expected)
    <debug> [1549611177.5816] device[0x55d1781ae5d0] (p2p-dev-wlan0): constructed (NMDeviceWifiP2P)
    <debug> [1549611177.5816] device[0x55d1781ae5d0] (p2p-dev-wlan0): add_pending_action (1): 'waiting-for-supplicant'

The previous commit already fixed this bug by dropping the constructor
property for NM_DEVICE_WIFI_P2P_MGMT_IFACE.

Still, refactor handling of pending actions to keep track of whether we
have a pending action registered.
2019-02-13 15:54:45 +01:00
Thomas Haller
75741ef5c8 wifi-p2p: drop constructor property NM_DEVICE_WIFI_P2P_MGMT_IFACE
We already have a setter function nm_device_wifi_p2p_set_mgmt_iface()
as we may need to change the mgmt-iface later on. Use that to set the
supplicant interface instead of a constructor property.

That makes the object creation simpler, because nothing noteworthy
happens, until the very last statement in constructed() to add the
pending action.
2019-02-13 15:52:13 +01:00
Thomas Haller
5c7a9f65b0 wifi-p2p: don't use g_signal_connect_object()
We already explicitly take care of the lifetime of mgmt_iface and
disconnect all signal handlers. No need to register an additional
weak-reference.
2019-02-13 15:52:06 +01:00
scootergrisen
e390cc0529 po: update Danish (da) translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/82
2019-02-13 08:29:42 +01:00
Thomas Haller
128099151d shared: fix nm_errno_from_native() for negative input
Fixes: 67130e6706
2019-02-12 09:13:29 +01:00
Thomas Haller
5d9a2d9168 all: merge branch 'th/errno'
https://github.com/NetworkManager/NetworkManager/pull/292
2019-02-12 08:50:39 +01:00
Thomas Haller
d83d5f1da2 shared: use nm_strerror_native_r() in lower layers
Subsequent calls to nm_strerror_native() overwrite the previous
buffer. That is potentially dangerious. At least functions in
shared/nm-utils (which are lower-layer utilities) should not do
that and instead use a stack-local buffer. That is because these
functions should not make assumptions about the way they are called.

On the other end, nmcli passing the return-value of nm_strerror_native()
to g_print() is clearly OK because the higher layers are in control of
when the call nm_strerror_native() -- by relying that lower layers don't
interfere.
2019-02-12 08:50:28 +01:00
Thomas Haller
2b630bc22e systemd: define strerror() in sd-adapt header to nm_strerror_native()
Systemd uses strerror() extensively. Patch the function to use the thread-safe
nm_strerror_native().
2019-02-12 08:50:28 +01:00
Thomas Haller
9beed4f661 all: replace strerror() calls with nm_strerror_native() 2019-02-12 08:50:28 +01:00
Thomas Haller
a4fb6ddfca all: replace g_strerror() calls with nm_strerror_native() 2019-02-12 08:50:28 +01:00
Thomas Haller
737ab51472 all: include "nm-utils/nm-errno.h" via "nm-default.h" 2019-02-12 08:50:28 +01:00
Thomas Haller
e1ca3bf7ed shared: add nm_strerror_native() to replace strerror() and g_strerror()
We have various options for strerror(), with ups and downsides:

- strerror()

    - returns pointer that is overwritten on next call. It's convenient
      to use, but dangerous.

    - not thread-safe.

    - not guaranteed to be UTF-8.

- strerror_r()

    - takes input buffer and is less convenient to use. At least, we
      are in control of when the buffer gets overwritten.

    - there is a Posix/XSI and a glibc variant, making it sligthly
      inconvenient to used. This could be solved by a wrapper we implement.

    - thread-safe.

    - not guaranteed to be UTF-8.

- g_strerror()

    - convenient and safe to use. Also the buffer is never released for the
      remainder of the program.

    - passing untrusted error numbers to g_strerror() can result in a
      denial of service, as the internal buffer grows until out-of-memory.

    - thread-safe.

    - guaranteed to be UTF-8 (depending on locale).

Add our own wrapper nm_strerror_native(). It is:

    - convenient to use (returning a buffer that does not require
      management).

    - slightly dangerous as the buffer gets overwritten on the next call
      (like strerror()).

    - thread-safe.

    - guaranteed to be UTF-8 (depending on locale).

    - doesn't keep an unlimited cache of strings, unlike g_strerror().

You can't have it all. g_strerror() is leaking all generated error messages.
I think that is unacceptable, because it would mean we need to
keep track where our error numbers come from (and trust libraries we
use to only set a restricted set of known error numbers).
2019-02-12 08:50:28 +01:00
Thomas Haller
4d9918aac2 all: assert that native errno numbers are positive
Use the NM_ERRNO_NATIVE() macro that asserts that these errno numbers are
indeed positive. Using the macro also serves as a documentation of what
the meaning of these numbers is.

That is often not obvious, whether we have an nm_errno(), an nm_errno_native()
(from <errno.h>), or another error number (e.g. WaitForNlResponseResult). This
situation already improved by merging netlink error codes (nle),
NMPlatformError enum and <errno.h> as nm_errno(). But we still must
always be careful about not to mix error codes from different
domains or transform them appropriately (like nm_errno_from_native()).
2019-02-12 08:50:28 +01:00