Commit Graph

21088 Commits

Author SHA1 Message Date
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
Beniamino Galvani
d978258924 dns: merge branch 'bg/dns-bgo746422'
https://bugzilla.gnome.org/show_bug.cgi?id=746422
2018-05-14 15:25:27 +02:00
Beniamino Galvani
1fbadecdbc libnm-core: document dns priority 2018-05-14 15:22:50 +02:00
Beniamino Galvani
5df69330b5 dns: sd-resolved: honor dns-priority
Honor dns-priority by using the preprocessed list of domains provided
by the manager.
2018-05-14 15:22:50 +02:00
Beniamino Galvani
6409e7719c dns: dnsmasq: honor dns-priority
Honor dns-priority by using the preprocessed list of domains provided
by the manager.
2018-05-14 15:22:50 +02:00
Beniamino Galvani
dd1e671fe5 dns: use dns-priority to provide a preprocessed domain list to plugins
Do some preprocessing on the DNS configuration sent to plugins:

 - add the '~' default routing (lookup) domain to IP configurations
   with the default route or, when there is none, to all non-VPN
   IP configurations

 - use the dns-priority to decide which connection to use in case
   multiple connections have the same domain

 - consider a negative dns-priority value as a way to 'shadow' all
   subdomains from other connections

 - compute reverse DNS domains

and add the resulting domain list to NMDnsIPConfigData so that
split-DNS plugins can use that directly instead of reimplementing the
same logic themselves.
2018-05-14 15:22:50 +02:00
Beniamino Galvani
82ebfa7351 core: reject invalid domains from ip configurations
Reject domains containing ".." or starting with "."
2018-05-14 15:22:50 +02:00
Beniamino Galvani
14b6e330e2 dns: dnsmasq: fix adding multiple domains
Fixes: e91f1a7d2a
2018-05-14 15:22:50 +02:00
Beniamino Galvani
db80d5f62a build: meson: add missing nm-autoptr.h to libnm headers
Fixes: ff8e563365

https://bugzilla.gnome.org/show_bug.cgi?id=795965
2018-05-11 18:20:24 +02:00
Thomas Haller
b87dc5630a cli: merge branch 'th/cli-unit-tests'
https://github.com/NetworkManager/NetworkManager/pull/110
2018-05-11 16:53:49 +02:00
Thomas Haller
6d34d5e41b tests: refactor finding device in NetworkManager stub
- add find_devices() and find_device_first() functions,
  to not re-implement iterating the device list.

- for test functions, accept the device's "ident", instead
  of ifname. The "ident" must b unique, contrary to the "ifname".
2018-05-11 16:51:20 +02:00
Thomas Haller
d4093a3a2c clients/tests: add python test script for nmcli tests
Add a test which runs nmcli against our stub NetworkManager
service and compares the output.

The output formats of nmcli are complicated and not easily understood.
For example how --mode tabular|multiline interacts with selecting
output-fields (--fields) and output modes ([default]|--terse|--pretty).
Also, there are things like `nmcli connection show --order $FIELD_SPEC`.

We need unit tests to ensure that we don't change the output
accidentally.
2018-05-11 16:51:20 +02:00
Thomas Haller
5e6b0382ad build: let make check re-generate clients/common/settings-doc.h.in with NM_TEST_REGENERATE=1
When building with --disable-introspection, we re-use the pre-generated
clients/common/settings-doc.h.in file.

When building with --enable-introspection, we generate
clients/common/settings-doc.h, and let `make check` verify that the
generated file is identical to what we would generate.

The common case where the generated file differ, is when code changed,
in this case, the developer is advised to update settings-doc.h.in.

Interpret environment variable NM_TEST_REGENERATE=1 to do this
automatically during `make check`.

This will be useful, as there might be several tests that compare a
generated file with a file from version control. NM_TEST_REGENERATE=1
will be the general way to re-generate all these files.

  $ NM_TEST_REGENERATE=1 make check
2018-05-11 16:51:20 +02:00
Thomas Haller
9628aabc2f tests: use libnm via pygobject in tools/test-networkmanager-service.py
tools/test-networkmanager-service.py is our NetworkManager stub server.

NetworkManager uses libnm(-core) heavily, for example to decide whether
a connection verifies (nm_connection_verify()) and for normalizing
connections (nm_connection_normalize()).

If the stub server wants to mimic NetworkManager, it also must use these
function. Luckily, we already can do so, by loading libnm using python
GObject introspection.

We already correctly set GI_TYPELIB_PATH search path, so that the
correct libnm is loaded -- provided that we build with introspection
enabled.

We still need to gracefully fail, if starting the stub server fails.
That requries some extra effort. If the stub server notices that
something is missing, it shall exit with status 77. That will cause
the tests to g_test_skip().
2018-05-11 16:51:20 +02:00
Thomas Haller
3934a2c392 build: set LD_LIBRARY_PATH and GI_TYPELIB_PATH variables in run-nm-test.sh
With autotools, we use libtool so that the right libraries are
automatically found. Still, we won't find the right GI typelib.

Add a mechanism so that when make/meson invokes the run-nm-test.sh
runner, it passes the build-root directory.

Also, try to autodetect when invoked manually.
2018-05-11 16:51:20 +02:00
Thomas Haller
11fedad544 tests: minor code cleanup of nmtst_main_loop_run() 2018-05-11 16:51:20 +02:00
Thomas Haller
34122c874e shared: add NM_PID_T_INVAL macro for invalid PIDs 2018-05-11 16:51:20 +02:00
Thomas Haller
286db5049e shared: add nm_auto_unref_gsource cleanup macro 2018-05-11 16:51:20 +02:00
Harry Mallon
fe3db7aed3 doc: fix GTK-Doc NMRoute links
https://mail.gnome.org/archives/networkmanager-list/2018-May/msg00000.html
2018-05-11 16:49:25 +02:00
Lubomir Rintel
62363ebc8f Revert "build: qualify plugin dir name with a version string"
This is broken -- looks for VPN plugins in a version-qualified path,
which is wrong and break installed VPN plugins.

This reverts commit 6384ad4ee1.
2018-05-11 10:41:50 +02:00
Lubomir Rintel
60b6cbff40 merge: branch 'lr/nmcli-colors'
https://github.com/NetworkManager/NetworkManager/pull/105
2018-05-10 14:56:07 +02:00
Lubomir Rintel
bcc9e58bfe cli: allow setting the colors with terminal-colors.d(5)
The present version of the specification is somewhat unclear at times,
Unclear points were discussed with the maintainers [1] and probably
some new version will address those.

https://www.spinics.net/lists/util-linux-ng/msg15222.html

Until then here's how the implementation copes with ambiguities
(after the discussion with util-linux maintainers):

1.) It is unclear whether multiple .schem files should override each
    other or be merged. We use the overriding behavior -- take the
    highest priority one and ignore the rest.

2.) We assume "name.schem" is more specific than "@term.schem".

3.) We assume the "Color name" are to be used as aliases for the color
    sequences and translate them to ANSI escape sequences.

4.) The "Escape sequences" are of no use since the specification
    pretty much assumes an ANSI terminal and none of the sequences make
    any sense in ANSI color codes. We don't support them.
    accept that.

5.) We don't implement TERMINAL_COLORS_DEBUG because it's unspecified
    what should it do.
2018-05-10 14:36:58 +02:00