From d7c98d64b83d93bd6c7fe29096cbaa018e5b054e Mon Sep 17 00:00:00 2001 From: zhangruifang2020 Date: Tue, 19 Dec 2023 17:53:24 +0800 Subject: [PATCH] backport patchs from upstream (cherry picked from commit 2e01aee7d2264d9f95b58cf86ca965c343e44027) --- ...e-Do-not-resume-on-iSCSI-FCoE-or-NBD.patch | 152 ++++++++++++++++++ ...-ask-no-warn-if-run-cryptsetup-exist.patch | 34 ++++ ...-add-ip_params_for_remote_addr-helpe.patch | 142 ++++++++++++++++ ...-fix-find_binary-to-return-full-path.patch | 62 +++++++ ...heck-for-invalid-configuration-files.patch | 52 ++++++ ...rt-fix-base-tr-needs-to-be-installed.patch | 25 +++ ...-gpg-execute-card-status-on-each-try.patch | 29 ++++ ...acut-install-tweaks-to-get_real_file.patch | 81 ++++++++++ ...ndle-i-option-to-include-files-begin.patch | 83 ++++++++++ ...ndle-symlinks-appropriately-while-us.patch | 31 ++++ ...all-handle-LIB-in-ldd-output-parsing.patch | 57 +++++++ ...t-fix-install-sane-default-kerneldir.patch | 31 ++++ ...-fix-install-segfault-on-popen-error.patch | 27 ++++ ...value-of-rd.retry-was-increased-to-1.patch | 28 ++++ ...-UUID-comparison-for-more-than-one-U.patch | 33 ++++ ...fix-multipath-revise-multipathd-stop.patch | 76 +++++++++ ...errors-and-warnings-when-network-int.patch | 70 ++++++++ ...heck-the-existence-of-sys-devices-qe.patch | 36 +++++ ...hellcheck-for-modules.d-95qeth_rules.patch | 55 +++++++ ...eck-for-presence-of-sys-power-resume.patch | 34 ++++ ...wn-be-robust-against-forced-shutdown.patch | 40 +++++ ...-pre-pivot-hook-separetely-per-nfs-m.patch | 25 +++ dracut.spec | 28 +++- 23 files changed, 1230 insertions(+), 1 deletion(-) create mode 100644 backport-95resume-Do-not-resume-on-iSCSI-FCoE-or-NBD.patch create mode 100644 backport-cryptroot-ask-no-warn-if-run-cryptsetup-exist.patch create mode 100644 backport-dracut-functions-add-ip_params_for_remote_addr-helpe.patch create mode 100644 backport-dracut-functions-fix-find_binary-to-return-full-path.patch create mode 100644 backport-dracut.sh-add-check-for-invalid-configuration-files.patch create mode 100644 backport-fix-base-tr-needs-to-be-installed.patch create mode 100644 backport-fix-crypt-gpg-execute-card-status-on-each-try.patch create mode 100644 backport-fix-dracut-install-tweaks-to-get_real_file.patch create mode 100644 backport-fix-dracut.sh-handle-i-option-to-include-files-begin.patch create mode 100644 backport-fix-dracut.sh-handle-symlinks-appropriately-while-us.patch create mode 100644 backport-fix-install-handle-LIB-in-ldd-output-parsing.patch create mode 100644 backport-fix-install-sane-default-kerneldir.patch create mode 100644 backport-fix-install-segfault-on-popen-error.patch create mode 100644 backport-fix-man-default-value-of-rd.retry-was-increased-to-1.patch create mode 100644 backport-fix-mdraid-allow-UUID-comparison-for-more-than-one-U.patch create mode 100644 backport-fix-multipath-revise-multipathd-stop.patch create mode 100644 backport-fix-network-add-errors-and-warnings-when-network-int.patch create mode 100644 backport-fix-qeth_rules-check-the-existence-of-sys-devices-qe.patch create mode 100644 backport-fix-qeth_rules-shellcheck-for-modules.d-95qeth_rules.patch create mode 100644 backport-fix-resume-check-for-presence-of-sys-power-resume.patch create mode 100644 backport-fix-shutdown-be-robust-against-forced-shutdown.patch create mode 100644 backport-fix-url-lib-make-pre-pivot-hook-separetely-per-nfs-m.patch diff --git a/backport-95resume-Do-not-resume-on-iSCSI-FCoE-or-NBD.patch b/backport-95resume-Do-not-resume-on-iSCSI-FCoE-or-NBD.patch new file mode 100644 index 0000000..34c967a --- /dev/null +++ b/backport-95resume-Do-not-resume-on-iSCSI-FCoE-or-NBD.patch @@ -0,0 +1,152 @@ +From 480aa9695f8c2e2b30c8f41ae8483140020d23db Mon Sep 17 00:00:00 2001 +From: Daniel Molkentin +Date: Tue, 4 Aug 2020 10:20:51 +0200 +Subject: [PATCH] 95resume: Do not resume on iSCSI, FCoE or NBD + +The iSCSI configuration is started after dracut checks for resume, +so we run into a timeout here. Additionally it's questionable if +resume on iSCSI makes sense (or is even supported on the platform). + +Same holds true for Network Block Devices and FcOE, cover those as well + +References: bsc#999663 + +Original-patch-by: Hannes Reinecke +Signed-off-by: Daniel Molkentin +--- + dracut-functions.sh | 44 ++++++++++++++++++++++++++++++ + modules.d/95iscsi/module-setup.sh | 14 ++-------- + modules.d/95nbd/module-setup.sh | 4 +-- + modules.d/95resume/module-setup.sh | 11 +++++++- + 4 files changed, 57 insertions(+), 16 deletions(-) + +diff --git a/dracut-functions.sh b/dracut-functions.sh +index 07ae88c0..e0ca7574 100755 +--- a/dracut-functions.sh ++++ b/dracut-functions.sh +@@ -842,3 +842,47 @@ ip_params_for_remote_addr() { + fi + + } ++ ++# block_is_nbd ++# Check whether $1 is an nbd device ++block_is_nbd() { ++ [[ -b /dev/block/$1 && $1 == 43:* ]] ++} ++ ++# block_is_iscsi ++# Check whether $1 is an nbd device ++block_is_iscsi() { ++ local _dir ++ local _dev=$1 ++ [[ -L "/sys/dev/block/$_dev" ]] || return ++ _dir="$(readlink -f "/sys/dev/block/$_dev")" || return ++ until [[ -d "$_dir/sys" || -d "$_dir/iscsi_session" ]]; do ++ _dir="$_dir/.." ++ done ++ [[ -d "$_dir/iscsi_session" ]] ++} ++ ++# block_is_fcoe ++# Check whether $1 is an FCoE device ++# Will not work for HBAs that hide the ethernet aspect ++# completely and present a pure FC device ++block_is_fcoe() { ++ local _dir ++ local _dev=$1 ++ [[ -L "/sys/dev/block/$_dev" ]] || return ++ _dir="$(readlink -f "/sys/dev/block/$_dev")" ++ until [[ -d "$_dir/sys" ]]; do ++ _dir="$_dir/.." ++ if [[ -d "$_dir/subsystem" ]]; then ++ subsystem=$(basename $(readlink $_dir/subsystem)) ++ [[ $subsystem == "fcoe" ]] && return 0 ++ fi ++ done ++ return 1 ++} ++ ++# block_is_netdevice ++# Check whether $1 is a net device ++block_is_netdevice() { ++ block_is_nbd "$1" || block_is_iscsi "$1" || block_is_fcoe "$1" ++} +diff --git a/modules.d/95iscsi/module-setup.sh b/modules.d/95iscsi/module-setup.sh +index dfacd797..20922442 100755 +--- a/modules.d/95iscsi/module-setup.sh ++++ b/modules.d/95iscsi/module-setup.sh +@@ -9,20 +9,9 @@ check() { + # If hostonly was requested, fail the check if we are not actually + # booting from root. + +- is_iscsi() { +- local _dev=$1 +- +- [[ -L "/sys/dev/block/$_dev" ]] || return +- cd "$(readlink -f "/sys/dev/block/$_dev")" +- until [[ -d sys || -d iscsi_session ]]; do +- cd .. +- done +- [[ -d iscsi_session ]] +- } +- + [[ $hostonly ]] || [[ $mount_needs ]] && { + pushd . >/dev/null +- for_each_host_dev_and_slaves is_iscsi ++ for_each_host_dev_and_slaves block_is_iscsi + local _is_iscsi=$? + popd >/dev/null + [[ $_is_iscsi == 0 ]] || return 255 +@@ -223,6 +212,7 @@ install() { + inst_hook cmdline 90 "$moddir/parse-iscsiroot.sh" + inst_hook cleanup 90 "$moddir/cleanup-iscsi.sh" + inst "$moddir/iscsiroot.sh" "/sbin/iscsiroot" ++ + if ! dracut_module_included "systemd"; then + inst "$moddir/mount-lun.sh" "/bin/mount-lun.sh" + else +diff --git a/modules.d/95nbd/module-setup.sh b/modules.d/95nbd/module-setup.sh +index 22f6a3bf..9254b49a 100755 +--- a/modules.d/95nbd/module-setup.sh ++++ b/modules.d/95nbd/module-setup.sh +@@ -7,11 +7,9 @@ check() { + # if an nbd device is not somewhere in the chain of devices root is + # mounted on, fail the hostonly check. + [[ $hostonly ]] || [[ $mount_needs ]] && { +- is_nbd() { [[ -b /dev/block/$1 && $1 == 43:* ]] ;} +- + _rootdev=$(find_root_block_device) + [[ -b /dev/block/$_rootdev ]] || return 1 +- check_block_and_slaves is_nbd "$_rootdev" || return 255 ++ check_block_and_slaves block_is_nbd "$_rootdev" || return 255 + } + require_binaries nbd-client || return 1 + +diff --git a/modules.d/95resume/module-setup.sh b/modules.d/95resume/module-setup.sh +index cb06b567..96c2573e 100755 +--- a/modules.d/95resume/module-setup.sh ++++ b/modules.d/95resume/module-setup.sh +@@ -2,9 +2,18 @@ + + # called by dracut + check() { ++ swap_on_netdevice() { ++ local _dev ++ for _dev in "${swap_devs[@]}"; do ++ block_is_netdevice $_dev && return 0 ++ done ++ return 1 ++ } ++ + # Only support resume if hibernation is currently on ++ # and no swap is mounted on a net device + [[ $hostonly ]] || [[ $mount_needs ]] && { +- [[ "$(cat /sys/power/resume)" == "0:0" ]] && return 255 ++ swap_on_netdevice || [[ "$(cat /sys/power/resume)" == "0:0" ]] && return 255 + } + + return 0 +-- +2.33.0 + diff --git a/backport-cryptroot-ask-no-warn-if-run-cryptsetup-exist.patch b/backport-cryptroot-ask-no-warn-if-run-cryptsetup-exist.patch new file mode 100644 index 0000000..605b7a6 --- /dev/null +++ b/backport-cryptroot-ask-no-warn-if-run-cryptsetup-exist.patch @@ -0,0 +1,34 @@ +From 17d62d12065c264d899609cf69e8d913fc84460d Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?= + +Date: Sat, 14 Mar 2020 11:44:47 +0700 +Subject: [PATCH] cryptroot-ask: no warn if /run/cryptsetup exist + +In either case: +- encrypted device is decrypted, udev will trigger device changes again, +- multiple encrypted device, + +cryptroot-ask will run multiple time, then report: +> mkdir: cannot create directory '/run/cryptsetup': File exists + +Pass `-p` into mkdir to ignore that warning. +--- + modules.d/90crypt/cryptroot-ask.sh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/modules.d/90crypt/cryptroot-ask.sh b/modules.d/90crypt/cryptroot-ask.sh +index e1f17975..97047ae9 100755 +--- a/modules.d/90crypt/cryptroot-ask.sh ++++ b/modules.d/90crypt/cryptroot-ask.sh +@@ -8,7 +8,7 @@ NEWROOT=${NEWROOT:-"/sysroot"} + + . /lib/dracut-lib.sh + +-mkdir -m 0700 /run/cryptsetup ++mkdir -p -m 0700 /run/cryptsetup + + # if device name is /dev/dm-X, convert to /dev/mapper/name + if [ "${1##/dev/dm-}" != "$1" ]; then +-- +2.33.0 + diff --git a/backport-dracut-functions-add-ip_params_for_remote_addr-helpe.patch b/backport-dracut-functions-add-ip_params_for_remote_addr-helpe.patch new file mode 100644 index 0000000..020bb9f --- /dev/null +++ b/backport-dracut-functions-add-ip_params_for_remote_addr-helpe.patch @@ -0,0 +1,142 @@ +From ceca74ccc397795db68ca6ffbe49d65af2178a50 Mon Sep 17 00:00:00 2001 +From: Martin Wilck +Date: Sat, 11 Jul 2020 00:15:34 +0200 +Subject: [PATCH] dracut-functions: add ip_params_for_remote_addr() helper + +This helper function takes a remote IP address, and tries to +determine the dracut command line arguments ip= and ifname= that +will make this remote address reachable during boot. + +Functionality was taken from the module-setup.sh scripts of 95iscsi and 95nfs, +cleaned up and fixed some issues in particular with statically configured +networks, where the old code would print the unsupported string +"$ifname:static". +--- + dracut-functions.sh | 114 ++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 114 insertions(+) + +diff --git a/dracut-functions.sh b/dracut-functions.sh +index b5c28248..07ae88c0 100755 +--- a/dracut-functions.sh ++++ b/dracut-functions.sh +@@ -728,3 +728,117 @@ btrfs_devs() { + printf -- "%s\n" "$_dev" + done + } ++ ++iface_for_remote_addr() { ++ set -- $(ip -o route get to "$1") ++ echo $3 ++} ++ ++local_addr_for_remote_addr() { ++ set -- $(ip -o route get to "$1") ++ echo $5 ++} ++ ++peer_for_addr() { ++ local addr=$1 ++ local qtd ++ ++ # quote periods in IPv4 address ++ qtd=${addr//./\\.} ++ ip -o addr show | \ ++ sed -n 's%^.* '"$qtd"' peer \([0-9a-f.:]\{1,\}\(/[0-9]*\)\?\).*$%\1%p' ++} ++ ++netmask_for_addr() { ++ local addr=$1 ++ local qtd ++ ++ # quote periods in IPv4 address ++ qtd=${addr//./\\.} ++ ip -o addr show | sed -n 's,^.* '"$qtd"'/\([0-9]*\) .*$,\1,p' ++} ++ ++gateway_for_iface() { ++ local ifname=$1 addr=$2 ++ ++ case $addr in ++ *.*) proto=4;; ++ *:*) proto=6;; ++ *) return;; ++ esac ++ ip -o -$proto route show | \ ++ sed -n "s/^default via \([0-9a-z.:]\{1,\}\) dev $ifname .*\$/\1/p" ++} ++ ++# This works only for ifcfg-style network configuration! ++bootproto_for_iface() { ++ local ifname=$1 ++ local dir ++ ++ # follow ifcfg settings for boot protocol ++ for dir in network-scripts network; do ++ [ -f "/etc/sysconfig/$dir/ifcfg-$ifname" ] && { ++ sed -n "s/BOOTPROTO=[\"']\?\([[:alnum:]]\{1,\}\)[\"']\?.*\$/\1/p" \ ++ "/etc/sysconfig/$dir/ifcfg-$ifname" ++ return ++ } ++ done ++} ++ ++is_unbracketed_ipv6_address() { ++ strglob "$1" '*:*' && ! strglob "$1" '\[*:*\]' ++} ++ ++# Create an ip= string to set up networking such that the given ++# remote address can be reached ++ip_params_for_remote_addr() { ++ local remote_addr=$1 ++ local ifname local_addr peer netmask= gateway ifmac ++ ++ [[ $remote_addr ]] || return 1 ++ ifname=$(iface_for_remote_addr "$remote_addr") ++ [[ $ifname ]] || { ++ berror "failed to determine interface to connect to $remote_addr" ++ return 1 ++ } ++ ++ # ifname clause to bind the interface name to a MAC address ++ if [ -d "/sys/class/net/$ifname/bonding" ]; then ++ dinfo "Found bonded interface '${ifname}'. Make sure to provide an appropriate 'bond=' cmdline." ++ elif [ -e "/sys/class/net/$ifname/address" ] ; then ++ ifmac=$(cat "/sys/class/net/$ifname/address") ++ [[ $ifmac ]] && printf 'ifname=%s:%s ' "${ifname}" "${ifmac}" ++ fi ++ ++ bootproto=$(bootproto_for_iface "$ifname") ++ case $bootproto in ++ dhcp|dhcp6|auto6) ;; ++ dhcp4) ++ bootproto=dhcp;; ++ static*|"") ++ bootproto=;; ++ *) ++ derror "bootproto \"$bootproto\" is unsupported by dracut, trying static configuration" ++ bootproto=;; ++ esac ++ if [[ $bootproto ]]; then ++ printf 'ip=%s:%s ' "${ifname}" "${bootproto}" ++ else ++ local_addr=$(local_addr_for_remote_addr "$remote_addr") ++ [[ $local_addr ]] || { ++ berror "failed to determine local address to connect to $remote_addr" ++ return 1 ++ } ++ peer=$(peer_for_addr "$local_addr") ++ # Set peer or netmask, but not both ++ [[ $peer ]] || netmask=$(netmask_for_addr "$local_addr") ++ gateway=$(gateway_for_iface "$ifname" "$local_addr") ++ # Quote IPv6 addresses with brackets ++ is_unbracketed_ipv6_address "$local_addr" && local_addr="[$local_addr]" ++ is_unbracketed_ipv6_address "$peer" && peer="[$peer]" ++ is_unbracketed_ipv6_address "$gateway" && gateway="[$gateway]" ++ printf 'ip=%s:%s:%s:%s::%s:none ' \ ++ "${local_addr}" "${peer}" "${gateway}" "${netmask}" "${ifname}" ++ fi ++ ++} +-- +2.33.0 + diff --git a/backport-dracut-functions-fix-find_binary-to-return-full-path.patch b/backport-dracut-functions-fix-find_binary-to-return-full-path.patch new file mode 100644 index 0000000..389841e --- /dev/null +++ b/backport-dracut-functions-fix-find_binary-to-return-full-path.patch @@ -0,0 +1,62 @@ +From f769154bccf22d2b5caf5e4888f88bf7edde2662 Mon Sep 17 00:00:00 2001 +From: Alexander Tsoy +Date: Mon, 25 May 2020 19:02:05 +0300 +Subject: [PATCH] dracut-functions: fix find_binary() to return full path + +Fixes: a01204202b30 (Allow running on a cross-compiled rootfs) +--- + dracut-functions.sh | 21 +++++++++++++-------- + 1 file changed, 13 insertions(+), 8 deletions(-) + +diff --git a/dracut-functions.sh b/dracut-functions.sh +index 3cb9c7af..b5c28248 100755 +--- a/dracut-functions.sh ++++ b/dracut-functions.sh +@@ -41,31 +41,36 @@ str_ends() { [ "${1%*"$2"}" != "$1" ]; } + # search in the usual places to find the binary. + find_binary() { + local _delim ++ local _path + local l + local p + [[ -z ${1##/*} ]] || _delim="/" + + if [[ "$1" == *.so* ]]; then + for l in libdirs ; do +- if { $DRACUT_LDD "$dracutsysrootdir$l$_delim$1" &>/dev/null; }; then +- printf "%s\n" "$1" ++ _path="${l}${_delim}${1}" ++ if { $DRACUT_LDD "${dracutsysrootdir}${_path}" &>/dev/null; }; then ++ printf "%s\n" "${_path}" + return 0 + fi + done +- if { $DRACUT_LDD "$dracutsysrootdir$_delim$1" &>/dev/null; }; then +- printf "%s\n" "$1" ++ _path="${_delim}${1}" ++ if { $DRACUT_LDD "${dracutsysrootdir}${_path}" &>/dev/null; }; then ++ printf "%s\n" "${_path}" + return 0 + fi + fi + if [[ "$1" == */* ]]; then +- if [[ -L $dracutsysrootdir$_delim$1 ]] || [[ -x $dracutsysrootdir$_delim$1 ]]; then +- printf "%s\n" "$1" ++ _path="${_delim}${1}" ++ if [[ -L ${dracutsysrootdir}${_path} ]] || [[ -x ${dracutsysrootdir}${_path} ]]; then ++ printf "%s\n" "${_path}" + return 0 + fi + fi + for p in $DRACUT_PATH ; do +- if [[ -L $dracutsysrootdir$p$_delim$1 ]] || [[ -x $dracutsysrootdir$p$_delim$1 ]]; then +- printf "%s\n" "$1" ++ _path="${p}${_delim}${1}" ++ if [[ -L ${dracutsysrootdir}${_path} ]] || [[ -x ${dracutsysrootdir}${_path} ]]; then ++ printf "%s\n" "${_path}" + return 0 + fi + done +-- +2.33.0 + diff --git a/backport-dracut.sh-add-check-for-invalid-configuration-files.patch b/backport-dracut.sh-add-check-for-invalid-configuration-files.patch new file mode 100644 index 0000000..90a98f6 --- /dev/null +++ b/backport-dracut.sh-add-check-for-invalid-configuration-files.patch @@ -0,0 +1,52 @@ +From dfe2247a43d6a216d9af533825c9a103e3b056cd Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Wed, 23 Oct 2019 14:16:56 +0200 +Subject: [PATCH] dracut.sh: add check for invalid configuration files + +Emit a warning about possible misconfigured configuration files, where +the spaces around values are missing for +="" + +Better report a possible source of problems. We can fix annoying false +positives later. +--- + dracut.sh | 14 +++++++++++++- + 1 file changed, 13 insertions(+), 1 deletion(-) + +diff --git a/dracut.sh b/dracut.sh +index 39fa3692..81c6d654 100755 +--- a/dracut.sh ++++ b/dracut.sh +@@ -279,6 +279,14 @@ read_arg() { + fi + } + ++check_conf_file() ++{ ++ if grep -H -e '^[^#]*[+]=\("[^ ]\|.*[^ ]"\)' "$@"; then ++ printf '\ndracut: WARNING: +=" ": should have surrounding white spaces!\n' >&2 ++ printf 'dracut: WARNING: This will lead to unwanted side effects! Please fix the configuration file.\n\n' >&2 ++ fi ++} ++ + dropindirs_sort() + { + local suffix=$1; shift +@@ -703,10 +711,14 @@ if [[ ! -d $confdir ]]; then + fi + + # source our config file +-[[ -f $conffile ]] && . "$conffile" ++if [[ -f $conffile ]]; then ++ check_conf_file "$conffile" ++ . "$conffile" ++fi + + # source our config dir + for f in $(dropindirs_sort ".conf" "$confdir" "$dracutbasedir/dracut.conf.d"); do ++ check_conf_file "$f" + [[ -e $f ]] && . "$f" + done + +-- +2.33.0 + diff --git a/backport-fix-base-tr-needs-to-be-installed.patch b/backport-fix-base-tr-needs-to-be-installed.patch new file mode 100644 index 0000000..785efe7 --- /dev/null +++ b/backport-fix-base-tr-needs-to-be-installed.patch @@ -0,0 +1,25 @@ +From dfbfd33b24524c0c10ad3594be143192f5b7da84 Mon Sep 17 00:00:00 2001 +From: Andre Russ +Date: Tue, 24 Aug 2021 21:38:41 +0000 +Subject: [PATCH] fix(base): tr needs to be installed + +--- + modules.d/99base/module-setup.sh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/modules.d/99base/module-setup.sh b/modules.d/99base/module-setup.sh +index cb445c34..10a44d91 100755 +--- a/modules.d/99base/module-setup.sh ++++ b/modules.d/99base/module-setup.sh +@@ -15,7 +15,7 @@ install() { + + inst_multiple mount mknod mkdir sleep chroot chown \ + sed ls flock cp mv dmesg rm ln rmmod mkfifo umount readlink setsid \ +- modprobe ++ modprobe tr + + inst_multiple -o findmnt less kmod + +-- +2.33.0 + diff --git a/backport-fix-crypt-gpg-execute-card-status-on-each-try.patch b/backport-fix-crypt-gpg-execute-card-status-on-each-try.patch new file mode 100644 index 0000000..044919f --- /dev/null +++ b/backport-fix-crypt-gpg-execute-card-status-on-each-try.patch @@ -0,0 +1,29 @@ +From 6610093698db25fda1d584b9771da1e2c2330095 Mon Sep 17 00:00:00 2001 +From: LinkTed +Date: Mon, 21 Jun 2021 19:15:01 +0200 +Subject: [PATCH] fix(crypt-gpg): execute --card-status on each try + +If the gpg card is not inserted before the --card-status command is +executed then the public key is not linked with the card. Therefore, +the LUKS partition cannot be decrypted. To solve this, the +--card--status command is executed on each try. +--- + modules.d/91crypt-gpg/crypt-gpg-lib.sh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/modules.d/91crypt-gpg/crypt-gpg-lib.sh b/modules.d/91crypt-gpg/crypt-gpg-lib.sh +index 0613803a..88ce16e2 100755 +--- a/modules.d/91crypt-gpg/crypt-gpg-lib.sh ++++ b/modules.d/91crypt-gpg/crypt-gpg-lib.sh +@@ -51,7 +51,7 @@ gpg_decrypt() { + fi + + ask_for_password \ +- --cmd "gpg $opts --decrypt $mntp/$keypath" \ ++ --cmd "GNUPGHOME=$gpghome gpg --card-status --no-tty > /dev/null 2>&1; gpg $opts --decrypt $mntp/$keypath" \ + --prompt "${inputPrompt:-Password ($keypath on $keydev for $device)}" \ + --tries 3 --tty-echo-off + +-- +2.33.0 + diff --git a/backport-fix-dracut-install-tweaks-to-get_real_file.patch b/backport-fix-dracut-install-tweaks-to-get_real_file.patch new file mode 100644 index 0000000..b746f73 --- /dev/null +++ b/backport-fix-dracut-install-tweaks-to-get_real_file.patch @@ -0,0 +1,81 @@ +From 1beeaf3b71aed763d5fc7a9ee044d675f8906e8c Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?= + +Date: Sun, 18 Jul 2021 10:28:37 +0200 +Subject: [PATCH] fix(dracut-install): tweaks to get_real_file() +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Fix potential memory leaks in two locations and use +_exit(EXIT_FAILURE) if asprintf(&abspath, ...) fails. + +Signed-off-by: Zoltán Böszörményi +--- + src/install/dracut-install.c | 27 ++++++++++++++++++--------- + 1 file changed, 18 insertions(+), 9 deletions(-) + +diff --git a/src/install/dracut-install.c b/src/install/dracut-install.c +index 00a4f586..6feb7782 100644 +--- a/install/dracut-install.c ++++ b/install/dracut-install.c +@@ -419,7 +419,7 @@ static char *get_real_file(const char *src, bool fullyresolve) + char linktarget[PATH_MAX + 1]; + ssize_t linksz; + _cleanup_free_ char *fullsrcpath; +- char *abspath = NULL; ++ char *abspath = NULL; /* this is returned from the function, don't _cleanup_free_ */ + struct stat sb; + + if (sysrootdirlen) { +@@ -455,30 +455,39 @@ static char *get_real_file(const char *src, bool fullyresolve) + log_debug("get_real_file: readlink('%s') returns '%s'", fullsrcpath, linktarget); + + if (linktarget[0] == '/') { +- if (asprintf(&abspath, "%s%s", (sysrootdirlen ? sysrootdir : ""), linktarget) < 0) +- return NULL; ++ if (asprintf(&abspath, "%s%s", (sysrootdirlen ? sysrootdir : ""), linktarget) < 0) { ++ log_error("Out of memory!"); ++ _exit(EXIT_FAILURE); ++ } + } else { + _cleanup_free_ char *fullsrcdir = strdup(fullsrcpath); + + if (!fullsrcdir) { + log_error("Out of memory!"); +- return NULL; ++ _exit(EXIT_FAILURE); + } + + fullsrcdir[dir_len(fullsrcdir)] = '\0'; + +- if (asprintf(&abspath, "%s/%s", fullsrcdir, linktarget) < 0) +- return NULL; ++ if (asprintf(&abspath, "%s/%s", fullsrcdir, linktarget) < 0) { ++ log_error("Out of memory!"); ++ _exit(EXIT_FAILURE); ++ } + } + + if (fullyresolve) { + struct stat st; + if (lstat(abspath, &st) < 0) { +- if (errno != ENOENT) ++ if (errno != ENOENT) { ++ free(abspath); + return NULL; ++ } ++ } ++ if (S_ISLNK(st.st_mode)) { ++ char *tmp = get_real_file(abspath, fullyresolve); ++ free(abspath); ++ abspath = tmp; + } +- if (S_ISLNK(st.st_mode)) +- return get_real_file(abspath, fullyresolve); + } + + log_debug("get_real_file('%s') => '%s'", src, abspath); +-- +2.33.0 + diff --git a/backport-fix-dracut.sh-handle-i-option-to-include-files-begin.patch b/backport-fix-dracut.sh-handle-i-option-to-include-files-begin.patch new file mode 100644 index 0000000..c28b245 --- /dev/null +++ b/backport-fix-dracut.sh-handle-i-option-to-include-files-begin.patch @@ -0,0 +1,83 @@ +From f1138012c9dc44e6614466c0a8e929fc55e4a5dd Mon Sep 17 00:00:00 2001 +From: Hari Bathini +Date: Fri, 11 Jun 2021 15:20:28 +0530 +Subject: [PATCH] fix(dracut.sh): handle '-i' option to include files beginning + with '.' +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +While including a directory using '--include' option, the file and +subdirectory names that begin with '.' are not included. Also, dracut +throws a warning message when a subdirectory is empty or only has +files or subdirectories that begin with '.'. + +For example, while trying to include /tmpdata directory with the +below tree: + + # tree -a /tmpdata + /tmpdata + ├── .anothertestdir + ├── testdir + │   └── .testsubdir + └── .testfile + +dracut throws the below warning message: + + # dracut --include /tmpdata /root + cp: cannot stat '/tmpdata/testdir/*': No such file or directory + # + +and this is how the included /tmpdata directory tree looks: + + # tree -a root + root + └── testdir + +No file or directory beginning with '.' is included & also, copying +/tmpdata/testdir reported "No such file or directory" warning. Using +'.' instead of '*' in the below command will fix the warning whether +the directory being copied is empty or only has files or directories +that begin with dot: + + $DRACUT_CP -t "$object_destdir" "$dracutsysrootdir$objectname"/* + +Also, enable 'dotglob' temporarily to include files and directories +beginning with a `.' in the results of pathname expansion of source +directory being included. + +Signed-off-by: Hari Bathini +--- + dracut.sh | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/dracut.sh b/dracut.sh +index 60ac46f4..e7f47752 100755 +--- a/dracut.sh ++++ b/dracut.sh +@@ -2067,6 +2067,8 @@ for ((i = 0; i < ${#include_src[@]}; i++)); do + # check for preexisting symlinks, so we can cope with the + # symlinks to $prefix + # Objectname is a file or a directory ++ reset_dotglob="$(shopt -p dotglob)" ++ shopt -q -s dotglob + for objectname in "$src"/*; do + [[ -e "$objectname" || -h "$objectname" ]] || continue + if [[ -d "$objectname" ]]; then +@@ -2077,11 +2079,12 @@ for ((i = 0; i < ${#include_src[@]}; i++)); do + mkdir -m 0755 -p "$object_destdir" + chmod --reference="$objectname" "$object_destdir" + fi +- $DRACUT_CP -t "$object_destdir" "$dracutsysrootdir$objectname"/* ++ $DRACUT_CP -t "$object_destdir" "$dracutsysrootdir$objectname"/. + else + $DRACUT_CP -t "$destdir" "$dracutsysrootdir$objectname" + fi + done ++ eval "$reset_dotglob" + elif [[ -e $src ]]; then + derror "$src is neither a directory nor a regular file" + else +-- +2.33.0 + diff --git a/backport-fix-dracut.sh-handle-symlinks-appropriately-while-us.patch b/backport-fix-dracut.sh-handle-symlinks-appropriately-while-us.patch new file mode 100644 index 0000000..3f2b9ea --- /dev/null +++ b/backport-fix-dracut.sh-handle-symlinks-appropriately-while-us.patch @@ -0,0 +1,31 @@ +From c7fbc0c8901917baf0d1f0822568e65c6ec00d18 Mon Sep 17 00:00:00 2001 +From: Kairui Song +Date: Sat, 12 Jun 2021 02:25:09 +0800 +Subject: [PATCH] fix(dracut.sh): handle symlinks appropriately while using + '-i' option + +[[ -d $symlink ]] will return true if the symlink points to a directory. +So the symlink will not be copied, instead a directory is created with +the symlink name and the content is copied. + +Signed-off-by: Kairui Song +--- + dracut.sh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/dracut.sh b/dracut.sh +index e7f47752..78917763 100755 +--- a/dracut.sh ++++ b/dracut.sh +@@ -2071,7 +2071,7 @@ for ((i = 0; i < ${#include_src[@]}; i++)); do + shopt -q -s dotglob + for objectname in "$src"/*; do + [[ -e "$objectname" || -h "$objectname" ]] || continue +- if [[ -d "$objectname" ]]; then ++ if [[ -d $objectname ]] && [[ ! -L $objectname ]]; then + # objectname is a directory, let's compute the final directory name + object_destdir=${destdir}/${objectname#$src/} + if ! [[ -e "$object_destdir" ]]; then +-- +2.33.0 + diff --git a/backport-fix-install-handle-LIB-in-ldd-output-parsing.patch b/backport-fix-install-handle-LIB-in-ldd-output-parsing.patch new file mode 100644 index 0000000..eeb8b41 --- /dev/null +++ b/backport-fix-install-handle-LIB-in-ldd-output-parsing.patch @@ -0,0 +1,57 @@ +From d1a36d3d80b0ed71ee814659e18a020c53cee05e Mon Sep 17 00:00:00 2001 +From: Jaroslav Jindrak +Date: Fri, 7 May 2021 15:11:55 +0200 +Subject: [PATCH] fix(install): handle $LIB in ldd output parsing + +The ldd output can contain the variable $LIB, which is a documented feature of +ldd. In a previous commit [0], dracut-install received support for this +variable, but that was later reverted [1] due to issues [2][3] on Gentoo ARM64. + +The part before '=>' does not necessarily refer to an existing file (e.g. due +to the usage of $LIB) and thus [1] could be seen as a regression to anyone +that uses this ldd feature. This PR combines both cases together and whenever +it find a '$' character (i.e. a variable) on the left side of the '=>' symbol, +it uses the right hand path (and thus uses evaluation done by ldd), otherwise +falls back to the behavior set by [1]. + +Reproducer that was presented to me: + +$ grep "ibz.so" /etc/ld.so.preload || cat << EOF >> /etc/ld.so.preload +/\$LIB/libz.so.1.2.11 +EOF +$ mkdir -p /var/tmp/dracut.xitk6p/initramfs +$ strace /usr/lib/dracut/dracut-install -D /var/tmp/dracut.xitk6p/initramfs -l /bin/bash 2>&1|grep ibz +$ rm -rf /var/tmp/dracut.xitk6p/ + +[0] 45404a2 +[1] 6d886bb +[2] #471 +[3] https://bugs.gentoo.org/667752 +--- + src/install/dracut-install.c | 10 +++++++++- + 1 file changed, 9 insertions(+), 1 deletion(-) + +diff --git a/src/install/dracut-install.c b/src/install/dracut-install.c +index b4eec363..9f044ae0 100644 +--- a/install/dracut-install.c ++++ b/install/dracut-install.c +@@ -589,7 +589,15 @@ static int resolve_deps(const char *src) + if (strstr(buf, destrootdir)) + break; + +- p = strchr(buf, '/'); ++ p = buf; ++ if (strchr(p, '$')) { ++ /* take ldd variable expansion into account */ ++ p = strstr(p, "=>"); ++ if (!p) ++ p = buf; ++ } ++ p = strchr(p, '/'); ++ + if (p) { + char *q; + +-- +2.33.0 + diff --git a/backport-fix-install-sane-default-kerneldir.patch b/backport-fix-install-sane-default-kerneldir.patch new file mode 100644 index 0000000..9d26ed3 --- /dev/null +++ b/backport-fix-install-sane-default-kerneldir.patch @@ -0,0 +1,31 @@ +From c1ab36139d416e580e768c29f2addf7ccbc2c612 Mon Sep 17 00:00:00 2001 +From: Marcos Mello +Date: Thu, 20 May 2021 15:41:26 -0300 +Subject: [PATCH] fix(install): sane default --kerneldir + +If --kerneldir is not specified, use /lib/modules/$(uname -r). + +Fixes #1505 +--- + src/install/dracut-install.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/src/install/dracut-install.c b/src/install/dracut-install.c +index 9f044ae0..3fd70fc8 100644 +--- a/install/dracut-install.c ++++ b/install/dracut-install.c +@@ -1167,7 +1167,10 @@ static int parse_argv(int argc, char *argv[]) + if (!kerneldir) { + struct utsname buf; + uname(&buf); +- kerneldir = strdup(buf.version); ++ if (asprintf(&kerneldir, "%s%s", "/lib/modules/", buf.release) < 0) { ++ log_error("Out of memory!"); ++ exit(EXIT_FAILURE); ++ } + } + + if (arg_modalias) { +-- +2.33.0 + diff --git a/backport-fix-install-segfault-on-popen-error.patch b/backport-fix-install-segfault-on-popen-error.patch new file mode 100644 index 0000000..b33f7b3 --- /dev/null +++ b/backport-fix-install-segfault-on-popen-error.patch @@ -0,0 +1,27 @@ +From 5c2f72f152ec319a8001d1ff0bfd1f81a9130b04 Mon Sep 17 00:00:00 2001 +From: Andrey Sokolov +Date: Thu, 21 Oct 2021 09:01:07 +0300 +Subject: [PATCH] fix(install): segfault on popen error + +--- + src/install/dracut-install.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/src/install/dracut-install.c b/src/install/dracut-install.c +index 4ec65a5a..9a53be15 100644 +--- a/install/dracut-install.c ++++ b/install/dracut-install.c +@@ -550,6 +550,10 @@ static int resolve_deps(const char *src) + ret = 0; + + fptr = popen(cmd, "r"); ++ if (fptr == NULL) { ++ log_error("Error '%s' initiating pipe stream from '%s'", strerror(errno), cmd); ++ exit(EXIT_FAILURE); ++ } + + while (!feof(fptr)) { + char *p; +-- +2.33.0 + diff --git a/backport-fix-man-default-value-of-rd.retry-was-increased-to-1.patch b/backport-fix-man-default-value-of-rd.retry-was-increased-to-1.patch new file mode 100644 index 0000000..3f21a8c --- /dev/null +++ b/backport-fix-man-default-value-of-rd.retry-was-increased-to-1.patch @@ -0,0 +1,28 @@ +From 4855242ce5cb586afd2eebd91df57ce1d28ae6b5 Mon Sep 17 00:00:00 2001 +From: Alexander Wenzel +Date: Fri, 12 Nov 2021 06:58:05 +0100 +Subject: [PATCH] fix(man): default value of rd.retry was increased to 180 + seconds + +The man page still states the old value of 30 seconds, +which does not reflect the current situation of 180 seconds. +--- + man/dracut.cmdline.7.asc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/man/dracut.cmdline.7.asc b/man/dracut.cmdline.7.asc +index bb351f4e..23f8b8d8 100644 +--- a/dracut.cmdline.7.asc ++++ b/dracut.cmdline.7.asc +@@ -151,7 +151,7 @@ Misc + + **rd.retry=**____:: + specify how long dracut should retry the initqueue to configure devices. +- The default is 30 seconds. After 2/3 of the time, degraded raids are force ++ The default is 180 seconds. After 2/3 of the time, degraded raids are force + started. If you have hardware, which takes a very long time to announce its + drives, you might want to extend this value. + +-- +2.33.0 + diff --git a/backport-fix-mdraid-allow-UUID-comparison-for-more-than-one-U.patch b/backport-fix-mdraid-allow-UUID-comparison-for-more-than-one-U.patch new file mode 100644 index 0000000..61a5d67 --- /dev/null +++ b/backport-fix-mdraid-allow-UUID-comparison-for-more-than-one-U.patch @@ -0,0 +1,33 @@ +From d364ce8334fef96f48492bd0fb3b7deac37bbb66 Mon Sep 17 00:00:00 2001 +From: Alexander Wenzel +Date: Tue, 2 Nov 2021 09:25:56 +0100 +Subject: [PATCH] fix(mdraid): allow UUID comparison for more than one UUID + +If the system provides more than one UUID, the _MD_UUID var +contains a line break after each UUID. Therefore the strstr +function could not find any UUID, caused by the additional +spaces provided to the function. + +Furthermore this could lead to a boot interruption, because +the start of a degraded raid1 won't be executed. So, manual +interaction is necessary. +--- + modules.d/90mdraid/mdraid_start.sh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/modules.d/90mdraid/mdraid_start.sh b/modules.d/90mdraid/mdraid_start.sh +index 9ac171d3..7b3d0de7 100755 +--- a/modules.d/90mdraid/mdraid_start.sh ++++ b/modules.d/90mdraid/mdraid_start.sh +@@ -54,7 +54,7 @@ _md_force_run() { + _UUID=$(str_replace "$_UUID" ":" "") + + # check if we should handle this device +- strstr " $_MD_UUID " " $_UUID " || continue ++ strstr "$_MD_UUID" "$_UUID" || continue + + _md_start "${_md}" "${_offroot}" + done +-- +2.33.0 + diff --git a/backport-fix-multipath-revise-multipathd-stop.patch b/backport-fix-multipath-revise-multipathd-stop.patch new file mode 100644 index 0000000..461bd4c --- /dev/null +++ b/backport-fix-multipath-revise-multipathd-stop.patch @@ -0,0 +1,76 @@ +From 7b8c78ff43a1f8e3690969e980d3d9d1dcb00c87 Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Wed, 31 Mar 2021 10:18:27 +0200 +Subject: [PATCH] fix(multipath): revise multipathd-stop + +A shellcheck regression quoted `HARD` in +```shell + kill "$HARD" "$pid" > /dev/null 2>&1 +``` + +which would error on an empty "HARD". + +Instead of fixing this, use `pkill` instead and also add it to the +non-optional list of binaries to install, which was revised also. + +Fixes: https://github.com/dracutdevs/dracut/issues/1275 +--- + modules.d/90multipath/module-setup.sh | 15 ++++++++++----- + modules.d/90multipath/multipathd-stop.sh | 16 +++++++++------- + 2 files changed, 19 insertions(+), 12 deletions(-) + +diff --git a/modules.d/90multipath/module-setup.sh b/modules.d/90multipath/module-setup.sh +index 48a9d09..31b1b86 100755 +--- a/modules.d/90multipath/module-setup.sh ++++ b/modules.d/90multipath/module-setup.sh +@@ -79,12 +79,16 @@ install() { + } + } + +- inst_multiple -o \ +- dmsetup \ +- kpartx \ ++ inst_multiple \ ++ pkill \ ++ pidof \ ++ kpartx \ ++ dmsetup \ ++ multipath \ ++ multipathd ++ ++ inst_multiple -o \ + mpath_wait \ +- multipath \ +- multipathd \ + mpathpersist \ + xdrgetuid \ + xdrgetprio \ +diff --git a/modules.d/90multipath/multipathd-stop.sh b/modules.d/90multipath/multipathd-stop.sh +index 57a0728..b11c987 100755 +--- a/modules.d/90multipath/multipathd-stop.sh ++++ b/modules.d/90multipath/multipathd-stop.sh +@@ -1,12 +1,14 @@ + #!/bin/sh + + if [ -e /etc/multipath.conf ]; then +- HARD="" +- while pidof multipathd >/dev/null 2>&1; do +- for pid in $(pidof multipathd); do +- kill $HARD $pid >/dev/null 2>&1 +- done +- HARD="-9" +- done ++ pkill multipathd > /dev/null 2>&1 ++ ++ if pidof multipathd > /dev/null 2>&1; then ++ sleep 0.2 ++ fi ++ ++ if pidofmultipathd>/dev/null 2>&1;then ++ pkill -9 multipathd>/dev/null 2>&1 ++ fi + fi + +-- +2.33.0 + diff --git a/backport-fix-network-add-errors-and-warnings-when-network-int.patch b/backport-fix-network-add-errors-and-warnings-when-network-int.patch new file mode 100644 index 0000000..feb6cda --- /dev/null +++ b/backport-fix-network-add-errors-and-warnings-when-network-int.patch @@ -0,0 +1,70 @@ +From 7938935267dd8824f074adf84c219340ad4c8db6 Mon Sep 17 00:00:00 2001 +From: Pavel Valena +Date: Mon, 22 Nov 2021 16:40:39 +0100 +Subject: [PATCH] fix(network): add errors and warnings when network interface + does not exist + +End with error, or show a warning when nonexistent device is specified for network setup like +`ip=10.12.8.12::10.12.255.254:255.255.0.0:xk12:eth0:off`. + +I've added the error only for `write-ifcfg.sh`, as I think no such setup should be written. + +Resolves: #1712424 +--- + modules.d/35network-legacy/ifup.sh | 6 +++++- + modules.d/35network-legacy/parse-ip-opts.sh | 5 +++++ + modules.d/45ifcfg/write-ifcfg.sh | 5 +++++ + 3 files changed, 15 insertions(+), 1 deletion(-) + +diff --git a/modules.d/35network-legacy/ifup.sh b/modules.d/35network-legacy/ifup.sh +index a05c4698..0dc9541c 100755 +--- a/modules.d/35network-legacy/ifup.sh ++++ b/modules.d/35network-legacy/ifup.sh +@@ -446,7 +446,11 @@ for p in $(getargs ip=); do + + # If this option isn't directed at our interface, skip it + if [ -n "$dev" ]; then +- [ "$dev" != "$netif" ] && continue ++ if [ "$dev" != "$netif" ]; then ++ [ ! -e "/sys/class/net/$dev" ] \ ++ && warn "Network interface '$dev' does not exist!" ++ continue ++ fi + else + iface_is_enslaved "$netif" && continue + fi +diff --git a/modules.d/35network-legacy/parse-ip-opts.sh b/modules.d/35network-legacy/parse-ip-opts.sh +index 35917bbf..19af8789 100755 +--- a/modules.d/35network-legacy/parse-ip-opts.sh ++++ b/modules.d/35network-legacy/parse-ip-opts.sh +@@ -97,6 +97,11 @@ for p in $(getargs ip=); do + fi + # IFACES list for later use + IFACES="$IFACES $dev" ++ ++ # Interface should exist ++ if [ ! -e "/sys/class/net/$dev" ]; then ++ warn "Network interface '$dev' does not exist" ++ fi + fi + + # Do we need to check for specific options? +diff --git a/modules.d/45ifcfg/write-ifcfg.sh b/modules.d/45ifcfg/write-ifcfg.sh +index 5f71515a..345863f9 100755 +--- a/modules.d/45ifcfg/write-ifcfg.sh ++++ b/modules.d/45ifcfg/write-ifcfg.sh +@@ -103,6 +103,11 @@ interface_bind() { + local _netif="$1" + local _macaddr="$2" + ++ if [ ! -e "/sys/class/net/$_netif" ]; then ++ derror "Cannot find network interface '$_netif'!" ++ return 1 ++ fi ++ + # see, if we can bind it to some hw parms + if hw_bind "$_netif" "$_macaddr"; then + # only print out DEVICE, if it's user assigned +-- +2.33.0 + diff --git a/backport-fix-qeth_rules-check-the-existence-of-sys-devices-qe.patch b/backport-fix-qeth_rules-check-the-existence-of-sys-devices-qe.patch new file mode 100644 index 0000000..11360b1 --- /dev/null +++ b/backport-fix-qeth_rules-check-the-existence-of-sys-devices-qe.patch @@ -0,0 +1,36 @@ +From 6c71ba4121ae64ccd13fefba68ca327ac623810f Mon Sep 17 00:00:00 2001 +From: Coiby Xu +Date: Wed, 14 Jul 2021 15:26:10 +0800 +Subject: [PATCH] fix(qeth_rules): check the existence of + /sys/devices/qeth/*/online beforehand + +On s390x KVM machines, the follow errors occurred, + $ kdumpctl rebuild + kdump: Rebuilding /boot/initramfs-4.18.0-321.el8.s390xkdump.img + /usr/lib/dracut/modules.d/95qeth_rules/module-setup.sh: line 13: +/sys/devices/qeth/*/online: No such file or directory + /usr/lib/dracut/modules.d/95qeth_rules/module-setup.sh: line 13: +/sys/devices/qeth/*/online: No such file or directory + +because s390x KVM uses virtual devices and /sys/devices/qeth/*/online +doesn't exist. Eliminate this error by checking the existence +beforehand. +--- + modules.d/95qeth_rules/module-setup.sh | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/modules.d/95qeth_rules/module-setup.sh b/modules.d/95qeth_rules/module-setup.sh +index 195ad48..fe37686 100755 +--- a/modules.d/95qeth_rules/module-setup.sh ++++ b/modules.d/95qeth_rules/module-setup.sh +@@ -10,6 +10,7 @@ check() { + + [[ $hostonly ]] && { + for i in /sys/devices/qeth/*/online; do ++ [ ! -f "$i" ] && continue + read -r _online < "$i" + [ "$_online" -eq 1 ] && return 0 + done +-- +2.33.0 + diff --git a/backport-fix-qeth_rules-shellcheck-for-modules.d-95qeth_rules.patch b/backport-fix-qeth_rules-shellcheck-for-modules.d-95qeth_rules.patch new file mode 100644 index 0000000..9cf2d5c --- /dev/null +++ b/backport-fix-qeth_rules-shellcheck-for-modules.d-95qeth_rules.patch @@ -0,0 +1,55 @@ +From d15441cef47e7d741923b779fef88be79e44b389 Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Fri, 26 Mar 2021 10:29:28 +0100 +Subject: [PATCH] fix(qeth_rules): shellcheck for modules.d/95qeth_rules +--- + modules.d/95qeth_rules/module-setup.sh | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) + +diff --git a/modules.d/95qeth_rules/module-setup.sh b/modules.d/95qeth_rules/module-setup.sh +index 543dd23..195ad48 100755 +--- a/modules.d/95qeth_rules/module-setup.sh ++++ b/modules.d/95qeth_rules/module-setup.sh +@@ -10,8 +10,8 @@ check() { + + [[ $hostonly ]] && { + for i in /sys/devices/qeth/*/online; do +- read _online < $i +- [ $_online -eq 1 ] && return 0 ++ read -r _online < "$i" ++ [ "$_online" -eq 1 ] && return 0 + done + } + return 255 +@@ -25,7 +25,7 @@ installkernel() { + # called by dracut + install() { + ccwid() { +- qeth_path=$(readlink -e -q $1/device) ++ qeth_path=$(readlink -e -q "$1"/device) + basename "$qeth_path" + } + +@@ -44,15 +44,15 @@ install() { + # not readable in qeth interfaces + # that have just been assembled, ignore + # read error and assume no carrier +- read carrier 2>/dev/null < "$1/carrier" ++ read -r carrier 2> /dev/null < "$1/carrier" + [ "$carrier" -eq 1 ] && return 0 + return 1; + } + + for dev in /sys/class/net/*; do +- has_carrier $dev || continue +- id=$(ccwid $dev) +- [ -n "$id" ] && inst_rules_qeth $id ++ has_carrier "$dev" || continue ++ id=$(ccwid "$dev") ++ [ -n "$id" ] && inst_rules_qeth "$id" + done + + inst_simple /usr/lib/udev/collect +-- +2.33.0 + diff --git a/backport-fix-resume-check-for-presence-of-sys-power-resume.patch b/backport-fix-resume-check-for-presence-of-sys-power-resume.patch new file mode 100644 index 0000000..ec68d8f --- /dev/null +++ b/backport-fix-resume-check-for-presence-of-sys-power-resume.patch @@ -0,0 +1,34 @@ +From 0b97790626bff3579755b38f78a9c524a075cfcc Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Dan=20Hor=C3=A1k?= +Date: Wed, 10 Nov 2021 12:14:15 +0100 +Subject: [PATCH] fix(resume): check for presence of /sys/power/resume +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +On platforms where the kernel is built without suspend/resume support we +see "cat: /sys/power/resume: No such file or directory" message when +creating an initrd image. Check for the presence of /sys/power/resume +first before reading it. + +Signed-off-by: Dan Horák +--- + modules.d/95resume/module-setup.sh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/modules.d/95resume/module-setup.sh b/modules.d/95resume/module-setup.sh +index f0507b13..b47acbec 100755 +--- a/modules.d/95resume/module-setup.sh ++++ b/modules.d/95resume/module-setup.sh +@@ -13,7 +13,7 @@ check() { + # Only support resume if hibernation is currently on + # and no swap is mounted on a net device + [[ $hostonly ]] || [[ $mount_needs ]] && { +- swap_on_netdevice || [[ "$(cat /sys/power/resume)" == "0:0" ]] && return 255 ++ swap_on_netdevice || [[ -f /sys/power/resume && "$(cat /sys/power/resume)" == "0:0" ]] && return 255 + } + + return 0 +-- +2.33.0 + diff --git a/backport-fix-shutdown-be-robust-against-forced-shutdown.patch b/backport-fix-shutdown-be-robust-against-forced-shutdown.patch new file mode 100644 index 0000000..4ed5e85 --- /dev/null +++ b/backport-fix-shutdown-be-robust-against-forced-shutdown.patch @@ -0,0 +1,40 @@ +From b9ba3c8bb8f0f1328cd1ffaa8dbf64585b28c474 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Renaud=20M=C3=A9trich?= +Date: Tue, 16 Nov 2021 11:15:52 +0100 +Subject: [PATCH] fix(shutdown): be robust against forced shutdown + +When a forced shutdown is issued through sending a burst of Ctrl-Alt-Del +keys, systemd sends SIGTERM to all processes. This ends up killing +dracut-initramfs-restore as well, preventing the script from detecting +that the unpack of the initramfs is incomplete, which later causes a +crash to happen when "shutdown" tries to execute from the unpacked +initramfs. + +This fix makes sure dracut-initramfs-restore remains alive to detect +the unpack failed (because cpio was killed by systemd too). + +Refs: + * https://bugzilla.redhat.com/show_bug.cgi?id=2023665 +--- + dracut-initramfs-restore.sh | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/dracut-initramfs-restore.sh b/dracut-initramfs-restore.sh +index abe6b1e2..d97030a3 100644 +--- a/dracut-initramfs-restore.sh ++++ b/dracut-initramfs-restore.sh +@@ -6,6 +6,11 @@ set -e + [ -e /run/initramfs/bin/sh ] && exit 0 + [ -e /run/initramfs/.need_shutdown ] || exit 0 + ++# SIGTERM signal is received upon forced shutdown: ignore the signal ++# We want to remain alive to be able to trap unpacking errors to avoid ++# switching root to an incompletely unpacked initramfs ++trap 'echo "Received SIGTERM signal, ignoring!" >&2' TERM ++ + KERNEL_VERSION="$(uname -r)" + + [[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut +-- +2.33.0 + diff --git a/backport-fix-url-lib-make-pre-pivot-hook-separetely-per-nfs-m.patch b/backport-fix-url-lib-make-pre-pivot-hook-separetely-per-nfs-m.patch new file mode 100644 index 0000000..d89db8e --- /dev/null +++ b/backport-fix-url-lib-make-pre-pivot-hook-separetely-per-nfs-m.patch @@ -0,0 +1,25 @@ +From 2f091b17075f81ff490b05d3d566d736fc32f0be Mon Sep 17 00:00:00 2001 +From: Masahiro Matsuya +Date: Fri, 11 Jun 2021 10:40:04 +0900 +Subject: [PATCH] fix(url-lib): make pre-pivot hook separetely per nfs mount + +--- + modules.d/45url-lib/url-lib.sh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/modules.d/45url-lib/url-lib.sh b/modules.d/45url-lib/url-lib.sh +index e1e7d5af..972596a1 100755 +--- a/modules.d/45url-lib/url-lib.sh ++++ b/modules.d/45url-lib/url-lib.sh +@@ -159,7 +159,7 @@ nfs_fetch_url() { + local mntdir="$(mkuniqdir /run nfs_mnt)" + mount_nfs "$nfs:$server:$filepath${options:+:$options}" "$mntdir" + # lazy unmount during pre-pivot hook +- inst_hook --hook pre-pivot --name 99url-lib-umount-nfs umount -l -- "$mntdir" ++ inst_hook --hook pre-pivot --name 99url-lib-umount-nfs-"$(basename "$mntdir")" umount -l -- "$mntdir" + fi + + if [ -z "$outloc" ]; then +-- +2.33.0 + diff --git a/dracut.spec b/dracut.spec index 619f4e1..c7664b2 100644 --- a/dracut.spec +++ b/dracut.spec @@ -9,7 +9,7 @@ Name: dracut Version: 050 -Release: 6 +Release: 7 Summary: Initramfs generator using udev @@ -42,6 +42,29 @@ Patch0014: backport-fix-always-use-mkdir-p.patch Patch0015: backport-fix-dracut.sh-omission-is-an-addition-to-other-omiss.patch Patch0016: backport-dracut-install-ignore-bogus-preload-libs.patch +Patch0017: backport-fix-multipath-revise-multipathd-stop.patch +Patch0018: backport-fix-install-handle-LIB-in-ldd-output-parsing.patch +Patch0019: backport-fix-install-sane-default-kerneldir.patch +Patch0020: backport-cryptroot-ask-no-warn-if-run-cryptsetup-exist.patch +Patch0021: backport-dracut-functions-fix-find_binary-to-return-full-path.patch +Patch0022: backport-fix-dracut.sh-handle-i-option-to-include-files-begin.patch +Patch0023: backport-fix-dracut.sh-handle-symlinks-appropriately-while-us.patch +Patch0024: backport-fix-crypt-gpg-execute-card-status-on-each-try.patch +Patch0025: backport-fix-url-lib-make-pre-pivot-hook-separetely-per-nfs-m.patch +Patch0026: backport-fix-qeth_rules-shellcheck-for-modules.d-95qeth_rules.patch +Patch0027: backport-fix-qeth_rules-check-the-existence-of-sys-devices-qe.patch +Patch0028: backport-fix-dracut-install-tweaks-to-get_real_file.patch +Patch0029: backport-fix-base-tr-needs-to-be-installed.patch +Patch0030: backport-fix-install-segfault-on-popen-error.patch +Patch0031: backport-fix-shutdown-be-robust-against-forced-shutdown.patch +Patch0032: backport-fix-man-default-value-of-rd.retry-was-increased-to-1.patch +Patch0033: backport-fix-network-add-errors-and-warnings-when-network-int.patch +Patch0034: backport-dracut-functions-add-ip_params_for_remote_addr-helpe.patch +Patch0035: backport-95resume-Do-not-resume-on-iSCSI-FCoE-or-NBD.patch +Patch0036: backport-fix-mdraid-allow-UUID-comparison-for-more-than-one-U.patch +Patch0037: backport-fix-resume-check-for-presence-of-sys-power-resume.patch +Patch0038: backport-dracut.sh-add-check-for-invalid-configuration-files.patch + Source1: https://www.gnu.org/licenses/lgpl-2.1.txt Source2: openEuler.conf.example @@ -491,6 +514,9 @@ install -m 0755 51-dracut-rescue-postinst.sh $RPM_BUILD_ROOT%{_sysconfdir}/kerne %endif %changelog +* Tue Dec 19 2023 zhangruifang - 050-7 +- backport patchs from upstream + * Thu Dec 7 2023 wangyuhang - 050-6 - [add] backport patches from upstream backport-dracut-install-ignore-bogus-preload-libs.patch -- Gitee