diff --git a/dracut.sh b/dracut.sh index 6de841a6f0..23b03f192e 100755 --- a/dracut.sh +++ b/dracut.sh @@ -1966,10 +1966,12 @@ if [[ $no_kernel != yes ]]; then if [[ $force_drivers ]]; then # shellcheck disable=SC2086 hostonly='' instmods -c $force_drivers - rm -f "$initdir"/etc/cmdline.d/20-force_driver.conf - for mod in $force_drivers; do - echo "rd.driver.pre=$mod" >> "$initdir"/etc/cmdline.d/20-force_drivers.conf - done + if [[ $kernel_only != yes ]]; then + rm -f "$initdir"/etc/cmdline.d/20-force_driver.conf + for mod in $force_drivers; do + echo "rd.driver.pre=$mod" >> "$initdir"/etc/cmdline.d/20-force_drivers.conf + done + fi fi if [[ $filesystems ]]; then # shellcheck disable=SC2086 @@ -2040,7 +2042,7 @@ if [[ $kernel_only != yes ]]; then if [[ $DRACUT_RESOLVE_LAZY ]] && [[ $DRACUT_INSTALL ]]; then dinfo "*** Resolving executable dependencies ***" # shellcheck disable=SC2086 - find "$initdir" -type f -perm /0111 -not -path '*.ko' -print0 \ + find "$initdir" -type f -perm /0111 -not -path '*.ko*' -print0 \ | xargs -r -0 $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${dracutsysrootdir:+-r "$dracutsysrootdir"} -R ${DRACUT_FIPS_MODE:+-f} -- # shellcheck disable=SC2181 if (($? == 0)); then @@ -2115,6 +2117,7 @@ if [[ $do_strip == yes ]]; then fi done + kstrip_args=(-g) if [[ $aggressive_strip == yes ]]; then # `eu-strip` and `strip` both strips all unneeded parts by default strip_args=(-p) @@ -2258,7 +2261,7 @@ if [[ $do_strip == yes ]] && ! [[ $DRACUT_FIPS_MODE ]]; then [[ -n $enhanced_cpio ]] && ddebug "strip is enabled alongside cpio reflink" dinfo "*** Stripping files ***" find "$initdir" -type f \ - -executable -not -path '*/lib/modules/*.ko' -print0 \ + -executable -not -path '*/lib/modules/*.ko*' -print0 \ | xargs -r -0 $strip_cmd "${strip_args[@]}" 2> /dev/null # strip kernel modules, but do not touch signed modules @@ -2266,7 +2269,7 @@ if [[ $do_strip == yes ]] && ! [[ $DRACUT_FIPS_MODE ]]; then | while read -r -d $'\0' f || [ -n "$f" ]; do SIG=$(tail -c 28 "$f" | tr -d '\000') [[ $SIG == '~Module signature appended~' ]] || { printf "%s\000" "$f"; } - done | xargs -r -0 $strip_cmd "${strip_args[@]}" + done | xargs -r -0 $strip_cmd "${kstrip_args[@]}" dinfo "*** Stripping files done ***" fi diff --git a/modules.d/01systemd-coredump/initrd.conf b/modules.d/01systemd-coredump/initrd.conf new file mode 100644 index 0000000000..e47baabb79 --- /dev/null +++ b/modules.d/01systemd-coredump/initrd.conf @@ -0,0 +1,7 @@ +# This file is part of dracut systemd-coredump module. +# SPDX-License-Identifier: GPL-2.0-or-later +# +# "external" (/var) is usually not mounted in the initrd, so it will not persist + +[Coredump] +Storage=journal diff --git a/modules.d/01systemd-coredump/module-setup.sh b/modules.d/01systemd-coredump/module-setup.sh index 17deb088a2..20e925d875 100755 --- a/modules.d/01systemd-coredump/module-setup.sh +++ b/modules.d/01systemd-coredump/module-setup.sh @@ -29,7 +29,8 @@ depends() { # Install the required file(s) and directories for the module in the initramfs. install() { - inst_dir /var/lib/systemd/coredump + inst_simple "$moddir/initrd.conf" "$systemdutildir/coredump.conf.d/initrd.conf" + inst_multiple -o \ "$sysctld"/50-coredump.conf \ "$systemdutildir"/coredump.conf \ diff --git a/modules.d/90btrfs/module-setup.sh b/modules.d/90btrfs/module-setup.sh index 5d88133205..4dd5ee9ba1 100755 --- a/modules.d/90btrfs/module-setup.sh +++ b/modules.d/90btrfs/module-setup.sh @@ -32,7 +32,6 @@ cmdline() { # called by dracut installkernel() { instmods btrfs - printf "%s\n" "$(cmdline)" > "${initdir}/etc/cmdline.d/00-btrfs.conf" } # called by dracut @@ -57,4 +56,8 @@ install() { inst_multiple -o btrfsck btrfs-zero-log inst "$(command -v btrfs)" /sbin/btrfs + + if [[ $hostonly_cmdline == "yes" ]]; then + printf "%s\n" "$(cmdline)" > "${initdir}/etc/cmdline.d/00-btrfs.conf" + fi } diff --git a/modules.d/90dmsquash-live/checkisomd5@.service b/modules.d/90dmsquash-live/checkisomd5@.service index c4ca10f3ce..0a6bd68c9d 100644 --- a/modules.d/90dmsquash-live/checkisomd5@.service +++ b/modules.d/90dmsquash-live/checkisomd5@.service @@ -10,5 +10,5 @@ ExecStart=/bin/checkisomd5 --verbose %f StandardInput=tty-force StandardOutput=inherit StandardError=inherit -TimeoutSec=0 +TimeoutSec=infinity SuccessExitStatus=2 diff --git a/modules.d/90dmsquash-live/dmsquash-generator.sh b/modules.d/90dmsquash-live/dmsquash-generator.sh index 8e3dfe8483..d180622e60 100755 --- a/modules.d/90dmsquash-live/dmsquash-generator.sh +++ b/modules.d/90dmsquash-live/dmsquash-generator.sh @@ -51,6 +51,8 @@ getargbool 0 rd.live.overlay.overlayfs && overlayfs="yes" [ -e /xor_readonly ] && xor_readonly="--readonly" ROOTFLAGS="$(getarg rootflags)" { + echo "# Automatically generated by dracut-dmsquash-generator" + echo echo "[Unit]" echo "Before=initrd-root-fs.target" echo "[Mount]" @@ -74,6 +76,8 @@ ROOTFLAGS="$(getarg rootflags)" mkdir -p "$GENERATOR_DIR/$_dev.device.d" { + echo "# Automatically generated by dracut-dmsquash-generator" + echo echo "[Unit]" echo "JobTimeoutSec=3000" echo "JobRunningTimeoutSec=3000" diff --git a/modules.d/90livenet/livenet-generator.sh b/modules.d/90livenet/livenet-generator.sh index 3e9226bebf..834bfffd43 100755 --- a/modules.d/90livenet/livenet-generator.sh +++ b/modules.d/90livenet/livenet-generator.sh @@ -55,6 +55,8 @@ getargbool 0 rd.live.overlay.overlayfs && overlayfs="yes" [ -e /xor_readonly ] && xor_readonly="--readonly" ROOTFLAGS="$(getarg rootflags)" { + echo "# Automatically generated by dracut-livenet-generator" + echo echo "[Unit]" echo "Before=initrd-root-fs.target" echo "[Mount]" @@ -78,6 +80,8 @@ ROOTFLAGS="$(getarg rootflags)" mkdir -p "$GENERATOR_DIR/$_dev.device.d" { + echo "# Automatically generated by dracut-livenet-generator" + echo echo "[Unit]" echo "JobTimeoutSec=3000" echo "JobRunningTimeoutSec=3000" diff --git a/modules.d/91pcsc/module-setup.sh b/modules.d/91pcsc/module-setup.sh index 245c1e3513..833df26652 100755 --- a/modules.d/91pcsc/module-setup.sh +++ b/modules.d/91pcsc/module-setup.sh @@ -51,7 +51,8 @@ install() { {"tls/$_arch/",tls/,"$_arch/",}"pcsc/drivers/ifd-ccid.bundle/Contents/Info.plist" \ {"tls/$_arch/",tls/,"$_arch/",}"pcsc/drivers/ifd-ccid.bundle/Contents/Linux/libccid.so" \ {"tls/$_arch/",tls/,"$_arch/",}"pcsc/drivers/serial/libccidtwin.so" \ - {"tls/$_arch/",tls/,"$_arch/",}"libpcsclite.so.*" + {"tls/$_arch/",tls/,"$_arch/",}"libpcsclite.so.*" \ + {"tls/$_arch/",tls/,"$_arch/",}"libpcsclite_real.so.*" # Install the hosts local user configurations if enabled. if [[ $hostonly ]]; then diff --git a/modules.d/95nbd/nbd-generator.sh b/modules.d/95nbd/nbd-generator.sh index 38603bf818..5ff2ef0852 100755 --- a/modules.d/95nbd/nbd-generator.sh +++ b/modules.d/95nbd/nbd-generator.sh @@ -52,6 +52,8 @@ else fi { + echo "# Automatically generated by dracut-nbd-generator" + echo echo "[Unit]" echo "Before=initrd-root-fs.target" echo "[Mount]" diff --git a/modules.d/98dracut-systemd/dracut-cmdline.sh b/modules.d/98dracut-systemd/dracut-cmdline.sh index d2919e18b7..9639c9150e 100755 --- a/modules.d/98dracut-systemd/dracut-cmdline.sh +++ b/modules.d/98dracut-systemd/dracut-cmdline.sh @@ -18,9 +18,9 @@ fi info "Using kernel command line parameters:" "$(getcmdline)" getargbool 0 rd.udev.log_level=info -d rd.udev.log-priority=info -d rd.udev.info -d -y rdudevinfo \ - && echo 'udev_log="info"' >> /etc/udev/udev.conf + && echo 'udev_log=info' >> /etc/udev/udev.conf getargbool 0 rd.udev.log_level=debug -d rd.udev.log-priority=debug -d rd.udev.debug -d -y rdudevdebug \ - && echo 'udev_log="debug"' >> /etc/udev/udev.conf + && echo 'udev_log=debug' >> /etc/udev/udev.conf source_conf /etc/conf.d diff --git a/modules.d/98dracut-systemd/dracut-emergency.sh b/modules.d/98dracut-systemd/dracut-emergency.sh index c6637a5c8f..5b4042833c 100755 --- a/modules.d/98dracut-systemd/dracut-emergency.sh +++ b/modules.d/98dracut-systemd/dracut-emergency.sh @@ -33,7 +33,8 @@ if getargbool 1 rd.shell -d -y rdshell || getarg rd.break -d rdbreak; then ) > /dev/"$_tty" done < /proc/consoles [ -f /etc/profile ] && . /etc/profile - [ -z "$PS1" ] && export PS1="$_name:\${PWD}# " + [ -z "$PS1" ] && PS1="$_rdshell_name:\${PWD}# " + export PS1 exec sulogin -e else export hook="shutdown-emergency" diff --git a/modules.d/98dracut-systemd/rootfs-generator.sh b/modules.d/98dracut-systemd/rootfs-generator.sh index cef3f49054..e9ddf5b58a 100755 --- a/modules.d/98dracut-systemd/rootfs-generator.sh +++ b/modules.d/98dracut-systemd/rootfs-generator.sh @@ -8,7 +8,7 @@ generator_wait_for_dev() { _name=$(dev_unit_name "$1") _timeout=$(getarg rd.timeout) - _timeout=${_timeout:-0} + _timeout=${_timeout:-infinity} if ! [ -L "$GENERATOR_DIR"/initrd.target.wants/"${_name}".device ]; then [ -d "$GENERATOR_DIR"/initrd.target.wants ] || mkdir -p "$GENERATOR_DIR"/initrd.target.wants @@ -18,6 +18,8 @@ generator_wait_for_dev() { if ! [ -f "$GENERATOR_DIR"/"${_name}".device.d/timeout.conf ]; then mkdir -p "$GENERATOR_DIR"/"${_name}".device.d { + echo "# Automatically generated by dracut-rootfs-generator" + echo echo "[Unit]" echo "JobTimeoutSec=$_timeout" echo "JobRunningTimeoutSec=$_timeout" @@ -35,6 +37,8 @@ generator_mount_rootfs() { _name=$(dev_unit_name "$1") if ! [ -f "$GENERATOR_DIR"/sysroot.mount ]; then { + echo "# Automatically generated by dracut-rootfs-generator" + echo echo "[Unit]" echo "Before=initrd-root-fs.target" echo "Requires=systemd-fsck@${_name}.service" @@ -61,6 +65,8 @@ generator_fsck_after_pre_mount() { [ -d "$GENERATOR_DIR"/systemd-fsck@"${_name}".service.d ] || mkdir -p "$GENERATOR_DIR"/systemd-fsck@"${_name}".service.d if ! [ -f "$GENERATOR_DIR"/systemd-fsck@"${_name}".service.d/after-pre-mount.conf ]; then { + echo "# Automatically generated by dracut-rootfs-generator" + echo echo "[Unit]" echo "After=dracut-pre-mount.service" } > "$GENERATOR_DIR"/systemd-fsck@"${_name}".service.d/after-pre-mount.conf diff --git a/modules.d/99base/dracut-dev-lib.sh b/modules.d/99base/dracut-dev-lib.sh index 63265f2101..daeac0cd09 100755 --- a/modules.d/99base/dracut-dev-lib.sh +++ b/modules.d/99base/dracut-dev-lib.sh @@ -69,7 +69,7 @@ set_systemd_timeout_for_dev() { _timeout=$(getarg rd.timeout) fi - _timeout=${_timeout:-0} + _timeout=${_timeout:-infinity} _name=$(dev_unit_name "$1") if ! [ -L "${PREFIX}/etc/systemd/system/initrd.target.wants/${_name}.device" ]; then diff --git a/modules.d/99base/module-setup.sh b/modules.d/99base/module-setup.sh index bfdc51d49e..6684130c8b 100755 --- a/modules.d/99base/module-setup.sh +++ b/modules.d/99base/module-setup.sh @@ -139,7 +139,7 @@ install() { _pdev=$(get_persistent_dev "$_dev") case "$_pdev" in - /dev/?*) wait_for_dev "$_pdev" 0 ;; + /dev/?*) wait_for_dev "$_pdev" "infinity" ;; *) ;; esac done diff --git a/modules.d/99suse-initrd/module-setup.sh b/modules.d/99suse-initrd/module-setup.sh index 375075af7b..6c019c8ce1 100755 --- a/modules.d/99suse-initrd/module-setup.sh +++ b/modules.d/99suse-initrd/module-setup.sh @@ -58,7 +58,7 @@ installkernel() { # strip whitespace all_mods="$(echo $all_mods)" if [[ "$all_mods" ]]; then - hostonly= dracut_instmods $all_mods + hostonly='' dracut_instmods $all_mods fi return 0 diff --git a/src/install/dracut-install.c b/src/install/dracut-install.c index 7a2ebdea01..d91ef03c65 100644 --- a/src/install/dracut-install.c +++ b/src/install/dracut-install.c @@ -42,6 +42,7 @@ #include #include #include +#include #include "log.h" #include "hashmap.h" @@ -271,6 +272,56 @@ static inline int clone_file(int dest_fd, int src_fd) return ioctl(dest_fd, BTRFS_IOC_CLONE, src_fd); } +static int copy_xattr(int dest_fd, int src_fd) +{ + int ret = 0; + ssize_t name_len = 0, value_len = 0; + char *name_buf = NULL, *name = NULL, *value = NULL, *value_save = NULL; + + name_len = flistxattr(src_fd, NULL, 0); + if (name_len < 0) + return -1; + + name_buf = calloc(1, name_len + 1); + if (name_buf == NULL) + return -1; + + name_len = flistxattr(src_fd, name_buf, name_len); + if (name_len < 0) + goto out; + + for (name = name_buf; name != name_buf + name_len; name = strchr(name, '\0') + 1) { + value_len = fgetxattr(src_fd, name, NULL, 0); + if (value_len < 0) { + ret = -1; + continue; + } + + value_save = value; + value = realloc(value, value_len); + if (value == NULL) { + value = value_save; + ret = -1; + goto out; + } + + value_len = fgetxattr(src_fd, name, value, value_len); + if (value_len < 0) { + ret = -1; + continue; + } + + value_len = fsetxattr(dest_fd, name, value, value_len, 0); + if (value_len < 0) + ret = -1; + } + +out: + free(name_buf); + free(value); + return ret; +} + static bool use_clone = true; static int cp(const char *src, const char *dst) @@ -312,6 +363,11 @@ static int cp(const char *src, const char *dst) log_info("Failed to chown %s: %m", dst); } + if (geteuid() == 0 && no_xattr == false) { + if (copy_xattr(dest_desc, source_desc) != 0) + log_error("Failed to copy xattr %s: %m", dst); + } + tv[0].tv_sec = sb.st_atime; tv[0].tv_usec = 0; tv[1].tv_sec = sb.st_mtime; diff --git a/suse/README.susemaint b/suse/README.susemaint index b67649d38e..d266ad0b84 100644 --- a/suse/README.susemaint +++ b/suse/README.susemaint @@ -383,3 +383,7 @@ d0c82322 fix(dracut): do not add all lib subdirs to `LD_LIBRARY_PATH` with `--sy 41332702 fix(nvmf): require NVMeoF modules 3748ed4d fix(nvmf): install (only) required nvmf modules d2ade8a6 fix(dm): remove 59-persistent-storage-dm.rules +3e1d0bc1 fix(dracut-install): copy xattr when use clone ioctl +a1c51af1 fix(dracut): don't apply aggressive strip to kernel modules +ad36b61e fix(dracut.sh): omit compressed kernel modules from find searching exec files +bfa00c2a fix(pcsc): add libpcsclite_real.so.*