Commit graph

24383 commits

Author SHA1 Message Date
Thomas Haller
e96bc190d6 clients/tests: read stdout/stderr buffers during test-clients.py
We need to actually read the stdout/stderr of the nmcli programs.
Otherwise, the pipe might fill uup and block to process (eventually
leading to timeout).
2019-11-07 11:34:36 +01:00
Thomas Haller
cdb95062e7 clients/tests: set NM_TEST_CALLING_NUM environement variable for client tests
Debugging tests that are called by test-client.py is cumbersome.
One way would be to set NM_TEST_CLIENT_NMCLI_PATH to a wrapper script.
However, then we want to know from the wrapper script which test
we are currently calling. Add that to the environment.
2019-11-07 11:34:36 +01:00
Thomas Haller
6a9ed0adfb cli: unsubscribe permission signal from NMClient on exit
During the libnm rework, we might still emit permissions changed
signal while destructing the instance. That triggers an assertion.

Backtrace, with a different libnm:

  #0  _g_log_abort (breakpoint=1) at ../glib/gmessages.c:554
  #1  0x00007ffff77d09b6 in g_logv (log_domain=0x7ffff7f511cd "libnm", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=args@entry=0x7fffffffcb80) at ../glib/gmessages.c:1373
  #2  0x00007ffff77d0b83 in g_log
      (log_domain=log_domain@entry=0x7ffff7f511cd "libnm", log_level=log_level@entry=G_LOG_LEVEL_CRITICAL, format=format@entry=0x7ffff78215df "%s: assertion '%s' failed")
      at ../glib/gmessages.c:1415
  #3  0x00007ffff77d137d in g_return_if_fail_warning
      (log_domain=log_domain@entry=0x7ffff7f511cd "libnm", pretty_function=pretty_function@entry=0x7ffff7f58aa0 <__func__.40223> "nm_client_get_permission_result", expression=expression@entry=0x7ffff7f54830 "NM_IS_CLIENT (client)") at ../glib/gmessages.c:2771
  #4  0x00007ffff7e9de9a in nm_client_get_permission_result (client=0x0, permission=permission@entry=NM_CLIENT_PERMISSION_ENABLE_DISABLE_NETWORK) at libnm/nm-client.c:3816
  #5  0x0000555555593ba3 in got_permissions (nmc=nmc@entry=0x55555562ec20 <nm_cli>) at clients/cli/general.c:587
  #6  0x0000555555593bcb in permission_changed (client=<optimized out>, permission=<optimized out>, result=<optimized out>, nmc=0x55555562ec20 <nm_cli>) at clients/cli/general.c:600
  #7  0x00007ffff73b1aa8 in ffi_call_unix64 () at ../src/x86/unix64.S:76
  #8  0x00007ffff73b12a4 in ffi_call (cif=cif@entry=0x7fffffffced0, fn=fn@entry=0x555555593bbf <permission_changed>, rvalue=<optimized out>, avalue=avalue@entry=0x7fffffffcde0)
      at ../src/x86/ffi64.c:525
  #9  0x00007ffff78b4746 in g_cclosure_marshal_generic_va
      (closure=<optimized out>, return_value=<optimized out>, instance=<optimized out>, args_list=<optimized out>, marshal_data=<optimized out>, n_params=<optimized out>, param_types=<optimized out>) at ../gobject/gclosure.c:1614
  #10 0x00007ffff78b3996 in _g_closure_invoke_va (closure=0x5555556f4330, return_value=0x0, instance=0x55555565a020, args=0x7fffffffd180, n_params=2, param_types=0x555555656f00)
      at ../gobject/gclosure.c:873
  #11 0x00007ffff78d0228 in g_signal_emit_valist (instance=0x55555565a020, signal_id=<optimized out>, detail=0, var_args=var_args@entry=0x7fffffffd180) at ../gobject/gsignal.c:3306
  #12 0x00007ffff78d09d3 in g_signal_emit (instance=instance@entry=0x55555565a020, signal_id=<optimized out>, detail=detail@entry=0) at ../gobject/gsignal.c:3453
  #13 0x00007ffff7e8989a in _emit_permissions_changed (self=self@entry=0x55555565a020, permissions=permissions@entry=0x555555690e40 = {...}, force_unknown=force_unknown@entry=1)
      at libnm/nm-client.c:2874
  #14 0x00007ffff7e9a0c9 in _init_release_all (self=self@entry=0x55555565a020) at libnm/nm-client.c:6092
  #15 0x00007ffff7e9bcde in dispose (object=0x55555565a020 [NMClient]) at libnm/nm-client.c:6838
  #16 0x00007ffff78b8c28 in g_object_unref (_object=<optimized out>) at ../gobject/gobject.c:3344
  #17 g_object_unref (_object=0x55555565a020) at ../gobject/gobject.c:3274
  #18 0x00005555555badcf in nmc_cleanup (nmc=0x55555562ec20 <nm_cli>) at clients/cli/nmcli.c:924
  #19 0x00005555555bbea7 in main (argc=<optimized out>, argv=0x7fffffffd498) at clients/cli/nmcli.c:987
