Commit graph

20409 commits

Author SHA1 Message Date
Thomas Haller 2cae37ca40 clients/tests: test nmcli output for active-connection state DEACTIVATING 2018-05-24 16:40:17 +02:00
Thomas Haller 6f82c880a6 clients/tests: load libnm via GObject introspection
We will use it, and it must be available anyway, because the stub server
also requires it.
2018-05-24 16:40:17 +02:00
Thomas Haller d424de10bf clients/tests: add SetProperties operation to test-networkmanager-service.py stub
It is a hook to set one or several D-Bus properties at once. Properties that are
to be set-able, have to be whitelisted in the stub.
2018-05-24 16:40:17 +02:00
Thomas Haller c834a8e822 tests: don't return path name from obj.get_managed_ifaces() in test-networkmanager-service.py 2018-05-24 16:40:17 +02:00
Thomas Haller 7ae5fb7ec6 clients/tests: test nmcli output for multiple activation of same profile
Activate the same profile on two devices. Arguably, real NetworkManager
(currently) does not allow that. But the D-Bus API is fine with
having multiple ActiveConnections for one SettingsConnection.

So, also the client should do something sensible.

Also, later we will add wildcard support to NetworkManager, which means
that a profile can be active multiple times (simultaneously).
2018-05-24 16:40:17 +02:00
Thomas Haller d5e25a4324 clients/tests: print active fields during nmcli con show 2018-05-24 16:40:17 +02:00
Thomas Haller ea1830a429 clients/tests: add extra_env argument to call_nmcli()
This is purely for (manual) printf debugging. Hence, it is unused in the commited code.
The point is, to add printf statements to nmcli or libnm, like

  if (getenv ("MY_HACK1")) { ...

and trigger it from test-client.py via

  self.call_nmcli(..., extra_env = { 'MY_HACK1': '1' } )
2018-05-24 16:40:17 +02:00
Francesco Giudici 869009ab11 shared/trivial: fix typo on comment 2018-05-24 16:21:28 +02:00
Thomas Haller 591cc60a5b dispatcher: rework creating dispatcher environment
- don't use GSList as intermediate data type to construct
  the environment, especially when all we want is to get
  a strv array at the end. This reverts the order of elements
  compared to previously.

- add and use helper methods _items_add_*() which assert against sensible
  input.

- merge IPv4 and IPv6 implementations for creating the environment.

https://github.com/NetworkManager/NetworkManager/pull/112
2018-05-24 13:07:15 +02:00
Thomas Haller 0c393aff8b build: merge branch 'th/contrib-rpm-use-gnutls'
https://bugzilla.redhat.com/show_bug.cgi?id=1581693
2018-05-24 12:15:27 +02:00
Thomas Haller ebd61e1bc1 contrib/rpm: use gnutls crypto library instead of NSS on rhel-8 and fedora-29
https://bugzilla.redhat.com/show_bug.cgi?id=1581693
2018-05-24 11:36:00 +02:00
Thomas Haller db99b6bba7 build: print used crypto library in ./configure result output
And cleanup handling --with-crypto in configure.ac.
2018-05-24 11:35:59 +02:00
Thomas Haller fb29212fb2 libnm-util/crypto: fix harmless compiler warning
libnm-util/crypto_gnutls.c: In function crypto_encrypt:
  libnm-util/crypto_gnutls.c:245:8: error: variable salt_len set but not used [-Werror=unused-but-set-variable]
    gsize salt_len;
          ^~~~~~~~

See-also: 312c72f761
2018-05-24 11:35:59 +02:00
Thomas Haller 0aff056a63 doc: add units to nm_device_get_mtu() 2018-05-23 16:17:03 +02:00
Harry Mallon 5f62b126d5 doc: add units to some libnm (and libnm-glib) function docs
https://mail.gnome.org/archives/networkmanager-list/2018-May/msg00027.html
2018-05-23 16:17:03 +02:00
Lubomir Rintel 6c2eb953d5 active-connection: fix build with clang-6.0
glib 2.56's g_steal_pointer() won't tolerate a function pointer in place
of a gpointer.

  CC       src/src_libNetworkManager_la-nm-active-connection.lo
    src/nm-active-connection.c:1017:17: error: pointer type mismatch
      ('NMActiveConnectionAuthResultFunc' (aka 'void (*)(struct _NMActiveConnection *,
      int, const char *, void *)') and 'gpointer' (aka 'void *'))
      [-Werror,-Wpointer-type-mismatch]
                result_func = g_steal_pointer (&priv->auth.result_func);
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /usr/include/glib-2.0/glib/gmem.h:200:6: note: expanded from macro 'g_steal_pointer'
    (0 ? (*(pp)) : (g_steal_pointer) (pp))
       ^ ~~~~~~~   ~~~~~~~~~~~~~~~~~~~~~~
  1 error generated.

There's just a single spot we use it that way, so it's perhaps better to
work around the warning instead of disabling it.
2018-05-21 12:02:26 +02:00
Lubomir Rintel 347e3e3689 tests: run the nmcli test with $PYTHON we autoconf'd
Avoids an annoying warning in Fedora:

  |DEPRECATION WARNING: python2 invoked with /usr/bin/python.
      Use /usr/bin/python3 or /usr/bin/python2
      /usr/bin/python will be removed or switched to Python 3 in the future.

Also allows the user to override the Python version that's actually
used.
2018-05-21 10:14:04 +02:00
Thomas Haller 468061419a build/meson: fix building internal systemd library
Fixes: d577888d8f
2018-05-19 15:24:59 +02:00
Thomas Haller d577888d8f systemd: merge branch systemd into master 2018-05-18 17:03:35 +02:00
Thomas Haller ac170893e9 systemd: update code from upstream (2018-05-18)
This is a direct dump from systemd git.

======

SYSTEMD_DIR=../systemd
COMMIT=7fbb5dd5e2cc733a83af813b13e859a8172a6046

(
  cd "$SYSTEMD_DIR"
  git checkout "$COMMIT"
  git reset --hard
  git clean -fdx
)

git ls-files :/src/systemd/src/ \
             :/shared/nm-utils/siphash24.c \
             :/shared/nm-utils/siphash24.h \
             :/shared/nm-utils/unaligned.h | \
  xargs -d '\n' rm -f

nm_copy_sd() {
    mkdir -p "./src/systemd/$(dirname "$1")"
    cp "$SYSTEMD_DIR/$1" "./src/systemd/$1"
}

nm_copy_sd_shared() {
    mkdir -p "./shared/nm-utils/"
    cp "$SYSTEMD_DIR/$1" "./shared/nm-utils/${1##*/}"
}

nm_copy_sd "src/basic/alloc-util.c"
nm_copy_sd "src/basic/alloc-util.h"
nm_copy_sd "src/basic/async.h"
nm_copy_sd "src/basic/escape.c"
nm_copy_sd "src/basic/escape.h"
nm_copy_sd "src/basic/ether-addr-util.c"
nm_copy_sd "src/basic/ether-addr-util.h"
nm_copy_sd "src/basic/extract-word.c"
nm_copy_sd "src/basic/extract-word.h"
nm_copy_sd "src/basic/fileio.c"
nm_copy_sd "src/basic/fileio.h"
nm_copy_sd "src/basic/fd-util.c"
nm_copy_sd "src/basic/fd-util.h"
nm_copy_sd "src/basic/fs-util.c"
nm_copy_sd "src/basic/fs-util.h"
nm_copy_sd "src/basic/hash-funcs.c"
nm_copy_sd "src/basic/hash-funcs.h"
nm_copy_sd "src/basic/hashmap.c"
nm_copy_sd "src/basic/hashmap.h"
nm_copy_sd "src/basic/hexdecoct.c"
nm_copy_sd "src/basic/hexdecoct.h"
nm_copy_sd "src/basic/hostname-util.c"
nm_copy_sd "src/basic/hostname-util.h"
nm_copy_sd "src/basic/in-addr-util.c"
nm_copy_sd "src/basic/in-addr-util.h"
nm_copy_sd "src/basic/io-util.c"
nm_copy_sd "src/basic/io-util.h"
nm_copy_sd "src/basic/list.h"
nm_copy_sd "src/basic/log.h"
nm_copy_sd "src/basic/macro.h"
nm_copy_sd "src/basic/mempool.h"
nm_copy_sd "src/basic/mempool.c"
nm_copy_sd "src/basic/parse-util.c"
nm_copy_sd "src/basic/parse-util.h"
nm_copy_sd "src/basic/path-util.c"
nm_copy_sd "src/basic/path-util.h"
nm_copy_sd "src/basic/prioq.h"
nm_copy_sd "src/basic/prioq.c"
nm_copy_sd "src/basic/process-util.h"
nm_copy_sd "src/basic/process-util.c"
nm_copy_sd "src/basic/random-util.c"
nm_copy_sd "src/basic/random-util.h"
nm_copy_sd "src/basic/refcnt.h"
nm_copy_sd "src/basic/set.h"
nm_copy_sd "src/basic/signal-util.h"
nm_copy_sd_shared "src/basic/siphash24.c"
nm_copy_sd_shared "src/basic/siphash24.h"
nm_copy_sd "src/basic/socket-util.c"
nm_copy_sd "src/basic/socket-util.h"
nm_copy_sd "src/basic/sparse-endian.h"
nm_copy_sd "src/basic/stat-util.c"
nm_copy_sd "src/basic/stat-util.h"
nm_copy_sd "src/basic/stdio-util.h"
nm_copy_sd "src/basic/string-table.c"
nm_copy_sd "src/basic/string-table.h"
nm_copy_sd "src/basic/string-util.c"
nm_copy_sd "src/basic/string-util.h"
nm_copy_sd "src/basic/strv.c"
nm_copy_sd "src/basic/strv.h"
nm_copy_sd "src/basic/time-util.c"
nm_copy_sd "src/basic/time-util.h"
nm_copy_sd "src/basic/umask-util.h"
nm_copy_sd_shared "src/basic/unaligned.h"
nm_copy_sd "src/basic/utf8.c"
nm_copy_sd "src/basic/utf8.h"
nm_copy_sd "src/basic/util.c"
nm_copy_sd "src/basic/util.h"
nm_copy_sd "src/libsystemd-network/arp-util.c"
nm_copy_sd "src/libsystemd-network/arp-util.h"
nm_copy_sd "src/libsystemd-network/dhcp6-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp6-lease-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp6-network.c"
nm_copy_sd "src/libsystemd-network/dhcp6-option.c"
nm_copy_sd "src/libsystemd-network/dhcp6-protocol.h"
nm_copy_sd "src/libsystemd-network/dhcp-identifier.c"
nm_copy_sd "src/libsystemd-network/dhcp-identifier.h"
nm_copy_sd "src/libsystemd-network/dhcp-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp-lease-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp-network.c"
nm_copy_sd "src/libsystemd-network/dhcp-option.c"
nm_copy_sd "src/libsystemd-network/dhcp-packet.c"
nm_copy_sd "src/libsystemd-network/dhcp-protocol.h"
nm_copy_sd "src/libsystemd-network/lldp-internal.h"
nm_copy_sd "src/libsystemd-network/lldp-neighbor.c"
nm_copy_sd "src/libsystemd-network/lldp-neighbor.h"
nm_copy_sd "src/libsystemd-network/lldp-network.c"
nm_copy_sd "src/libsystemd-network/lldp-network.h"
nm_copy_sd "src/libsystemd-network/network-internal.c"
nm_copy_sd "src/libsystemd-network/network-internal.h"
nm_copy_sd "src/libsystemd-network/sd-dhcp6-client.c"
nm_copy_sd "src/libsystemd-network/sd-dhcp6-lease.c"
nm_copy_sd "src/libsystemd-network/sd-dhcp-client.c"
nm_copy_sd "src/libsystemd-network/sd-dhcp-lease.c"
nm_copy_sd "src/libsystemd-network/sd-ipv4ll.c"
nm_copy_sd "src/libsystemd-network/sd-ipv4acd.c"
nm_copy_sd "src/libsystemd-network/sd-lldp.c"
nm_copy_sd "src/libsystemd/sd-event/sd-event.c"
nm_copy_sd "src/libsystemd/sd-id128/id128-util.c"
nm_copy_sd "src/libsystemd/sd-id128/id128-util.h"
nm_copy_sd "src/libsystemd/sd-id128/sd-id128.c"
nm_copy_sd "src/shared/dns-domain.c"
nm_copy_sd "src/shared/dns-domain.h"
nm_copy_sd "src/systemd/_sd-common.h"
nm_copy_sd "src/systemd/sd-dhcp6-client.h"
nm_copy_sd "src/systemd/sd-dhcp6-lease.h"
nm_copy_sd "src/systemd/sd-dhcp-client.h"
nm_copy_sd "src/systemd/sd-dhcp-lease.h"
nm_copy_sd "src/systemd/sd-event.h"
nm_copy_sd "src/systemd/sd-ndisc.h"
nm_copy_sd "src/systemd/sd-id128.h"
nm_copy_sd "src/systemd/sd-ipv4acd.h"
nm_copy_sd "src/systemd/sd-ipv4ll.h"
nm_copy_sd "src/systemd/sd-lldp.h"
2018-05-18 16:58:03 +02:00
Francesco Giudici 5e8c12eece active-connection: fix harmless typo 2018-05-18 10:22:32 +02:00
Frederic Danis 227e179560 devices/wwan: Stop PPP manager in deactivate_cleanup()
When ModemManager exits, pppd is not killed due to nm_exported_object not
unexported (ppp_manager refcount = 2).
Call to nm_ppp_manager_stop_sync() allows to correctly clean ppp_manager
before calling g_clear_object(), as this is done in nm-device-ethernet.c and
nm-device-adsl.c.

[thaller@redhat.com: rebase and adjust patch]

https://bugzilla.gnome.org/show_bug.cgi?id=796108

https://mail.gnome.org/archives/networkmanager-list/2018-May/msg00015.html
2018-05-18 09:51:29 +02:00
Thomas Haller 641c111277 dispatcher: fix leak in construct_device_dhcp4_items()
Fixes: c86d0b4722
2018-05-16 18:13:17 +02:00
Thomas Haller c86d0b4722 dispatcher: extra sanitize names of environment variables
The DHCP options should already be sanitized. Still, make sure we don't
create a bogus environment.
2018-05-16 08:46:52 +02:00
Thomas Haller 009b7d61ad core: minor cleanup using helpers NM_IN_STRSET() and nm_utils_strdict_get_keys() 2018-05-16 08:45:42 +02:00
Thomas Haller c905ee94f0 tests: fix quitting mainloop in test-networkmanager-service.py
Previously, the callbacks would return gl.mainloop.quit(), which is None
and thus the source got removed already. The later GLib.source_remove()
would thus use an invalid source-id.

Fix that, by no removing the source id from the callback.

Fixes: b1ff82eba5
2018-05-15 11:44:47 +02:00
Thomas Haller d66b277471 cli: merge branch 'th/cli-connection-handling' (part 1)
https://github.com/NetworkManager/NetworkManager/pull/100
2018-05-15 11:01:01 +02:00
Thomas Haller 2ef24490a3 tests: explicitly export/unexport objects
Instead of exporting exported-objects during construction, export
them right before we register them (for example, in case of device
instances, before we add the device to the manager's device list).

Likewise, when removing the object from the list, always explicitly
unexport them.

Without explicitly unexporting the objects, they can also not be
removed, because object-manage and D-Bus library keep references
to them.
2018-05-15 10:32:02 +02:00
Thomas Haller 39118a1f42 tests/trivial: move code 2018-05-15 10:06:38 +02:00
Thomas Haller b1ff82eba5 tests: rework handling of D-Bus properties in NetworkManager stub service
Instead of registering a __get_props() function which constructs the
entire hash anew each time, register a props dictionary. This dictionary
is used as cache for the properies.

In most cases, we don't need to additionally cache the properties
outside the props dictionary. Also, add _dbus_property_set() which
sets the property and emits the notification.

Also, cleanup the property names by giving them a PRP_ prefix.
2018-05-15 10:04:13 +02:00
Thomas Haller fc475f25f2 cli: use macro for list of argument for NmcMetaGenericInfo.get_fcn()
The reasons are:

- I want to locate all implmenetations of the get_fcn() handler. By
  consistently using this macro, you can just grep for the macro and
  find them all.

- all implementations should follow the same style. This macro
  enforces the same names for arguments and avoids copy&paste.

- if we are going to add or change an argument, it becomes easier.
  That's because we can easily identify all implementation and can
  change arguments in one place.
2018-05-14 17:53:03 +02:00
Thomas Haller 5975e4a39e cli: add helper methods for implementing NmcMetaGenericInfo's get_fcn() 2018-05-14 17:53:03 +02:00
Thomas Haller 69d5fc9bce cli: add and use macro for creating NmcMetaGenericInfo parent groups 2018-05-14 17:53:03 +02:00
Thomas Haller 0cba6bf1d2 cli/trivial: move code
These helper function will be needed in the next commit to be earlier.
Helper functions like these, that operate solely on trival types (in
this case, converting an enum to a string), make generally sense to have
at the beginning of the source file. Because they themself have few/no
dependencies and are rather trivial and self contained.
2018-05-14 17:53:03 +02:00
Thomas Haller 4b3297271e cli: rework connection handling for multiple results
Functions like nmc_find_connection() and nmc_find_active_connection()
can easily find multiple matching results. For example, the
"connection.id" in NetworkManager is not enforced to be unique,
so if the user adds multiple connections with the same name,
they should be all selected.

The previous API had a @pos argument, that allowed to iterate over
the results. Change that, to return all matches in a GPtrArray.

Also, extend connection-show and other places, to anticipate that
a connection might be active multiple times in any moment.
2018-05-14 17:53:03 +02:00
Thomas Haller 4029d4df0c cli: rework converting enums to strings in "connections.c"
Also, let the enum2str function return a non-translated string.
The user may choose to call gettext() on it.
2018-05-14 17:53:03 +02:00
Thomas Haller 5e34a4b424 cli: move find_active_connection() to common.c
Beside nmc_find_connection(), which is very similar.

Also, drop unused argument @cons.
2018-05-14 17:53:03 +02:00
Thomas Haller f0a2686545 cli: cleanup code paths in "connections.c" 2018-05-14 17:53:03 +02:00
Thomas Haller 2f50c8d915 clients/common: add nmc_objects_sort_by_path() helper 2018-05-14 17:53:03 +02:00
Thomas Haller 7ba3f4f35b shared: add nm_utils_dbus_path_cmp() helper
At various places we sort our D-Bus paths. For example,
server sorts them before exporting them on D-Bus.

Server knows well, that a lot of these paths are build
by attaching an incrementing number as last component.
It looks nicer to sort by this number, instead of strictly
lexical with strcmp().

Note that this handles the cases correctly where paths have
different prefixes, or where they don't end with a number.
2018-05-14 17:53:03 +02:00
Thomas Haller 3b0d50475b shared: add nm_utils_dbus_path_get_last_component() helper 2018-05-14 17:53:03 +02:00
Thomas Haller bb649fc3cd shared: add nm_utf8_collate0() helper
Like g_utf8_collate(), which complains about NULL strings.
2018-05-14 17:53:03 +02:00
Thomas Haller 8d5febbb38 shared: add NM_CMP_DIRECT_STRCMP0() macro 2018-05-14 17:53:03 +02:00
Thomas Haller 15071e4741 clients/tests: add nmcli test for activating connection
Add a test to call `nmcli con up`, and also how the activated
state looks afterwards.
2018-05-14 17:53:03 +02:00
Thomas Haller 7224461069 clients/tests: add more checks for output of nmcli by language
Let the computer do the hard stuff. Since we already call the tests,
why only check for one language?
2018-05-14 17:53:03 +02:00
Thomas Haller 0d302caab8 tests: better implement ActivateConnection in NetworkManager stub service
Transition the states, so that `nmcli con up` can succeed.
2018-05-14 17:53:03 +02:00
Thomas Haller f563a6dfeb tests: various refactoring in tools/test-networkmanager-service.py
- no more global variables, except those in the new variable "gl".

- don't pass that bus instance around. Use the singleton gl.bus.

- separate creation of ExportedObj from exporting on D-Bus.

- use enum values loaded from NM via GObject introspection.

- the visible change is that the generated D-Bus paths now start
  counting at one. That is also how NetworkManager behaves, and
  it looks nicer to have no zero ID for an object.
2018-05-14 17:53:03 +02:00
Thomas Haller beca21be80 clients/tests: add test for nmcli device wifi output
Thereby, drop unneeded NM_TEST_CLIENT_IN_DBUS_SESSION=0 environment
variable from Makefile.am.
2018-05-14 17:53:03 +02:00
Lubomir Rintel 320422e4cf build: qualify plugin dir name with a version string
This makes package updates more robust, avoiding in-place replaces of
the plugins.

Previously, if an upgrade transaction was terminated, NetworkManager
library could end up being of a different version than the plugins.
If the user was unfortunate enough to connect using a connection that
required a plugin (say, Wi-Fi), he would be left without a network
connection making it somewhat inconvenient to recover from the botched
upgrade.

This makes the whole situation a little bit less sad.

The VPN plugins are kept where they always have been -- the path is not
qualified with a version number.
2018-05-14 16:05:12 +02:00
Lubomir Rintel bade13129b contrib/rpm: optionally depend on iwd
When built with iwd support, add an option to use iwd in place of
wpa_supplicant.

The "boolean dependencies" are only supported since RPM 4.13, with older
versions just keep things the way they were before.
2018-05-14 15:36:56 +02:00