222 Commits

Author SHA1 Message Date
Antonio Alvarez Feijoo
8640ea822f systemd: add initrd-specific services
Decouple from a specific initrd generator (dracut) the systemd services that
provide networking in the initrd using NM, thus allowing other systemd-based
initrd generators to take advantage of it.

These new services are:
- `NetworkManager-config-initrd.service`: it starts very early at boot, parses
the kernel command line using `nm-initrd-generator` and sets the
`/run/NetworkManager/initrd/neednet` flag to activate the other initrd services,
and also sets the hostname if needed.
- `NetworkManager-initrd.service`: it basically does the same job as the
`NetworkManager.service`, but in the initrd.
- `NetworkManager-wait-online-initrd.service`: ordered before
`network-online.target`, it will allow other services that require networking to
delay their start until NM has finished.
2025-02-26 09:31:05 +00:00
Fernando Fernandez Mancera
8d639abb2f .gitignore: include m4/build-to-host.m4
When the build environment is different from the target runtime
environment, file names may need to be converted from the build env
syntax to the target env syntax. This is handled by some generated
macros. This must be ignored by git.

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2024-02-20 12:12:25 +01:00
Thomas Haller
03b9a255d2 libnm: remove unused "nm-property-compare.c"
"nm-property-compare.c" only contains nm_property_compare(), which is
broken.

It tries to compare string dictionaries as equal regardless of the
order of elements. It gets it wrong, for dictionaries with duplicate
keys. Which means, it can only be used with trusted variants that are
known to not contain duplicates. Which is quite a non-starter.

Also, the idea of a compare function for GVariant that ignores the order
of dictionary elements seems wrong. Even if for a certain application
the order does not matter, it still depends what the upper layer makes
of duplicate keys (will they bail out, or take the first/last occurrence
of a duplicate key?). nm_property_compare() doesn't have the knowledge
how upper layer handles it, and it's not obvious what's the right
choice. For example, if you use g_variant_lookup(), the first occurrence
is preferred. If you iterate over the children, possibly later
occurrences overwrite earlier ones.

It's ill defined, and maybe shouldn't be done. What should instead
happen, is that upper layers normalize (sort, uniquify) the keys, so
that we can do a full comparison. For that we have nm_g_variant_cmp().

Drop the now unused code. The core of the function still exists as
nm_g_variant_cmp().
2024-01-04 10:03:00 +01:00
Íñigo Huguet
81fdd4da3a gitignore: ignore nm-settings-docs-gir-*.xml
The old src/libnm-client-impl/nm-settings-docs-gir.xml has been splitted
into different files specific for nmcli, keyfile, ifcfg-rh and dbus.
Ignore these files that are autogenerated.

We don't expect to add more variants, but better to use a wilcard to
cover this possibility. Also for the nm-property-infos-*.xml files.

