Skip to content

Commit

Permalink
Merge pull request #384 from aafeijoo-suse/059-upstream-fixes-13
Browse files Browse the repository at this point in the history
Backport fixes to 059
  • Loading branch information
aafeijoo-suse authored Nov 6, 2024
2 parents c186c6a + 721fccd commit d2af702
Show file tree
Hide file tree
Showing 17 changed files with 110 additions and 18 deletions.
17 changes: 10 additions & 7 deletions dracut.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -2258,15 +2261,15 @@ 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
find "$initdir" -type f -path '*/lib/modules/*.ko' -print0 \
| 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
Expand Down
7 changes: 7 additions & 0 deletions modules.d/01systemd-coredump/initrd.conf
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion modules.d/01systemd-coredump/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
5 changes: 4 additions & 1 deletion modules.d/90btrfs/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
2 changes: 1 addition & 1 deletion modules.d/90dmsquash-live/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ ExecStart=/bin/checkisomd5 --verbose %f
StandardInput=tty-force
StandardOutput=inherit
StandardError=inherit
TimeoutSec=0
TimeoutSec=infinity
SuccessExitStatus=2
4 changes: 4 additions & 0 deletions modules.d/90dmsquash-live/dmsquash-generator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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]"
Expand All @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions modules.d/90livenet/livenet-generator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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]"
Expand All @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion modules.d/91pcsc/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions modules.d/95nbd/nbd-generator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ else
fi

{
echo "# Automatically generated by dracut-nbd-generator"
echo
echo "[Unit]"
echo "Before=initrd-root-fs.target"
echo "[Mount]"
Expand Down
4 changes: 2 additions & 2 deletions modules.d/98dracut-systemd/dracut-cmdline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion modules.d/98dracut-systemd/dracut-emergency.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 7 additions & 1 deletion modules.d/98dracut-systemd/rootfs-generator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion modules.d/99base/dracut-dev-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion modules.d/99base/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion modules.d/99suse-initrd/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
56 changes: 56 additions & 0 deletions src/install/dracut-install.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include <fts.h>
#include <regex.h>
#include <sys/utsname.h>
#include <sys/xattr.h>

#include "log.h"
#include "hashmap.h"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions suse/README.susemaint
Original file line number Diff line number Diff line change
Expand Up @@ -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.*

0 comments on commit d2af702

Please sign in to comment.