Commit graph

364 commits

Author SHA1 Message Date
Thomas Haller 85c6ab97ef
tools: add debug printf statements to "tools/generate-docs-nm-settings-docs-merge.py"
It's hard to understand what "tools/generate-docs-nm-settings-docs-merge.py"
does. Add dbg() statements that are all NOP by default. But the user can
easily patch the code to print what is happening. This is only for
debugging the script.
2021-06-09 12:46:32 +02:00
Thomas Haller 26f0fb0604
python: remove unused imports
They are flagged by lgtm.com. Avoid the warning by dropping unused
includes.
2021-05-27 08:52:30 +02:00
Thomas Haller c3d3429916
tools: drop spurious whitespace in "src/libnm-client-impl/nm-property-infos-*.xml"
<nm-setting-docs>
  -  <setting name="6lowpan">
  +<setting name="6lowpan">
   </setting>
2021-05-26 15:33:29 +02:00
Wen Liang c3504f7e62
Rewrite ./tools/generate-docs-nm-property-infos.py with XML library
Instead of writing XML text word by word, it is less error prone to
write with XML library.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-05-20 10:41:20 +02:00
Wen Liang dd38eb1f76
Adjust property tag format in nm-property-infos-*.xml
In order to make the generated XML file format consistent before and
after using XML library, adjust `property` tag format.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-05-20 10:41:19 +02:00
Thomas Haller c34e36bb8d
Revert "Rewrite ./tools/generate-docs-nm-property-infos.py with XML library"
This breaks build on RHEL7, probably due to an older python version.
Revert for now.

This reverts commit a83fb33840.
2021-05-18 16:00:25 +02:00
Wen Liang a83fb33840
Rewrite ./tools/generate-docs-nm-property-infos.py with XML library
Instead of writing XML text word by word, it is less error prone to
write with XML library.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-05-17 23:28:56 +02:00
Wen Liang 403d776730
Remove unnecessary escaping for single quote
When writing XML text with XML library, single quote will not be
escaped. So remove the escaping for single quote in current tool.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-05-17 23:28:56 +02:00
Wen Liang f6e52708a2
Add paired property tag to nm-property-infos-*.xml
In order to make the generated XML file format consistent before and
after using XML library, replace self-closing `property` tag with
paired `property` tag.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-05-17 23:28:56 +02:00
Wen Liang 90422ddd1a
Remove line breaks in attribute value of nm-property-infos-*.xml
Since line breaks are not needed for XML's attribute tag, remove the
unnecessary line breaks.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-05-17 23:28:56 +02:00
Thomas Haller b6a195cf81
tools: remove deprecated PropertiesChanged signal in "test-networkmanager-service.py" 2021-05-14 10:57:35 +02:00
Wen Liang 86dcb31ab3
build: replace ./tools/generate-docs-nm-property-infos.pl with python script
In order to have more structured settings in man page and make it more
manageable to generate the docbook, it is recommended to use python
script to replace `./tools/generate-docs-nm-property-infos.pl` (this
tool is used to parse the comment section starting with `---nmcli---`,
`---dbus---`, `---keyfile---`, `---ifcfg-rh---`).

Signed-off-by: Wen Liang <liangwen12year@gmail.com>

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/824
2021-05-05 15:28:17 +02:00
orbea 68913466af
tools: use libtool --mode=execute
Better fix for https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/732

The original issue was that when compiling NetworkManager with slibtool
the create-exports-NetworkManager.sh script gave the NetworkManager-all-sym
slibtool wrapper script to nm(1) instead of the actual binary. This is
because slibtool and GNU libtool do not place the compiled programs in
the same location. The original fix was to test both locations, but this
is bit of a hack especially since the build system should not be using the
.libs directory directly. However with $(LIBTOOL) --mode=execute this is
not a problem since both implementations can figure out where the correct
binary is.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/805
2021-04-04 09:27:35 +02:00
Thomas Haller d8dd6e94e6
tui: move from "clients/tui/" to "src/nmtui/" 2021-03-15 17:10:54 +01:00
Thomas Haller 61f99307c6
cli: move from "clients/cli/" to "src/nmcli/" 2021-03-15 17:10:54 +01:00
Thomas Haller 7767aaaee2
build: move "clients/nm-online.c" to "src/nm-online/" 2021-03-02 08:38:26 +01:00
Thomas Haller 54976f23cd
build: move "clients/common/" to "src/libnmc-{base,setting}/" 2021-03-02 08:38:25 +01:00
Thomas Haller 9bba4871f3
build: move "libnm/" to "src/" and split it
Like with "libnm-core/", split "libnm/" into different directories for
the public headers, for the implementation and for the helper "aux"
library.
2021-02-24 12:48:37 +01:00
Thomas Haller 4d12a6ac3d
build: move "shared/nm-{base,udev-aux}" to "src/libnm-{base,udev-aux}" 2021-02-24 12:48:19 +01:00
Thomas Haller fdf9614ba7
build: move "libnm-core/" to "src/" and split it
"libnm-core/" is rather complicated. It provides a static library that
is linked into libnm.so and NetworkManager. It also contains public
headers (like "nm-setting.h") which are part of public libnm API.

Then we have helper libraries ("libnm-core/nm-libnm-core-*/") which
only rely on public API of libnm-core, but are themself static
libraries that can be used by anybody who uses libnm-core. And
"libnm-core/nm-libnm-core-intern" is used by libnm-core itself.

Move "libnm-core/" to "src/". But also split it in different
directories so that they have a clearer purpose.

The goal is to have a flat directory hierarchy. The "src/libnm-core*/"
directories correspond to the different modules (static libraries and set
of headers that we have). We have different kinds of such modules because
of how we combine various code together. The directory layout now reflects
this.
2021-02-18 19:46:51 +01:00
Thomas Haller b13a2b27e9
all: move shared/nm-meta-setting.[hc] to libnm-core and clients
"shared/nm-meta-setting.[hc]" contains meta data about settings.
As such it is similarly used by libnm-core (as internal API) and
by clients (as extension of public API of libnm). However, it must
be compiled twice, because while it defines in both cases a
NMMetaSettingInfo type, these types are different between internal and
public API.
Hence, the files must also be compiled twice (and differently), once
against libnm-core and once against the client helper library.

Previously, the file was under "shared/", but there it's a bit odd
it doesn't clearly belong anywhere.

There are two goals here:

 - copy the file to the two places where it is used. We also have
   a "check-tree" unit test that ensures those files don't diverge in
   the future.

 - we no longer require CFLAGS set during built. Instead, the sources
   should control the build. For that we have new (simple) headers
   "nm-meta-setting-base.h" that define the right behavior for the
   impl files.

There is still an ugliness (among several): the files must be named the
same for libnm-core and clients/common. Preferably, all our sources have
unique names, but that is not possible with this scheme (without
introducing other ugliness). To mitigate that, include the files only at
one exact place.
2021-02-09 12:38:19 +01:00
Thomas Haller 83a97f887b
tests: add "tools/check-tree.sh" script for checking consistency of sources
Our source tree also has certain consistency requirements. Since the
source is in git, this is a rather static check. However, we want to
ensure that future changes don't break it by adding a test.
2021-02-09 12:38:18 +01:00
Thomas Haller ac1a9e03e4
all: move "src/" directory to "src/core/"
Currently "src/" mostly contains the source code of the daemon.
I say mostly, because that is not true, there are also the device,
settings, wwan, ppp plugins, the initrd generator, the pppd and dhcp
helper, and probably more.

Also we have source code under libnm-core/, libnm/, clients/, and
shared/ directories. That is all confusing.

We should have one "src" directory, that contains subdirectories. Those
subdirectories should contain individual parts (libraries or
applications), that possibly have dependencies on other subdirectories.
There should be a flat hierarchy of directories under src/, which
contains individual modules.

As the name "src/" is already taken, that prevents any sensible
restructuring of the code.

As a first step, move "src/" to "src/core/". This gives space to
reorganize the code better by moving individual components into "src/".

For inspiration, look at systemd's "src/" directory.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/743
2021-02-04 09:45:55 +01:00
Thomas Haller 81369ac83c
libnm/docs: hook up new nm-keyfile API in libnm documentation (fix)
Fixes: 25d64c861c ('libnm/docs: hook up new nm-keyfile API in libnm documentation')
2021-02-02 16:14:04 +01:00
Frederic Martinsons 38331fc02c
tests: add a dbus test function to change delay of active connection state change
Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/740
2021-02-02 10:42:33 +01:00
Thomas Haller 484b699c78
tools/tests: add usage to "tools/run-nm-test.sh"
Also support specifying the test name after "--".
2021-01-29 08:43:11 +01:00
orbea e643662348
tools: find the NetworkManager-all-sym binary location
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/732
2021-01-26 19:34:00 +01:00
Thomas Haller 462668b0c3
tools: fix parameters to "tools/run-nm-test.sh" in mixed order
Fixes: 608b5f0515 ('tools: parse parameters to "tools/run-nm-test.sh" in mixed order')
2021-01-22 13:15:27 +01:00
Thomas Haller 608b5f0515
tools: parse parameters to "tools/run-nm-test.sh" in mixed order
When "tools/run-nm-test.sh" is called from the build scripts,
it has as first argument "--called-from-make". Then all arguments
must follow in a well defined order, which autotools/meson understand
and follow.

Another main use is however to call "tools/run-nm-test.sh" form the command
line. In that case, we want to have the command line parsing convenient.

Some of the parameters to the script are interpreted by the script, and
some are passed on to the test. The user can use "--" to separate the
parameters:

   ./tools/run-nm-test.sh -m shared/nm-glib-aux/tests/test-shared-general -- -p /general/test_strv_cmp

Otherwise, on the first unknown argument "tools/run-nm-test.sh" would
assume all following arguments are for the test. So this worked too:

   ./tools/run-nm-test.sh -m shared/nm-glib-aux/tests/test-shared-general -p /general/test_strv_cmp

However, if you now want to run the test with valgrind, you need to edit
the command line before the test arguments, like

   ./tools/run-nm-test.sh -m shared/nm-glib-aux/tests/test-shared-general -v -p /general/test_strv_cmp

That is inconvenient because I call the script from the shell history and
the cursor is at the end of the line. Instead, assume that all unknown parameters
are for the test (until "--" is encountered).

Now this works:

   ./tools/run-nm-test.sh -m shared/nm-glib-aux/tests/test-shared-general -p /general/test_strv_cmp -v

Arguably, now also

   ./tools/run-nm-test.sh -m shared/nm-glib-aux/tests/test-shared-general -p -v /general/test_strv_cmp

works, which is a bid odd.
2021-01-22 12:13:33 +01:00
Thomas Haller 977ea352a0
all: update deprecated SPDX license identifiers
These SPDX license identifiers are deprecated ([1]). Update them.

[1] https://spdx.org/licenses/

  sed \
     -e '1 s%^/\* SPDX-License-Identifier: \(GPL-2.0\|LGPL-2.1\)+ \*/$%/* SPDX-License-Identifier: \1-or-later */%' \
     -e '1,2 s%^\(--\|#\|//\) SPDX-License-Identifier: \(GPL-2.0\|LGPL-2.1\)+$%\1 SPDX-License-Identifier: \2-or-later%' \
     -i \
     $(git grep -l SPDX-License-Identifier -- \
         ':(exclude)shared/c-*/' \
         ':(exclude)shared/n-*/' \
         ':(exclude)shared/systemd/src' \
         ':(exclude)src/systemd/src')
2021-01-05 09:46:21 +01:00
Thomas Haller d07cd5dbf2
all: avoid GNU "which" from shell scripts
"which" is a separate package and may not be installed.
Also, shell has a built-in command for the same purpose.
Use that.
2020-12-11 16:42:23 +01:00
Thomas Haller b9d4026f85
tools: improve detection of "ci-fairy" command in "tools/check-gitlab-ci.sh"
The previous implementation would print

    ./tools/check-gitlab-ci.sh: line 22: ci-fairy: command not found

also, it's not nice to execute the program, just to find out whether
we have it.
2020-12-11 16:08:47 +01:00
Thomas Haller 76f3cf41ac
tests: allow to skip check-local-gitlab-ci via "$NMTST_SKIP_CHECK_GITLAB_CI"
This will be used on our gitlab-ci tests. We do have a separate,
dedicated test on gitlab-ci for checking that "gitlab-ci.yml" is
correct.

We may intentionally want to violate that condition, but then our
`make check` should not fail.

Add a way to skip that test.
2020-12-11 16:08:46 +01:00
Thomas Haller bef8166893
build: add make-check step to check and generate ".gitlab-ci.yml" 2020-11-17 13:19:14 +01:00
Thomas Haller 62411390e2
build: rename "tools/check-settings-docs.sh" to "check-compare-generated.sh"
It's a better name, because the script merely compiles files and
is not specific to "settings-docs.h".
2020-11-03 15:41:39 +01:00
Thomas Haller 82ebd73bec
build: cleanup "tools/check-settings-docs.sh" script 2020-11-03 15:41:39 +01:00
Thomas Haller 85a60f9d53
tools: fix "check-config-options.sh" for detecting multiple NM_CON_DEFAULT() on one line
If there are multiple NM_CON_DEFAULT() mentionings on the same line,
previously the script would not parse them all. Adjust, by first wrapping
the line.
2020-10-30 16:52:55 +01:00
Frederic Martinsons c8b13dc92f
Manage deactivation of active connection
Like what was done for activating an active connection, so
some state change are simulated and a dbus test method is added

Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2020-10-29 09:35:10 +01:00
Frederic Martinsons 51dd9ed89a
Enhance device state and active connection management
Add reason for device state change.
Add dbus test method to force failure of activation, set the
device state and the active connection state.

Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2020-10-29 09:35:10 +01:00
Frederic Martinsons a3f596e273
Add basic modem device support
The modem device will have hardcoded capability which make it
compatible with GSM connection settings.
It will be seen with hardcoded ModemManager manager dbus object path
for the UDI property.
Add also a dbus test method to add the modem device.

Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2020-10-29 09:35:06 +01:00
Frederic Martinsons f225148754
Initialize correctly _dbus_error_name in BusErr classes
To be consistent with dbus.DbusException classes which do the
following in __init__:

    def __init__(self, *args, **kwargs):
        name = kwargs.pop('name', None)
        if name is not None or getattr(self, '_dbus_error_name', None) is None:
            self._dbus_error_name = name
        if kwargs:
            raise TypeError('DBusException does not take keyword arguments: %s'
                            % ', '.join(kwargs.keys()))
        Exception.__init__(self, *args)

Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2020-10-29 09:35:06 +01:00
Frederic Martinsons 7bc01ea14c
Add dbus.Int32 support for variant parsing
Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2020-10-29 09:35:06 +01:00
Thomas Haller 7fe76f54e3
build: fix "create-exports-NetworkManager.sh" to fail if "nm" fails
Despite `set -e`, the shell script does not fail if the command in the
here document fails. This can happen if binutils' "nm" fails.

  NM=/bin/false "./tools/create-exports-NetworkManager.sh" --called-from-build "."
2020-10-06 13:30:50 +02:00
Thomas Haller 12823f60af
format: replace tabs with spaces in sheell scripts 2020-09-29 09:19:29 +02:00
Antonio Cardace 471c5b7c1d
tools: update script for new code-style
Signed-off-by: Antonio Cardace <acardace@redhat.com>
2020-09-28 15:08:42 +02:00
Thomas Haller 7141537097
l3cfg/tests: add unit test for NML3Cfg 2020-09-24 09:44:04 +02:00
Valentin David 54e25f23f5
build/docs: fix generated XML syntax in tools/generate-docs-nm-settings-docs-gir.py
Class description may contains double quotes which is not valid as XML
attribute value.