Fixes: f4fbc59a16 ('man nm-setting-*: proper format for gtkdoc constants')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1748
2023-10-18 08:04:44 +02:00
Íñigo Huguet
69f58fcb01 gitignore: ignore VSCode project and clangd cache folders
(cherry picked from commit cea9d4634f)
2023-07-29 15:01:56 +02:00
Thomas Haller
1d767bb1cd gitignore: ignore "po/.Makefile.patched" file
Fixes: 7ee0da3eaf ('build: don't "update-po" during make dist')
2022-10-31 09:20:53 +01:00
Thomas Haller
d699f76855 libnm: generate "gen-metadata-nm-settings-libnm-core.xml" with meta data
libnm-core-impl has lots of internal meta data about the properties.
In particular, which properties exist (their names), and their D-Bus
type.

We should use this information for our manual pages. For example,
currently `man nm-settings-dbus` has nonsense like: "Value Type: array
of string", when it should be reall "as".

In a first step, generate an XML with that meta data for later use.
2022-10-31 09:11:30 +01:00
Thomas Haller
1bfe908c2e nmcli: rename "generate-docs-nm-settings-nmcli" to "gen-metadata-nm-settings-nmcli"
This is the better name, becuse this is not in particular about "docs".
It's about generating an XML with the information from the settings
meta data for nmcli.

We will do something similar with the libnm-core meta data.
2022-10-31 09:11:30 +01:00
Thomas Haller
1c9bc85d0c gitignore: ignore m4/gettext artifacts 2022-07-05 18:31:37 +02:00
Martin Blanchard
19a6affd3a build: stop relying on intltool for i18n
Recent gettext version can extract and merge back strings from and to
various file formats, no need for intltool anymore.

https://wiki.gnome.org/Initiatives/GnomeGoals/GettextMigration

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/133

https://github.com/NetworkManager/NetworkManager/pull/303
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/96

Clarification about the use of AM_GNU_GETTEXT_REQUIRE_VERSION:

In configure.ac, specify the minimum gettext version we require, rather
than the exact one. This fixes a situation where the autoconf macros
used for gettext will be the latest available on the system (for
example, 0.20); but the copied-in Makefile.in.in will be for the exact
version specified in configure.ac (in this case, 0.19).

In that situation, the gettext build rules will error out at `make` time
with the message:
   *** error: gettext infrastructure mismatch: using a Makefile.in.in
   from gettext version 0.19 but the autoconf macros are from gettext
   version 0.20

Avoid that by specifying a minimum version dependency rather than an
exact one. This should not cause problems as we haven’t committed any
generated or external gettext files into git, so each developer will end
up regenerating the build system for their system’s version of gettext,
as expected.

See the subsection of
https://www.gnu.org/software/gettext/manual/html_node/Version-Control-Issues.html
for more information.

Note that autoreconf currently doesn’t recognise
AM_GNU_GETTEXT_REQUIRE_VERSION, so we must continue also using
AM_GNU_GETTEXT_VERSION. autopoint will ignore the latter if the former
is present. See
https://lists.gnu.org/archive/html/autoconf-patches/2015-10/msg00000.html.

[lkundrak@v3.sk: Fixed the meson build, adjusted autogen.sh:
droped "|| exit 1", dropped call to aclocal,
dropped --copy from gtkdocize.]
2022-06-27 13:40:09 +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
58287cbcc0 core: rework IP configuration in NetworkManager using layer 3 configuration
Completely rework IP configuration in the daemon. Use NML3Cfg as layer 3
manager for the IP configuration of an interface. Use NML3ConfigData as
pieces of configuration that the various components collect and
configure. NMDevice is managing most of the IP configuration at a higher
level, that is, it starts DHCP and other IP methods. Rework the state
handling there.

This is a huge rework of how NetworkManager daemon handles IP
configuration. Some fallout is to be expected.

It appears the patch deletes many lines of code. That is not accurate, because
you also have to count the files `src/core/nm-l3*`, which were unused previously.

Co-authored-by: Beniamino Galvani <bgalvani@redhat.com>
2021-11-18 16:21:29 +01:00
Ana Cabral
e6583941b1 .gitignore: include files used by eclipse-cdt IDE
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/957
2021-08-06 20:18:56 +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
Beniamino Galvani
00126e57b4 core: add infrastructure for spawning a helper process
(cherry picked from commit 6ac21ba916)
2021-06-11 21:59:11 +02:00
Thomas Haller
067893f8d3 gitignore: ignore "examples/C/glib/vpn-import-libnm" 2021-03-22 21:51:36 +01: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
71f0511b1f cloud-setup: move from "clients/cloud-setup/" to "src/nm-cloud-setup/" 2021-03-15 17:10:53 +01:00
Thomas Haller
9fc1bf90fa initrd: move "src/core/initrd/" to "src/nm-initrd-generator/" 2021-03-15 17:10:53 +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
107861ff57 build: move "dispatcher/" to "src/nm-dispatcher/" 2021-02-28 18:56:09 +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
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
2439374457 build: move "shared/nm-platform" to "src/libnm-platform" 2021-02-24 12:48:17 +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
Wen Liang
6b78406460 docs: improve manual page about ipv4.addresses
Signed-off-by: Wen Liang <liangwen12year@gmail.com>

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/738
2021-02-17 17:55:56 +01:00
Thomas Haller
7e8809a9c5 cloud-setup/tests: add unit test for nm-cloud-setup 2021-02-10 18:23:44 +01:00
Thomas Haller
dfddab88ac gitignore: ignore *.a files 2021-02-10 18:23:43 +01:00
Thomas Haller
318824cb41 libnm: move "nm-version-macros.h" from shared/ to libnm-core/
"nm-version-macros.h" is used directly by libnm-core and indirectly by
libnm and core.

Let's not have it randomly under shared/. Move it closer to where it's
used.
2021-02-09 12:38:19 +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
186f2da2fc shared,platform: add "shared/nm-platform" library
NetworkManager core is huge. We should try to split out
parts that are independent.

Platform code is already mostly independent. But due to having it
under "src/", there is no strict separation/layering which determines
the parts that can work independently. So, while the code is mostly
independent (in practice), that is not obvious from looking at the
source tree. It thus still contributes to cognitive load.

Add a shared library "shared/nm-platform", which should have no
dependencies on libnm-core or NetworkManager core.

In a first step, move the netlink code there. More should follow.
2021-01-15 11:32:30 +01:00
Thomas Haller
abccc8b8fe build: ignore "docs/api/NetworkManager.actions" build artifact
I still don't understand why we get now these ".actions" build
artifacts. Anyway, I don't think we need to care. Just ignore
it.
2020-12-03 17:31:30 +01:00
Thomas Haller
df76da8ea0 gitignore: ignore "/docs/libnm/libnm.actions"
Dunno why this file now gets generated.
2020-11-23 19:07:53 +01:00
Thomas Haller
7141537097 l3cfg/tests: add unit test for NML3Cfg 2020-09-24 09:44:04 +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
ae5e8fc26b shared/tests: add test for checking "nm-json-aux.h"
Our "nm-json-aux.h" redefines various things from <jansson.h> header.

Add a unit test that checks that what we redefine exactly matches what
libjansson would provide, so that they are compatible.
2020-07-09 12:57:15 +02:00
Thomas Haller
10020a9466 docs: generate nm-settings-docs-nmcli.xml based on nmcli meta data
We have the correct meta-data of supported properties for nmcli. It is
in clients/common. Use that for generating the manual page instead of
the properties that are part of libnm (some properties may be in libnm
but not supported by nmcli, or some properties may not be GObject
properties, and not detected as by GObject introspection).
2020-06-11 10:53:50 +02:00
Thomas Haller
d2f8d5a4fa docs: move "nm-settings-docs-{dbus,nmcli}.xml" from "libnm/" to "man/"
"nm-settings-docs-nmcli.xml" will be generated by a tool that depends on
"clients/common/". The file should thus not be in libnm directory, otherwise
there is a circular dependency.

Move the file to "man/" directory.

For consistency, also move "nm-settings-docs-dbus.xml". Note that we
cannot move "nm-settings-docs-gir.xml" to "man/", because that one is
needed for building clients.
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
d8992ce931 docs: rename "nm-settings-docs.xml" to "nm-settings-docs-dbus.xml"
"nm-settings-docs-dbus.xml" is "nm-settings-docs-gir.xml" merged with
"nm-property-infos-dbus.xml". The name should reflect that, also because
we will get more files with this naming scheme.
2020-06-11 10:53:49 +02:00
Thomas Haller
960ab39739 docs: rename "nm-property-docs.xml" to "nm-settings-docs-gir.xml"
The name is bad. For one, we will have more files of the same format
("nm-settings-docs-nmcli.xml").

Also, "libnm/nm-settings-docs.xml" and "libnm/nm-property-docs.xml" had
basically the same file format. Their name should be similar.

Also the tool to generate the file should have a name that reminds to
the file that it creates.
2020-06-11 10:53:49 +02:00
Thomas Haller
a9001261fb docs: rename "nm-property-infos" doc files
The naming was inconsistent. Rename.

- all the property infos of this kind a now consistently called
  "libnm/nm-property-infos-$TAG.xml".

- the script to generate files "libnm/nm-property-infos-$TAG.xml" is
  now called "libnm/generate-docs-nm-property-infos.pl".
2020-06-11 10:53:49 +02:00
Beniamino Galvani
53aa5bd207 platform: add tc tests 2020-05-28 17:25:31 +02:00
Antonio Cardace
d450c07a31 git: ignore clangd and ctags generated files 2020-01-29 17:25:21 +01:00
Thomas Haller
44c5331e29 shared: move "shared/nm-utils/tests/test-shared-general" to "shared/nm-glib-aux/tests"
"shared/nm-utils" got long renamed and split into separate parts. The remaining
tests are really to test nm-std-aux and nm-glib-aux (no libnm dependencies). Move
the tests to the appropriate place.
2019-12-10 09:17:17 +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
878d4963ed bluetooth/tests: add "nm-bt-test helper" program for manual testing of bluetooth code
Just add a stub implementation and let it build. More will be added
later.
2019-09-22 16:05:50 +02:00