Skip to content
Snippets Groups Projects
Verified Commit 1e5fd157 authored by Casey's avatar Casey :recycle: Committed by Clayton Craft
Browse files

systemd/networkmanager: new aport


Clayton says: integrates with systemd (logind)

Signed-off-by: default avatarCaleb Connolly <caleb@postmarketos.org>
parent 46a5c335
Branches
No related tags found
1 merge request!5859Draft: ElementaryOS pantheon desktop w/ systemd
# Forked from Alpine to build with systemd support.
# integrates with logind for sleepmonitor and sessionmonitor.
pkgname=networkmanager
pkgver=9999
_pkgver=1.42.6
pkgrel=0
pkgdesc="Network Management daemon"
url="https://wiki.gnome.org/Projects/NetworkManager"
arch="all"
license="GPL-2.0-or-later"
depends_dev="$pkgname=$pkgver-r$pkgrel libnm=$pkgver-r$pkgrel"
makedepends="
bash
curl-dev
dbus-glib-dev
eudev-dev
gettext-dev
gnutls-dev
gobject-introspection-dev
gtk-doc
jansson-dev
libgudev-dev
libndp-dev
libnl3-dev
libpsl-dev
libxslt
linux-headers
meson
mobile-broadband-provider-info
modemmanager-dev
newt-dev
nss-dev
openresolv
perl
polkit-dev
ppp-dev
py3-gobject3
python3
readline-dev
systemd-dev
util-linux-dev
vala
"
checkdepends="
bash
dbus
iproute2-minimal
iproute2-tc
py3-dbus
"
install="
$pkgname.pre-install
$pkgname.pre-upgrade
$pkgname.post-install
$pkgname.post-upgrade
"
subpackages="
$pkgname-dbg
libnm
$pkgname-dev
$pkgname-elogind
$pkgname-lang
$pkgname-service
$pkgname-adsl
$pkgname-bluetooth
$pkgname-ovs
$pkgname-ppp
$pkgname-wwan
$pkgname-wifi
$pkgname-cli
$pkgname-tui
$pkgname-initrd-generator:initrd_generator
$pkgname-bash-completion
$pkgname-dnsmasq
"
source="https://download.gnome.org/sources/NetworkManager/${_pkgver:0:4}/NetworkManager-$_pkgver.tar.xz
$pkgname.conf
pppd-2.5.patch
$pkgname.rules
"
builddir="$srcdir/NetworkManager-$_pkgver"
# on the builders:
# mount("/sys") failed with Operation not permitted (1)
options="!check"
_plugindir="usr/lib/NetworkManager/$_pkgver"
build() {
#msg 'Building without systemd'
#_build output \
# -Dsession_tracking=no \
# -Dsuspend_resume=consolekit \
# -Dsystemd_journal=false \
# -Dsystemdsystemunitdir=no
msg 'Building with systemd'
_build output \
-Dsession_tracking=systemd \
-Dsuspend_resume=systemd \
-Dsystemd_journal=true \
-Dtests="$(want_check && echo yes || echo no)"
}
_build() {
local outdir=$1; shift
#-Db_lto=true \
abuild-meson \
-Dconfig_dhcp_default=internal \
-Dconfig_plugins_default=ifupdown \
-Dcrypto=nss \
-Ddbus_conf_dir=/usr/share/dbus-1/system.d \
-Ddhcpcd=true \
-Ddnsmasq=/usr/sbin/dnsmasq \
-Ddocs=false \
-Difupdown=true \
-Diptables=/sbin/iptables \
-Diwd=true \
-Dlibaudit=no \
-Dmodify_system=true \
-Dnft=/usr/sbin/nft \
-Dofono=true \
-Dpolkit=true \
-Dpppd=/usr/sbin/pppd \
-Dpppd_plugin_dir=/usr/lib/pppd/2.5.0 \
-Dqt=false \
-Dselinux=false \
-Dsystemdsystemunitdir=/usr/lib/systemd/system \
-Dtests=no \
-Dudev_dir=/usr/lib/udev \
-Dvapi=true \
"$@" \
. "$outdir"
meson compile -C "$outdir"
}
check() {
XDG_RUNTIME_DIR="$(mktemp -d -p "$builddir")" \
dbus-run-session -- \
meson test -t 4 --no-rebuild --print-errorlogs -C output-elogind
}
package() {
depends="
libnm=$pkgver-r$pkgrel
dbus
"
provides="networkmanager-common"
provider_priority=500
DESTDIR="$pkgdir" meson install --no-rebuild -C output
install -m644 -D "$srcdir/$pkgname.conf" "$pkgdir"/etc/NetworkManager/NetworkManager.conf
# allow plugdev users to modify connections
install -m644 -D "$srcdir/$pkgname.rules" \
"$pkgdir/usr/share/polkit-1/rules.d/01-org.freedesktop.NetworkManager.settings.modify.system.rules"
mv "$pkgdir/usr/share/doc/NetworkManager" "$pkgdir/usr/share/doc/$pkgname"
# post-install message
cat > "$pkgdir"/usr/share/doc/$pkgname/README.alpine <<-EOF
To modify system network connections without the root password: add your user account to the 'plugdev' group, or use Polkit.
To use iwd instead of the default wpa_supplicant install iwd, start its service and add the following to your /etc/NetworkManager/NetworkManager.conf:
[device]
wifi.backend=iwd
EOF
}
dev() {
default_dev
amove usr/share/dbus-1/interfaces/*.xml
}
libnm() {
pkgdesc="GObject-based client library for NetworkManager"
replaces_priority=200
amove usr/lib/libnm.so*
}
elogind() {
pkgdesc="NetworkManager with logind support"
depends="$pkgname"
mkdir -p "$subpkgdir"
}
adsl() {
_default_plugin
pkgdesc="ADSL device plugin for NetworkManager"
}
bluetooth() {
_default_plugin
pkgdesc="BlueTooth device plugin for NetworkManager"
depends="$depends bluez"
}
ovs() {
_default_plugin
pkgdesc="Open vSwitch device plugin for NetworkManager"
depends="$depends openvswitch"
}
ppp() {
pkgdesc="PPP plugin for NetworkManager"
depends="$pkgname=$pkgver-r$pkgrel"
amove $_plugindir/libnm-ppp-plugin.so
amove usr/lib/pppd/*/nm-pppd-plugin.so
}
# TODO: Add dependency on wpa_supplicant or iwd via some virtual (?).
wifi() {
_default_plugin
pkgdesc="WiFi device plugin for NetworkManager"
depends="$depends wireless-regdb"
install="$subpkgname.post-install"
}
wwan() {
_default_plugin
pkgdesc="Mobile broadband device plugin for NetworkManager"
depends="$depends mobile-broadband-provider-info"
}
cli() {
pkgdesc="$pkgdesc (command line interface)"
depends="$pkgname=$pkgver-r$pkgrel"
amove usr/bin/nmcli
}
tui() {
pkgdesc="$pkgdesc (textbased user interface)"
depends="$pkgname=$pkgver-r$pkgrel"
amove usr/bin/nmtui*
}
initrd_generator() {
pkgdesc="Early boot NetworkManager configuration generator"
depends="" # Q: should it depend on $pkgname?
replaces="$pkgname<1.34.0-r3"
amove usr/libexec/nm-initrd-generator
}
gtkdoc() {
pkgdesc="$pkgdesc (gtk docs)"
amove usr/share/gtk-doc
}
dnsmasq() {
pkgdesc="Support for NetworkManager dnsmasq features"
depends="$pkgname=$pkgver-r$pkgrel dnsmasq-dnssec-dbus"
mkdir -p "$subpkgdir"
}
service() {
default_service
}
_default_plugin() {
depends="$pkgname=$pkgver-r$pkgrel"
amove $_plugindir/libnm*-${subpkgname#$pkgname-}.so
}
sha512sums="
606a996043d8fbc7972329b94bc9854557950f665790381611eddfc632850b31584a4ba2d773fa9d12127db4c37ea2076c657521b78cedb012144df6f41d3748 NetworkManager-1.42.6.tar.xz
0f79016bf717dea43830962f524deae8d1cedc274376e40bd912ebe63208c5b1c3b7a5aa14379da19020c587dbd5588df2f0066ca1540070a226983a43e4159b networkmanager.conf
0190d8c757dcb5c1a50f8b080952ed138e4fe78b06b8a2649521f18fd87f2fec274a35b0aaf0d0579d05a369feb9015dfd6469777f70444744d401525de834cb pppd-2.5.patch
9820ed2ead0af689644842de57657bb10330a1eaff0e85b21ae9913f55e399e47d8b41b0a12956f30de80272b4424c6e55f33acbc88e156879003a260bf576f6 networkmanager.rules
"
#!/bin/sh
cat >&2 <<EOF
*
* To control WiFi devices, install either 'wpa_supplicant' or 'iwd' package,
* enable and start the corresponding service (rc-update add <name>;
* rc-service <name> start), and restart networkmanager.
*
* If you chose iwd, you have to also add 'wifi.backend=iwd' into section
* '[device]' in /etc/NetworkManager/NetworkManager.conf.
*
EOF
exit 0
[main]
dhcp=internal
#!/bin/sh
cat >&2 <<EOF
*
* To modify system network connections without the root password, add your user
* account to the 'plugdev' group.
*
* If you use wifi, bluetooth, ppp, wwan (mobile broadband), adsl or ovs (Open
* vSwitch), install the corresponding plugin: apk add networkmanager-<name>.
*
* If you use NetworkManager features which require dnsmasq, you need to install
* dnsmasq support: apk add networkmanager-dnsmasq
*
EOF
exit 0
#!/bin/sh
old_ver=$2
if [ "$(apk version -t "$ver_old" '1.34.0-r3')" = '<' ]; then
cat >&2 <<-EOF
*
* NetworkManager plugins adsl, bluetooth, ovs, ppp, wwan (mobile broadband),
* and wifi have been split into subpackages. If you use some of them, install
* the corresponding packages (e.g. 'apk add networkmanager-wifi').
*
EOF
fi
exit 0
#!/bin/sh
addgroup -S plugdev 2>/dev/null
exit 0
networkmanager.pre-install
\ No newline at end of file
// Let users in plugdev group modify NetworkManager
polkit.addRule(function(action, subject) {
if (action.id == "org.freedesktop.NetworkManager.settings.modify.system" &&
subject.isInGroup("plugdev") && subject.active) {
return "yes";
}
});
Patch-Source: https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1558
--
From c1c2d24b557ceb90d28bd3b818bb61bcb6753975 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Eivind=20N=C3=A6ss?= <eivnaes@yahoo.com>
Date: Sat, 4 Mar 2023 22:26:00 +0000
Subject: [PATCH 1/2] ppp, adding support for compiling against pppd-2.5.0
This change does the following
* Adding in nm-pppd-compat.h to mask details regarding different
versions of pppd.
* Fix the nm-pppd-plugin.c regarding differences in API between
2.4.9 (current) and latet pppd 2.5.0 in master branch
* Additional fixes to the configure.ac to appropriately set defines used
for compilation
---
configure.ac | 17 ++++-
src/core/ppp/nm-pppd-compat.h | 127 ++++++++++++++++++++++++++++++++++
src/core/ppp/nm-pppd-plugin.c | 45 ++++++------
3 files changed, 164 insertions(+), 25 deletions(-)
create mode 100644 src/core/ppp/nm-pppd-compat.h
diff --git a/configure.ac b/configure.ac
index 6af061ddbc..ce0c23722c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -767,13 +767,17 @@ else
fi
AM_CONDITIONAL(WITH_PPP, test "${enable_ppp}" = "yes")
+PPPD_VERSION=2.4.9
+PKG_CHECK_EXISTS([pppd], [
+ PPPD_VERSION=`$PKG_CONFIG --modversion pppd`
+])
+
AC_ARG_WITH([pppd-plugin-dir],
AS_HELP_STRING([--with-pppd-plugin-dir=DIR], [path to the pppd plugins directory]))
-
if test -n "$with_pppd_plugin_dir" ; then
PPPD_PLUGIN_DIR="$with_pppd_plugin_dir"
else
- PPPD_PLUGIN_DIR="${libdir}/pppd/2.4.5"
+ PPPD_PLUGIN_DIR="${libdir}/pppd/$PPPD_VERSION"
fi
AC_SUBST(PPPD_PLUGIN_DIR)
@@ -786,6 +790,15 @@ fi
AC_DEFINE_UNQUOTED(PPPD_PATH, "$PPPD_PATH", [Define to path of pppd binary])
AC_SUBST(PPPD_PATH)
+AC_CHECK_HEADERS(pppd/chap.h pppd/chap-new.h pppd/chap_ms.h)
+AC_DEFINE_UNQUOTED([PPP_VERSION(x,y,z)],
+ [((x & 0xFF) << 16 | (y & 0xFF) << 8 | (z & 0xFF) << 0)],
+ [Macro to help determine the particular version of pppd])
+PPP_VERSION=$(echo $PPPD_VERSION | sed -e "s/\./\,/g")
+AC_DEFINE_UNQUOTED(WITH_PPP_VERSION, PPP_VERSION($PPP_VERSION),
+ [The real version of pppd represented as an int])
+
+
# ModemManager1 with libmm-glib
AC_ARG_WITH(modem-manager-1,
AS_HELP_STRING([--with-modem-manager-1],
diff --git a/src/core/ppp/nm-pppd-compat.h b/src/core/ppp/nm-pppd-compat.h
new file mode 100644
index 0000000000..c7bea084ae
--- /dev/null
+++ b/src/core/ppp/nm-pppd-compat.h
@@ -0,0 +1,127 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) Eivind Næss, eivnaes@yahoo.com
+ */
+
+#ifndef __NM_PPPD_COMPAT_H__
+#define __NM_PPPD_COMPAT_H__
+
+/* Define INET6 to compile with IPv6 support against older pppd headers,
+ pppd >= 2.5.0 use PPP_WITH_IPV6CP and is defined in pppdconf.h */
+#define INET6 1
+
+/* PPP < 2.5.0 defines and exports VERSION which overlaps with current package VERSION define.
+ this silly macro magic is to work around that. */
+#undef VERSION
+#include <pppd/pppd.h>
+
+#ifndef PPPD_VERSION
+#define PPPD_VERSION VERSION
+#endif
+
+#include <pppd/fsm.h>
+#include <pppd/eui64.h>
+#include <pppd/ipcp.h>
+#include <pppd/ipv6cp.h>
+#include <pppd/upap.h>
+
+#if 1
+#include <pppd/chap.h>
+#endif
+
+#if 0
+#include <pppd/chap-new.h>
+#endif
+
+#if 1
+#include <pppd/chap_ms.h>
+#endif
+
+#ifndef PPP_PROTO_CHAP
+#define PPP_PROTO_CHAP 0xc223
+#endif
+
+#ifndef PPP_PROTO_EAP
+#define PPP_PROTO_EAP 0xc227
+#endif
+
+#if 0
+
+static inline bool
+debug_on(void)
+{
+ return debug;
+}
+
+static inline const char *
+ppp_ipparam(void)
+{
+ return ipparam;
+}
+
+static inline int
+ppp_ifunit(void)
+{
+ return ifunit;
+}
+
+static inline const char *
+ppp_ifname(void)
+{
+ return ifname;
+}
+
+static inline int
+ppp_get_mtu(int idx)
+{
+ return netif_get_mtu(idx);
+}
+
+static inline void
+ppp_set_ifname(const char *new_name)
+{
+ g_strlcpy(ifname, new_name, IF_NAMESIZE);
+}
+
+typedef enum ppp_notify {
+ NF_PID_CHANGE,
+ NF_PHASE_CHANGE,
+ NF_EXIT,
+ NF_SIGNALED,
+ NF_IP_UP,
+ NF_IP_DOWN,
+ NF_IPV6_UP,
+ NF_IPV6_DOWN,
+ NF_AUTH_UP,
+ NF_LINK_DOWN,
+ NF_FORK,
+ NF_MAX_NOTIFY
+} ppp_notify_t;
+
+typedef void(ppp_notify_fn)(void *ctx, int arg);
+
+static inline void
+ppp_add_notify(ppp_notify_t type, ppp_notify_fn *func, void *ctx)
+{
+ struct notifier **list[NF_MAX_NOTIFY] = {
+ [NF_PID_CHANGE] = &pidchange,
+ [NF_PHASE_CHANGE] = &phasechange,
+ [NF_EXIT] = &exitnotify,
+ [NF_SIGNALED] = &sigreceived,
+ [NF_IP_UP] = &ip_up_notifier,
+ [NF_IP_DOWN] = &ip_down_notifier,
+ [NF_IPV6_UP] = &ipv6_up_notifier,
+ [NF_IPV6_DOWN] = &ipv6_down_notifier,
+ [NF_AUTH_UP] = &auth_up_notifier,
+ [NF_LINK_DOWN] = &link_down_notifier,
+ [NF_FORK] = &fork_notifier,
+ };
+
+ struct notifier **notify = list[type];
+ if (notify) {
+ add_notifier(notify, func, ctx);
+ }
+}
+
+#endif /* #if WITH_PPP_VERSION < PPP_VERSION(2,5,0) */
+#endif /* #ifdef __NM_PPPD_COMPAT_H__ */
diff --git a/src/core/ppp/nm-pppd-plugin.c b/src/core/ppp/nm-pppd-plugin.c
index e2e34d2aaf..59a2dcc94b 100644
--- a/src/core/ppp/nm-pppd-plugin.c
+++ b/src/core/ppp/nm-pppd-plugin.c
@@ -7,29 +7,23 @@
#include <config.h>
#define ___CONFIG_H__
-#include <pppd/pppd.h>
-#include <pppd/fsm.h>
-#include <pppd/ipcp.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <net/if.h>
#include <arpa/inet.h>
#include <dlfcn.h>
+#include <glib.h>
-#define INET6
-#include <pppd/eui64.h>
-#include <pppd/ipv6cp.h>
+#include "nm-pppd-plugin.h"
+#include "nm-pppd-compat.h"
+#include "nm-ppp-status.h"
#include "libnm-glib-aux/nm-default-glib.h"
-
#include "nm-dbus-interface.h"
-#include "nm-pppd-plugin.h"
-#include "nm-ppp-status.h"
-
int plugin_init(void);
-char pppd_version[] = VERSION;
+char pppd_version[] = PPPD_VERSION;
static struct {
GDBusConnection *dbus_connection;
@@ -125,7 +119,7 @@ nm_phasechange(int arg)
char new_name[IF_NAMESIZE];
int ifindex;
- ifindex = if_nametoindex(ifname);
+ ifindex = if_nametoindex(ppp_ifname());
/* Make a sync call to ensure that when the call
* terminates the interface already has its final
@@ -143,9 +137,11 @@ nm_phasechange(int arg)
NULL);
/* Update the name in pppd if NM changed it */
- if (if_indextoname(ifindex, new_name) && !nm_streq0(ifname, new_name)) {
- g_message("nm-ppp-plugin: interface name changed from '%s' to '%s'", ifname, new_name);
- g_strlcpy(ifname, new_name, IF_NAMESIZE);
+ if (if_indextoname(ifindex, new_name) && !nm_streq0(ppp_ifname(), new_name)) {
+ g_message("nm-ppp-plugin: interface name changed from '%s' to '%s'",
+ ppp_ifname(),
+ new_name);
+ ppp_set_ifname(new_name);
}
}
}
@@ -166,7 +162,7 @@ nm_ip_up(void *data, int arg)
ipcp_options opts = ipcp_gotoptions[0];
ipcp_options peer_opts = ipcp_hisoptions[0];
GVariantBuilder builder;
- guint32 pppd_made_up_address = htonl(0x0a404040 + ifunit);
+ guint32 pppd_made_up_address = htonl(0x0a404040 + ppp_ifunit());
g_return_if_fail(G_IS_DBUS_CONNECTION(gl.dbus_connection));
@@ -186,7 +182,7 @@ nm_ip_up(void *data, int arg)
g_variant_builder_add(&builder,
"{sv}",
NM_PPP_IP4_CONFIG_INTERFACE,
- g_variant_new_string(ifname));
+ g_variant_new_string(ppp_ifname()));
g_variant_builder_add(&builder,
"{sv}",
@@ -292,7 +288,7 @@ nm_ip6_up(void *data, int arg)
g_variant_builder_add(&builder,
"{sv}",
NM_PPP_IP6_CONFIG_INTERFACE,
- g_variant_new_string(ifname));
+ g_variant_new_string(ppp_ifname()));
g_variant_builder_add(&builder, "{sv}", NM_PPP_IP6_CONFIG_OUR_IID, eui64_to_variant(go->ourid));
g_variant_builder_add(&builder,
"{sv}",
@@ -393,6 +389,7 @@ nm_exit_notify(void *data, int arg)
static void
add_ip6_notifier(void)
{
+#if 0
static struct notifier **notifier = NULL;
static gsize load_once = 0;
@@ -409,6 +406,9 @@ add_ip6_notifier(void)
add_notifier(notifier, nm_ip6_up, NULL);
else
g_message("nm-ppp-plugin: no IPV6CP notifier support; IPv6 not available");
+#else
+ ppp_add_notify(NF_IPV6_UP, nm_ip6_up, NULL);
+#endif
}
int
@@ -427,17 +427,16 @@ plugin_init(void)
return -1;
}
- gl.ipparam = g_strdup(ipparam);
+ gl.ipparam = g_strdup(ppp_ipparam());
chap_passwd_hook = get_credentials;
chap_check_hook = get_chap_check;
pap_passwd_hook = get_credentials;
pap_check_hook = get_pap_check;
- add_notifier(&phasechange, nm_phasechange_hook, NULL);
- add_notifier(&ip_up_notifier, nm_ip_up, NULL);
- add_notifier(&exitnotify, nm_exit_notify, NULL);
+ ppp_add_notify(NF_PHASE_CHANGE, nm_phasechange_hook, NULL);
+ ppp_add_notify(NF_IP_UP, nm_ip_up, NULL);
+ ppp_add_notify(NF_EXIT, nm_exit_notify, NULL);
add_ip6_notifier();
-
return 0;
}
--
GitLab
Avoid unnecessary dependency on libelogind.
sd_booted() always returns FALSE on Alpine.
--- a/src/core/devices/wwan/nm-modem-manager.c
+++ b/src/core/devices/wwan/nm-modem-manager.c
@@ -11,11 +11,8 @@
#include <libmm-glib.h>
-#if HAVE_LIBSYSTEMD
-#include <systemd/sd-daemon.h>
-#else
+// XXX-Patched
#define sd_booted() FALSE
-#endif
#include "libnm-std-aux/nm-dbus-compat.h"
#include "nm-modem.h"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment