Commit graph

20162 commits

Author SHA1 Message Date
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
Lubomir Rintel
31aa2cfe29 cli: use a palette to implement coloring
This basically replaces the (NMMetaTermColor, NMMetaTermFormat) combo
with NMMetaColor that describes the colored element semantically as
opposed to storing the raw attributes.

A (currently static) paletted is used to translate the semantic color
code to the actual ANSI controle sequence. This matches what
terminal-colors.d(5) schemes use, making it convenient to implement
customizable palettes.
2018-05-10 14:36:58 +02:00
Lubomir Rintel
9dfe825840 cli: rework enabling and disabling colors
This actually makes very little difference at the moment, but will make
things more confortable later on, when the logic of enabling/disabling
coloring will involve terminal-colors.d(5).

Instead of deciding whether to use colors lazily with use_colors(), it's
done very early on nmcli initialization and a boolean use_colors field
is stored in the NmcConfig instance instead of the raw tristate option
of NmcColorOption type (which is now confined to nmcli.c).

Wherever the NmcColorOption was used previously, the whole NmcConfig
instance is passed around. That might seem pointless (since only the
use_colors boolean is actually used at the moment), but will be utilized
to pass around the actual color palette in future.
2018-05-10 14:36:58 +02:00
Lubomir Rintel
56a5b27389 cli: drop --prompt-color
It's undocumented, useless, somewhat expensive in volume of code and
probably just downright stupid. We'll get a more general way to set
colors.

Hacking in some code to keep this working wouldn't be too difficult, but
it seems entirely pointless.
2018-05-10 14:36:58 +02:00
Lubomir Rintel
30d67c99ea cli: use static initializer for NmCli
It's perhaps but a small improvement here, but will make things a lot
more convenient when the color palette will be added.
2018-05-10 14:36:58 +02:00
Lubomir Rintel
f70abef5c6 cli: drop a useless comment
Thomas doesn't like it and who am I to argue with him.
2018-05-10 14:36:58 +02:00
Lubomir Rintel
bf7529823e cli: do not leave dangling pointers in a global struct
Makes Thomas content and happy..
2018-05-10 14:36:58 +02:00
Lubomir Rintel
e69d386975 all: use the elvis operator wherever possible
Coccinelle:

  @@
  expression a, b;
  @@
  -a ? a : b
  +a ?: b

Applied with:

  spatch --sp-file ternary.cocci --in-place --smpl-spacing --dir .

With some manual adjustments on spots that Cocci didn't catch for
reasons unknown.

Thanks to the marvelous effort of the GNU compiler developer we can now
spare a couple of bits that could be used for more important things,
like this commit message. Standards commitees yet have to catch up.
2018-05-10 14:36:58 +02:00
Lubomir Rintel
f0c1efbf42 all: add and utilize nm_utils_is_separator()
It is meant to be rather similar in nature to isblank() or
g_ascii_isspace().

Sadly, isblank() is locale dependent while g_ascii_isspace() also considers
vertical whitespace as a space. That's no good for configuration files that
are strucutured into lines, which happens to be a pretty common case.
2018-05-10 14:35:52 +02:00
Beniamino Galvani
1829126f3a device: start IP configuration when master carrier goes up
If the master has no carrier in act_stage3_ip6_config_start(), we set
IP state WAIT and wait until carrier goes up before starting IP
configuration.

However, in carrier_changed() if the device state is ACTIVATED we only
call nm_device_update_dynamic_ip_setup(), which just restarts DHCP if
it was already running.

Let's also ensure that we start IP configuration if the IP state is
WAIT.

Fixes: b0f6baad90

https://bugzilla.redhat.com/show_bug.cgi?id=1575944
2018-05-09 14:20:02 +02:00
Lubomir Rintel
8e066af7d5 core-utils: don't load modules not ending with ".so"
This prevents attempts to load garbage from the module directory.
2018-05-09 13:16:59 +02:00
Lubomir Rintel
57e06bc0b8 merge: branch 'lr/version-dir'
https://github.com/NetworkManager/NetworkManager/pull/104
2018-05-09 12:59:57 +02:00
Lubomir Rintel
6384ad4ee1 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.
2018-05-09 12:59:39 +02:00
Lubomir Rintel
6aac441f1c meson: distinguish arch specific and arch neutral lib dir
Plugins go to the arch specific place while conf.d/ and VPN/ are in
lib/. Use the same naming as is used with autoconf.
2018-05-09 12:59:39 +02:00
Lubomir Rintel
84a6010718 meson: quote dist_version properly 2018-05-09 12:59:39 +02:00
Lubomir Rintel
121be232ad session-monitor: avoid an assertion failure if there's no session monitor
The constructor can bail out early, not setting monitor->sd.watch:

  (NetworkManager:373): GLib-CRITICAL **: 20:35:58.601: g_source_remove: assertion 'tag > 0' failed