2019-11-07 11:34:36 +01:00
Thomas Haller
44a56fca60 libnm/tests: fix stub implementation for remote-next-connection
We cannot first remove the connection (and emit property changed signals),
before replying with the newly added path (that already no longer exists).
Fix the stub implementation.
2019-11-07 11:34:36 +01:00
Thomas Haller
6bf206eb81 libnm/tests: drop test_activate_failed() test
With this test the stub service simulates a failure to add-and-activate
the connection.

However the implementation of the stub service was not simulating the
real behavior of NetworkManager service. libnm will add the possibility
to assert against invalid server behavior by setting LIBNM_CLIENT_DEBUG=error.
With that change, libnm will complain that the stub service behaves
invalid, and rightly so.

Instead of fixing the test, just drop it.
2019-11-07 11:34:36 +01:00
Thomas Haller
feea4222ef libnm/tests: unsubscribe signal handler during test_activate_virtual()
libnm is gonna change, where it would still emit signals when the
instance gets destructed. In particular, when the device gets removed
from the NMClient cache, the references to other objects would be
cleared (and consequently property changed signals emitted).

This will cause a test failure, because the signal was not unsubscribed:

    test:ERROR:libnm/tests/test-nm-client.c:694:device_ac_changed_cb: assertion failed: (nm_device_get_active_connection (NM_DEVICE (device)) != NULL)
2019-11-07 11:34:36 +01:00
Thomas Haller
f21b8781ed tests: use nmtstc_client_new() to create NMClient instance and cleanup tests
The advantage of nmtstc_client_new() is that it randomly either uses the
synchronous or asynchronous constructor. Of course, both should behave
pretty much the same. Hence, this increases our test coverage.
2019-11-07 11:34:36 +01:00
Thomas Haller
8def37dd65 tests: add nmtstc_client_new() helper 2019-11-07 11:34:36 +01:00
Thomas Haller
ec39498fc6 tests: support D-Bus property Device.StateReason in mock service
The device interface (org.freedesktop.NetworkManager.Device) has
two properties: "State" and "StateReason". Both of them are supported by
NetworkManager for a very long time.

Note that "StateReason" is a tuple and also exposes the state along the
reason.

When reworking libnm, we will ignore the "State" property and only
consider "StateReason". The advantage is less code and not using
redundant state. This will also work well, because NetworkManager's
D-Bus API supports this property for a very long time.

However, that would then break the CI tests, because currently
"tools/test-networkmanager-service.py" does not expose that property.

Add it.
2019-11-07 11:34:36 +01:00
Thomas Haller
abb68d90fc libnm: retire nm_client_wimax_*() functions
The server doesn's support WiMAX anymore. Hence there is no point in keeping
this functionality. While we cannot drop the functions, let them not do anything.

The code in NMManager is still there. But since we will soon drop
NMManager entirely, it doesn't matter.
2019-11-07 11:34:36 +01:00
Thomas Haller
2e91add7e4 libnm: move nm_permission_to_client()/nm_permission_result_to_client() to nm-libnm-utils.c
It's nicely trivial and independent. Move it to a separate place,
to avoid cluttering the more complicated code and to make it testable.

Also, use binary search to find the value by string.
2019-11-07 11:34:36 +01:00
Thomas Haller
83d7599acc libnm: deprecate nm_device_set_managed() and nm_device_set_autoconnect() API
These setters not only invoke a synchronous D-Bus call (ignoring the
return value). They also modify the content of the cache client-side,
bypassing the information that we receive via notifications from the
server.

Also, they don't emit property changed signals, but in any case they
are broken beyond repair.