[thaller@redhat.com: adjust original patch to reformat code with python black]

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/620
2020-09-08 17:35:14 +02:00
Thomas Haller 2cb40f6e36
tests: ignore valgrind warning about unhandled syscalls
On Fedora rawhide (34), valgrind gives a lot of warnings like:

    ./src/platform/tests/test-cleanup-linux.valgrind-log:--48279-- WARNING: unhandled amd64-linux syscall: 439
    ./src/platform/tests/test-cleanup-linux.valgrind-log:--48279-- You may be able to write your own handler.
    ./src/platform/tests/test-cleanup-linux.valgrind-log:--48279-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
    ./src/platform/tests/test-cleanup-linux.valgrind-log:--48279-- Nevertheless we consider this a bug.  Please report
    ./src/platform/tests/test-cleanup-linux.valgrind-log:--48279-- it at http://valgrind.org/support/bug_reports.html.

Ignore them.
2020-09-07 16:50:44 +02:00
Thomas Haller c92a3ca5c2
build: fix generating "NetworkManager.ver" with LTO
We use a linker version script "NetworkManager.ver", to hide
symbols from NetworkManager that are not used. That is important
due to our habit of using internal helper libraries that we link
statically everywhere, without handpicking the symbols we actually
need. We want the tooling to get rid of unnecessary symbols.

However, NetworkManager loads shared libraries for settings and device
plugins. These libraries require symbols from the NetworkManager binary,
but which one depends on build options. Hence, we also generate
"NetworkManager.ver" by the "tools/create-exports-NetworkManager.sh"
script.

For that the script uses "nm" to find symbols that are undefined in the
plugin libraries but defined in NetworkManager. With autotools the
script looked at "./src/.libs/libNetworkManager.a" to find the present
symbols. Note that for meson that already didn't work, and we build
instead an intermediate NetworkManager binary first (with all symbols
exposed). With LTO, "nm" doesn't find all symbols in
"./src/.libs/libNetworkManager.a", and consequently they are not
exported and dropped/hidden.

This also causes unit tests to fail with LTO, because our test script
"tools/check-exports.sh" catches such bugs.

Fix that by also with autotools generate a complete "NetworkManager-all-sym"
binary that is used to generate "NetworkManager.ver", before rebuilding
"NetworkManager" again.
2020-08-17 15:18:05 +02:00
Thomas Haller 0bd8160029
tests: fix handling of $NMTST_LIBTOOL in "tools/run-nm-test.sh" script 2020-08-17 15:18:02 +02:00
Thomas Haller 3b70efa9b6
tools: minor cleanup to ensure "from_meson" variable is yet set from extern 2020-08-12 12:10:33 +02:00
Thomas Haller 5b7d39f8e1
docs: fix escaping XML in "tools/generate-docs-nm-settings-docs-gir.py"
The gtk-doc text that the tool receives is not XML, it's a plain text.
When setting the plain text as XML attribute, we need to properly escape
it. The previous XML escape code was naive, and didn't cover for a
plain ampersand.

(cherry picked from commit 1641cc1d03)
2020-06-26 13:33:41 +02:00
Sayed Shah be822b52e6
all: reformat python files with python black
Part of !537.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/537
2020-06-15 16:40:38 +02:00
Thomas Haller 125cbf5737
docs: show aliases for settings in man nm-settings-nmcli 2020-06-12 14:01:26 +02:00
Thomas Haller a3b9b661d4
docs: add "Alias" column to man nm-settings-nmcli 2020-06-12 12:09:30 +02:00
Thomas Haller 3c11116c48
docs: in "generate-docs-nm-settings-docs-merge.py" only take properties from first setting
Especially for "nm-settings-docs-nmcli.xml", the first XML to merge is
"clients/cli/generate-docs-nm-settings-nmcli.xml". That file is
generated with the meta data from nmcli, and it contains all the
properties that are supported. Properties from other XML files,
that are passed as additional arguments should not be merged.

In most cases, there is no difference. It only matters for
"ipv6.dad-timeout" and "user.data". For example, "ipv6.dad-timeout"
is supported by GObject (part of "libnm/nm-settings-docs-gir.xml"),
but not by nmcli. Don't include it in the manual.

This also drops the now empty settings "dummy", "user", and "generic".
2020-06-12 10:26:27 +02:00
Thomas Haller 87edf2f298
docs: move generate-docs scripts from "libnm/" to "tools/"
They are not only used in "libnm/" directory. Move to "tools/".
2020-06-11 10:53:50 +02:00
Thomas Haller 47d39a7fb7
docs: add more nm-settings manpages (dbus,nmcli,keyfile,ifcfg-rh)
A significant part of NetworkManager's API are the connection profiles, documented
in `man nm-settings*`. But there are different aspects about profiles, depending
on what you are interested. There is the D-Bus API, nmcli options, keyfile format,
and ifcfg-rh format. Additionally, there is also libnm API.

Add distinct manual pages for the four aspects. Currently the two new manual
pages "nm-settings-dbus" and "nm-settings-nmcli" are still identical to the
former "nm-settings.5" manual. In the future, they will diverge to
account for the differences.

There are the following aspects:

 - "dbus"
 - "keyfile"
 - "ifcfg-rh"
 - "nmcli"

For "libnm" we don't generate a separate "nm-settings-libnm" manual
page. That is instead documented via gtk-doc.

Currently the keyfile and ifcfg-rh manual pages only detail settings
which differ. But later I think also these manual pages should contain
all settings that apply.
2020-06-11 10:53:49 +02:00
Thomas Haller d507563a80
tests: suppress valgrind warning about unsupported syscall for "test-config" 2020-06-07 15:26:07 +02:00
Thomas Haller 42d45299f9
tests/sanitizer: make ASAN/LSAN/UBSAN options configurable in "tools/run-nm-test.sh"
Also add a suppressions file for LSAN.
2020-05-14 12:03:24 +02:00
Thomas Haller 24ab6b6cdc tests: abort test runner if exec fails
(cherry picked from commit 2ad8e6acae)
2020-04-20 11:52:11 +02:00
Thomas Haller 3e616c306d tests: ignore valgrind warnings for unhandled syscalls in libnm,service-provider tests
Otherwise, we get test failures with valgrind on fedora:rawhide
(valgrind-3.15.0-18.fc33.x86_64.rpm, gcc-10.0.1-0.8.fc33.x86_64,
glib2-devel-2.63.5-3.fc33.x86_64):

    >>>> PRINT VALGRIND LOGS (valgrind test) (start)
    + find -name '*.valgrind-log' -print0
    + xargs -0 grep -H '^'
    ./src/devices/wwan/tests/test-service-providers.valgrind-log:--95634-- WARNING: unhandled amd64-linux syscall: 315
    ./src/devices/wwan/tests/test-service-providers.valgrind-log:--95634-- You may be able to write your own handler.
    ./src/devices/wwan/tests/test-service-providers.valgrind-log:--95634-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
    ./src/devices/wwan/tests/test-service-providers.valgrind-log:--95634-- Nevertheless we consider this a bug.  Please report
    ./src/devices/wwan/tests/test-service-providers.valgrind-log:--95634-- it at http://valgrind.org/support/bug_reports.html.
    ./libnm/tests/test-remote-settings-client.valgrind-log:--95245-- WARNING: unhandled amd64-linux syscall: 315
    ./libnm/tests/test-remote-settings-client.valgrind-log:--95245-- You may be able to write your own handler.
    ./libnm/tests/test-remote-settings-client.valgrind-log:--95245-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
    ./libnm/tests/test-remote-settings-client.valgrind-log:--95245-- Nevertheless we consider this a bug.  Please report
    ./libnm/tests/test-remote-settings-client.valgrind-log:--95245-- it at http://valgrind.org/support/bug_reports.html.
    ./libnm/tests/test-secret-agent.valgrind-log:--95280-- WARNING: unhandled amd64-linux syscall: 315
    ./libnm/tests/test-secret-agent.valgrind-log:--95280-- You may be able to write your own handler.
    ./libnm/tests/test-secret-agent.valgrind-log:--95280-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
    ./libnm/tests/test-secret-agent.valgrind-log:--95280-- Nevertheless we consider this a bug.  Please report
    ./libnm/tests/test-secret-agent.valgrind-log:--95280-- it at http://valgrind.org/support/bug_reports.html.
    ./libnm/tests/test-nm-client.valgrind-log:--95208-- WARNING: unhandled amd64-linux syscall: 315
    ./libnm/tests/test-nm-client.valgrind-log:--95208-- You may be able to write your own handler.
    ./libnm/tests/test-nm-client.valgrind-log:--95208-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
    ./libnm/tests/test-nm-client.valgrind-log:--95208-- Nevertheless we consider this a bug.  Please report
    ./libnm/tests/test-nm-client.valgrind-log:--95208-- it at http://valgrind.org/support/bug_reports.html.
    + echo '>>>> PRINT VALGRIND LOGS (valgrind test) (done)'
    >>>> PRINT VALGRIND LOGS (valgrind test) (done)