2018-05-09 12:59:08 +02:00
Beniamino Galvani
9e7a324916 platform: fix adding direct route to gateway
Without ifindex, adding the direct route to gateway fails:

 platform: route-sync: failure to add IPv6 route: fd02::/64 via fd01::1 dev 1635 metric 101 mss 0 rt-src user: No route to host (113); try adding direct route to gateway fd01::1/128 via :: metric 101 mss 0 rt-src user
 platform: route: append     IPv6 route: fd01::1/128 via :: metric 101 mss 0 rt-src user
 platform-linux: delayed-action: schedule wait-for-nl-response (seq 269, timeout in 0.199999195, response-type 0)
 platform-linux: delayed-action: handle wait-for-nl-response (any)
 platform-linux: netlink: recvmsg: new message NLMSG_ERROR, flags 0, seq 269
 platform-linux: netlink: recvmsg: error message from kernel: No such device (19) for request 269

Fixes: c9f89cafdf
2018-05-07 17:15:34 +02:00
Thomas Haller
896ea5252b build: add missing dependencies for building nmcli 2018-05-05 15:28:24 +02:00
Beniamino Galvani
ed817e9ca3 libnm: export nm_connection_get_setting_tc_config()
Fixes: da13c7a1a4
2018-05-05 10:45:33 +02:00
Thomas Haller
30a4fa454d checkpoint: fix D-Bus operation to destroy checkpoint
When passing "/" to destroy all checkpoints, wrongly no
checkpoint was destroyed.

When passing a particular path that should be destroyed,
wrongly all checkpoints were destroyed.

Fixes: 79458a558b
2018-05-03 14:38:10 +02:00
Lubomir Rintel
43e3ebfaa2 build: add a missing dependency
Parallel make failed for me:

  /usr/bin/xsltproc --output man/nm-settings-keyfile.xml ...
    ... man/nm-settings-keyfile.xsl libnm/nm-settings-keyfile-docs.xml
  man/nm-settings-keyfile.xsl:4: warning: failed to load external entity "man/common.ent"
  %entities;
            ^
  man/nm-settings-keyfile.xsl:26: parser error : Entity 'NM_VERSION' not defined
          <refmiscinfo class="version">&NM_VERSION;</refmiscinfo>
                                                   ^
  cannot parse man/nm-settings-keyfile.xsl
  make[2]: *** [Makefile:18130: man/nm-settings-keyfile.xml] Error 4
2018-05-02 14:55:01 +02:00
Lubomir Rintel
2244352583 auth-manager: use the correct function to deallocate a GError
This one ruins the party.
2018-05-02 14:55:01 +02:00
Thomas Haller
b3880b3142 build: fix missing dependency when building clients/tui/newt/libnmt-newt.a
We need to declare explicit dependencies, otherwise, the required header
files may not yet be created when building nmtui helper library.
2018-05-02 13:03:59 +02:00
Beniamino Galvani
37dc58f6c7 libnm: add missing device includes to NetworkManager.h 2018-05-02 09:14:56 +02:00
Thomas Haller
c2bdd44c4d core: merge branch 'th/manager-activation-cleanup'
https://github.com/NetworkManager/NetworkManager/pull/106
2018-05-01 10:45:05 +02:00
Thomas Haller
5ab7f6f108 manager: search all existing active connections during nm_manager_get_best_device_for_connection()
In nm_manager_get_best_device_for_connection(), not only check whether the first found
active-connection has a device. There might be multiple candidates, in which case iterate
over them and figure out which one is the most suitable.

Also, despite the found @ac has the same settings-connection, it does not
mean that the connection is available on the device. Extend the check and
only return compatible and ready devices. This can easily happen that
the settings-connection was modified in the meantime and no longer is
compatible with the device (despite currently being active on the
device, but with the previous settings).
2018-04-30 16:36:30 +02:00
Thomas Haller
f1a58e7517 manager: disconnect all conflicting concurrent active connections in _internal_activate_device()
It is possible, that there are multiple such conflicting connections.
Maybe not now, but with connecition cardinality it will soon be.

Find and disconnect them all.
2018-04-30 16:36:30 +02:00