Fully mark them as deprecated. Note that they were already marked as
_NM_DEPRECATED_SYNC_METHOD. However, that does not actually mark
the API as deprecated, because fully deprecating all synchronous
methods is premature at this point.
2019-11-07 11:34:36 +01:00
Thomas Haller
9c01d6ca67 libnm: print timestamp in LIBNM_CLIENT_DEBUG debug logging
It's useful, because it's easy to get overwhelemed by the logging output.
The timestamp makes it easier to keep track. Also, it allows to see how long
things take.
2019-11-07 11:34:36 +01:00
Thomas Haller
1463450393 all: use nm_dbus_path_not_empty() 2019-11-07 11:34:36 +01:00
Thomas Haller
88ef02ec33 shared/tests: add nmtst_main_context_iterate_until() helper 2019-11-07 11:34:36 +01:00
Thomas Haller
afa54fdfd5 shared: add nm_g_main_context_push_thread_default*() and nm_auto helper 2019-11-07 11:34:36 +01:00
Thomas Haller
3b95905ae3 shared: add nm_auto_destroy_and_unref_gsource macro 2019-11-07 11:34:36 +01:00
Thomas Haller
01335ecec6 shared: assert in nm_ref_string_unref() for valid NMRefString instance 2019-11-07 11:34:36 +01:00
Thomas Haller
15fe8ad851 shared: add nm_dbus_path_not_empty() helper 2019-11-07 11:34:36 +01:00
Thomas Haller
9b2d5742c1 shared: add nm_g_set_error_take*() util 2019-11-07 11:34:36 +01:00
Thomas Haller
d21439eaa0 shared: add nm_ppdirect_hash()/nm_ppdirect_equal() helpers
Useful for hashing pointers to a pointer to a pointer, and
compare the resulting pointer directly. This will be actually
used.
2019-11-07 11:34:36 +01:00
Thomas Haller
86352ceaf8 shared: add NM_STRUCT_OFFSET_ENSURE_TYPE() helper 2019-11-07 11:34:36 +01:00
Thomas Haller
4a870c57f5 nmcli/tests: fix broken test after "nmcli: show IP interface name when doing 'nmcli connection show <PROFILE>'"
Fixes: 303fc17450 ('nmcli: show IP interface name when doing 'nmcli connection show <PROFILE>'')
2019-11-07 09:36:11 +01:00
Antonio Cardace
303fc17450 nmcli: show IP interface name when doing 'nmcli connection show <PROFILE>'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/218

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/322
2019-11-06 21:08:23 +01:00
Thomas Haller
e2dac63de6 libnm: fix handling "q" (uint16) property types in libnm
NMDeviceVxlan has some "q" type properties. They were not handled:

    $ G_MESSAGES_DEBUG=all PAGER= LIBNM_GLIB_DEBUG=properties-changed nmcli 2>&1 | grep "couldn't be set from D-Bus type"
    libnm-Message: 10:44:04.538: demarshal_generic: NMDeviceVxlan:dst-port (type guint) couldn't be set from D-Bus type q.
    libnm-Message: 10:44:04.538: demarshal_generic: NMDeviceVxlan:src-port-max (type guint) couldn't be set from D-Bus type q.
    libnm-Message: 10:44:04.538: demarshal_generic: NMDeviceVxlan:src-port-min (type guint) couldn't be set from D-Bus type q.
    libnm-Message: 10:44:04.539: demarshal_generic: NMDeviceWireGuard:listen-port (type guint) couldn't be set from D-Bus type q.
2019-11-06 17:30:25 +01:00
Thomas Haller
ea8546b622 libnm/license: relicense "libnm-core/nm-json.[hc]" under LGPL-2.1+
The only contributors to this code are Red Hat employees who agree
with this license change.

  $ git log --pretty=format:'%Cred%h%Creset - %Cgreen(%ai)%Creset [%C(yellow)%an%Creset] %s%C(yellow)%d%Creset' --no-merges -- 'libnm-core/nm-json.?' 'libnm-core/nm-jansson.?'
  ...

  $ git shortlog -s --no-merges -- 'libnm-core/nm-json.?' 'libnm-core/nm-jansson.?'
     1    Beniamino Galvani
     1    Lubomir Rintel
     8    Thomas Haller

Signed-off-by: Beniamino Galvani <bgalvani@redhat.com>
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2019-11-06 17:30:25 +01:00
Beniamino Galvani
14992ab9cd acd: poll the acd fd after starting the announcements
In nm_acd_manager_announce_addresses() we should not only start the
probes but also add the acd file descriptor to the main loop.
Otherwise, a timer is armed to send the announcements but it never
fires and no announcements are sent.

Fixes: d9a4b59c18 ('acd: adapt NM code and build options')

