Commit Graph

21088 Commits

Author SHA1 Message Date
Thomas Haller
d0f1dc654e core: ensure NUL terminated secret_key buffer
The secret_key is binary random data, so one shouldn't ever use it as a
NUL terminated string directly.

Still, just ensure that the entire buffer is always NUL terminated.
2018-05-28 14:58:24 +02:00
Thomas Haller
5f5f75ce0e libnm: expose _bin2str() helper function as internal API 2018-05-28 14:58:24 +02:00
Thomas Haller
4e463df100 libnm: allow nm_utils_hwaddr_valid() of length zero
nm_utils_hwaddr_valid() is used for validating strings. It should
not assert against calling it with an empty string "". That is just
an invalid hwaddr.
2018-05-28 14:58:24 +02:00
Lubomir Rintel
c28b334fdd rpm/build.sh: suggest dnf builddep after BUILDTYPE=SRPM
Convenient for copy & paste.
2018-05-28 11:44:02 +02:00
Lubomir Rintel
de326a4e8a rpm: prefer python3
From Fedora 28 on we can build without Python 2. That is good,
because it's eventually going to be removed.

Based on a change in Fedora dist-git by Iryna Shcherbina.
2018-05-28 11:44:02 +02:00
Beniamino Galvani
1f7780cba9 cli: fix property matching
@ret was not initialized when there was only one partial match.

Also, refactor the code to return all matching values.

Fixes: 3fd9bf9d7d

https://github.com/NetworkManager/NetworkManager/pull/123
2018-05-28 11:33:40 +02:00
Beniamino Galvani
af94687161 tests: implement Update2() in NetworkManager stub 2018-05-28 11:21:07 +02:00
Thomas Haller
78e877ee3c clients/tests: refactor by moving replace-text helper function
Have less logic in TestNmcli.
2018-05-28 08:57:29 +02:00
Thomas Haller
ee85151a4a clients/tests: generate Makefile.am for expected files
The developer can re-generate .expected files with

 $ NM_TEST_REGENERATE=1 ./clients/tests/test-client.py

Note that these files are also dist-ed, so that the tests also work
from a source-tarball. For that, we need to add them to EXTRA_DIST.

Previously, this was done manually in the base Makefile.am file. This
was cumbersome, because when adding a new test, the developer would need
to manually add the files.

Now, let the test (with NM_TEST_REGENERATE=1) also generate a makefile
part.
2018-05-27 22:25:44 +02:00
Thomas Haller
c9b0d3a425 core/dhcp: merge branch 'th/dhcp-cleanup'
https://github.com/NetworkManager/NetworkManager/pull/122
2018-05-26 20:13:30 +02:00
Thomas Haller
6d41864c8b dhcp: refactor dhclient_start() to use cleanup attribute 2018-05-26 20:11:04 +02:00
Thomas Haller
5bd3f7bd67 dhcp: cache errno in nm_dhcp_client_stop_existing() before using it 2018-05-26 20:11:04 +02:00
Thomas Haller
181cf5c709 dhcp: use NMIPConfig type for argument of nm_dhcp_client_set_state() 2018-05-26 20:11:04 +02:00
Thomas Haller
ef8782127f dhcp: use cleanup attribute in nm_dhcp_client_handle_event()
and use NMIPConfig type.
2018-05-26 20:11:04 +02:00
Thomas Haller
97dc1ec1e4 dhcp: minor cleanup initializing name of leasefile for NMDhcpDhclint 2018-05-26 20:11:04 +02:00
Thomas Haller
1c5e790277 core: let NM_IS_IP_CONFIG() check for expected addr-family
Still unused...
2018-05-26 20:11:04 +02:00
Thomas Haller
f11bb3d93d shared: minor cleanup of nm_utils_get_start_time_for_pid() 2018-05-26 20:11:04 +02:00
Thomas Haller
fd9f1b7cdd dhcp: fix leaking error in dhclient_start()
Fixes: 1b1b4bd91c
2018-05-26 20:11:04 +02:00
Thomas Haller
e1bbc2e155 cli: avoid bogus line seprator in pretty-output
This bug resulted in spurious lines with "--pretty --mode tabular",
whenever nmc_print() was called with multiple rows.

Currently, the only case where this was visible was with:

  $ nmcli --pretty general permissions

(note that "--mode tabular" is the default).

