Commit graph

23205 commits

Author SHA1 Message Date
Lubomir Rintel
ff2d0f5add manager: don't allow femoving a device without traversing proper states
There was a special case for ensuring that the device's configuration
doesn't disappear when some factory is too late at recognizing the
device is just a component of another one.

It was always a bad idea. If the device already had an active
connection (such as for a generated default wired connection), it would
remain around, with a dangling reference to the device.

This effectively reverts commit 5ad69cb29b ('core: remove child devices
without deconfiguring them (bgo #738479)'). It's okay to do so, because
we now wouldn't deconfigure the device upon its removal anyway.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/151/
2019-05-20 12:50:01 +02:00
Thomas Haller
eebcbfae75 dhcp: store dhclient's pid file in "/var/run/NetworkManager" instead of "/var/run"
The pid-file is private to NetworkManager. It should reside in NetworkManager's
run directory instead of "/var/run".

I don't think that changing this location can break existing uses. Why
would somebody outside of NetworkManager care about this file?

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/157
2019-05-20 11:52:31 +02:00
Thomas Haller
b18cda2671 all: merge branch 'th/rename-tests'
Rename tests so that they have unique names.

meson requires that the build executables have unique names (at least,
older versions). Hence, we used to name the test binary different from
the source file ("libnm-test-general" vs. "test-general.c").

The tests should be named "*/tests/test-*", and the source file should
have the same name as the test executable.

Rename the sources so that the names are unique.
2019-05-19 15:55:41 +02:00
Thomas Haller
1da7dfc408 gitignore: merge gitignore files
For the most part, we only have one main .gitignore file.

There were a few nested files, merge them into the main file.

I find it better to have only one gitignore file, otherwise the
list of ignored files is spread out through the working directory.
2019-05-19 14:41:21 +02:00
Thomas Haller
5c0dd32622 src/tests: rename core's "test-general*" to "test-core*" 2019-05-19 14:41:00 +02:00
Thomas Haller
fbe2fdd167 libnm/tests: rename libnm's "test-general" to "test-libnm" 2019-05-19 14:41:00 +02:00
Thomas Haller
0c7bc1a5d9 clients/tests: rename clients/common's "test-general" to "test-clients-common" 2019-05-19 14:00:16 +02:00
Thomas Haller
c99bbc99b0 wifi/tests: rename Wi-Fi's "test-general" to "test-devices-wifi"
We already have 4 other tests that are named "test-general". Rename.
2019-05-19 11:28:53 +02:00
Thomas Haller
d27f6b9d0a keyfile/tests: rename core's "test-keyfile" to "test-keyfile-settings"
We already have "libnm-core/tests/test-keyfile.c" from which we build
"test-keyfile".

Our test binaries should be named the following:

- "*/tests/test-*"

- the test binary "*/tests/test-*" should be build from a source file
  "*/tests/test-*.c". Meaning: the source's and executable's name should
  correspond.

- test binaries should be named uniquely. Also, because older meson
  versions don't like having the same binary name more than once.

Rename to avoid the duplicate name.
2019-05-19 11:25:59 +02:00
Thomas Haller
a80c199e9e gitignore: move ignored libnm-glib/libnm-util files to the bottom of the .gitignore
The bottom contains the tombstones for files that we ignored in
the past, but no longer actually have. Move the lines.
2019-05-19 11:23:23 +02:00
Patrick J. Volkerding
e1df17e0ac hostname-manager: use fqdn for persistent hostname on Slackware
This will be the default for Slackware 15.0 and on.

This should be safe for both master and 1.12.x stable branch, as
no existing Slackware releases are expected to run NM-1.12.x or
later.

Signed-off-by: Robby Workman <rworkman@slackware.com>

https://mail.gnome.org/archives/networkmanager-list/2019-May/msg00011.html
2019-05-19 10:45:07 +02:00
Thomas Haller
041aa3d605 platform/tests: rename platform's "test-general.c"
Older versions of meson don't like building multiple artifacts
with the same name (even if they are in different directories). We
have multiple tests called "test-general.c", and it would be natural
to compile a test binary of the same name.

  Meson encountered an error in file src/tests/meson.build, line 14, column 2:
  Tried to create target "test-general", but a target of that name already exists.

It's generally a bad idea to have in our source tree multiple files with the
same name. Rename the test.

Fixes: 16cd84d346 ('build/meson: rename platform tests to use same name as autotools'):
2019-05-18 11:37:47 +02:00
Thomas Haller
5e11d4bf1f gitlab-ci: disable valgrind on Fedora 30 and Fedora 31 depending on glib2 package
Valgrind is known to report many false positives with certain glib2
versions. Workaround that by disabling it based on the installed
package version.

See-also: https://bugzilla.redhat.com/show_bug.cgi?id=1710417
See-also: https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/155
2019-05-18 11:37:35 +02:00
Thomas Haller
faf55eb2f8 ci: merge branch 'th/gitlab-ci-valgrind'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/155
2019-05-18 10:54:33 +02:00
Thomas Haller
6d76a0974e gitlab-ci: run unit tests under valgrind in gitlab-ci
On Ubuntu 16.04 (trusty) valgrind fails due to rdrand being advertised
but not implemented.

Work around that by installing valgrind from Ubuntu 18.04 (bionic) via
the "contrib/scripts/nm-ci-install-valgrind-in-ubuntu1604.sh" script.
2019-05-18 09:58:52 +02:00
Thomas Haller
16cd84d346 build/meson: rename platform tests to use same name as autotools
First of all, all file names in our source-tree should be unique. We should
not have stuff like "libnm-core/tests/test-general.c" and "src/tests/test-general.c".
The problem here are the C source files, and consequently also the test
binaries have duplicate names. We should avoid that in general. However,
our binaries should have a matching name with the C source. If
"test-general.c" is not good enough, that needs renaming. Not building
"platform-test-general" out of it.

On the other hand, all our tests should have a filename "*/tests/test-*", like
they do for autotools.

Rename the meson platform tests.

It's also important because "tools/run-nm-test.sh" relies on the test
name to workaround valgrind warnings.
2019-05-17 21:47:04 +02:00
Thomas Haller
e966f942cc build: merge branch 'th/build-runstatedir'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/145
2019-05-17 21:34:02 +02:00
Thomas Haller
0cbef232c9 contrib/rpm: set runstatedir to "/run" instead of "/var/run"
Do so on all RHEL/Fedora releases. They all use systemd, and it's the right
choice for all of them.
2019-05-17 21:33:36 +02:00
Thomas Haller
921b7eb716 configure: add --with-runstatedir option to configure
Nowadays, it's adivisable to use "/run" instead of "/var/run" ([1]). This is because
"/var" might not be mounted in early boot, during shutdown, or during rescue mode.

Autoconf 2.70 will add an option --runstatedir ([2], [3]). However, the latest
autoconf release is 2.69 from April 2012, so this might take a while longer. Note
that some distributions patched their autoconf 2.69 to support --runstatedir [4],
but not Fedora.

See also [5], [6] for when we added support for autoconf 2.70's
"--runstatedir".

Add a "--with-runstatedir" option that we can use. Note that this
overwrites autoconf's "--runstatedir" (should it be supported). That
makes sense, because this way the user can set the option regardless of
whether autoconf supports "--runstatedir".

For example, Xen did something similar [7].

Meson currently does not support this either. I will not add a
workaround, because there is hope that it will be eventually fixed [8].
Also, autotools is still our default way for building. There is a
NetworkManager issue about this ([9]), which is still unfixed.

[1] http://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch03s15.html
[2] https://www.gnu.org/prep/standards/html_node/Directory-Variables.html
[3] https://lists.gnu.org/archive/html/bug-autoconf/2013-09/msg00000.html
[4] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=759647
[5] https://bugzilla.gnome.org/show_bug.cgi?id=737139
[6] commit cd3c52a24d ('build: support runstatedir configure option')
[7] https://patchwork.kernel.org/patch/9576621/
[8] https://github.com/mesonbuild/meson/issues/4141
[9] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/24
2019-05-17 21:32:44 +02:00
Thomas Haller
b32ad2344e session-monitor: use "/run/ConsoleKit/database" instead of "/var/run/ConsoleKit/database"
There should be no difference in pratice. But we should not mention "/var/run"
as /var might not be mounted in early boot or rescue environment. Of course,
in those cases ConsoleKit is not running either. But still...
2019-05-17 21:24:18 +02:00
Thomas Haller
6a89f6c368 trivial: fix code comment mentioning "/var/run/NetworManager" to refer to "/run" 2019-05-17 21:24:18 +02:00
Thomas Haller
10688e3d88 tests: use "/run" instead of "/var/run" 2019-05-17 21:24:18 +02:00
Thomas Haller
80c0dab9c7 contrib/rpm: reword comment in NetworkManager.conf
This change is a bit annoying, because we package "NetworkManager.conf" file in
our RPM. So, upon package upgrade, rpm will note that a new config file should
be installed and thus will leave ".rpmnew" files.

Also, don't mention "/var/run". It should really be just "/run" because
"/var" might not be mounted in early boot/initrd or in rescue environment.
2019-05-17 21:24:18 +02:00
Thomas Haller
ad142e1945 build: remove duplicate and unused RUNDIR define 2019-05-17 21:24:18 +02:00
Thomas Haller
5c3f5a846e dhcp/dhcpcd: fix location of PID file for dhcpcd
"RUNDIR" is set to "$runstatedir/NetworkManager". That is not correct,
we must use "$runstatedir".

I don't understand how this could have ever worked. Commit e2ecf5b808
('dhcp: dhcpcd uses a fixed path for PID files') seems to address this issue,
but already then "RUNDIR" was set to "$(localstatedir)/run/NetworkManager".
2019-05-17 21:24:18 +02:00
Thomas Haller
2edf18376f logging: merge branch 'th/logging-syslog-facility'
https://bugzilla.redhat.com/show_bug.cgi?id=1709741

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/147
2019-05-17 21:16:00 +02:00
Thomas Haller
f8cbf06a77 logging: use stack allocated string buffer to constuct NM_LOG_DOMAINS field
NM_LOG_DOMAINS is a comma-separated list of the selected logging domains.

As the number of all logging domains is fixed at compile-time, the maximum
length of the buffer is known.

  $ git grep $'^\t{ LOGD_' | sed 's/.*"\(.*\)" .*/\1/' | xargs | sed 's/  */,/g' | sed 's/^/NM_LOG_DOMAINS=/'
  NM_LOG_DOMAINS=PLATFORM,RFKILL,ETHER,WIFI,BT,MB,DHCP4,DHCP6,PPP,WIFI_SCAN,IP4,IP6,AUTOIP4,DNS,VPN,SHARING,SUPPLICANT,AGENTS,SETTINGS,SUSPEND,CORE,DEVICE,OLPC,INFINIBAND,FIREWALL,ADSL,BOND,VLAN,BRIDGE,DBUS_PROPS,TEAM,CONCHECK,DCB,DISPATCH,AUDIT,SYSTEMD,VPN_PLUGIN,PROXY

Note that the static buffer "_all_logging_domains_to_str" is known
to be large enough to contain these domain names (it's even longer,
as it also contains "ALL", "IP", and "DHCP" alises). We can use that
to define the array of suitable size.
2019-05-17 21:12:38 +02:00
Thomas Haller
9cddb9f8bd logging: use static buffer in nm_logging_all_domains_to_string()
Don't create a heap allocated GString to hold the static
result of nm_logging_all_domains_to_string().

Instead, use a static buffer of the exactly required size.

The main reason to do this, is to get the exact size of
"_all_logging_domains_to_str" buffer. This is the upper
boundary for the size of a string buffer to hold all domain
names.
We will need that boundary in the next commit. The attractive
thing here is that we will have a unit-test failure if this
boundery no longer matches (--with-more-asserts). That means,
this boundary is guarded by unit tests and we don't accidentally
get it wrong when the domains change.

Also, take care to initialize the buffer in a thread-safe manner.
It's easy enough to get right, so there is no excuse for having
non-thread-safe code in logging.
2019-05-17 21:12:38 +02:00
Thomas Haller
cc2553e871 logging: don't misuse SYSLOG_FACILITY field in journal
Syslog's "facility" is a well defined thing and must be
one of a few well-known numbers. Don't re-use it for our
own purposes.

Fixes: 1b808d3b25 ('logging: add native systemd-journald support to nm-logging')

https://bugzilla.redhat.com/show_bug.cgi?id=1709741
2019-05-17 21:12:38 +02:00
Thomas Haller
467ac96dd1 logging: use char pointer for iov_free in _nm_log_impl() 2019-05-17 21:09:20 +02:00
Thomas Haller
138c187376 logging: fix stack overflow in logging for iov_data array
This overflow could only happen when we would try to log a message
with "NM_DEVICE=", "NM_CONNECTION=", and more than 8 logging domains
(_NUM_MAX_FIELDS_SYSLOG_FACILITY - 2).

The latter is never the case. While we sometimes log messages with
more than one logging domain, there are no logging statements that
use most as 8 different logging domains. So, this overflow is not
actually reachable from current code (I think).

Fixes: ed552c732c ('logging: log device and connection along with the message'):
2019-05-17 21:08:34 +02:00
Thomas Haller
87f3c50f48 wwan: minor cleanup for owns_port() to return early
I find

    for (i = 0; i < n_ports && !owns; i++)
        owns = ...

hard to read.

If the condition is satisfied, we can just return the result right
away.
2019-05-17 17:50:16 +02:00
Thomas Haller
4a10feec16 ci: merge branch 'th/randomize-tests-for-gitlab-ci'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/125
2019-05-17 13:46:37 +02:00
Thomas Haller
70487d9ff8 ci: randomize tests during our CI
This affects gitlab-ci and travis-ci, which both run this script.
2019-05-17 13:30:14 +02:00
Jonas DOREL
13be449296 doc: replace "Split DNS" with "Conditional Forwarding"
Split DNS usually refers to "Split Horizon DNS" whereas "Conditional
Forwarding" is specifically for what the documentation describes.

[thaller@redhat.com: rewrote commit message]

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/143
2019-05-17 12:08:45 +02:00
Thomas Haller
ac14ebb322 CONTRIBUTING: explain how assertions work for us 2019-05-16 17:38:07 +02:00
Thomas Haller
03ab1466bd dhcp: use g_return_if_fail() instead of g_assert() in nm_dhcp_client_start_timeout() 2019-05-16 17:01:15 +02:00
Thomas Haller
c307f07207 contrib/rpm: fix comment in ./build_clean.sh -h output 2019-05-16 14:57:39 +02:00
Thomas Haller
bb38bfe731 libnm: mark static "eap_methods_table" array as const
This allows the linker to put the variable into read-only memory,
which is desirable here.
2019-05-16 13:43:07 +02:00
Thomas Haller
fbddd27e73 shared: fix type shenanigans for data pointer of nm_memdup_maybe_a()
The type of the "data" pointer may not be compatible with the type of
the "to_free" / output pointer. This is due to constness, and that we
are unable in C to remove constness from a type.

For example,

    {
        const char *const *data = ...;
        gs_free const char **cpy_to_free = NULL;
        const char **cpy;

        cpy = nm_memdup_maybe_a (300, data, NM_PTRARRAY_LEN (data) + 1, &cpy_to_free);
    }

is prefectly valid , but would not have compiled.

It shows that "data" is not of type "*(&cpy_to_free)", but rather
it might be a non-const pointer of the same type.

Fixes: d0e1d0e626 ('shared: propagate types in nm_malloc_maybe_a(), nm_malloc0_maybe_a(), nm_memdup_maybe_a()')
2019-05-16 11:42:16 +02:00
Thomas Haller
98f4122673 core: ensure NUL padding interface name in nm_utils_ifname_cpy()
Always ensure that the entire buffer is initialized with padding NULs.

For example, valgrind checks whether we access uninitalized memory,
so leaving this uninitalized can be unexpected and cause valgrind
failures. In general, one might be tempted to copy the ifname buffer (of
well known size IFNAMSIZ) with memcpy(). In that case, we should not
have trailing garbage there.

We could use strncpy() for that (which guarantees NUL padding), but
then we still would have to ensure NUL termination. But strncpy() is
frowned upon, so let's not use it here.

Note that g_strlcpy() does not guarantee NUL padding, so it's
unsuitable.

We could also implement this with a combination of memcpy() and
memset(). But in this case, it just seems simpler to iterate over the
16 bytes and do it manually.
2019-05-16 10:17:33 +02:00
Thomas Haller
e9c76f375b platform: avoid valgrind warning about uninitialised memory in _ioctl_call()
==6207== Syscall param ioctl(SIOCETHTOOL) points to uninitialised byte(s)
==6207==    at 0x514603B: ioctl (syscall-template.S:78)
==6207==    by 0x19FC2F: _ioctl_call (nm-platform-utils.c:183)
==6207==    by 0x1A026B: _ethtool_call_handle (nm-platform-utils.c:319)
==6207==    by 0x1A031F: ethtool_get_stringset (nm-platform-utils.c:378)
==6207==    by 0x1A03BC: ethtool_get_stringset_index (nm-platform-utils.c:414)
==6207==    by 0x1A181E: nmp_utils_ethtool_supports_vlans (nm-platform-utils.c:912)
==6207==    by 0x1756D7: link_supports_vlans (nm-linux-platform.c:6508)
==6207==    by 0x1A81D8: nm_platform_link_supports_vlans (nm-platform.c:1536)
==6207==    by 0x14B96B: test_internal (test-link.c:602)
==6207==    by 0x4F5C18D: test_case_run (gtestutils.c:2597)
==6207==    by 0x4F5C18D: g_test_run_suite_internal (gtestutils.c:2685)
==6207==    by 0x4F5BF33: g_test_run_suite_internal (gtestutils.c:2697)
==6207==    by 0x4F5C679: g_test_run_suite (gtestutils.c:2772)
==6207==    by 0x4F5C694: g_test_run (gtestutils.c:2007)
==6207==    by 0x166B4D: main (test-common.c:2092)
==6207==  Address 0x1ffeffeecf is on thread 1's stack
==6207==  in frame #1, created by _ioctl_call (nm-platform-utils.c:110)
==6207==

"ifname" is the stack-allocated array "known_ifnames" of suitable
IFNAMSIZ bytes. But it may not be fully initialized, so using memcpy()
to copy the string leads to unintialized warning.

We really should only copy the valid bytes, either with strcpy() or our
nm_utils_ifname_cpy() wrapper.

Fixes: 856322562e ('platform/ethtool,mii: retry ioctl when interface name was renamed for ehttool/mii')
2019-05-16 10:17:04 +02:00
Thomas Haller
065d891402 platform: use memset() to initialize ifr struct in _ioctl_call()
"struct ifreq" contains a union field, and initalizing the struct is not
guaranteed to fill all bytes with zero (it only sets the first union
member to zero).

Since we later return the entire struct, ensure that it's initialized to
all zero by using memset().
2019-05-16 08:51:56 +02:00
Thomas Haller
d0e1d0e626 shared: propagate types in nm_malloc_maybe_a(), nm_malloc0_maybe_a(), nm_memdup_maybe_a()
The "to_free" pointer should have the suitable type that we are
requesting. Use "typeof()" to preserve and propagate the pointer
type in the macro.
2019-05-16 08:06:46 +02:00
Jose Riha
dc2ef4250e po: update Slovak translation
https://github.com/NetworkManager/NetworkManager/pull/350
2019-05-15 19:56:13 +02:00
Lubomir Rintel
5d44db9108 po/sk: update-po 2019-05-15 19:55:58 +02:00
Thomas Haller
7a0e347b38 libnm: don't assert for success of g_dbus_error_register_error()
libnm/tests/test-general statically links against libnm/libnm-utils.la
and dynamically against libnm/libnm.so. Hence, _nm_utils_init() is invoked
twice, failing the assertion.

That is a bug that must be fixed. For now, just don't assert.
2019-05-15 10:37:03 +02:00
Thomas Haller
8fcadf5328 shared: embed scheme_type in NMSetting8021xSchemeVtable
Since we can easily lookup the vtable for a NMSetting8021xSchemeType,
it is convenient to also easily get the scheme_type for a given
NMSetting8021xSchemeVtable.

On my x86_64, this change is basically for free as it does not increase
the size of NMSetting8021xSchemeVtable, because the scheme_type fits in a
previously unused part of the NMSetting8021xSchemeVtable struct.
2019-05-15 09:49:42 +02:00
Thomas Haller
e813bdaf5e ifcfg-rh: use a macro to initialize setting_8021x_scheme_vtable
Without macro, there is a lot of redundant information which makes it harder
to visually parse what is set.
2019-05-15 09:40:49 +02:00
Thomas Haller
a7c812f9f9 libnm: cleanup register_error_domain() 2019-05-15 08:45:22 +02:00