https://bugzilla.redhat.com/show_bug.cgi?id=1767681
2019-11-06 16:37:59 +01:00
Beniamino Galvani
551fd3e28f libnm: adjust symbol versioning after backporting 802-1x.optional to 1.20.6
NM 1.22 is not released yet and 1.20.6 will happen before 1.22.0, so
we can introduce the new API with version libnm_1_20_6 in both
releases without having duplicate symbols on 1.22.
2019-11-06 13:39:54 +01:00
Lubomir Rintel
c820c98f2a clients: draw border around qr code on linux console
Scanners won't recognize it on black background otherwise.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/327
2019-11-05 16:32:20 +01:00
Lubomir Rintel
8eb20013ab merge: branch 'sharkcz/s390-initrd'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/317
2019-11-04 16:22:54 +01:00
Lubomir Rintel
927ae6d927 initrd/tests: test that we generate the s390 interface names correctly 2019-11-04 16:22:14 +01:00
Dan Horák
22e388d90e initrd: handle rd.znet with legacy interface names
Handle rd.znet with legacy interface names too, the index for eth or ctc
corresponds to the position on the command line.
2019-11-04 16:22:14 +01:00
Dan Horák
c7423dca89 initrd: prepare interface in rd.znet only if persistent interface names are enabled
When processing the rd.znet option set the interface name only in case when
the persistent interface names feature isn't disabled via net.ifnames=0

[lkundrak@v3.sk: minor tweaks to the net.ifnames=0 parsing]
2019-11-04 16:21:58 +01:00
Dan Horák
c27f5030e9 initrd/tests: use a valid combination of device and interface name for testing 2019-11-04 16:21:16 +01:00
Dan Horák
adcc52c3da initrd: use proper interface when adding s390 specific details
The current solution for s390 specific details relies on an interface to
exist before adding the s390 details. It means the ip= option must precede
the rd.znet= option. Also only a single interface can be configured. With
this change the s390 details are put to the right interface and properly
named interface is created if it hasn't existed yet.
2019-11-04 15:44:58 +01:00
Lubomir Rintel
4e34807a8c release: bump version to 1.21.3-dev 2019-11-03 09:01:30 +01:00
Lubomir Rintel
c2ec79217a merge: branch 'lr/fix-iwd-1-0'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/325
2019-11-03 08:54:56 +01:00
Lubomir Rintel
186d22a963 iwd: unbreak iwd-1.0
The upstream apparently thought it's a great idea to change the agent
manager path. This fixes things for those unfortunate enough to run
IWD.
2019-11-03 07:51:24 +01:00
Lubomir Rintel
59923ad85d iwd: add some missing error handling
g_dbus_object_manager_get_interface() can happily return NULL and we
need to check for that.
2019-11-02 07:02:59 +01:00
worldofpeace
e1ead6fa98 build: add PPPD_PATH to config.h.meson
Without this using -Dpppd= was completely broken.

First observed in NixOS [0]

[0]: https://github.com/NixOS/nixpkgs/issues/72330

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/323
2019-11-01 07:25:26 +01:00
Lubomir Rintel
9242b5ebc1 po/de: fix quoting 2019-10-31 07:23:24 +01:00
Lubomir Rintel
e63b2afe7c clients/cli: give some hints to the translators 2019-10-30 17:15:14 +01:00
Thomas Haller
4340f6111a po: merge branch with translation fixes for German
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/320
2019-10-30 16:55:02 +01:00
maxbachmann
777ccb79a4 fix translation 2019-10-30 16:54:41 +01:00
maxbachmann
5535dcf51b po/de: fix some spelling mistakes
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/320
2019-10-30 14:54:08 +01:00
Lubomir Rintel
35e4e106cb merge: branch 'lr/hotspot-reuse'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/305
2019-10-30 14:32:46 +01:00
Lubomir Rintel
9c5ea0917d devices: reuse the hotspot connection if we find appropriate one
Otherwise repeated "nmcli d wifi hotspot" commands create multiple
Hostpot connections, which is just sad. We do already reuse existing
connections with "nmcli d wifi connect" -- let's just do a similar thing
here.
2019-10-30 14:29:38 +01:00
Lubomir Rintel
9f5711bec4 cli: split off the update or add-and-activate logic 2019-10-30 14:08:57 +01:00
Thomas Haller
074e5503d7 libnm: merge branch 'th/libnm-various-fixes'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/319
2019-10-27 14:31:05 +01:00
Thomas Haller
0dfabef46e libnm: add and use _nml_coerce_property_*()
Our NMObject implementations should behave in a similar manner.
For example, string properties should be coerced the a consistent
manner.

Add functions _nml_coerce_property_*() for that. Of course, they
are trivial. Their value is not that they encapsulate some complex
implementation, but that they convey a general concept of how we
want to handle certain properties in NMClient's object cache.
2019-10-27 14:30:51 +01:00