Commit Graph

21088 Commits

Author SHA1 Message Date
Lubomir Rintel
abaa852866 manager: don't assign a new link to a device of a different link type 2017-10-30 17:38:37 +01:00
Lubomir Rintel
097d41b8e6 manager: match device type when removing an ip interface
Otherwise we might end up removing a wrong device of a same name.
2017-10-30 17:38:37 +01:00
Lubomir Rintel
67b265182f utils: don't assume a device with master won't have IP configuration
Whether the ip[46]-config exists is a better way, and we already check
that.
2017-10-30 17:38:37 +01:00
Lubomir Rintel
4391ba82dd cli/trivial: drop default branch from some cases
This way not handling a known enum value will be caught by a compiler
warning.
2017-10-30 17:38:37 +01:00
Lubomir Rintel
acd814d50a generate-setting-docs: error out on missing documentation 2017-10-30 17:38:37 +01:00
Lubomir Rintel
c3080c79dc ip-tunnel: fix a typo 2017-10-30 17:38:37 +01:00
Thomas Haller
7f84f15e06 core: avoid coverity warning in device factory's _add_factory() (3)
2. NetworkManager-1.9.2/src/devices/nm-device-factory.c:312:
returned_pointer: Assigning value from "g_slist_append(list,
g_object_ref(factory))" to "list" here, but that stored value is
overwritten before it can be used.

Fixes: 98afc76184
Fixes: 449940af1d
2017-10-30 16:55:26 +01:00
Thomas Haller
d0d962d3d1 ifcfg: fix invalid free in parse_route_line()
Cannot free NM_PTRARRAY_EMPTY(). Discovered by coverity.

Fixes: 6d675a943b
2017-10-30 16:35:02 +01:00
Thomas Haller
62a57dab49 device: workaround coverity warning
Coverity doesn't like this. Refactor a bit, hoping that it fares better.

1. Defect type: ASSERT_SIDE_EFFECT
1. NetworkManager-1.9.2/src/devices/nm-device.c:10226: assignment_where_comparison_intended: Assignment "ip_ifindex = nm_device_get_ip_ifindex(self)" has a side effect. This code will work differently in a non-debug build.
2. NetworkManager-1.9.2/src/devices/nm-device.c:10226: remediation: Did you intend to use a comparison ("==") instead?
2017-10-30 16:28:44 +01:00
Thomas Haller
449940af1d core: avoid coverity warning in device factory's _add_factory() (2)
2. NetworkManager-1.9.2/src/devices/nm-device-factory.c:312:
returned_pointer: Assigning value from "g_slist_append(list,
g_object_ref(factory))" to "list" here, but that stored value is
overwritten before it can be used.

Fixes: 98afc76184
2017-10-30 16:28:44 +01:00
Lubomir Rintel
fb8ea059e6 cli: ignore PAGER when escalating privileges
nmcli typically doesn't run setuid, nor uses file capabilities or is labelled
for a SELinux domain trainsition upon execution.

But in case anyone has any reason to do that, we should follow good
security practices and not exec whatever is set in the environment.
2017-10-30 15:27:05 +01:00
Thomas Haller
98afc76184 core: avoid coverity warning in device factory's _add_factory()
2. NetworkManager-1.9.2/src/devices/nm-device-factory.c:312:
returned_pointer: Assigning value from "g_slist_append(list,
g_object_ref(factory))" to "list" here, but that stored value is
overwritten before it can be used.
2017-10-30 14:43:42 +01:00
Thomas Haller
66e1fdb7ec core: workaround coverity/compiler warning about tautological compare in nm_log_ptr()
Coverity claims:

1. NetworkManager-1.9.2/src/devices/team/nm-device-team.c:303:
unsigned_compare: This greater-than-or-equal-to-zero comparison of an
unsigned value is always true. "0U <= LOGL_DEBUG".
2017-10-30 14:41:41 +01:00
Thomas Haller
f088afe7e9 platform: remove unreachable code from nmp_cache_lookup_link_full()
If @ifname is set, we above lookup by name (nmp_lookup_init_link_by_ifname)
and set ifname to NULL. Hence, inside the loop, the check for ifname is
never true.
2017-10-30 14:34:04 +01:00
Thomas Haller
89a9908abf ifcfg-rh: avoid Unreachable coverity warning in reader
The loops never run more then once.

