Commit graph

33 commits

Author SHA1 Message Date
Thomas Haller
3a97604a27
libnm: don't depend nm-crypto on "nm-error.h"
"nm-error.h" is public API of libnm, and contains error numbers and
quarks. Clearly our "nm-crypto" implementation wants to use those
errors.

I want to move "nm-crypto" out of libnm, and as it's more basic, I think
it should not have a dependency on all of libnm-core. Also because
libnm-core currently uses nm-crypto, so there would be a circular
dependency. Which would be possible to do (libnm-core-aux-intern is
also used in such a way). But it's better avoided, to have clear
hierarchy of dependencies.

Add a version of the same error codes to libnm-base. libnm-base is a
very basic dependency (just one step above libnm-glib-aux).
2022-03-29 11:56:03 +02:00
Thomas Haller
89bba8fa84
libnm-base: add "nm-base.c" for implementing stuff from "nm-base.h" 2022-03-29 11:56:03 +02:00
Thomas Haller
b21138f4e9
priv-helper: fix D-Bus patch to not contain forbidden character '-'
"-" is not allowed as D-Bus path and interface name, and discouraged as
bus name. This cause nm-priv-helper to crash, because GDBus asserts the
the object path is valid.

Replace the '-' with '_'. This way, it's consistent with
"nm_dispatcher".

Fixes: d68ab6b8f0 ('nm-sudo: rename to nm-priv-helper')
(cherry picked from commit 16a45d07ed)
2022-02-09 18:49:47 +01:00
Beniamino Galvani
d68ab6b8f0 nm-sudo: rename to nm-priv-helper
The name "nm-sudo" reminds of the "sudo" tool, and this is a bit
confusing because it's not related. Rename the service to
"nm-priv-helper", which stands for "NM privileged helper".

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/938
2022-01-11 21:46:55 +01:00
Thomas Haller
615221a99c format: reformat source tree with clang-format 13.0
We use clang-format for automatic formatting of our source files.
Since clang-format is actively maintained software, the actual
formatting depends on the used version of clang-format. That is
unfortunate and painful, but really unavoidable unless clang-format
would be strictly bug-compatible.

So the version that we must use is from the current Fedora release, which
is also tested by our gitlab-ci. Previously, we were using Fedora 34 with
clang-tools-extra-12.0.1-1.fc34.x86_64.

As Fedora 35 comes along, we need to update our formatting as Fedora 35
comes with version "13.0.0~rc1-1.fc35".
An alternative would be to freeze on version 12, but that has different
problems (like, it's cumbersome to rebuild clang 12 on Fedora 35 and it
would be cumbersome for our developers which are on Fedora 35 to use a
clang that they cannot easily install).

