Commit graph

461 commits

Author SHA1 Message Date
Thomas Haller be78a12012 contrib/rpm: fix spec file using bare words
error: bare words are no longer supported, please use "...":  no != yes
  error: /builds/NetworkManager/NetworkManager/contrib/fedora/rpm/NetworkManager.20200418-163008.VM582H/SPECS/NetworkManager.spec:596: bad %if condition:  no != yes
2020-04-18 18:33:55 +02:00
Thomas Haller 68b38a09d1 contrib/rpm: avoid bare words in spec file
error: bare words are no longer supported, please use "...":  "x" != x
   error:                                                               ^
   error: /root/nm-build/NetworkManager/contrib/fedora/rpm/NetworkManager.20200402-030113.Hk7EGs/SPECS/NetworkManager.spec:32: bad %if condition:  "x" != x
   ERROR: rpmbuild FAILED
2020-04-02 09:36:37 +02:00
Thomas Haller 1bc5a7c778 contrib/scripts: add "checkpatch-git-post-commit-hook" script to contrib/
This can be used as git post-commit hook.
2020-02-21 07:40:10 +01:00
Thomas Haller 5cc8ca4038 contrib/REQUIRED_PACKAGES: fix script to work without GNU which installed
`which` is convenient, but not installed in Fedora container images.
Fix detection of whether to use `dnf` or `yum`.
2020-02-10 11:26:59 +01:00
Thomas Haller bdd45e6afa contrib/REQUIRED_PACKAGES: ignore for non-existing packages "dbus-python", "pygobject3-base" on Fedora 32
These packages no longer exist on Fedora 32 and dnf fails due to
that. Ignore such errors.
2020-02-10 11:18:51 +01:00
Antonio Cardace df1d214b2e clients: polkit-agent: implement polkit agent without using libpolkit 2019-12-24 10:13:51 +01:00
Thomas Haller 2fa4827eb9 checkpatch: catch "gs_free GError *" declations
(cherry picked from commit ec0adbfaf0)
2019-12-16 17:45:16 +01:00
Thomas Haller d27fcd0754 build/meson: allow configuring default for main.auth-polkit setting
We always build PolicyKit support, because it merely depends on some
D-Bus calls. However, there are two things to configure:

 - the default value for main.auth-polkit in NetworkManager.conf. This
   is now called "-Dconfig_auth_polkit_default=$VAL".

 - whether to install the policy file. This is called "-Dpolkit=$VAL".

These settings are mostly independent, so add "config_auth_polkit_default" to
make the default explicitly configurable.

(cherry picked from commit c21c6bc0be)
2019-12-11 13:13:05 +01:00
Thomas Haller 7302be3b32 cloud-setup: add comment that the tool is still experimental
(cherry picked from commit 16223cff91)
2019-12-02 15:24:17 +01:00
Thomas Haller 7ff866e679 contrib/rpm: explicitly enable/disable bluetooth support
The bluetooth plugin (with BlueZ5/NAP support) always gets
build, but DUN support requires a library.

When enabling build of the bluetooth subpackage, then always
enable DUN support. And enable it explicitly, especially meson
would not autodetect support and disable it by default.

(cherry picked from commit 30f6a5dd21)
2019-12-02 15:16:52 +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 5996b4f166 contrib/rpm: fix comment in "NetworkManager.conf" about default [main].plugins
The "ibft" plugin is no more. The default on RHEL/Fedora is now "ifcfg-rh[,keyfile]".
Adjust the configuration, because a wrong comment is confusing here.

Modifying configuration snippets is potentially annoying, because the user might
have edited the file, so on upgrade a "NetworkManager.conf.rpmnew" file
will be created. Still do it.
2019-11-28 18:33:35 +01:00
Thomas Haller 0521e06ff1 contrib/rpm: avoid warning in specfile about tokens after %endif
warning: extra tokens at the end of %endif directive in line 717:  %endif # end autotools
warning: extra tokens at the end of %endif directive in line 775:  %endif # end autotools
2019-11-23 17:01:41 +01:00
Thomas Haller 0f4819ab36 contrib/rpm: use proper check for nmtui conditional build 2019-11-22 15:32:52 +01:00
Thomas Haller 0bff8d7710 contrib: fix detection of whether being sourced in NM-log script 2019-10-26 14:22:44 +02:00
Lubomir Rintel f222dad838 contrib: move scripts from test/ to scripts/
There's no reason to have them separate. Also add the missing executable
bit to btmodem.pl.

