]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
systemd: make predictable name mac policy opt-out
authorPeter Marko <peter.marko@siemens.com>
Fri, 12 Apr 2024 13:43:17 +0000 (15:43 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Sun, 14 Apr 2024 05:25:47 +0000 (06:25 +0100)
Even the patch says it's inappropriate for upstream,
and it's also inappropriate for some downstream projects, too.
So make it possible to opt-out on it by replacing
the patch by sed and depend on distro feature pni-names.

Signed-off-by: Peter Marko <peter.marko@siemens.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-core/systemd/systemd/0001-NamePolicy.patch [deleted file]
meta/recipes-core/systemd/systemd_255.4.bb

diff --git a/meta/recipes-core/systemd/systemd/0001-NamePolicy.patch b/meta/recipes-core/systemd/systemd/0001-NamePolicy.patch
deleted file mode 100644 (file)
index 46955cb..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-From 9bb09886320eb286108fb370b2634a66b3e3b9ff Mon Sep 17 00:00:00 2001
-From: Joe Slater <joe.slater@windriver.com>
-Date: Thu, 21 Mar 2024 16:28:31 +0000
-Subject: [PATCH] systemd: enable mac based names in NamePolicy
-
-The default NamePolicy for network interface names does not
-include names based on mac addresses.  Some BSPs, though, do
-not provide information to compute other names, so we enable
-mac names as a last resort.
-
-Upstream-Status: Inappropriate [enable feature]
-
-Signed-off-by: Joe Slater <joe.slater@windriver.com>
----
- network/99-default.link | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/network/99-default.link b/network/99-default.link
-index 429ac31e80..543ce54661 100644
---- a/network/99-default.link
-+++ b/network/99-default.link
-@@ -15,6 +15,6 @@
- OriginalName=*
- [Link]
--NamePolicy=keep kernel database onboard slot path
--AlternativeNamesPolicy=database onboard slot path
-+NamePolicy=keep kernel database onboard slot path mac
-+AlternativeNamesPolicy=database onboard slot path mac
- MACAddressPolicy=persistent
--- 
-2.35.5
-
index 8a816c4bc1df223dad1916daa78915347d0b0819..e7498c802db9f8d53062be8572f85abd1511b04e 100644 (file)
@@ -28,7 +28,6 @@ SRC_URI += " \
            file://systemd-pager.sh \
            file://0002-binfmt-Don-t-install-dependency-links-at-install-tim.patch \
            file://0008-implment-systemd-sysv-install-for-OE.patch \
-           file://0001-NamePolicy.patch \
            "
 
 # patches needed by musl
@@ -66,7 +65,7 @@ PAM_PLUGINS = " \
 "
 
 PACKAGECONFIG ??= " \
-    ${@bb.utils.filter('DISTRO_FEATURES', 'acl audit efi ldconfig pam selinux smack usrmerge polkit seccomp', d)} \
+    ${@bb.utils.filter('DISTRO_FEATURES', 'acl audit efi ldconfig pam pni-names selinux smack usrmerge polkit seccomp', d)} \
     ${@bb.utils.contains('DISTRO_FEATURES', 'minidebuginfo', 'coredump elfutils', '', d)} \
     ${@bb.utils.contains('DISTRO_FEATURES', 'wifi', 'rfkill', '', d)} \
     ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'xkbcommon', '', d)} \
@@ -197,6 +196,7 @@ PACKAGECONFIG[polkit] = "-Dpolkit=true,-Dpolkit=false"
 PACKAGECONFIG[polkit_hostnamed_fallback] = ",,,,dbus-broker,polkit"
 PACKAGECONFIG[portabled] = "-Dportabled=true,-Dportabled=false"
 PACKAGECONFIG[pstore] = "-Dpstore=true,-Dpstore=false"
+PACKAGECONFIG[pni-names] = ",,,"
 PACKAGECONFIG[qrencode] = "-Dqrencode=true,-Dqrencode=false,qrencode,,qrencode"
 PACKAGECONFIG[quotacheck] = "-Dquotacheck=true,-Dquotacheck=false"
 PACKAGECONFIG[randomseed] = "-Drandomseed=true,-Drandomseed=false"
@@ -389,6 +389,15 @@ do_install() {
         sed -i -e 's/#RebootWatchdogSec=10min/RebootWatchdogSec=${WATCHDOG_TIMEOUT}/' \
             ${D}/${sysconfdir}/systemd/system.conf
     fi
+
+       if ${@bb.utils.contains('PACKAGECONFIG', 'pni-names', 'true', 'false', d)}; then
+               if ! grep -q '^NamePolicy=.*mac' ${D}${rootlibexecdir}/systemd/network/99-default.link; then
+                       sed -i '/^NamePolicy=/s/$/ mac/' ${D}${rootlibexecdir}/systemd/network/99-default.link
+               fi
+               if ! grep -q 'AlternativeNamesPolicy=.*mac' ${D}${rootlibexecdir}/systemd/network/99-default.link; then
+                       sed -i '/AlternativeNamesPolicy=/s/$/ mac/' ${D}${rootlibexecdir}/systemd/network/99-default.link
+               fi
+       fi
 }
 
 python populate_packages:prepend (){