2020-02-21 18:24:25 +01:00
Thomas Haller 69f048bf0c cloud-setup: add tool for automatic IP configuration in cloud
This is a tool for automatically configuring networking in a cloud
environment.

Currently it only supports IPv4 on EC2, but it's intended for extending
to other cloud providers (Azure). See [1] and [2] for how to configure
secondary IP addresses on EC2. This is what the tool currently aims to
do (but in the future it might do more).

[1] https://aws.amazon.com/premiumsupport/knowledge-center/ec2-ubuntu-secondary-network-interface/

It is inspired by SuSE's cloud-netconfig ([1], [2]) and ec2-net-utils
package on Amazon Linux ([3], [4]).

[1] https://www.suse.com/c/multi-nic-cloud-netconfig-ec2-azure/
[2] https://github.com/SUSE-Enceladus/cloud-netconfig
[3] https://github.com/aws/ec2-net-utils
[4] https://github.com/lorengordon/ec2-net-utils.git

It is also intended to work without configuration. The main point is
that you boot an image with NetworkManager and nm-cloud-setup enabled,
and it just works.
2019-11-28 19:52:18 +01:00
Thomas Haller 21845ae4e3 build/meson: cleanup "meson-post-install.sh"
- the variables in meson.build and in the meson-post-install.sh script
  should have the same names.

- the positional command line arguments should be assigned to variables,
  because the variable name acts like a documentation what the variable
  means (contrary to the argument number).

- the boolean flags should not map to other special values, like
  "enable_docs ? 'install_docs' : ''". The name "enable_docs" is
  good already, it shall be either passed as 1 or 0 and use the name
  consistently.
2019-11-22 16:07:02 +01:00
Beniamino Galvani 62c811b2bd cli: print interface flags 2019-11-22 10:18:26 +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 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 dab1d780fd libnm: retire deprecated WiMAX NMObject types
WiMAX is deprecated since NetworkManager 1.2.0. Note that also
NetworkManager on server side no longer supports this type, hence
the server's D-Bus API will never expose devices of this type.

Note that NMDeviceWimax and NMWimaxNsp are NMObject types. That means,
they are instantiated by NMClient to represent information on the D-Bus
interface. As NetworkManager no longer exposes WiMAX devices, such
devices are never created. Note that it makes no sense that a user would
directly instantiate NMObject types, because they only work together with
NMClient.

Don't drop the related symbols and definitions from libnm, so that there
is no API/ABI change (as far as building and linking is concerned). But
make the types defunctional (which of course is a behavioral API change).
Calling the API now triggers a g_return_*() warning.

Also belatedly mark the WimaxNsp API as deprecated. It should have been
done in 1.2. Note that here we deprecate the API and retire it at the
same time. Optimally, we would have deprecated it a few releases ago,
before retiring it. However, marking something for deprecation is anyway
no excuse for anything. I mean, removing or retiring API is usually
painful, regardless whether it was marked for deprecation or not. In this
case, there is no possibility that a libnm user gets hold on a NMDeviceWimax
or NMWimaxNsp instance, because NMClient simply no longer instantiates
them. Hence, this change should not affect any user in practice.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/316
2019-10-23 15:31:51 +02:00
Thomas Haller 3b69f02164 all: unify format of our Copyright source code comments
```bash

readarray -d '' FILES < <(
  git ls-files -z \
    ':(exclude)po' \
    ':(exclude)shared/c-rbtree' \
    ':(exclude)shared/c-list' \
    ':(exclude)shared/c-siphash' \
    ':(exclude)shared/c-stdaux' \
    ':(exclude)shared/n-acd' \
    ':(exclude)shared/n-dhcp4' \
    ':(exclude)src/systemd/src' \
    ':(exclude)shared/systemd/src' \
    ':(exclude)m4' \
    ':(exclude)COPYING*'
  )

sed \
  -e 's/^\(--\|#\| \*\) *\(([cC]) *\)\?Copyright \+\(\(([cC])\) \+\)\?\(\(20\|19\)[0-9][0-9]\) *[-–] *\(\(20\|19\)[0-9][0-9]\) \+\([^ ].*\)$/\1 C1pyright#\5 - \7#\9/' \
  -e 's/^\(--\|#\| \*\) *\(([cC]) *\)\?Copyright \+\(\(([cC])\) \+\)\?\(\(20\|19\)[0-9][0-9]\) *[,] *\(\(20\|19\)[0-9][0-9]\) \+\([^ ].*\)$/\1 C2pyright#\5, \7#\9/' \
  -e 's/^\(--\|#\| \*\) *\(([cC]) *\)\?Copyright \+\(\(([cC])\) \+\)\?\(\(20\|19\)[0-9][0-9]\) \+\([^ ].*\)$/\1 C3pyright#\5#\7/' \
  -e 's/^Copyright \(\(20\|19\)[0-9][0-9]\) \+\([^ ].*\)$/C4pyright#\1#\3/' \
  -i \
  "${FILES[@]}"

echo ">>> untouched Copyright lines"
git grep Copyright "${FILES[@]}"

echo ">>> Copyright lines with unusual extra"
git grep '\<C[0-9]pyright#' "${FILES[@]}" | grep -i reserved

sed \
  -e 's/\<C[0-9]pyright#\([^#]*\)#\(.*\)$/Copyright (C) \1 \2/' \
  -i \
  "${FILES[@]}"

```

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/298
2019-10-02 17:03:52 +02:00
Thomas Haller b9c4d2bb72 run-nm-test: fix using exec instead of running and exiting
Otherwise, the script tries to run

  dbus-run-session -- exec ...

which fails (because `exec` is a shell command, not a program).
After the failure, the code falls through to run the test under
valgrind.

Fixes: 6a58c55ca4 ('run-nm-test: Just use exec instead of running and exiting')
2019-10-02 09:47:54 +02:00
Marco Trevisan (Treviño) 6a58c55ca4 run-nm-test: Just use exec instead of running and exiting 2019-10-02 09:11:28 +02:00
Marco Trevisan (Treviño) 073eda68fc run-nm-test: Set NM_TEST_UNDER_VALGRIND accordingly
When a test is going to be run under valgrind we set NM_TEST_UNDER_VALGRIND
so that we can properly check whether this is happening.
2019-10-02 09:11:28 +02:00
Iñigo Martínez a010fcb5f7 meson: Move network-config directory creation to main install file
The `ifcfg-rh` meson build file installs a new post install script
to create the `network-config` directory.