The (differently painful) solution is to reformat from time to time, as we
switch to a new Fedora (and thus clang) version.
Usually we would expect that such a reformatting brings minor changes.
But this time, the changes are huge. That is mentioned in the release
notes [1] as

  Makes PointerAligment: Right working with AlignConsecutiveDeclarations. (Fixes https://llvm.org/PR27353)

[1] https://releases.llvm.org/13.0.0/tools/clang/docs/ReleaseNotes.html#clang-format
2021-11-29 09:31:09 +00:00
Thomas Haller
45bcedb77e
core: move NM_DNS_PRIORITY_DEFAULT_{NORMAL,VPN} to libnm-base
We will use these values from NML3Cfg, and it seems wrong that NML3Cfg
would include "dns/nm-dns-manager.h" for this.

Enums are very "static". They have no logic, and there is less need to
separate the code well. Meaning, it doesn't hurt to define this enum
in "libnm-base/nm-base.h" which can be included by (almost) anybody.
2021-09-15 22:08:42 +02:00
Gris Ge
9958510f28
bond: add support of queue_id of bond port
Introduced `NMSettingBondPort` to hold the new setting class with single
property `NM_SETTING_BOND_PORT_QUEUE_ID`.

For dbus interface, please use `bond-port` as setting name and
`queue-id` as property name.

Unit test cases for ifcfg reader and writer included.

Signed-off-by: Gris Ge <fge@redhat.com>

https://bugzilla.redhat.com/show_bug.cgi?id=1949127

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/952
2021-08-26 23:04:31 +02:00
Thomas Haller
ea49b50651
all: add some README.md files describing the purpose of our sources 2021-08-19 17:51:11 +02:00
Thomas Haller
5d9a46ad34
nm-sudo: use nm_io_sockaddr_un_set() in nm_sudo_utils_open_fd() 2021-08-04 08:23:59 +02:00
Beniamino Galvani
bace14fe1f core: introduce device 'allowed-connections' property
Configuration can have [device*] and [connection*] settings and both
can include a 'match-device=' key, which is a list of device-specs.

Introduce a new 'allowed-connections' key for [device*] sections,
which specifies a list of connection-specs to indicate which
connections can be activated on the device.

With this, it becomes possible to have a device configuration like:

  [device-enp1s0]
  match-device=interface-name:enp1s0
  allowed-connections=except:origin:nm-initrd-generator

so that NM in the real root ignores connections created by the
nm-initrd-generator, and starts activating a persistent
connection. This requires also setting 'keep-configuration=no' to not
generate an assumed connection.
2021-07-27 17:43:45 +02:00
Beniamino Galvani
df2fe15714 core: add 'keep-configuration' device configuration option
Add a new 'keep-configuration' device option, set to 'yes' by
default. When set to 'no', on startup NetworkManager ignores that the
interface is pre-configured and doesn't try to keep its
configuration. Instead, it activates one of the persistent
connections.
2021-07-27 16:36:48 +02:00
Thomas Haller
de5dddccbe
core: get file descriptor to ovsdb unix socket from nm-sudo
To talk to ovsdb, we use the unix socket at
/var/run/openvswitch/db.sock. But that socket is owned by another user
and NetworkManager would need dac_override capability to open it.

We want to drop dac_override, but we still need to talk to ovsdb. Add a
GetFD() method to nm-sudo.

We still first try to open the socket directly. Maybe it just works.

Note that SELinux may block passing file descriptors from nm-sudo. If it
doesn't work for you, test with SELinux permissive mode and wait for an
SELinux update.
2021-07-26 15:31:46 +02:00
Thomas Haller
f137b32d31
sudo: introduce nm-sudo D-Bus service
NetworkManager runs as root and has lots of capabilities.
We want to reduce the attach surface by dropping capabilities,
but there is a genuine need to do certain things.

For example, we currently require dac_override capability, to open
the unix socket of ovsdb. Most users wouldn't use OVS, so we should
find a way to not require that dac_override capability. The solution
is to have a separate, D-Bus activate service (nm-sudo), which
has the capability to open and provide the file descriptor.

For authentication, we only rely on D-Bus. We watch the name owner
of NetworkManager, and only accept requests from that service. We trust
D-Bus to get it right a request from that name owner is really coming
from NetworkManager. If we couldn't trust that, how could PolicyKit
or any authentication via D-Bus work? For testing, the user can set
NM_SUDO_NO_AUTH_FOR_TESTING=1.

https://bugzilla.redhat.com/show_bug.cgi?id=1921826
2021-07-26 15:31:46 +02:00
Thomas Haller
bae22a45d8
lgtm: suppress lgtm[cpp/duplicate-include-guard] warning in ethtool header
lgtm.com doesn't like this:

  Query pack:com.lgtm/cpp-queries
  Query ID:cpp/duplicate-include-guard

  Using the same include guard macro in more than one header file may
  cause unexpected behavior from the compiler.

both for src/libnm-base/nm-ethtool-utils-base.h and
src/libnm-client-public/nm-ethtool-utils.h. But this is intentional,
because these two files are supposed to be identical (but compiled
twice, under different context).

Suppress the warning.
2021-06-01 17:54:07 +02:00
Thomas Haller
6439c243e7
systemd: move "src/core/systemd" to "src/libnm-systemd-core"
This follows the recently introduced naming scheme and directory layout.
"libnm-systemd-core" is an independent component, and as such should no
be inside "src/core/".

Move it.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/875
2021-05-30 09:45:05 +02:00
Thomas Haller
1da1ad9c99
firewall: make firewall-backend configurable via "NetworkManager.conf"
"iptables" and "nftables" will be supported. Currently, the code is
unused and only "iptables" is supported.
2021-05-14 11:41:32 +02:00
Gris Ge
652ddca04c
ethtool: Introducing PAUSE support
Introducing ethtool PAUSE support with:

 * ethtool.pause-autoneg on/off
 * ethtool.pause-rx on/off
 * ethtool.pause-tx on/off

Limitations:
 * When `ethtool.pause-autoneg` is set to true, the `ethtool.pause-rx`
   and `ethtool.pause-tx` will be ignored. We don't have warning for
   this yet.

Unit test case included.

Signed-off-by: Gris Ge <fge@redhat.com>

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/829
2021-05-12 18:04:46 +02:00
Andrew Zaborowski
4229c97012
iwd: Mirror NM connections to IWD network config files
Watch for NMSettingConnection changes and creation signals and convert
them to IWD format and write them to the configured IWD profile storage
directory.  The logic is off by default and gets enabled when the new
iwd-config-path setting in nm.conf's [main] group is set to a path to
an existing directory.

The idea here is that when a user edits an NM connection profile, the
change is immediately mirrored in IWD since IWD watches its
configuration directory using inotify.  This way NM clients can be used
to edit 802.1x settings, the PSK passphrase or the SSID -- changes that
would previously not take effect with the IWD backend.

Some precautions are taken to not make connections owned by a user
available to other users, such connections are not converted at all.
In all other cases where a connection cannot be converted sufficiently
well to the IWD format, for various reasons, we also give up and not
mirror these connections.

Due to IWD limitations and design differences with NM this logic has
many problems where it may not do its task properly.  It's meant to work
on a best-effort and "better than nothing" basis, but it should be safe
in that it shouldn't delete users data or reveal secrets, etc.  The most
obvious limitation is that there can be multiple NM connections
referring to the same SSID+Security tuple and only one IWD profile can
exist because the filename is based on only the SSID+Security type.  We
already had one NM connection selected for each IWD KnownNetwork and
referenced by a pointer, so we ignore changes in NM connections other
than that selected one.
2021-03-23 14:24:42 +01:00
Thomas Haller
0ef94bd1f0
base: add nm_net_aux_rtnl_rtntype_{n2a,a2n}() helpers 2021-03-23 14:19:37 +01:00
Thomas Haller
5852cd2252
base: add "nm-net-aux.c" helper 2021-03-23 14:19:37 +01:00
Thomas Haller
cd00b04099
libnm: expose NM_IW_ESSID_MAX_SIZE define 2021-03-18 11:30:56 +01:00
Thomas Haller
0033da8f61
config: add "nm-base/nm-config-base.h"
Note that we take defines from "src/core/nm-config.h" which
are GPL-2.0-or-later licensed.

libnm-base we want to include in other LGPL licensed sources,
we it must also be LGPL.

"relicense" the code that I take. I don't think it's a problem, because:

- these are only plain defines. To which extend is that even
  copyrightable?

- as far as I see, all the code was contributed by people who agreed
  to such relicensing. See RELICENSE.md file.
2021-03-15 17:10:52 +01:00
Thomas Haller
398b509931
base: move "libnm-core-intern/nm-core-types-internal.h" to libnm-base
"libnm-platform" has no dependency on libnm-core. To have the symbols
accessible, move them to libnm-base.
2021-03-05 11:27:02 +01:00
Thomas Haller
40fc7bd39a
base: move bridge defines to libnm-base/nm-base.h 2021-03-05 11:09:15 +01:00
Thomas Haller
8a3df8419a
libnm-base: add internal _NMVlanFlags type 2021-03-05 11:09:13 +01:00
Thomas Haller
ad91e92b25
libnm-base: add internal _NM80211Mode type 2021-03-05 11:09:13 +01:00
Thomas Haller
367be3585f
libnm-base: add internal _NMDeviceWifiCapabilities type 2021-03-05 11:09:13 +01:00
Thomas Haller
096ee5ed6e
libnm-base: add internal _NMSettingWirelessWakeOnWLan type
NMSettingWirelessWakeOnWLan is public API of libnm/libnm-core
in "src/libnm-core-public/"

We want that libnm-platform is independet of libnm-core to keep
the dependencies smaller and code better separated. Hence we
cannot use that enum there.

Duplicate NMSettingWirelessWakeOnWLan as _NMSettingWirelessWakeOnWLan
in libnm-base.
2021-03-05 11:09:13 +01:00
Thomas Haller
08ce50c6d8
build/meson: cleanup dependencies for libnm-base 2021-02-28 10:42:04 +01:00
Thomas Haller
309dccf5f9
build/meson: cleanup libnm-glib-aux dependencies
Avoid dependencies but explicitly link the static library where it is
used.

This also fixes that we linked libnm-log-core into
libnm-settings-plugin-ifcfg-rh.so, which duplicated the symbols
while it should used them from NetworkManager.
2021-02-28 10:42:04 +01:00
Thomas Haller
635d84b896
build: remove "shared/" from include search path
There is nothing left there.
2021-02-24 12:49:06 +01:00
Thomas Haller
9dc84b32b0
build: move "shared/nm-{glib-aux,log-null,log-core}" to "src/libnm-{glib-aux,log-null,log-core}" 2021-02-24 12:48:20 +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