unreachable: Since the loop increment "iter++;" is unreachable, the loop
body will never execute more than once.
2017-10-30 14:31:29 +01:00
Thomas Haller
e3a582202f wifi: refactor nm_wifi_utils_level_to_quality() not to assert
Apparantly, the assert might fail (on i386?). Unclear why that would possibly
happen. Anyway, replace the assert.
2017-10-30 14:14:18 +01:00
Thomas Haller
8cbb6d9e86 wifi/tests: add test whether nm_wifi_utils_level_to_quality() is in range 2017-10-30 14:14:17 +01:00
Thomas Haller
6d63b6484f systemd: avoid coverity warning about Deadcode
Coverity is unhappy about comparing the literal LOG_DEBUG value:

1. Defect type: CONSTANT_EXPRESSION_RESULT
1. NetworkManager-1.9.2/src/systemd/src/libsystemd/sd-event/sd-event.c:2652:
result_independent_of_operands: "7 >= (_level & 7)" is always true regardless
of the values of its operands. This occurs as the logical first operand of "?:".

Work around by instead using an inline function.
2017-10-30 14:14:05 +01:00
Thomas Haller
287d1aee77 all: avoid coverity warnings about "Missing Initialization"
31. NetworkManager-1.9.2/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c:974:
uninit_use_in_call: Using uninitialized value "contents_rest" when
calling "__strtok_r_1c".

33. NetworkManager-1.9.2/src/nm-core-utils.c:1957:
uninit_use: Using uninitialized value "s".

148. NetworkManager-1.9.2/src/nm-core-utils.c:1924:
uninit_use_in_call: Using uninitialized value "s" when calling
"nm_strstrip_avoid_copy".
2017-10-30 14:13:15 +01:00
Thomas Haller
f3146de41b libnm: avoid unnecessary copies accessing NMIPRoute's attributes
We want to support large number of routes. Reduce the number
of copies, by adding internal accessor functions.

Also, work around a complaint from coverity:

  46. NetworkManager-1.9.2/libnm-core/nm-utils.c:1987:
  dereference: Dereferencing a null pointer "names".
2017-10-30 14:12:41 +01:00
Thomas Haller
4a8a5495a9 all: avoid coverity warnings about "Wrong Check of Return Value"
30. NetworkManager-1.9.2/src/settings/plugins/keyfile/nms-keyfile-writer.c:218:
check_return: Calling "g_mkdir_with_parents" without checking return
value (as is done elsewhere 4 out of 5
 times).

25. NetworkManager-1.9.2/src/platform/nm-linux-platform.c:3969:
check_return: Calling "_nl_send_nlmsg" without checking return value (as
is done elsewhere 4 out of 5 times).

34. NetworkManager-1.9.2/src/nm-core-utils.c:2843:
negative_returns: "fd2" is passed to a parameter that cannot be negative.

26. NetworkManager-1.9.2/src/devices/wwan/nm-modem-broadband.c:897:
check_return: Calling "nm_utils_parse_inaddr_bin" without checking
return value (as is done elsewhere 4 out of 5 times).

3. NetworkManager-1.9.2/src/devices/bluetooth/nm-bluez5-manager.c:386:
check_return: Calling "g_variant_lookup" without checking return value
(as is done elsewhere 79 out of 83 times).

16. NetworkManager-1.9.2/libnm-util/nm-setting.c:405:
check_return: Calling "nm_g_object_set_property" without checking return
value (as is done elsewhere 4 out of 5 times).
2017-10-30 14:10:56 +01:00
Thomas Haller
de65d3da91 shared: fix nm_steal_fd() for handling zero file descriptor
Zero is a valid file descriptor.

Fixes: 956b3e8bd5
2017-10-30 11:44:37 +01:00
Thomas Haller
31facf6fad cli: fix leak in _output_selection_parse()
Reported by coverity.

Fixes: fdd40b6a68
2017-10-30 11:18:25 +01:00
Murilo Opsfelder Araujo
fa61e78d80 contrib/fedora: Add mockbuild.sh
This script comes handy to build from git tree without having to
install build dependencies on the system, the actual build happens
inside mock environment.

