From fbb2532e93d103ab9248f765081a35a37e631130 Mon Sep 17 00:00:00 2001 From: Dusty Mabe Date: Mon, 19 Apr 2021 10:52:39 -0400 Subject: [PATCH] Backport a few upstream fixes - Backport: fix(dracut-logger.sh): double dash trigger unknown logger warnings during run - Backport: fix(network-manager): nm-run.service: don't kill forked processes - Backport: fix(network-manager): only run NetworkManager if rd.neednet=1 - Backport: fix(network-manager): use /run/NetworkManager/initrd/neednet in initqueue --- ...r.sh-double-dash-trigger-unknown-log.patch | 38 +++++++++++++ ...ger-nm-run.service-don-t-kill-forked.patch | 46 ++++++++++++++++ ...ger-only-run-NetworkManager-if-rd.ne.patch | 47 ++++++++++++++++ ...ger-use-run-NetworkManager-initrd-ne.patch | 55 +++++++++++++++++++ dracut.spec | 18 +++++- 5 files changed, 203 insertions(+), 1 deletion(-) create mode 100644 0001-fix-dracut-logger.sh-double-dash-trigger-unknown-log.patch create mode 100644 0001-fix-network-manager-nm-run.service-don-t-kill-forked.patch create mode 100644 0001-fix-network-manager-only-run-NetworkManager-if-rd.ne.patch create mode 100644 0002-fix-network-manager-use-run-NetworkManager-initrd-ne.patch diff --git a/0001-fix-dracut-logger.sh-double-dash-trigger-unknown-log.patch b/0001-fix-dracut-logger.sh-double-dash-trigger-unknown-log.patch new file mode 100644 index 0000000..2511dab --- /dev/null +++ b/0001-fix-dracut-logger.sh-double-dash-trigger-unknown-log.patch @@ -0,0 +1,38 @@ +From 4fbccde50456f513d388cdfd858018cd889890dc Mon Sep 17 00:00:00 2001 +From: Dusty Mabe +Date: Wed, 14 Apr 2021 16:23:29 -0400 +Subject: [PATCH] fix(dracut-logger.sh): double dash trigger unknown logger + warnings during run + +There are a bunch of `logger: unknown facility name: --user` errors +during a run. This is because logger is getting passed something like: + +``` +logger -p --user.info +``` + +Where it should be something like: + +``` +logger -p user.info +``` +--- + dracut-logger.sh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/dracut-logger.sh b/dracut-logger.sh +index c36525d0..07389285 100755 +--- a/dracut-logger.sh ++++ b/dracut-logger.sh +@@ -241,7 +241,7 @@ _lvl2char() { + # @retval 0 if @a lvl is correct. + # @result Echoes logger priority. + _lvl2syspri() { +- printf "%s" -- "$syslogfacility." ++ printf -- "%s" "$syslogfacility." + case "$1" in + 1) echo crit;; + 2) echo error;; +-- +2.30.2 + diff --git a/0001-fix-network-manager-nm-run.service-don-t-kill-forked.patch b/0001-fix-network-manager-nm-run.service-don-t-kill-forked.patch new file mode 100644 index 0000000..73bebc4 --- /dev/null +++ b/0001-fix-network-manager-nm-run.service-don-t-kill-forked.patch @@ -0,0 +1,46 @@ +From 1f21fac646daa46cbe184ef8ff7705842f06ba15 Mon Sep 17 00:00:00 2001 +From: Dusty Mabe +Date: Wed, 14 Apr 2021 10:46:12 -0400 +Subject: [PATCH] fix(network-manager): nm-run.service: don't kill forked + processes + +If teaming is set up via NetworkManager we don't want systemd to take +down the userspace teamd process when NetworkManager quits. `KillMode=process` +will allow it to leave those processes behind. + +This is fallout from the change to run NetworkManager via systemd (c17c5b7). + +With `KillMode=process` we get something like: + +``` +sh-5.1# journalctl -u nm-run -o cat | tail + [1618411262.7030] quitting now that startup is complete + [1618411262.7030] device (team0): carrier: link connected + [1618411262.7033] device (team0): team port ens2 was released + [1618411262.7033] device (team0): team port ens3 was released + [1618411262.7033] manager: NetworkManager state is now CONNECTED_SITE + [1618411262.7034] exiting (success) +nm-run.service: Deactivated successfully. +nm-run.service: Unit process 476 (teamd) remains running after unit stopped. +Finished nm-run.service. +``` +--- + modules.d/35network-manager/nm-run.service | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/modules.d/35network-manager/nm-run.service b/modules.d/35network-manager/nm-run.service +index f3493c41..b667ce37 100644 +--- a/modules.d/35network-manager/nm-run.service ++++ b/modules.d/35network-manager/nm-run.service +@@ -23,6 +23,8 @@ ConditionPathExistsGlob=|/etc/sysconfig/network-scripts/ifcfg-* + #run the script and wait before it finishes + Type=oneshot + ExecStart=/usr/sbin/NetworkManager --configure-and-quit=initrd --no-daemon ++#don't kill forked off processes (for example: teamd for teaming) ++KillMode=process + + [Install] + WantedBy=initrd.target +-- +2.30.2 + diff --git a/0001-fix-network-manager-only-run-NetworkManager-if-rd.ne.patch b/0001-fix-network-manager-only-run-NetworkManager-if-rd.ne.patch new file mode 100644 index 0000000..25d40df --- /dev/null +++ b/0001-fix-network-manager-only-run-NetworkManager-if-rd.ne.patch @@ -0,0 +1,47 @@ +From ac0e8f7dcc81432311906c3fca0d4211f6a2f68c Mon Sep 17 00:00:00 2001 +From: Dusty Mabe +Date: Tue, 13 Apr 2021 11:36:21 -0400 +Subject: [PATCH 1/2] fix(network-manager): only run NetworkManager if + rd.neednet=1 + +Don't run the new systemd unit (nm-run.service) if rd.neednet=1 +isn't set. nm-initrd-generator will generate configuration even +without rd.neednet=1 so determining if we should start based on +just if connection profiles exist isn't enough. We need some other +indicator. In this case we lay down a /run/NetworkManager/initrd/neednet +if rd.neednet=1, which is used by nm-run.service to determine the +need to run. +--- + modules.d/35network-manager/nm-lib.sh | 1 + + modules.d/35network-manager/nm-run.service | 3 +++ + 2 files changed, 4 insertions(+) + +diff --git a/modules.d/35network-manager/nm-lib.sh b/modules.d/35network-manager/nm-lib.sh +index fe053cf..d756022 100644 +--- a/modules.d/35network-manager/nm-lib.sh ++++ b/modules.d/35network-manager/nm-lib.sh +@@ -14,6 +14,7 @@ nm_generate_connections() + /etc/sysconfig/network-scripts/ifcfg-*; do + [ -f "$i" ] || continue + echo '[ -f /tmp/nm.done ]' >$hookdir/initqueue/finished/nm.sh ++ : > /run/NetworkManager/initrd/neednet # activate nm-run.service + break + done + fi +diff --git a/modules.d/35network-manager/nm-run.service b/modules.d/35network-manager/nm-run.service +index b667ce3..f041ade 100644 +--- a/modules.d/35network-manager/nm-run.service ++++ b/modules.d/35network-manager/nm-run.service +@@ -15,6 +15,9 @@ Before=network.target network-online.target + #run before we try to mount anything from the dracut hooks + Before=dracut-initqueue.service + ++#do not run if networking not needed ++ConditionPathExists=/run/NetworkManager/initrd/neednet ++ + #do not run, if there is no configuration + ConditionPathExistsGlob=|/usr/lib/NetworkManager/system-connections/* + ConditionPathExistsGlob=|/run/NetworkManager/system-connections/* +-- +2.30.2 + diff --git a/0002-fix-network-manager-use-run-NetworkManager-initrd-ne.patch b/0002-fix-network-manager-use-run-NetworkManager-initrd-ne.patch new file mode 100644 index 0000000..e187e0e --- /dev/null +++ b/0002-fix-network-manager-use-run-NetworkManager-initrd-ne.patch @@ -0,0 +1,55 @@ +From 6a37c6f6302f950df608db3fd45acf9342ee3de2 Mon Sep 17 00:00:00 2001 +From: Dusty Mabe +Date: Tue, 13 Apr 2021 11:45:35 -0400 +Subject: [PATCH 2/2] fix(network-manager): use + /run/NetworkManager/initrd/neednet in initqueue + +We don't want to start NetworkManager if networking is not needed. +Right now nm-config.sh lays down /usr/lib/dracut/hooks/initqueue/finished/nm.sh +which will cause the initqueue to run. If nothing exists in +/usr/lib/dracut/hooks/initqueue/finished/ then it will short circuit and +the initqueue won't run anything. But what if something else needed +something to run in the initqueue? nm-run.sh would still get started, +even though /usr/lib/dracut/hooks/initqueue/finished/nm.sh didn't exist. +In this case let's just trigger off of /run/NetworkManager/initrd/neednet +like we are doing in the systemd unit (nm-run.service). +--- + modules.d/35network-manager/nm-run.sh | 22 +++++++++++++--------- + 1 file changed, 13 insertions(+), 9 deletions(-) + +diff --git a/modules.d/35network-manager/nm-run.sh b/modules.d/35network-manager/nm-run.sh +index d48028df..359bc9ee 100755 +--- a/modules.d/35network-manager/nm-run.sh ++++ b/modules.d/35network-manager/nm-run.sh +@@ -6,15 +6,19 @@ if [ -e /tmp/nm.done ]; then + return + fi + +-[ -z "$DRACUT_SYSTEMD" ] && \ +-for i in /usr/lib/NetworkManager/system-connections/* \ +- /run/NetworkManager/system-connections/* \ +- /etc/NetworkManager/system-connections/* \ +- /etc/sysconfig/network-scripts/ifcfg-*; do +- [ -f "$i" ] || continue +- /usr/sbin/NetworkManager --configure-and-quit=initrd --no-daemon +- break +-done ++if [ -z "$DRACUT_SYSTEMD" ]; then ++ # Only start NM if networking is needed ++ if [ -e /run/NetworkManager/initrd/neednet ]; then ++ for i in /usr/lib/NetworkManager/system-connections/* \ ++ /run/NetworkManager/system-connections/* \ ++ /etc/NetworkManager/system-connections/* \ ++ /etc/sysconfig/network-scripts/ifcfg-*; do ++ [ -f "$i" ] || continue ++ /usr/sbin/NetworkManager --configure-and-quit=initrd --no-daemon ++ break ++ done ++ fi ++fi + + if [ -s /run/NetworkManager/initrd/hostname ]; then + cat /run/NetworkManager/initrd/hostname > /proc/sys/kernel/hostname +-- +2.30.2 + diff --git a/dracut.spec b/dracut.spec index 3e4261e..d2db0b7 100644 --- a/dracut.spec +++ b/dracut.spec @@ -5,7 +5,7 @@ # strip the automatically generated dep here and instead co-own the # directory. %global __requires_exclude pkg-config -%define dist_free_release 3 +%define dist_free_release 4 Name: dracut Version: 053 @@ -39,6 +39,16 @@ Patch0: 0001-fix-network-manager-no-default-deps-for-nm-run.servi.patch # https://bugzilla.redhat.com/show_bug.cgi?id=1936781#c6 # Should fix loss of critical system files with kdump enabled Patch1: 0001-Partially-revert-41cfdfc-to-fix-RHBZ-1936781-per-ryn.patch +# Fix logger error when building initramfs +# https://github.com/dracutdevs/dracut/pull/1351 +Patch2: 0001-fix-dracut-logger.sh-double-dash-trigger-unknown-log.patch +# Fix issue where teaming would get brought down by systemd +# https://github.com/dracutdevs/dracut/pull/1349 +Patch3: 0001-fix-network-manager-nm-run.service-don-t-kill-forked.patch +# Fix issue where NM was getting brought up unconditionally +# https://github.com/dracutdevs/dracut/pull/1347 +Patch4: 0001-fix-network-manager-only-run-NetworkManager-if-rd.ne.patch +Patch5: 0002-fix-network-manager-use-run-NetworkManager-initrd-ne.patch BuildRequires: bash BuildRequires: git-core @@ -488,6 +498,12 @@ echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/ %{_prefix}/lib/kernel/install.d/51-dracut-rescue.install %changelog +* Mon Apr 19 2021 Dusty Mabe - 053-4 +- Backport: fix(dracut-logger.sh): double dash trigger unknown logger warnings during run +- Backport: fix(network-manager): nm-run.service: don't kill forked processes +- Backport: fix(network-manager): only run NetworkManager if rd.neednet=1 +- Backport: fix(network-manager): use /run/NetworkManager/initrd/neednet in initqueue + * Mon Apr 19 2021 Adam Williamson - 053-3 - Fix removal of key system files when kdump enabled (thanks kasong) (#1936781)