Commit graph

17662 commits

Author SHA1 Message Date
Thomas Haller
ae112d0070 wifi: fix leaking fake AP in NMDeviceWifi's act_stage1_prepare()
Fixes: 96f40dcdcd
(cherry picked from commit ef61d7909f)
(cherry picked from commit d08530ac4b)
(cherry picked from commit 6c4c12c796)
(cherry picked from commit 4a345b2e78)
2018-09-13 16:30:33 +02:00
Thomas Haller
13aaad7c5b dhcp: fix leak in dhclient's dhclient_start()
Fixes: 5d6d5cd136
(cherry picked from commit c87faf07a1)
(cherry picked from commit 8f9240de96)
(cherry picked from commit c740726b57)
(cherry picked from commit 0a69572cae)
2018-09-10 14:39:41 +02:00
Thomas Haller
fd6acf6183 libnm/keyfile: fix double free in keyfile's get_bytes()
Fixes: 5e7b14af03
(cherry picked from commit fcf254c03a)
(cherry picked from commit 1c56be4090)
(cherry picked from commit 71e2a25a0d)
2018-09-04 07:49:55 +02:00
Beniamino Galvani
ca231f6c8e libnm-core: support private keys encrypted with AES-{192,256}-CBC
https://github.com/NetworkManager/NetworkManager/pull/189
(cherry picked from commit 93f85edcce)
(cherry picked from commit 74fc6f30b2)
(cherry picked from commit 9b46af1a62)
2018-08-30 10:26:32 +02:00
Thomas Haller
9f41fae864 wifi: don't use :1 bitfield for gboolean type
gboolean is a typedef for "int".

While older compilers might treat such bitfields as unsigned ([1]),
commonly such a bitfield is signed and can only contain the values 0
and -1.

We only want to use numeric 1 for TRUE, hence, creating such bitfields
is wrong, or at least error prone.

In fact, in this case it's a bug, because later we compare
it with a regular gboolean

  if (priv->scanning != new_scanning)

[1] https://lgtm.com/rules/1506024027114/

Fixes: e0f9677018
(cherry picked from commit 610ca87016)
(cherry picked from commit f326feaba3)
(cherry picked from commit 7689b9b73b)
2018-08-26 18:34:35 +02:00
Beniamino Galvani
8d4fce4daf libnm: add (allow-none) annotations to nm_device_reapply()
The @connection argument can be NULL; add the (allow-none) annotation
otherwise calling the API with a NULL argument through GObject
introspection fails with:

 Argument 1 does not allow None as a value

Fixes: 278fd4fb0f
(cherry picked from commit f396826466)
(cherry picked from commit a03b867ba4)
(cherry picked from commit cd6c17cb21)
2018-07-04 14:19:13 +02:00
Thomas Haller
2d23f2142c release: bump version to 1.8.9 (development) 2018-06-16 09:52:29 +02:00
Thomas Haller
0d234b6f38 release: bump version to 1.8.8 2018-06-16 09:52:29 +02:00
Thomas Haller
01c8cf1afe release: update NEWS 2018-06-16 09:52:29 +02:00
Thomas Haller
d7170e21fc ifnet: avoid compiler warning about casting function pointers
../../src/settings/plugins/ifnet/nms-ifnet-plugin.c: In function ‘monitor_file_changes’:
  ../../src/settings/plugins/ifnet/nms-ifnet-plugin.c:140:42: error: cast between incompatible function types from ‘void (*)(void *)’ to ‘void (*)(void *, GObject *)’ {aka ‘void (*)(void *, struct _GObject *)’} [-Werror=cast-function-type]
     g_object_weak_ref (G_OBJECT (monitor), (GWeakNotify) g_free,
                                            ^

(cherry picked from commit dccc449522)
2018-06-16 09:52:29 +02:00
Lubomir Rintel
fa1f2bc26c libnm/vpn-plugin: avoid bad function pointer type casts
This makes GCC 8.0 unhappy and it is probably right about that -- it's more
difficult to get things wrong when the function prototypes actually match.

(cherry picked from commit 7f7207f36b)
(cherry picked from commit 17b488cfd5)
2018-06-16 09:52:29 +02:00
Lubomir Rintel
343cc27961 session-monitor: fix a -Wcast-function-type warning
See-Also: ee916a1e9e
(cherry picked from commit b686dd8488)
(cherry picked from commit aeaa895049)
2018-06-16 09:52:29 +02:00
Lubomir Rintel
3cd8c64c6d all: fix -Wcast-function-type warnings
GCC 8.0's -Wcast-function-type objects casting function pointers to ones
with incompatible prototypes. Sometimes we do that on purpose though.

Notably, the g_source_set_callback()'s func argument can point to functions
of various prototypes. Also, libnm-glib/nm-remote-connection is perhaps
just not worth reworking, that would just be a waste of time.

A cast to void(*)(void) avoids the GCC warning, let's use it.

(cherry picked from commit ee916a1e9e)
(cherry picked from commit 42913505a3)
2018-06-16 09:52:29 +02:00
Lubomir Rintel
70bd824eff ppp/plugin: use g_strlcpy()
It's nicer but also doesn't annoy gcc 8: "error: ‘strncpy’ specified bound
depends on the length of the source argument [-Werror=stringop-overflow=]"

(cherry picked from commit 85c0dc4a92)
(cherry picked from commit 04a6600a60)
2018-06-16 09:52:29 +02:00
Lubomir Rintel
c5ae1c5ead ppp-manager: fix build with GCC 8
src/ppp/nm-ppp-manager.c: In function ‘monitor_cb’:
src/ppp/nm-ppp-manager.c:184:2: error: ‘strncpy’ specified bound 16 equals destination size [-Werror=stringop-truncation]
  strncpy (req.ifr_name, priv->ip_iface, sizeof (req.ifr_name));
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

(cherry picked from commit 520542fc45)
2018-06-16 09:46:11 +02:00
Thomas Haller
a8411d11f8 device: fix crash during reapply
Fixes: bf3b3d444c
(cherry picked from commit fe1f5871c8)
(cherry picked from commit 28cf2ecd0d)
2018-06-15 09:14:24 +02:00
Beniamino Galvani
e958209891 manager: trust the state file more when assuming connections
If we can't generate a connection and maybe_later is TRUE, it means
that the device can generate/assume connections but it failed for the
moment due to missing master/slaves/addresses. In this case, just
assume the connection from state file.

https://bugzilla.redhat.com/show_bug.cgi?id=1551958
(cherry picked from commit 236edfc908)
2018-05-05 09:57:51 +02:00
Benjamin Berg
2e62853509 Add calls to g_simple_async_result_set_check_cancellable
If an operation is cancelled through the GCancellable, then the idiom is
that the operation is always cancelled, even if it has finished
successfully. To ensure this is the case, add calls to
g_simple_async_result_set_check_cancellable everywhere.

Without this, e.g. gnome-control-center will crash when switching away
from the power panel quickly, as the NMClient creation finishes
asynchronously and g-c-c assume that G_IO_ERROR_CANCELLED is returned to
ensure it doesn't access the now invalid user_data parameter.

https://bugzilla.gnome.org/show_bug.cgi?id=794088
(cherry picked from commit 26c215e22d)
(cherry picked from commit e1b99d9201)
2018-03-08 15:10:24 +01:00
Lubomir Rintel
13064745b5 nmcli: fix signal handling
Hook the signal handlers right before the main loop. Prior to that
the default handlers are good enough and our one crashes (due to
loop being instantialized).

Also, set the return value properly to indicate a termination by a
signal.

(cherry picked from commit edf6f826b5)
2018-01-24 09:56:18 +01:00
Lubomir Rintel
848894b832 nmcli/agent: fix handling of polkit agent failure
On "nmcli agent all", when the polkit agent fails (while the NM agent
succeeds), the failure is not communicated until the client exits.

(cherry picked from commit 7e8a84ae10)
2018-01-24 09:56:18 +01:00
Lubomir Rintel
40a5059949 shared/utils: don't warn of unknown warning disables with clang
When pushing a warning disable with clang, always disable
-Wunknown-warning-option first -- it might be that clang wouldn't warn
of what we're trying to disable because it doesn't recognize it in the
first place. That is entierely okay.

With clang-5.0.0:

    CC       libnm/tests/libnm_tests_test_secret_agent-test-secret-agent.o
  In file included from libnm/tests/test-secret-agent.c:29:
  In file included from ./shared/nm-test-libnm-utils.h:23:
  ./shared/nm-utils/nm-test-utils.h:432:3: error: unknown warning group '-Wunused-but-set-variable', ignored [-Werror,-Wunknown-warning-option]
                  NM_PRAGMA_WARNING_DISABLE("-Wunused-but-set-variable")
                  ^
  ./shared/nm-utils/nm-macros-internal.h:223:9: note: expanded from macro 'NM_PRAGMA_WARNING_DISABLE'
          _Pragma(_NM_PRAGMA_WARNING_DO(warning))
          ^
  <scratch space>:204:25: note: expanded from here
   GCC diagnostic ignored "-Wunused-but-set-variable"
                          ^
  1 error generated.

(cherry picked from commit fc4552d391)
2018-01-24 09:56:18 +01:00
Pavel Šimerda
b2b28cb644 libnm: fix empty statements that were supposed to return NULL
Discovered thanks to `-Wunused-value` when building on openSUSE Leap 42.3.

(cherry picked from commit c4f655579c)
(cherry picked from commit a30b2fcd84)
2018-01-17 19:21:34 +01:00
Lubomir Rintel
01d41c08a7 release: bump version to 1.8.7 (development) 2018-01-15 12:12:14 +01:00
Lubomir Rintel
15eeb1c895 release: bump version to 1.8.6 2018-01-15 12:00:22 +01:00
Lubomir Rintel
9e5959231c release: update NEWS 2018-01-15 11:22:39 +01:00
Lubomir Rintel
d954411def secret-agent: construct the dbus proxy for async agent with the correct bus name
The asynchronous secret agent initialization doesn't work at all due to a
rather silly typo. Oops.

While at it, fix a whitespace error too.

(cherry picked from commit 603daa5b25)
2018-01-11 13:43:13 +01:00
Francesco Giudici
029f78983c platform/tests: relax checking for signals in test-address-linux
# Start of ipv6 tests
  ../tools/run-nm-test.sh: line 193: 32194 Trace/breakpoint trap   (core dumped) "${NMTST_DBUS_RUN_SESSION[@]}" "$TEST" "$@"
  # NetworkManager-FATAL-ERROR: NMPlatformSignalAssert: ../src/platform/tests/test-address.c:153, test_ip6_address_general(): failure to accept signal [0,1] times: 'ip6-address-changed-changed' ifindex 11 (2 times received)

(cherry picked from commit f9b9c5979e)
2018-01-08 16:50:09 +01:00
Francesco Giudici
116214ecf0 devices/test: give more time to dad checking in test-arping
# random seed: R02Sc708af827453d4ace33cd27ffd3d7f0b
  1..2
  # Start of arping tests
  **
  NetworkManager:ERROR:src/devices/tests/test-arping.c:95:test_arping_common: assertion failed (nm_arping_manager_check_address (manager, info->addresses[i]) == info->expected_result[i]): (1 == 0)
  ok 1 /arping/1
  PASS: src/devices/tests/test-arping 1 /arping/1
  ./tools/run-nm-test.sh: line 193:  2836 Aborted                 "${NMTST_DBUS_RUN_SESSION[@]}" "$TEST" "$@"
  # NetworkManager:ERROR:src/devices/tests/test-arping.c:95:test_arping_common: assertion failed (nm_arping_manager_check_address (manager, info->addresses[i]) == info->expected_result[i]): (1 == 0)
  ERROR: src/devices/tests/test-arping - too few tests run (expected 2, got 1)
  ERROR: src/devices/tests/test-arping - exited with status 134 (terminated by signal 6?)

(cherry picked from commit 5c6a382d4d)
(cherry picked from commit 2638d53ca8)
2017-12-13 10:30:46 +01:00
Thomas Haller
54706e6557 tests: increase timeout for arping test
I hit an assertion failure running with valgrind on a busy machine.
Maybe the timeout is just not long enough for every case.

Increase it.

(cherry picked from commit 88c24ffc6a)
2017-12-13 10:30:35 +01:00
Thomas Haller
903ed7bc59 platform/tests: relax checking for signals in test-link-linux
# random seed: R02S4ca8cfc3dace399c0f15b42411e45d2e
  1..48
  # Start of link tests
  ok 1 /link/bogus
  PASS: src/platform/tests/test-link-linux 1 /link/bogus
  ok 2 /link/loopback
  PASS: src/platform/tests/test-link-linux 2 /link/loopback

  nmtst: initialize nmtst_get_rand() with NMTST_SEED_RAND=2697682474
  ok 3 /link/internal
  PASS: src/platform/tests/test-link-linux 3 /link/internal
  ok 4 /link/external
  PASS: src/platform/tests/test-link-linux 4 /link/external
  # Start of software tests
  ./tools/run-nm-test.sh: line 193:  7589 Trace/breakpoint trap   (core dumped) "${NMTST_DBUS_RUN_SESSION[@]}" "$TEST" "$@"
  NMPlatformSignalAssert: src/platform/tests/test-link.c:298, test_slave(): failure to accept signal 0 times: 'link-changed-changed' ifindex 9 (1 times received)
  ERROR: src/platform/tests/test-link-linux - too few tests run (expected 48, got 4)
  ERROR: src/platform/tests/test-link-linux - exited with status 133 (terminated by signal 5?)

(cherry picked from commit 1ee6dea02f)
2017-12-12 18:45:35 +01:00
Thomas Haller
11975066d3 all: merge fixing pointers casts for g_object_ref()
See related bug https://bugzilla.gnome.org/show_bug.cgi?id=790697

https://mail.gnome.org/archives/desktop-devel-list/2012-July/msg00100.html

(cherry picked from commit cdbe1ad715)
(cherry picked from commit 42fb6976aa)
2017-12-06 10:56:49 +01:00
Thomas Haller
23bf70e654 shared: propagate type for g_object_ref()
See related bug https://bugzilla.gnome.org/show_bug.cgi?id=790697

(cherry picked from commit 7ca601d529)
(cherry picked from commit 85b1c11b8f)
2017-12-06 10:52:27 +01:00
Thomas Haller
9f3d152f47 all: use cast macros instead of C cast
When building with assertions, they nm_assert() for the
type. Otherwise, they are identical to a C cast.

Also, where possible, don't cast at all, but adjust
the type instead.

Also, there were a few missing casts.

(cherry picked from commit 7661ad64ba)
(cherry picked from commit ceeeb51e1d)
2017-12-06 10:51:47 +01:00
Colin Walters
2c30198d91 tree-wide: cast after g_object_ref() for proposed GLib patch
This fixes the build with related bug https://bugzilla.gnome.org/show_bug.cgi?id=790697

https://mail.gnome.org/archives/networkmanager-list/2017-December/msg00005.html
(cherry picked from commit 3f6bef47f3)
(cherry picked from commit 4bd3069b68)
2017-12-06 10:51:47 +01:00
Beniamino Galvani
1c9c0a4368 cli: exit from main loop after 'quit' editor command
When we stop processing the editor command loop (after a 'quit'
command) we must quit the GLib main loop.

https://bugzilla.redhat.com/show_bug.cgi?id=1517401
(cherry picked from commit 21cfeff777)
(cherry picked from commit 66a728e8ac)
2017-11-29 11:12:52 +01:00
Beniamino Galvani
e2c6a0dd6a settings: preserve agent-owned secrets on connection add
Settings plugins now return the connection that was reread from file
when adding a connection, which means that any agent-owned secret is
lost. Ensure that we don't forget agent-owned secrets by caching them
and readding them to the new connection returned by plugins.

Fixes: 8a1d483ca8
Fixes: b4594af55e

https://bugzilla.gnome.org/show_bug.cgi?id=789383
(cherry picked from commit 62141d59cb)
(cherry picked from commit 0bd8b34725)
2017-11-21 13:40:51 +01:00
Thomas Haller
59517f1f35 keyfile: fix escaping ascii control characters in nm_keyfile_key_encode()
Matters when backslash escaping ascii charaters <= 0xF, to
produce "\\XX" instead of "\\ X". For example tabulator is "\\09".

This also can trigger an nm_assert() failure, when building with
--with-more-asserts=5 (or higher).

(cherry picked from commit 89c89143b5)
(cherry picked from commit 54dad379f3)
2017-11-20 15:42:02 +01:00
Murilo Opsfelder Araujo
5f2855fad9 contrib/fedora: Add mockbuild.sh
This script comes handy to build from git tree without having to
install build dependencies on the system, the actual build happens
inside mock environment.

https://github.com/NetworkManager/NetworkManager/pull/34
(cherry picked from commit fa61e78d80)
2017-11-02 15:32:56 +01:00
Murilo Opsfelder Araujo
3cd716e229 contrib/fedora: Update required packages
Add dhclient and iptables packages to build dependencies to satisfy
rpmbuild complaints:

```
error: Failed build dependencies:
	dhclient is needed by NetworkManager-1:1.9.2-18653.43dba57439.fc28.x86_64
	iptables is needed by NetworkManager-1:1.9.2-18653.43dba57439.fc28.x86_64
ERROR: rpmbuild FAILED
```

https://github.com/NetworkManager/NetworkManager/pull/33
(cherry picked from commit 301cf7151b)
2017-11-02 15:32:35 +01:00
Thomas Haller
da2139b87d contrib/rpm: explicitly set default dhcp configuration
It will also be autodetected, but be explicit about it.

(cherry picked from commit 5a00811b5a)
2017-11-02 15:30:49 +01:00
Thomas Haller
eeedf51f08 systemd: let "NetworkManager-wait-online.service" require "NetworkManager.service"
`systemctl start network-online.target` should suffice to start
"NetworkManager.service".

That would work because
 - "network-online.target" has "Wants=NetworkManager-wait-online.service"
 - "NetworkManager-wait-online.service" has "Require=NetworkManager.service".

But previously, "NetworkManager-wait-online.service" would just
fail with missing dependency.

See also https://github.com/systemd/systemd/pull/6065 which does the
same for networkd's wait-online serice, and see rh#1452866 for a
use-case.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=1452866
(cherry picked from commit 28b97f02f6)
2017-11-02 15:29:30 +01:00
Thomas Haller
c6efa864eb contrib/rpm: enable "NetworkManager-wait-online.service" on package upgrade
Since commit d61eaf2545 ("service: don't
install dependency for "NetworkManager-wait-online.service" to
"network-online.target.wants") we no longer install NM-w-o.service
in "network-online.target.wants" directory.

Obviously, for previous RPM versions NM-w-o.service was always enabled.
For current versions, it depends now on the preset. Most importantly,
this allows the user to disable the service, without masking it.
Previously NM-w-o.service was always implicitly enabled.

But presets are not applied during package upgrade, so it means that
after upgrade the service will be disabled. Hack around that via an RPM
scriptlet.

https://bugzilla.redhat.com/show_bug.cgi?id=1455704
(cherry picked from commit 513d0c2286)
2017-11-02 15:28:48 +01:00
Lubomir Rintel
34035ceee8 libnm/client: proxy *_enabled and metered properties to the right object
They're provided by the Manager, not by the RemoteSettings.

(cherry picked from commit c81005b846)
2017-11-02 09:05:04 +01:00
Beniamino Galvani
9fea242f72 manager: fix evaluation of manager state
The state should be set to CONNECTED_GLOBAL only when there is full
connectivity.

Fixes: 9d43869e47

https://bugzilla.gnome.org/show_bug.cgi?id=785281
(cherry picked from commit ebb30c53cd)
2017-10-20 11:15:16 +02:00
Beniamino Galvani
01b10fe24d core: don't close input fd in nm_utils_fd_get_contents()
The function should not close the input file descriptor; however
fdopen() associates the fd to the new stream so that when the stream
is closed, the fd is too. The result is a double close() and the
second call can in certain cases affect a wrong fd.

Use a duplicate fd for the stream.

Fixes: 1d9bdad1df

https://bugzilla.redhat.com/show_bug.cgi?id=1451236
(cherry picked from commit 597072296a)
2017-10-19 09:06:09 +02:00
Beniamino Galvani
bb4b6be912 bus-manager: don't leak connections
The bus manager takes extra references to the GDBusConnection every
time g_dbus_object_manager_server_get_connection() its called,
preventing its disposal once the connection is closed. This causes a
leak for each DHCP event.

https://bugzilla.redhat.com/show_bug.cgi?id=1461643
(cherry picked from commit 5b81d40338)
2017-10-12 09:19:06 +02:00
Lubomir Rintel
51c7520752 platform: treat dsa devices as regular wired ethernet
https://bugzilla.redhat.com/show_bug.cgi?id=1371289
(cherry picked from commit 5c2ee8b26e)
2017-10-09 19:40:52 +02:00
Beniamino Galvani
5bd8269315 device: fix frozen notify signals on unrealize error path
If unrealize() failed we returned without thawing notify signals. Fix
this by moving g_object_freeze_notify() after the
unrealization/deletion but before the properties are reset in
unrealize_notify().

Fixes: a93807c288
(cherry picked from commit 24a7f88bc5)
2017-10-04 15:52:35 +02:00
Thomas Haller
0288f58667 libnm,keyfile: merge branch 'th/libnm-keyfile-route-metric'
(cherry picked from commit b17d2a538e)
2017-10-04 12:09:53 +02:00
Thomas Haller
482fcb507e keyfile: fix reading/writing route metric zero
Zero is a valid route metric and distinct from -1, which means unspecified.
Fix reader and writer.

Fixes: e374923bbe
(cherry picked from commit 099be8e4db)
2017-10-04 12:09:15 +02:00