https://github.com/NetworkManager/NetworkManager/pull/34
2017-10-30 11:04:20 +01:00
Thomas Haller
1ee6dea02f platform/tests: relax checking for signals in test-link-linux
# random seed: R02S4ca8cfc3dace399c0f15b42411e45d2e
  1..48
  # Start of link tests
  ok 1 /link/bogus
  PASS: src/platform/tests/test-link-linux 1 /link/bogus
  ok 2 /link/loopback
  PASS: src/platform/tests/test-link-linux 2 /link/loopback

  nmtst: initialize nmtst_get_rand() with NMTST_SEED_RAND=2697682474
  ok 3 /link/internal
  PASS: src/platform/tests/test-link-linux 3 /link/internal
  ok 4 /link/external
  PASS: src/platform/tests/test-link-linux 4 /link/external
  # Start of software tests
  ./tools/run-nm-test.sh: line 193:  7589 Trace/breakpoint trap   (core dumped) "${NMTST_DBUS_RUN_SESSION[@]}" "$TEST" "$@"
  NMPlatformSignalAssert: src/platform/tests/test-link.c:298, test_slave(): failure to accept signal 0 times: 'link-changed-changed' ifindex 9 (1 times received)
  ERROR: src/platform/tests/test-link-linux - too few tests run (expected 48, got 4)
  ERROR: src/platform/tests/test-link-linux - exited with status 133 (terminated by signal 5?)
2017-10-30 11:03:55 +01:00
juga0
3aba3e38c3 dhcp: add support for dhcpcanon client
https://github.com/NetworkManager/NetworkManager/pull/31
2017-10-30 10:43:10 +01:00
Beniamino Galvani
be320e2be7 ifcfg-rh: set team and bond master for any connection type
Now the plugin can only recognize team or bond slaves of type
ethernet, vlan or infiniband.