Fixes: 16299e5ac0
2018-05-25 17:36:47 +02:00
Thomas Haller
5090c1f255 cli/tests: add test for output of nmcli general permissions 2018-05-25 17:24:57 +02:00
Thomas Haller
dbedce8674 ppp: merge branch 'th/ppp-stop'
https://github.com/NetworkManager/NetworkManager/pull/113
2018-05-25 12:41:21 +02:00
Thomas Haller
eaf36db68b core: add and use NM_SHUTDOWN_TIMEOUT_MS as duration that we plan for shutdown
nm_ppp_manager_stop() wants to ensure that the pppd process is really
gone. For that it uses nm_utils_kill_child_async() to first send
SIGTERM, and sending SIGKILL after a timeout.

Later, we want to fix shutdown of NetworkManager to iterate the mainloop
during shutdown, so that such operations are still handled. However, we
can only delay shutdown for a certain time. After a timeout (NM_SHUTDOWN_TIMEOUT_MS
plus NM_SHUTDOWN_TIMEOUT_MS_GRACE) we really have to give up and
terminate.

That means, the right amount of time between sending SIGTERM and SIGKILL
is exactly NM_SHUTDOWN_TIMEOUT_MS. Hopefully that is of course
sufficient in the first place. If not, send SIGKILL afterwards, and give
a bit more time (NM_SHUTDOWN_TIMEOUT_MS_GRACE) to reap the child.
And if all this time is still not enough, something is really odd and we
abort waiting, with a warning in the logfile.

Since we don't properly handle shutdown yet, the description above is
not really true. But with this patch, we fix it from point of view of
NMPPPManager.
2018-05-25 12:35:49 +02:00
Thomas Haller
43f67b4210 ppp-manager: rework stopping NMPPPManager by merging async/sync methods
Previously, there were two functions nm_ppp_manager_stop_sync() and
nm_ppp_manager_stop_async().

However, stop-sync() would still kill the process asynchronously (with a
2 seconds timeout before sending SIGKILL).

On the other hand, stop-async() did pretty much the same thing as
sync-code, except also using the GAsyncResult.

Merge the two functions. Stopping the instance for the most part can be
done entirely synchrnous. The only thing that is asynchronous, is
to wait for the process to terminate. For that, add a new callback
argument to nm_ppp_manager_stop(). This replaces the GAsyncResult
pattern.

Also, always ensure that NetworkManager runs the mainloop at least as
long until the process really terminated. Currently we don't get that
right, and during shutdown we just stop iterating the mainloop. However,
fix this from point of view of NMPPPManager and register a wait-object,
that later will correctly delay shutdown.

Also, NMDeviceWwan cared to wait (asynchronously) until pppd really
terminated. Keep that functionality. nm_ppp_manager_stop() returns
a handle that can be used to cancel the asynchrounous request and invoke
the callback right away. However note, that even when cancelling the
request, the wait-object that prevents shutdown of NetworkManager is
kept around, so that we can be sure to properly clean up.
2018-05-25 12:35:49 +02:00
Thomas Haller
53d04a1dfa ppp-manager/trivial: rename variables holding self pointers
We usually structure our code in a (pseudo) object oriented way.
It makes sense to call the variable for the target object "self",
it is more familiar and usually done.
2018-05-25 12:35:49 +02:00
Thomas Haller
515663519f ppp-manager: refactor killing pppd process by using _ppp_kill() function
- add callback arguments to _ppp_kill(). Although most callers don't
  care, it makes it more obvious that this kills the process
  asynchronously.

- the call to nm_utils_kill_child_async() is complicated, with many
  arguments. Only call it from one place, and re-use the simpler wrapper
  function _ppp_kill() everywhere.
2018-05-25 12:35:49 +02:00
Thomas Haller
f09e7797d4 core: add nm_shutdown_register_watchdog() for marking object to wait for shutdown
Eventually we should do a coordinated shutdown when NetworkManager exits.
That is a large work, ensuring that all asynchronous actions are cancellable
(in time), and that we wait for all pending operations to complete.

Add a function nm_shutdown_register_watchdog(), so that objects can register
themselves, to block shutdown until they are destroyed. It's not yet used,
because actually iterating the mainloop during shutdown can only be done,
once the code is prepared to be ready for that. But we already need the
function, so that we can refactor individual parts of the code, in preparation
of using it in the future.
2018-05-25 12:35:49 +02:00
Lubomir Rintel
3fd9bf9d7d clients: fix an error message in case of property ambiguity
Before:

  $ nmcli c modify Dukkha ipv4.ignore no
  Error: invalid property 'ignore': 'ignore' is ambiguous (ignore-auto-routes x (null)).

After:

  $ nmcli c modify Dukkha ipv4.ignore no
  Error: invalid property 'ignore': 'ignore' is ambiguous (ignore-auto-routes x ignore-auto-dns).
2018-05-24 18:39:11 +02:00
Thomas Haller
bb87c67f10 tests: merge branch 'th/cli-tests' 2018-05-24 16:40:27 +02:00
Thomas Haller
41dbf2b9d3 clients/tests: drop duplicate tests for German translation
call_nmcli_l() would test for 3 languages: 'C', 'de', and 'pl'. There
is no fundamental difference between 'de' and 'pl', so there is no need
to test for two languages.
2018-05-24 16:40:17 +02:00
Thomas Haller
2cae37ca40 clients/tests: test nmcli output for active-connection state DEACTIVATING 2018-05-24 16:40:17 +02:00
Thomas Haller
6f82c880a6 clients/tests: load libnm via GObject introspection
We will use it, and it must be available anyway, because the stub server
also requires it.
2018-05-24 16:40:17 +02:00
Thomas Haller
d424de10bf clients/tests: add SetProperties operation to test-networkmanager-service.py stub
It is a hook to set one or several D-Bus properties at once. Properties that are
to be set-able, have to be whitelisted in the stub.
2018-05-24 16:40:17 +02:00
Thomas Haller
c834a8e822 tests: don't return path name from obj.get_managed_ifaces() in test-networkmanager-service.py 2018-05-24 16:40:17 +02:00
Thomas Haller
7ae5fb7ec6 clients/tests: test nmcli output for multiple activation of same profile
Activate the same profile on two devices. Arguably, real NetworkManager
(currently) does not allow that. But the D-Bus API is fine with
having multiple ActiveConnections for one SettingsConnection.

So, also the client should do something sensible.

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

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

and trigger it from test-client.py via

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

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

- merge IPv4 and IPv6 implementations for creating the environment.

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

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

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

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

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

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

======

SYSTEMD_DIR=../systemd
COMMIT=7fbb5dd5e2cc733a83af813b13e859a8172a6046

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

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

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

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