https://github.com/NetworkManager/NetworkManager/pull/355
2019-10-09 11:38:22 +02:00
Thomas Haller 3019648b4b checkpatch,gitlab-ci: let checkpatch script compare against latest upstream master
When opening a merge request from a fork of NetworkManager, then the
pipeline runs with the a checkout of the fork. That means, checkpatch
would compare the branch against "master" (or "nm-x-y" stable branches)
of the fork, instead of upstream.

That doesn't seem too useful. Instead, also add upstream NetworkManager
as git remote, fetch the branches, and use the branches from there as
base for checkpatch.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/255
2019-10-02 18:46:36 +02:00
Thomas Haller 3b69f02164 all: unify format of our Copyright source code comments
```bash

readarray -d '' FILES < <(
  git ls-files -z \
    ':(exclude)po' \
    ':(exclude)shared/c-rbtree' \
    ':(exclude)shared/c-list' \
    ':(exclude)shared/c-siphash' \
    ':(exclude)shared/c-stdaux' \
    ':(exclude)shared/n-acd' \
    ':(exclude)shared/n-dhcp4' \
    ':(exclude)src/systemd/src' \
    ':(exclude)shared/systemd/src' \
    ':(exclude)m4' \
    ':(exclude)COPYING*'
  )

sed \
  -e 's/^\(--\|#\| \*\) *\(([cC]) *\)\?Copyright \+\(\(([cC])\) \+\)\?\(\(20\|19\)[0-9][0-9]\) *[-–] *\(\(20\|19\)[0-9][0-9]\) \+\([^ ].*\)$/\1 C1pyright#\5 - \7#\9/' \
  -e 's/^\(--\|#\| \*\) *\(([cC]) *\)\?Copyright \+\(\(([cC])\) \+\)\?\(\(20\|19\)[0-9][0-9]\) *[,] *\(\(20\|19\)[0-9][0-9]\) \+\([^ ].*\)$/\1 C2pyright#\5, \7#\9/' \
  -e 's/^\(--\|#\| \*\) *\(([cC]) *\)\?Copyright \+\(\(([cC])\) \+\)\?\(\(20\|19\)[0-9][0-9]\) \+\([^ ].*\)$/\1 C3pyright#\5#\7/' \
  -e 's/^Copyright \(\(20\|19\)[0-9][0-9]\) \+\([^ ].*\)$/C4pyright#\1#\3/' \
  -i \
  "${FILES[@]}"

echo ">>> untouched Copyright lines"
git grep Copyright "${FILES[@]}"

echo ">>> Copyright lines with unusual extra"
git grep '\<C[0-9]pyright#' "${FILES[@]}" | grep -i reserved

sed \
  -e 's/\<C[0-9]pyright#\([^#]*\)#\(.*\)$/Copyright (C) \1 \2/' \
  -i \
  "${FILES[@]}"

```

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/298
2019-10-02 17:03:52 +02:00
Lubomir Rintel 8d352b5a47 contrib: add a Bluetooth DUN modem emulator
Useful for quickly testing Bluetooth DUN support. Duplicates some
modemu.pl logic, but hey...

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/297
2019-10-02 11:29:53 +02:00
Thomas Haller abff46cacf all: manually drop code comments with file description 2019-10-01 07:50:52 +02:00
Francesco Giudici e150307ab5 artwork: introduce NetworkManager stickers 2019-09-30 17:36:59 +02:00
Francesco Giudici d5dbea05be artwork: fix the reversed NetworkManager logo
Slightly changed the size to have a perfect square.
2019-09-30 17:27:16 +02:00
Francesco Giudici dce1aa87c2 artwork: introduce the new NetworkManager logo and logotype
The preferred logo and logotype are the ones in the main "logo" folder.
There are also few variants available in the "alternate" folder that are
allowed.

Main color for the logo is blue #32557dff.
The alternatei logo red is #cc0000ff.
The font is Montserrat.

Thanks to Máirín Duffy for all the help and support!
2019-09-27 16:15:39 +02:00
Thomas Haller 9fc4490513 contrib/rpm: drop BuildRequires to deprecated "wireless-tools-devel"
"wireless-tools-devel" is long depreacted and not used by
NetworkManager, not even for WEXT.

Drop it from the build dependencies.
2019-09-25 15:47:39 +02:00
Thomas Haller 3a1b2b9885 tests: don't install bzip2 as REQUIRED_PACKAGES on Fedora/RHEL 2019-09-25 15:47:39 +02:00
Thomas Haller 1a2a5b37b4 tests: don't install unnecessary package in gitlab-ci tests
REQUIRED_PACKAGES has two uses:

 - to setup a system for developing NetworkManager. This installs
   convenience packages like "cscope".

 - to install the packages required for unit testing in gitlab-ci.