Instead, check the presence of a team or bond master for all types of
connection to allow arbitrary stacking of interfaces.
2017-10-27 22:52:15 +02:00
Beniamino Galvani
44ffa57c5d ifcfg-rh/trivial: move code 2017-10-27 22:51:50 +02:00
Beniamino Galvani
6d21711445 device: add proxy setting to generated connections
Add a proxy setting to generated connections because after commit
6f94b16507 ("libnm: fix nm_connection_diff() for settings without
properties") the matching between a connection having the setting and
another connection without it fails.  Before the commit, since no proxy
property is marked as inferrable, such comparison succeeded.
2017-10-27 20:31:01 +02:00
Thomas Haller
88c24ffc6a tests: increase timeout for arping test
I hit an assertion failure running with valgrind on a busy machine.
Maybe the timeout is just not long enough for every case.

Increase it.
2017-10-27 11:15:51 +02:00
Thomas Haller
e1dbe35acd systemd: merge branch systemd into master 2017-10-27 10:42:32 +02:00
Thomas Haller
268a9d971c systemd: update code from upstream (2017-10-27)
This is a direct dump from systemd git on 2017-10-27, git commit
f630daaae90b48606f857c2d35a68f82e4471c8e.

======

SYSTEMD_DIR=../systemd
COMMIT=f630daaae90b48606f857c2d35a68f82e4471c8e

(
  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/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"
2017-10-27 10:40:31 +02:00
Thomas Haller
ba13c02e48 ifcfg-rh: merge branch 'th/ifcfg-reread-add' 2017-10-27 10:28:55 +02:00
Thomas Haller
8a1d483ca8 ifcfg-rh: reread from disk when adding new connection 2017-10-27 10:28:41 +02:00
Thomas Haller
304bf5563f ifcfg-rh: refactor nm_settings_plugin_add_connection() to return on error early 2017-10-27 10:28:41 +02:00
Thomas Haller
74eeb90d96 ifcfg-rh: don't check can_write_conection before writing
nms_ifcfg_rh_writer_write_connection() also calls nms_ifcfg_rh_writer_can_write_connection()
as first check. No need to duplicate the check.
2017-10-27 10:28:41 +02:00
Thomas Haller
4af4e92646 ifcfg-rh: split function to write connection to disk 2017-10-27 10:28:41 +02:00
Beniamino Galvani
7ed57f2286 ifcfg-rh: write wired setting for bridge connections
Write the wired setting of bridge connections, otherwise properties
such as ethernet.cloned-mac-address won't be saved.
2017-10-26 22:37:15 +02:00
Thomas Haller
53aa340476 nmcli: fix wrongly adding a generic setting when constructing connection
nmc_read_connection_properties() iterates over the input arguments, and
completes the connection.

Initially, the type is not yet known, in that case, we should not wrongly
assume that this is a generic connection. Later, when the type is specified,
con_settings() will return the correct settings.

Previously, this would wrongly add a [generic] section:

  $ nmcli connection add type ethernet ifname eth1 con-name ethie autoconnect no ipv4.method auto ethernet.cloned-mac-address random

With the fix, it still works to specify the type later:

  $ nmcli connection add ifname eth1 con-name ethie autoconnect no ipv4.method auto type ethernet

but it doesn't work, to specify the type after type-specific options:

  $ nmcli connection add ifname eth1 con-name ethie autoconnect no ipv4.method auto ethernet.cloned-mac-address random type ethernet
  Error: invalid or not allowed setting 'ethernet': 'ethernet' not among [connection, ipv4, ipv6, proxy].

The patch doesn't change the latter limitation.

Fixes: c5324ed285
2017-10-26 19:07:24 +02:00
Beniamino Galvani
ef52122469 shared: fix compilation on 32-bit archictectures
shared/nm-utils/nm-hash-utils.c:110:3: error: right shift count >= width of type [-Werror]
   h = h ^ ((guint) (((uintptr_t) ptr) >> 32)) ^ ((guint) ((uintptr_t) ptr));
   ^

Even if the branch is not reached on 32-bit architectures, the
compiler still emits a warning for the 32-bit right shift.

Fixes: ee76b0979f
2017-10-26 15:13:40 +02:00
Thomas Haller
095a419e70 libnm: merge branch 'th/connection-diff-empty' 2017-10-26 15:08:30 +02:00
Thomas Haller
975eeda611 libnm: fix the return value of nm_setting_diff() if a results hash was given
Previously, nm_setting_diff() would return !(*results), that means,
if the caller passed in a hash table (empty or not), the return value
would always be FALSE, indicating a difference.

That is not documented, and makes no sense.

The return value, should solely indicate whether some difference was
found. The only convenience is, if nm_setting_diff() created a hash
table internally and no difference was found, it would destroy
it again, without returning it to the caller.
2017-10-26 14:27:45 +02:00
Thomas Haller
6f94b16507 libnm: fix nm_connection_diff() for settings without properties
NMSettingGeneric has no properties at all. Hence, nm_connection_diff() would report that
a connection A with a generic setting and a connection B without a generic setting are
equal.

They are not. For empty settings, let nm_setting_diff() return also empty difference
hash.
2017-10-26 14:23:46 +02:00
Thomas Haller
ecf85fd50f ifcfg-rh/tests: test nm_connection_diff() not showing difference for empty generic setting 2017-10-26 14:16:02 +02:00
Beniamino Galvani
33cb2f3723 settings: keep connection alive in delete_auth_cb()
Before commit 3ecb57fdc4 ("settings: get rid of callback arguments
for nm_settings_connection_delete()") audit logging was done in the
callback, which was run by nm_settings_connection_delete() with a
reference to the connection to keep it alive. Now we have to keep an
extra reference to ensure it doesn't go away.

Fixes: 3ecb57fdc4
2017-10-26 08:54:53 +02:00
Murilo Opsfelder Araujo
301cf7151b contrib/fedora: Update required packages
Add dhclient and iptables packages to build dependencies to satisfy
rpmbuild complaints:

```
error: Failed build dependencies:
	dhclient is needed by NetworkManager-1:1.9.2-18653.43dba57439.fc28.x86_64
	iptables is needed by NetworkManager-1:1.9.2-18653.43dba57439.fc28.x86_64
ERROR: rpmbuild FAILED
```

https://github.com/NetworkManager/NetworkManager/pull/33
2017-10-25 18:08:34 +02:00
Beniamino Galvani
429a1becbb release: bump version to 1.9.3 (development) 2017-10-25 15:40:00 +02:00
Thomas Haller
fda635f5e9 ifcfg-rh: merge branch 'th/ifcfg-rule-write-rh1384799'
https://bugzilla.redhat.com/show_bug.cgi?id=1384799
2017-10-25 14:06:52 +02:00
Thomas Haller
7028818a83 ifcfg-rh/trivial: add code comment about re-reading connection in writer 2017-10-25 14:04:36 +02:00
Thomas Haller
669e693169 ifcfg-rh: don't allow policy routing mixed with an existing rule file
Eventually, we want to fully implement policy routing and
handle rules as well. When that happens, we will use the
route-table setting to tell NetworkManager to handle the
rule file as well.

Since we currently don't yet support that, we should reject
configuring a non-zero routing table combined with a rule file,
because later we will change behavior in that case.
2017-10-25 14:04:36 +02:00