nm_copy_sd "src/basic/alloc-util.c"
nm_copy_sd "src/basic/alloc-util.h"
nm_copy_sd "src/basic/async.h"
nm_copy_sd "src/basic/escape.c"
nm_copy_sd "src/basic/escape.h"
nm_copy_sd "src/basic/ether-addr-util.c"
nm_copy_sd "src/basic/ether-addr-util.h"
nm_copy_sd "src/basic/extract-word.c"
nm_copy_sd "src/basic/extract-word.h"
nm_copy_sd "src/basic/fileio.c"
nm_copy_sd "src/basic/fileio.h"
nm_copy_sd "src/basic/fd-util.c"
nm_copy_sd "src/basic/fd-util.h"
nm_copy_sd "src/basic/fs-util.c"
nm_copy_sd "src/basic/fs-util.h"
nm_copy_sd "src/basic/hash-funcs.c"
nm_copy_sd "src/basic/hash-funcs.h"
nm_copy_sd "src/basic/hashmap.c"
nm_copy_sd "src/basic/hashmap.h"
nm_copy_sd "src/basic/hexdecoct.c"
nm_copy_sd "src/basic/hexdecoct.h"
nm_copy_sd "src/basic/hostname-util.c"
nm_copy_sd "src/basic/hostname-util.h"
nm_copy_sd "src/basic/in-addr-util.c"
nm_copy_sd "src/basic/in-addr-util.h"
nm_copy_sd "src/basic/io-util.c"
nm_copy_sd "src/basic/io-util.h"
nm_copy_sd "src/basic/list.h"
nm_copy_sd "src/basic/log.h"
nm_copy_sd "src/basic/macro.h"
nm_copy_sd "src/basic/mempool.h"
nm_copy_sd "src/basic/mempool.c"
nm_copy_sd "src/basic/parse-util.c"
nm_copy_sd "src/basic/parse-util.h"
nm_copy_sd "src/basic/path-util.c"
nm_copy_sd "src/basic/path-util.h"
nm_copy_sd "src/basic/prioq.h"
nm_copy_sd "src/basic/prioq.c"
nm_copy_sd "src/basic/process-util.h"
nm_copy_sd "src/basic/process-util.c"
nm_copy_sd "src/basic/random-util.c"
nm_copy_sd "src/basic/random-util.h"
nm_copy_sd "src/basic/refcnt.h"
nm_copy_sd "src/basic/set.h"
nm_copy_sd "src/basic/signal-util.h"
nm_copy_sd_shared "src/basic/siphash24.c"
nm_copy_sd_shared "src/basic/siphash24.h"
nm_copy_sd "src/basic/socket-util.c"
nm_copy_sd "src/basic/socket-util.h"
nm_copy_sd "src/basic/sparse-endian.h"
nm_copy_sd "src/basic/stat-util.c"
nm_copy_sd "src/basic/stat-util.h"
nm_copy_sd "src/basic/stdio-util.h"
nm_copy_sd "src/basic/string-table.c"
nm_copy_sd "src/basic/string-table.h"
nm_copy_sd "src/basic/string-util.c"
nm_copy_sd "src/basic/string-util.h"
nm_copy_sd "src/basic/strv.c"
nm_copy_sd "src/basic/strv.h"
nm_copy_sd "src/basic/time-util.c"
nm_copy_sd "src/basic/time-util.h"
nm_copy_sd "src/basic/umask-util.h"
nm_copy_sd_shared "src/basic/unaligned.h"
nm_copy_sd "src/basic/utf8.c"
nm_copy_sd "src/basic/utf8.h"
nm_copy_sd "src/basic/util.c"
nm_copy_sd "src/basic/util.h"
nm_copy_sd "src/libsystemd-network/arp-util.c"
nm_copy_sd "src/libsystemd-network/arp-util.h"
nm_copy_sd "src/libsystemd-network/dhcp6-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp6-lease-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp6-network.c"
nm_copy_sd "src/libsystemd-network/dhcp6-option.c"
nm_copy_sd "src/libsystemd-network/dhcp6-protocol.h"
nm_copy_sd "src/libsystemd-network/dhcp-identifier.c"
nm_copy_sd "src/libsystemd-network/dhcp-identifier.h"
nm_copy_sd "src/libsystemd-network/dhcp-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp-lease-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp-network.c"
nm_copy_sd "src/libsystemd-network/dhcp-option.c"
nm_copy_sd "src/libsystemd-network/dhcp-packet.c"
nm_copy_sd "src/libsystemd-network/dhcp-protocol.h"
nm_copy_sd "src/libsystemd-network/lldp-internal.h"
nm_copy_sd "src/libsystemd-network/lldp-neighbor.c"
nm_copy_sd "src/libsystemd-network/lldp-neighbor.h"
nm_copy_sd "src/libsystemd-network/lldp-network.c"
nm_copy_sd "src/libsystemd-network/lldp-network.h"
nm_copy_sd "src/libsystemd-network/network-internal.c"
nm_copy_sd "src/libsystemd-network/network-internal.h"
nm_copy_sd "src/libsystemd-network/sd-dhcp6-client.c"
nm_copy_sd "src/libsystemd-network/sd-dhcp6-lease.c"
nm_copy_sd "src/libsystemd-network/sd-dhcp-client.c"
nm_copy_sd "src/libsystemd-network/sd-dhcp-lease.c"
nm_copy_sd "src/libsystemd-network/sd-ipv4ll.c"
nm_copy_sd "src/libsystemd-network/sd-ipv4acd.c"
nm_copy_sd "src/libsystemd-network/sd-lldp.c"
nm_copy_sd "src/libsystemd/sd-event/sd-event.c"
nm_copy_sd "src/libsystemd/sd-id128/id128-util.c"
nm_copy_sd "src/libsystemd/sd-id128/id128-util.h"
nm_copy_sd "src/libsystemd/sd-id128/sd-id128.c"
nm_copy_sd "src/shared/dns-domain.c"
nm_copy_sd "src/shared/dns-domain.h"
nm_copy_sd "src/systemd/_sd-common.h"
nm_copy_sd "src/systemd/sd-dhcp6-client.h"
nm_copy_sd "src/systemd/sd-dhcp6-lease.h"
nm_copy_sd "src/systemd/sd-dhcp-client.h"
nm_copy_sd "src/systemd/sd-dhcp-lease.h"
nm_copy_sd "src/systemd/sd-event.h"
nm_copy_sd "src/systemd/sd-ndisc.h"
nm_copy_sd "src/systemd/sd-id128.h"
nm_copy_sd "src/systemd/sd-ipv4acd.h"
nm_copy_sd "src/systemd/sd-ipv4ll.h"
nm_copy_sd "src/systemd/sd-lldp.h"
2018-05-18 16:58:03 +02:00
Francesco Giudici
5e8c12eece active-connection: fix harmless typo 2018-05-18 10:22:32 +02:00