For gitlab-ci we should only install the packages that we actually
need.
2019-09-25 15:47:39 +02:00
Thomas Haller 185567559c tests: fix failure installing non-existing packages in REQUIRED_PACKAGES
Previously, dnf/yum used to ignore packages that didn't exist.
In Fedora 32, dnf starts to fail the entire command:

  No match for argument: python-gobject-base
  Error: Unable to find a match: python-gobject-base

Since this script is supposed to work with different RHEL/Fedora
versions, it's expected that not all packages are available everywhere.

Fix that, by installing packages that we know that they might be missing
one by one (and ignore the error).
2019-09-25 15:47:39 +02:00
Thomas Haller 4b1cb404fd contrib/rpm: "Suggest" wpa_supplicant for NetworkManager-wifi package
"NetworkManager-wifi" package requires either wpa_supplicant or iwd.
When installing the package without explicitly installing supplicant
or iwd (and not having it installed yet), then we want to drag in
wpa_supplicant by default. That is accomplished by suggesting wpa_supplicant
package.

Otherwise, the user installing NetworkManager-wifi might get iwd,
which is only functioning if the user explicitly enables the backend
in "NetworkManager.conf".

https://bugzilla.redhat.com/show_bug.cgi?id=1743585
2019-09-23 13:29:12 +02:00
Lubomir Rintel 455f6dcbdc build/debian: install mobile-broadband-provider-info 2019-09-11 14:54:34 +02:00
Lubomir Rintel 7c53930ceb wwan/modem-broadband: add capability to look up default APN/username/password
This allows the GSM connection to Just Work most of the time, as in:
"nmcli d connect ttyUSB0".
2019-09-11 14:32:05 +02:00
Lubomir Rintel b1f7f431e6 contrib/modemu: also clean up on SIGTERM 2019-09-10 14:33:38 +02:00
Lubomir Rintel ae6668ae85 contrib/checkpatch: fix the systemd code path 2019-09-10 11:20:03 +02:00
Lubomir Rintel 1b0ee8756b contrib/checkpatch: check for SPDX tags 2019-09-10 11:20:03 +02:00
Lubomir Rintel 24028a2246 all: SPDX header conversion
$ find * -type f |xargs perl contrib/scripts/spdx.pl
  $ git rm contrib/scripts/spdx.pl
2019-09-10 11:19:56 +02:00
Lubomir Rintel e4784327c0 contrib/spdx: add a tool that determines SPDX licensing headers
This is a one-off hacky tool that we'll use to convert the long license
boilerplates to SPDX headers that are more friendly to automated tools.

Then we can drop it and forget it existed.
2019-09-10 11:18:49 +02:00
Lubomir Rintel e9f2ea6c22 COPYING: make sure we ship the relevant license texts
This adds LGPL and GFDL texts from the GNU web site and updates the GPL
one:

  COPYING: https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
  COPYING.LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
  COPYING.GFDL: https://www.gnu.org/licenses/old-licenses/fdl-1.1.txt

The update to the GPL text is purely cosmetic. However, shipping the
exact same file as GNU publishes may help distros that deduplicate the
license texts or hardlink duplicates.
2019-09-10 11:10:52 +02:00
Thomas Haller 081b16cdb8 contrib/rpm: explicitly set runstatedir to "/run" when building release tarball
Nowadays, we should prefer "/run" over "/var/run". When not specifying
during ./configure, autotools however still defaults to "/var/run".

This default is also visible in the pre-generated documenation, for
example `man NetworkManager.conf` says

  Unless the symlink points to the internal file /run/NetworkManager/resolv.conf,
  in which case the ...