This has been moved to the main post install file so it's easier to
find because all post install steps are together and it avoids and
extra post install script execution.
2019-10-01 09:49:33 +02:00
Thomas Haller abff46cacf all: manually drop code comments with file description 2019-10-01 07:50:52 +02:00
Thomas Haller ceae05cc4b tests: avoid deprecated GLib.IOChannel.add_watch() in "test-networkmanager-service.py"
test_001 (__main__.TestNmcli) ... /tmp/NetworkManager/tools/test-networkmanager-service.py:2346: PyGIDeprecationWarning: add_watch is deprecated; use GLib.io_add_watch() instead
  id1 = GLib.IOChannel(0).add_watch(GLib.IOCondition.HUP,
2019-09-25 15:47:39 +02:00
Lubomir Rintel 24028a2246 all: SPDX header conversion
$ find * -type f |xargs perl contrib/scripts/spdx.pl
  $ git rm contrib/scripts/spdx.pl
2019-09-10 11:19:56 +02:00
Beniamino Galvani 11cf082a62 build: use regexp in gtkdoc --ignore-decorators option
gtkdoc-scan supports regular expressions in the --ignore-decorators
command-line option. Since it is easier to use a regexp than grepping
macros from a source file, revert the ugly solution from commit
2d941dc95a ('build: fix errors when building with gtk-doc 1.32').
2019-09-06 14:18:24 +02:00
Beniamino Galvani 2d941dc95a build: fix errors when building with gtk-doc 1.32
gtkdoc-scan 1.32 performs stricter checks on structures definitions
and so it complains on:

 /build/networkmanager/src/NetworkManager/libnm/./nm-vpn-plugin-old.h:0: warning: partial declaration (struct) : typedef struct {
 	NM_DEPRECATED_IN_1_2
 	GObject parent;
 } NMVpnPluginOld NM_DEPRECATED_IN_1_2;

because of the unrecognized token 'NM_DEPRECATED_IN_1_2'.

Pass all allowed macros to gtkdoc-scan through the --ignore-decorators
argument.

https://gitlab.gnome.org/GNOME/gtk-doc/issues/98
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/238
2019-09-05 11:17:54 +02:00
Thomas Haller d35d3c468a settings: rework tracking settings connections and settings plugins
Completely rework how settings plugin handle connections and how
NMSettings tracks the list of connections.

Previously, settings plugins would return objects of (a subtype of) type
NMSettingsConnection. The NMSettingsConnection was tightly coupled with
the settings plugin. That has a lot of downsides.

Change that. When changing this basic relation how settings connections
are tracked, everything falls appart. That's why this is a huge change.
Also, since I have to largely rewrite the settings plugins, I also
added support for multiple keyfile directories, handle in-memory
connections only by keyfile plugin and (partly) use copy-on-write NMConnection
instances. I don't want to spend effort rewriting large parts while
preserving the old way, that anyway should change. E.g. while rewriting ifcfg-rh,
I don't want to let it handle in-memory connections because that's not right
long-term.

--

If the settings plugins themself create subtypes of NMSettingsConnection
instances, then a lot of knowledge about tracking connections moves
to the plugins.
Just try to follow the code what happend during nm_settings_add_connection().
Note how the logic is spread out:
 - nm_settings_add_connection() calls plugin's add_connection()
 - add_connection() creates a NMSettingsConnection subtype
 - the plugin has to know that it's called during add-connection and
   not emit NM_SETTINGS_PLUGIN_CONNECTION_ADDED signal
 - NMSettings calls claim_connection() which hocks up the new
   NMSettingsConnection instance and configures the instance
   (like calling nm_settings_connection_added()).
This summary does not sound like a lot, but try to follow that code. The logic
is all over the place.

Instead, settings plugins should have a very simple API for adding, modifying,
deleting, loading and reloading connections. All the plugin does is to return a
NMSettingsStorage handle. The storage instance is a handle to identify a profile
in storage (e.g. a particular file). The settings plugin is free to subtype
NMSettingsStorage, but it's not necessary.
There are no more events raised, and the settings plugin implements the small
API in a straightforward manner.
NMSettings now drives all of this. Even NMSettingsConnection has now
very little concern about how it's tracked and delegates only to NMSettings.

This should make settings plugins simpler. Currently settings plugins
are so cumbersome to implement, that we avoid having them. It should not be
like that and it should be easy, beneficial and lightweight to create a new
settings plugin.

Note also how the settings plugins no longer care about duplicate UUIDs.
Duplicated UUIDs are a fact of life and NMSettings must handle them. No
need to overly concern settings plugins with that.

--

NMSettingsConnection is exposed directly on D-Bus (being a subtype of
NMDBusObject) but it was also a GObject type provided by the settings
plugin. Hence, it was not possible to migrate a profile from one plugin to
another.
However that would be useful when one profile does not support a
connection type (like ifcfg-rh not supporting VPN). Currently such
migration is not implemented except for migrating them to/from keyfile's
run directory. The problem is that migrating profiles in general is
complicated but in some cases it is important to do.

For example checkpoint rollback should recreate the profile in the right
settings plugin, not just add it to persistent storage. This is not yet
properly implemented.

--

Previously, both keyfile and ifcfg-rh plugin implemented in-memory (unsaved)
profiles, while ifupdown plugin cannot handle them. That meant duplication of code
and a ifupdown profile could not be modified or made unsaved.
This is now unified and only keyfile plugin handles in-memory profiles (bgo #744711).
Also, NMSettings is aware of such profiles and treats them specially.
In particular, NMSettings drives the migration between persistent and non-persistent
storage.

Note that a settings plugins may create truly generated, in-memory profiles.
The settings plugin is free to generate and persist the profiles in any way it
wishes. But the concept of "unsaved" profiles is now something explicitly handled
by keyfile plugin. Also, these "unsaved" keyfile profiles are persisted to file system
too, to the /run directory. This is great for two reasons: first of all, all
profiles from keyfile storage in fact have a backing file -- even the
unsaved ones. It also means you can create "unsaved" profiles in /run
and load them with `nmcli connection load`, meaning there is a file
based API for creating unsaved profiles.
The other advantage is that these profiles now survive restarting
NetworkManager. It's paramount that restarting the daemon is as
non-disruptive as possible. Persisting unsaved files to /run improves
here significantly.

--

In the past, NMSettingsConnection also implemented NMConnection interface.
That was already changed a while ago and instead users call now
nm_settings_connection_get_connection() to delegate to a
NMSimpleConnection. What however still happened was that the NMConnection
instance gets never swapped but instead the instance was modified with
nm_connection_replace_settings_from_connection(), clear-secrets, etc.
Change that and treat the NMConnection instance immutable. Instead of modifying
it, reference/clone a new instance. This changes that previously when somebody
wanted to keep a reference to an NMConnection, then the profile would be cloned.
Now, it is supposed to be safe to reference the instance directly and everybody
must ensure not to modify the instance. nmtst_connection_assert_unchanging()
should help with that.
The point is that the settings plugins may keep references to the
NMConnection instance, and so does the NMSettingsConnection. We want
to avoid cloning the instances as long as they are the same.
Likewise, the device's applied connection can now also be referenced
instead of cloning it. This is not yet done, and possibly there are
further improvements possible.

--

Also implement multiple keyfile directores /usr/lib, /etc, /run (rh #1674545,
bgo #772414).

It was always the case that multiple files could provide the same UUID
(both in case of keyfile and ifcfg-rh). For keyfile plugin, if a profile in
read-only storage in /usr/lib gets modified, then it gets actually stored in
/etc (or /run, if the profile is unsaved).

--

While at it, make /etc/network/interfaces profiles for ifupdown plugin reloadable.

--

https://bugzilla.gnome.org/show_bug.cgi?id=772414
https://bugzilla.gnome.org/show_bug.cgi?id=744711
https://bugzilla.redhat.com/show_bug.cgi?id=1674545
2019-07-16 19:09:08 +02:00
Thomas Haller 7b6f1c2d90 tools: export more symbols from NetworkManager binary to plugins
Plugins also may use nmtst_*() functions (when built with --with-more-asserts)
or c_list_*(). Whitelist them too.
2019-06-26 12:26:11 +02:00
Thomas Haller 74641be816 settings: drop ibft settings plugin
The functionality of the ibft settings plugin is now handled by
nm-initrd-generator. There is no need for it anymore, drop it.

Note that ibft called iscsiadm, which requires CAP_SYS_ADMIN to work
([1]). We really want to drop this capability, so the current solution
of a settings plugin (as it is implemented) is wrong. The solution
instead is nm-initrd-generator.

Also, on Fedora the ibft was disabled and probably on most other
distributions as well. This was only used on RHEL.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1371201#c7
2019-06-20 16:06:44 +02:00
Thomas Haller c0e075c902 all: drop emacs file variables from source files
We no longer add these. If you use Emacs, configure it yourself.

Also, due to our "smart-tab" usage the editor anyway does a subpar
job handling our tabs. However, on the upside every user can choose
whatever tab-width he/she prefers. If "smart-tabs" are used properly
(like we do), every tab-width will work.

No manual changes, just ran commands:

    F=($(git grep -l -e '-\*-'))
    sed '1 { /\/\* *-\*-  *[mM]ode.*\*\/$/d }'     -i "${F[@]}"
    sed '1,4 { /^\(#\|--\|dnl\) *-\*- [mM]ode/d }' -i "${F[@]}"

Check remaining lines with:

    git grep -e '-\*-'

The ultimate purpose of this is to cleanup our files and eventually use
SPDX license identifiers. For that, first get rid of the boilerplate lines.
2019-06-11 10:04:00 +02:00
Lubomir Rintel a95b674c39 build: install dispatcher dirs in /usr
The dispatcher looks there for scripts now. This actually doesn't break
the RPM build, since it doesn't mind extra empty directories in
buildroot. Good.
2019-04-26 22:07:30 +02:00
Thomas Haller 17adf58d5d tools: fix out-of-tree build test "tools/check-docs.sh" for duplicate generated sources
When we do an in-tree-build with autotools and an out-of-tree build
with meson (all in the same source directory), then we have the
following files:

  libnm-core/nm-core-enum-types.h
  libnm/nm-enum-types.h
  build/libnm-core/nm-core-enum-types.h
  build/libnm/nm-enum-types.h

This caused "tools/check-docs.sh" for `ninja -C build test` to fail,
because the files are detected twice:

    --- command ---
    /data/src/NetworkManager/tools/check-docs.sh /data/src/NetworkManager /data/src/NetworkManager/build
    --- stderr ---
    8a9
    > nm-core-enum-types
    38a40
    > nm-enum-types
    *** Error: libnm classes not included in docs/libnm/libnm-docs.xml ***
    -------
2019-04-23 11:45:06 +02:00
Thomas Haller a9b4362fc5 tools: cleanup path variable in "tools/check-docs.sh"
- don't append the path separator to the SOURCEDIR variable.
  Instead, use the path separator when we need it.
2019-04-23 11:45:06 +02:00
Lubomir Rintel 5801f89f4d all: goodbye libnm-glib
This removes libnm-glib, libnm-glib-vpn, and libnm-util for good.
The it has been replaced with libnm since NetworkManager 1.0, disabled
by default since 1.12 and no up-to-date distributions ship it for years
now.

Removing the libraries allows us to:

* Remove the horrible hacks that were in place to deal with accidental use
  of both the new and old library in a single process.
* Relief the translators of maintenance burden of similar yet different
  strings.
* Get rid of known bad code without chances of ever getting fixed
  (libnm-glib/nm-object.c and libnm-glib/nm-object-cache.c)
* Generally lower the footprint of the releases and our workspace

If there are some really really legacy users; they can just build
libnm-glib and friends from the NetworkManager-1.16 distribution. The
D-Bus API is stable and old libnm-glib will keep working forever.

https://github.com/NetworkManager/NetworkManager/pull/308
2019-04-16 15:52:27 +02:00
Lubomir Rintel b027723e00 Revert "all: goodbye libnm-glib"
We need this for a little little longer :(

This reverts commit 1de8383ad9.
2019-04-03 08:52:38 +02:00
Beniamino Galvani 8200078ec5 lldp: support IEEE 802.3 TLVs
Add support for IEEE 802.3 organizationally specific TLVs:

 - MAC/PHY configuration/status (IEEE 802.1AB-2009 clause F.2)
 - power via medium dependent interface (clause F.3)
 - maximum frame size (clause F.4)
2019-03-27 10:47:24 +01:00
Beniamino Galvani 452851cc35 lldp: support multiple PPVIDs
As done for VLANs, add a new 'ppvids' attribute that reports all 'port
and protocol VLAN ID' TLVs for the neighbor.
2019-03-27 10:47:24 +01:00
Beniamino Galvani c4be4ea298 lldp: support multiple vlans
Previously we exported the contents of VLAN Name TLV in the 'vid'
(uint32) and 'vlan-name' (string) attributes. This is not entirely
correct as the TLV can appear multiple times.

We need a way to export all the VLAN IDs and names for the
neighbor. Add a new 'vlans' attribute which obsoletes the other two
and is an array of dictionaries, where each dictionary contains the
'vid' and 'name' keys.
2019-03-27 10:47:24 +01:00
Beniamino Galvani 6c52d946fc lldp: add support for management address TLV
Support the management address TLV (IEEE 802.1AB-2009 clause
8.5.9). The TLV can appear multiple times and so it is exported on
D-Bus as an array of dictionaries.
2019-03-27 10:47:24 +01:00
Beniamino Galvani b1d5f11b3d cli: add lldp output tests
Check the result of 'nmcli device lldp' command.
2019-03-27 10:17:39 +01:00
Lubomir Rintel 1de8383ad9 all: goodbye libnm-glib
This removes libnm-glib, libnm-glib-vpn, and libnm-util for good.
The it has been replaced with libnm since NetworkManager 1.0, disabled
by default since 1.12 and no up-to-date distributions ship it for years
now.

Removing the libraries allows us to:

* Remove the horrible hacks that were in place to deal with accidental use
  of both the new and old library in a single process.
* Relief the translators of maintenance burden of similar yet different
  strings.
* Get rid of known bad code without chances of ever getting fixed
  (libnm-glib/nm-object.c and libnm-glib/nm-object-cache.c)
* Generally lower the footprint of the releases and our workspace

If there are some really really legacy users; they can just build
libnm-glib and friends from the NetworkManager-1.16 distribution. The
D-Bus API is stable and old libnm-glib will keep working forever.

https://github.com/NetworkManager/NetworkManager/pull/308
2019-03-19 17:15:15 +01:00
Frédéric Danis 10502f1701 tests: Fix variant_from_dbus() for arrays of UInt32
Using test-networkmanager-servic.py, I get the following error when
trying to add manual config with a dns address:

    Error: g-io-error-quark: Traceback (most recent call last):
      File "/usr/lib/python2.7/dist-packages/dbus/service.py", line 707, in _message_cb
        retval = candidate_method(self, *args, **keywords)
      File "tools/test-networkmanager-service.py", line 1727, in AddConnection
        return self.add_connection(con_hash)
      File "tools/test-networkmanager-service.py", line 1731, in add_connection
        con_inst = Connection(self.c_counter, con_hash, do_verify_strict)
      File "tools/test-networkmanager-service.py", line 1601, in __init__
        NmUtil.con_hash_verify(con_hash, do_verify_strict=do_verify_strict)
      File "tools/test-networkmanager-service.py", line 497, in con_hash_verify
        BusErr.raise_nmerror(e)
      File "tools/test-networkmanager-service.py", line 419, in raise_nmerror
        raise e
    Exception: Unsupported value ipv4.dns = dbus.Array([dbus.UInt32(168430090L), dbus.UInt32(218893066L)], signature=dbus.Signature('u'), variant_level=1) (Cannot convert array element to type 'u': Must be number, not Variant)

https://mail.gnome.org/archives/networkmanager-list/2019-March/msg00013.html
(cherry picked from commit 9a71d7d273)
2019-03-11 16:44:22 +01:00
Lubomir Rintel 640164e979 clients/test: vary RSN capabilities across APs
This allows us to test if we distinguish WPA1, WPA2 and WPA3 in the
client.
2019-02-05 10:20:29 +01:00
Thomas Haller fbb038af5e all: return output dictionary from "AddAndActivate2"
Add a "a{sv}" output argument to "AddAndActivate2" D-Bus API.
"AddAndActivate2" replaces "AddAndActivate" with more options.
It also has a dictionary argument to be forward compatible so that we
hopefully won't need an "AddAndActivate3". However, it lacked a similar
output dictionary. Add it for future extensibility. I think this is
really to workaround a shortcoming of D-Bus, which does provide strong
typing and type information about its API, but does not allow to extend
an existing API in a backward compatible manner. So we either resort to
Method(), Method2(), Method3() variants, or a catch-all variant with a
generic "a{sv}" input/output argument.

In libnm, rename "nm_client_add_and_activate_connection_options()" to
"nm_client_add_and_activate_connection2()". I think libnm API should have
an obvious correspondence with D-Bus API. Or stated differently, if
"AddAndActivateOptions" would be a better name, then the D-Bus API should
be renamed. We should prefer one name over the other, but regardless
of which is preferred, the naming for D-Bus and libnm API should
correspond.

In this case, I do think that AddAndActivate2() is a better name than
AddAndActivateOptions(). Hence I rename the libnm API.

Also, unless necessary, let libnm still call "AddAndActivate" instead of
"AddAndActivate2". Our backward compatibility works the way that libnm
requires a server version at least as new as itself. As such, libnm
theoretically could assume that server version is new enough to support
"AddAndActivate2" and could always use the more powerful variant.
However, we don't need to break compatibility intentionally and for
little gain. Here, it's easy to let libnm also handle old server API, by
continuing to use "AddAndActivate" for nm_client_add_and_activate_connection().
Note that during package update, we don't restart the currently running
NetworkManager instance. In such a scenario, it can easily happen that
nmcli/libnm is newer than the server version. Let's try a bit harder
to not break that.

Changes as discussed in [1].

[1] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/37#note_79876
2019-01-14 11:56:18 +01:00
Beniamino Galvani 81bc218e6d meson: add check on settings docs
Move the autotools check on settings docs to a shell script and call
it from meson too.
2018-12-12 14:38:18 +01:00
Beniamino Galvani 446e5b27d6 core: add checks on connection default properties
Add a new CON_DEFAULT() macro that places a property name into a
special section used at runtime to check whether it is a supported
connection default.

Unfortunately, this mechanism doesn't work for plugins so we have to
enumerate the connection defaults from plugins in the daemon using
another CON_DEFAULT_NOP() macro.
2018-12-01 15:16:48 +01:00
Beniamino Galvani 2e45d4ada6 build: check that the list of supported config options is up to date
Add a script run during 'make check' to verify that all config options
are in the list of supported ones.
2018-12-01 15:16:48 +01:00
Benjamin Berg 00236ef977 libnm: Add support to pass options to AddAndActivateConnection
This adds the new methods nm_client_add_and_activate_connection_options_*
and ports the existing methods to use the new AddAndActivateConnection2
call rather than AddAndActivateConnection, allowing further parameters
to be passed in.
2018-11-17 12:15:40 +01:00
Beniamino Galvani 38299a1d78 build: meson: fix wrong man page link
Fixes: 98b4a19a53

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/78
2018-11-08 10:21:58 +01:00
Beniamino Galvani 5ba301f4eb tests: simulate old LastScan wifi value in test-networkmanager-service.py
In this way clients will randomly find that the AP list is older than
30 seconds and they will issue a new scan.
2018-11-02 14:56:40 +01:00
Thomas Haller 168e8b9b6f build: fix check-docs.sh for out-of-tree builds
Fixes: 7a59cd2744
2018-10-25 11:08:39 +02:00
Thomas Haller 7a59cd2744 docs: rework check-docs test script
Try to make check-docs.sh script more readable.

Also, previously the script would check that one side was a subset
of the other side. Tighten this check up, now both sides of the
comparison must agree and yield the same lines.
2018-10-25 09:40:53 +02:00
Michael Biebl e11ee4582a docs: fix bashism in tools/check-docs.sh
[thaller@redhat.com: fixed issue in original patch]
2018-10-25 08:00:40 +02:00
Beniamino Galvani 1408ffd9f6 build: fix ibft option in create-exports-NetworkManager.sh 2018-10-24 22:10:31 +02:00
Thomas Haller 0f503efd64 tests: support UInt64 type in test-networkmanager-service.py
and also accept "gsm" connection-type. Both will be used next.
2018-10-17 16:22:34 +02:00
Thomas Haller 343b99f891 acd/tests: skip NAcd tests under valgrind
Under valgrind, we cannot create an NAcd instance.

    --10916-- WARNING: unhandled amd64-linux syscall: 321
    --10916-- You may be able to write your own handler.
    --10916-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
    --10916-- Nevertheless we consider this a bug.  Please report
    --10916-- it at http://valgrind.org/support/bug_reports.html.

This limitation already poses a problem, because running NetworkManager
under valgrind might fail. However, for tests it doesn't matter and we
can just skip them.
2018-10-04 10:58:50 +02:00
Thomas Haller 15857ad958 build: silence message in "tools/create-exports-NetworkManager.sh" about missing directory
When building with meson -Dppp=false, the following message is printed
during build:

  [623/671] Generating NetworkManager.ver with a custom command. find: ‘./src/ppp/’: No such file or directory

The message is harmless. Hide it.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/43
2018-10-01 18:38:38 +02:00
Beniamino Galvani 24fc3c54a3 build: meson: fix install script
Fix directory paths and modes.

Fixes: 98b4a19a53
2018-09-28 17:25:46 +02:00
Beniamino Galvani 19a718bc13 build: meson: fix computing NM exported symbols
The script didn't include all the symbols needed by plugins because
libNetworkManager.a, as built by meson, doesn't include symbols from
other static libraries that are linked in. Since we used
libNetworkManager.a to know which symbols are potentiall available
from NM, the result was an incomplete list.

Unfortunately, the only way to include the whole static library is to
create a dependency object and use 'link_whole', but this is only
available in meson >= 0.46. Since 'link_whole' is available for
executables in meson >= 0.40, create a fake executable and use that to
enumerate symbols.

Also add tests to check that plugins can be loaded correctly.

Fixes: dfa2a2b40c
2018-09-19 16:03:32 +02:00
Beniamino Galvani 98b4a19a53 build: meson: support $DESTDIR in installation script
Adapt the meson post-installation script to handle the $DESTDIR
variable supplied by user to specify the installation target
directory. While at it, convert the script to shell because it seems
simpler to me.
2018-09-19 16:03:32 +02:00
luz.paz 58510ed566 docs: misc. typos pt2
Remainder of typos found using `codespell -q 3 --skip="./shared,./src/systemd,*.po" -I ../NetworkManager-word-whitelist.txt` whereby whitelist consists of:
 ```
ans
busses
cace
cna
conexant
crasher
iff
liftime
creat
nd
sav
technik
uint
```

https://github.com/NetworkManager/NetworkManager/pull/205
2018-09-17 11:26:13 +02:00
Beniamino Galvani 10ca2444b9 build: support meson builds in create-exports script
(cherry picked from commit 9b4bc0824c)
2018-09-13 14:35:25 +02:00
Thomas Haller 921db9132e build: fix whitelisting c-siphash symbols in NetworkManager.ver for device plugin
NetworkManager.ver needs to whitelist symbols needed by device,
settings, and ppp plugin. Fix the generator script to also allow
using c_siphash_*() symbols. These are needed by nm_hash_*().

Without this, wifi device plugin is broken.

Fixes: ccf36ff4ce
2018-09-05 16:55:45 +02:00
Lubomir Rintel d70185ddf1 all: point git references to the GitLab instance
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/2
2018-08-27 11:36:56 +02:00
Thomas Haller 9730961a02 tests/trivial: rename ip4_addr_ne32() to ip4_addr_be32() in test-networkmanager-service.py
The function is supposed to return the IPv4 address as 32 bit integer in
network byte order (bit endian). The ip4_addr_ne32() name is confusing,
because "ne" commonly stands for "native endianness".

Compare also "unaligned.h" and unaligned_read_ne32(), which also
stands for native endianness (host order), not network order (big
endian).

Rename.
2018-07-11 17:53:44 +02:00
Lubomir Rintel 4fa1a49542 docs: include missing documentation in libnm and D-Bus docs
Check that we don't repeat the omission in future.

(cherry picked from commit cb1172ee3d)
2018-06-28 20:43:26 +02:00
Thomas Haller 296da44235 tests: don't exit test-networkmanager-service.py after 20 seconds
Tests might just take longer than 20 seconds.

Also, we already watch stdin to determine whether the service
should exit.

(cherry picked from commit 4e18ef49bf)
2018-06-18 11:33:15 +02:00
Thomas Haller efddb0cef5 tests: improve NetworkManager stub service for Wi-Fi scanning
Now that nmcli initiates a scan before displaying Wi-Fi networks,
the stub service must properly support that as well.

For the moment, the stub service chooses "now" as LastScan timestamp.
This causes nmcli not to trigger a new scan, because nmcli gives
unstable output if multiple nmcli processes in parallel race to
trigger a Wi-Fi scan. That should be fixed.

(cherry picked from commit 56a0488bba)
2018-06-18 10:58:05 +02:00
Thomas Haller e05ce581b6 tests: fix race in setting signal strength for Wi-Fi AP in NM stub
This opens the tests up to races. If we want to change the strength, we
need to do it in a controlled, race-free manner. This is especially the
case, because clients/tests run a large number of nmcli instances in
parallel, and it's thus racy which signal the nmcli processes will
see.

This also fixes a bug at

    self._dbus_property_set(IFACE_WIFI_AP, PRP_WIFI_AP_STRENGTH, strength)

@strength must be a D-Bus type, so that python-dbus knows the correct
type for serialization.

(cherry picked from commit 7e118c0091)
2018-06-18 10:58:04 +02:00
Lubomir Rintel cfa3a02b91 tools/test-service: utilize nm_utils_get_timestamp_msec()
This is probably better than a hardcoded timestamp.
2018-06-15 16:23:30 +02:00
Lubomir Rintel 07fd0502f6 wifi: expose LastScan as milliseconds not seconds
This doesn't wrap around in 68 years of uptime and is consistent with
o.fd.NM.Checkpoint.Created.
2018-06-15 16:23:30 +02:00
Thomas Haller 9a14f9caa5 clients/tests: fix unstable tests for Python2 vs. Python3
Currently, nmcli does not sort the list of available connections
for display. Instead, it shows them in the order as NetworkManager
exposes them on D-Bus.

Previously, test-networkmanager-service.py, would generate the list
of available connections by iterating the connections dictionary.
In Python (at least until Python 3.6), the order when iterating over
dictionaries is undefined. This inconsistancy lets tests behave
differently depending on the python version. Possibly with Python
3.4 and 3.5, tests might even behave differently between individual
runs (since Python there uses siphash with a randomized hash seed).
2018-06-14 16:38:33 +02:00
Lubomir Rintel c00e17578f wifi: expose the LastScan property
This is the time when the last Wi-Fi scan finished. It will help clients
decide whether the AP list is fresh enough.
2018-06-13 14:44:06 +02:00
Lubomir Rintel f037aaeb90 tools/test-service: mock o.fd.NM.Settings.Connection.Filename property 2018-06-11 15:06:49 +02:00
Thomas Haller f671fa5137 clients/tests: expose IP and DHCP configs in test-networkmanager-service.py stub
For adding tests what nmcli shows regarding IP and DHCP configuration,
let the stub service generate config instances.
2018-06-11 11:20:31 +02:00
Thomas Haller dd2da759de clients/tests: seed generated numbers for test-networkmanager-service.py
At several places, "test-networkmanager-service.py" uses generated numbers
with a defined seed. For example, generated connection's UUID is
generated in a predictable, but randomized way (if you forgive the
inprecise use of the word "random" in context of using a deterministic
seed).

Aside the connection's UUID, this becomes more interesting in the next commit
where the stub server generates a list of IP and DHCP settings in a predictable
randomized way.

For "clients/tests" we spawn the test service multiple times, but also
create similar environments by calling init_001(). This is done for
convenience, where out of lazyness all the tests share one setup. But it's
still a good idea that these tests generate slightly different setups,
wherever applicable. this increases the possible setups which get tested.
For example, the number of static IPv4 addresses (the following commit) is
interested to explicitly test for zero or a non-zero number of
addresses. If all tests happen to use the same seed, the tests are expected
to also generate the same number of addresses, and we miss an opportunity to
hit interesting test cases.

There is still no guarantee that all interesting cases are hit, the chances are just
better. The approach of generating the setup randomly, does not preclude that
the stub-server allows to explicitly configure the setup. However, due to the
sheer number of combinations that might be interesting to test, it's much simpler
to rely on some randomization and have the justifid hope we catch interesting cases.
Also in terms of runtime of the test, the cli unit tests should complete within
few seconds. Testing every combination would result in huge tests and long runtimes.

Also, the patch refactors generating random numbers in
"test-networkmanager-service.py". For example, it introduces
Util.RandomSeed(), which can be used to generate a sequence of different
random numbers. It works by having an internal state and a counter which is
combined to chain the seed and generate different numbers on each call.
2018-06-11 11:20:31 +02:00
Thomas Haller 2a53555faa tests: simulate available-connections in test-networkmanager-service.py 2018-06-11 10:30:27 +02:00
Thomas Haller 3255a97b3a tests: fix dry-run for _dbus_property_set() in test-networkmanager-service.py 2018-06-11 10:30:27 +02:00
Thomas Haller 2e22c931f9 clients/tests: test creating and activating VPN connection 2018-06-06 10:27:35 +02:00
Thomas Haller 360f952399 clients/tests: test nmcli con mod command with different locale
Just to give it some variety. Also, note how the message from the
server cannot be translated. Which is the case with real NetworkManager
as well, and is a major usability issue.
2018-06-05 20:08:03 +02:00
Thomas Haller f3dddcff2a clients/tests: verify connections in test-networkmanager-service.py using libnm
The real NetworkManager service has a clear understanding how a valid
connection looks like. This is what nm_connection_verify() returns.

Let also our stub-service verify connections the same way.

Note that this is cumbersome, because the stub service uses python's
dbus module, while libnm only accepts creating NMConnection instances
from GVariant. Thus, we need to a cumbersome conversion first.

It would be better if test-networkmanager-service.py would also expose
normalized connections on D-Bus. But that requires the inverse converion
from GVariant to python dbus.
2018-06-05 20:08:03 +02:00
Thomas Haller 780af4cffb tests: nest custom exceptions in common namespace 2018-06-05 20:08:03 +02:00
Thomas Haller ef612b8e23 tests: reorder definitions in test-networkmanager-service.py
Define all custom exception types together.
2018-06-05 20:08:03 +02:00
Thomas Haller e862e67f48 tests: use libnm defines for NM test stub
These names are unique and well-known.
2018-06-05 20:08:03 +02:00
Thomas Haller 78576794eb tests: rename local variables in NM test stub (2)
lso, the name "connection" and "con" is overused.

Use "con_inst" where we mean an instance of a "Connection" class,
that is, the object exposed on D-Bus.
2018-06-05 20:08:03 +02:00
Thomas Haller 9cc1876fd7 tests: rename local variables in NM test stub (1)
- don't use "hash" for a local variable in python.
  The editor highlights it like a special python name.

- don't use "settings" for Connection.settings. Name it
  Connection.con_hash. The name "settings" is over-used already.
  "con_hash" really is the nested dictionary that we expose/receive
  from D-Bus. If we would use libnm for it, it would be an
  NMSimpleConnection instance, but we don't.
2018-06-05 20:08:03 +02:00
Thomas Haller 3645be6484 clients/tests: add test for showing invisible connection in nmcli
It also shows how we handle invisible connections wrongly, when we have
multiple active-connections that reference them.
2018-06-01 16:03:23 +02:00
Beniamino Galvani af94687161 tests: implement Update2() in NetworkManager stub 2018-05-28 11:21:07 +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 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 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 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 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