2019-08-27 16:31:55 +02:00
Lubomir Rintel 36fec3be75 contrib/modemu: ensure the udev messages specify SEQNUM
Newer systemd rejects messages without one.
2019-08-26 12:58:55 +02:00
Lubomir Rintel 505208a448 contrib/rpm: install our dispatcher scripts into /usr/lib/NetworkManager
That's where they always should have been.
2019-08-23 08:52:13 +02:00
Lubomir Rintel b171f20141 contrib/rpm: enable IWD (outside RHEL)
Let's enable the option to use IWD as an alternative to wpa_supplicant
for Wi-Fi support. People have been asking for this, it works, and is well
maintained.
2019-08-15 23:07:02 +02:00
Lubomir Rintel 20f735972f contrib/rpm: fix libnm License tag
https://bugzilla.redhat.com/show_bug.cgi?id=1723395
(cherry picked from commit 2752e3a774)
2019-07-31 11:30:21 +02:00
Thomas Haller 0a0084e133 contrib/rpm: use --with-runstatedir=%{_rundir} instead of hard-coding /run
(cherry picked from commit ea5e96cb06)
2019-07-29 23:54:20 +02:00
Thomas Haller d734a4766c contrib/rpm: fix parsing of %real_version_major for ".0" versions
(cherry picked from commit 6c9880f8ca)
2019-07-29 23:54:19 +02:00
Lubomir Rintel 3c6644db32 all: codespell fixes
Codespel run with the same arguments as described in
commit 58510ed566 ('docs: misc. typos pt2').
2019-07-24 11:30:19 +02:00
Thomas Haller d35d3c468a settings: rework tracking settings connections and settings plugins
Completely rework how settings plugin handle connections and how
NMSettings tracks the list of connections.

Previously, settings plugins would return objects of (a subtype of) type
NMSettingsConnection. The NMSettingsConnection was tightly coupled with
the settings plugin. That has a lot of downsides.

Change that. When changing this basic relation how settings connections
are tracked, everything falls appart. That's why this is a huge change.
Also, since I have to largely rewrite the settings plugins, I also
added support for multiple keyfile directories, handle in-memory
connections only by keyfile plugin and (partly) use copy-on-write NMConnection
instances. I don't want to spend effort rewriting large parts while
preserving the old way, that anyway should change. E.g. while rewriting ifcfg-rh,
I don't want to let it handle in-memory connections because that's not right
long-term.

--

If the settings plugins themself create subtypes of NMSettingsConnection
instances, then a lot of knowledge about tracking connections moves
to the plugins.
Just try to follow the code what happend during nm_settings_add_connection().
Note how the logic is spread out:
 - nm_settings_add_connection() calls plugin's add_connection()
 - add_connection() creates a NMSettingsConnection subtype
 - the plugin has to know that it's called during add-connection and
   not emit NM_SETTINGS_PLUGIN_CONNECTION_ADDED signal
 - NMSettings calls claim_connection() which hocks up the new
   NMSettingsConnection instance and configures the instance
   (like calling nm_settings_connection_added()).
This summary does not sound like a lot, but try to follow that code. The logic
is all over the place.

Instead, settings plugins should have a very simple API for adding, modifying,
deleting, loading and reloading connections. All the plugin does is to return a
NMSettingsStorage handle. The storage instance is a handle to identify a profile
in storage (e.g. a particular file). The settings plugin is free to subtype
NMSettingsStorage, but it's not necessary.
There are no more events raised, and the settings plugin implements the small
API in a straightforward manner.
NMSettings now drives all of this. Even NMSettingsConnection has now
very little concern about how it's tracked and delegates only to NMSettings.

This should make settings plugins simpler. Currently settings plugins
are so cumbersome to implement, that we avoid having them. It should not be
like that and it should be easy, beneficial and lightweight to create a new
settings plugin.

Note also how the settings plugins no longer care about duplicate UUIDs.
Duplicated UUIDs are a fact of life and NMSettings must handle them. No
need to overly concern settings plugins with that.

--

NMSettingsConnection is exposed directly on D-Bus (being a subtype of
NMDBusObject) but it was also a GObject type provided by the settings
plugin. Hence, it was not possible to migrate a profile from one plugin to
another.
However that would be useful when one profile does not support a
connection type (like ifcfg-rh not supporting VPN). Currently such
migration is not implemented except for migrating them to/from keyfile's
run directory. The problem is that migrating profiles in general is
complicated but in some cases it is important to do.

For example checkpoint rollback should recreate the profile in the right
settings plugin, not just add it to persistent storage. This is not yet
properly implemented.

--

Previously, both keyfile and ifcfg-rh plugin implemented in-memory (unsaved)
profiles, while ifupdown plugin cannot handle them. That meant duplication of code
and a ifupdown profile could not be modified or made unsaved.
This is now unified and only keyfile plugin handles in-memory profiles (bgo #744711).
Also, NMSettings is aware of such profiles and treats them specially.
In particular, NMSettings drives the migration between persistent and non-persistent
storage.

Note that a settings plugins may create truly generated, in-memory profiles.
The settings plugin is free to generate and persist the profiles in any way it
wishes. But the concept of "unsaved" profiles is now something explicitly handled
by keyfile plugin. Also, these "unsaved" keyfile profiles are persisted to file system
too, to the /run directory. This is great for two reasons: first of all, all
profiles from keyfile storage in fact have a backing file -- even the
unsaved ones. It also means you can create "unsaved" profiles in /run
and load them with `nmcli connection load`, meaning there is a file
based API for creating unsaved profiles.
The other advantage is that these profiles now survive restarting
NetworkManager. It's paramount that restarting the daemon is as
non-disruptive as possible. Persisting unsaved files to /run improves
here significantly.

--

In the past, NMSettingsConnection also implemented NMConnection interface.
That was already changed a while ago and instead users call now
nm_settings_connection_get_connection() to delegate to a
NMSimpleConnection. What however still happened was that the NMConnection
instance gets never swapped but instead the instance was modified with
nm_connection_replace_settings_from_connection(), clear-secrets, etc.
Change that and treat the NMConnection instance immutable. Instead of modifying
it, reference/clone a new instance. This changes that previously when somebody
wanted to keep a reference to an NMConnection, then the profile would be cloned.
Now, it is supposed to be safe to reference the instance directly and everybody
must ensure not to modify the instance. nmtst_connection_assert_unchanging()
should help with that.
The point is that the settings plugins may keep references to the
NMConnection instance, and so does the NMSettingsConnection. We want
to avoid cloning the instances as long as they are the same.
Likewise, the device's applied connection can now also be referenced
instead of cloning it. This is not yet done, and possibly there are
further improvements possible.

--

Also implement multiple keyfile directores /usr/lib, /etc, /run (rh #1674545,
bgo #772414).

It was always the case that multiple files could provide the same UUID
(both in case of keyfile and ifcfg-rh). For keyfile plugin, if a profile in
read-only storage in /usr/lib gets modified, then it gets actually stored in
/etc (or /run, if the profile is unsaved).

--

While at it, make /etc/network/interfaces profiles for ifupdown plugin reloadable.

--

https://bugzilla.gnome.org/show_bug.cgi?id=772414
https://bugzilla.gnome.org/show_bug.cgi?id=744711
https://bugzilla.redhat.com/show_bug.cgi?id=1674545
2019-07-16 19:09:08 +02:00
Lubomir Rintel 07fdc1828d contrib/rpm: disable rp_filter in config-connectivity-redhat
RHEL ships with a rp_filter and can't change that for historic reasons.
That's unfortunate, because it breaks the connectivity checking. Let's
override it if the connectivity checking package is installed.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/185
2019-07-15 20:16:31 +02:00
Tom Gundersen 6adade6f21 dhcp: add nettools dhcp4 client
This is inspired by the existing systemd integration, with a few differences:

* This parses the WPAD option, which systemd requested, but did not use.
* We hook into the DAD handling, only making use of the configured address
  once DAD has completed successfully, and declining the lease if it fails.

There are still many areas of possible improvement. In particular, we need
to ensure the parsing of all options are compliant, as n-dhcp4 treats all
options as opaque, unlike sd-dhcp4. We probably also need to look at how
to handle failures and retries (in particular if we decline a lease).

We need to query the current MTU at client startu, as well as the hardware
broadcast address. Both these are provided by the kernel over netlink, so
it should simply be a matter of hooking that up with NM's netlink layer.

Contribution under LGPL2.0+, in addition to stated licenses.
2019-07-05 11:04:32 +02:00
Lubomir Rintel a5dd31afeb contrib/checkpatch: allow empty lines within continuations
This chunk from nm-device.c is, in fact, okay:

               |<-tab->nm_assert (   !new_config
               |<-tab->           || (   new_config
               |<-tab->               && ({
               |<-tab->                    int ip_ifindex = ...
 empty line -> |
               |<-tab->                    (   ip_ifindex > 0
               |<-tab->                     && ip_ifindex == ...
               |<-tab->                  })));
2019-06-25 20:27:39 +02:00
Lubomir Rintel da312e6220 contrib/checkpatch: be a bit stricter about whitespace
In continations (that use spaces for alignment), don't allow the number
of leading tabs to change. Previously only removal of tabs was
disallowed, but addition doesn't make sense either, as only spaces
should be used for further alignemnt.

This catches situations like this:

  |<-tab->all_work_and_no_play (makes,
  |<-tab->                      jack,
  |<-tab-><-tab->               a dull boy);
2019-06-25 20:27:39 +02:00
Lubomir Rintel 5ff19ea8d2 contrib/checkpatch: discourage g_assert*() 2019-06-25 20:27:39 +02:00