This commit is contained in:
illiliti
2020-09-10 22:53:39 +03:00
parent 4f94d6e40c
commit ee6fea9a50
26 changed files with 226 additions and 295 deletions

View File

@@ -3,18 +3,17 @@
#
# false positive
# shellcheck disable=2154
{
for _binary in udevd udevadm; do
copy_binary "$_binary"
done
mkdir -p "${tmpdir}/lib/udev/rules.d"
for _binary in udevd udevadm; do
copy_binary "$_binary"
done
printf "%s\n" \
'SUBSYSTEMS=="block", ACTION=="add", RUN+="/bin/device-helper"' \
> "${tmpdir}/lib/udev/rules.d/device-helper.rules"
mkdir -p "${tmpdir}/lib/udev/rules.d"
[ "$monolith" = 1 ] || printf "%s\n" \
'ENV{MODALIAS}=="?*", ACTION=="add", RUN+="/bin/modprobe %E{MODALIAS}"' \
>> "${tmpdir}/lib/udev/rules.d/device-helper.rules"
}
printf "%s\n" \
'SUBSYSTEMS=="block", ACTION=="add", RUN+="/bin/device-helper"' \
> "${tmpdir}/lib/udev/rules.d/device-helper.rules"
[ "$monolith" = 1 ] || printf "%s\n" \
'ENV{MODALIAS}=="?*", ACTION=="add", RUN+="/bin/modprobe %E{MODALIAS}"' \
>> "${tmpdir}/lib/udev/rules.d/device-helper.rules"

View File

@@ -3,11 +3,10 @@
#
# false positive
# shellcheck disable=2154,2034
{
[ "$break" = devmgr ] && { print "break before run_eudev()"; sh; }
udevd -dN never
udevadm trigger -c add -t subsystems
udevadm trigger -c add -t devices
udevadm settle
}
[ "$break" = eudev ] && { print "break before eudev.init"; sh; }
udevd -dN never
udevadm trigger -c add -t subsystems
udevadm trigger -c add -t devices
udevadm settle

View File

@@ -3,6 +3,5 @@
#
# false positive
# shellcheck disable=2154
{
udevadm control -e
}
udevadm control -e

View File

@@ -3,7 +3,6 @@
#
# false positive
# shellcheck disable=2154
{
copy_file "$keymap_path" "$keymap_path" 644 0
copy_binary loadkmap
}
copy_file "$keymap_path" "$keymap_path" 644 0
copy_binary loadkmap

View File

@@ -3,8 +3,7 @@
#
# false positive
# shellcheck disable=2154
{
[ "$break" = keymap ] && { print "break before run_keymap()"; sh; }
loadkmap < "$keymap_path"
}
[ "$break" = keymap ] && { print "break before keymap.init"; sh; }
loadkmap < "$keymap_path"

View File

@@ -3,36 +3,35 @@
#
# false positive
# shellcheck disable=2154
{
[ "$hostonly" = 1 ] &&
for _module in \
aes ecb xts lrw wp512 sha256 \
sha512 twofish serpent dm-crypt
do
copy_module "$_module"
done
copy_binary cryptsetup
[ "$luks_key" ] && {
copy_file "${luks_key#*=}" /root/key 400 0
# avoid possible issues with libgcc_s.so.1
# see https://bugs.archlinux.org/task/56771
[ -e /lib/libgcc_s.so.1 ] && copy_file /lib/libgcc_s.so.1 /lib/libgcc_s.so.1 755 1
sed "s|${luks_key#*=}|/root/key|" \
"${tmpdir}/etc/tinyramfs/config" > "${tmpdir}/_"
if [ "$luks_key" ]; then
copy_file "${luks_key#*=}" /root/key 400 0
sed "s|${luks_key#*=}|/root/key|" \
"${tmpdir}/etc/tinyramfs/config" > "${tmpdir}/_"
mv "${tmpdir}/_" "${tmpdir}/etc/tinyramfs/config"
fi
if [ "$luks_header" ]; then
copy_file "${luks_header#*=}" /root/header 400 0
sed "s|${luks_header#*=}|/root/header|" \
"${tmpdir}/etc/tinyramfs/config" > "${tmpdir}/_"
mv "${tmpdir}/_" "${tmpdir}/etc/tinyramfs/config"
fi
mv "${tmpdir}/_" "${tmpdir}/etc/tinyramfs/config"
}
[ "$luks_header" ] && {
copy_file "${luks_header#*=}" /root/header 400 0
sed "s|${luks_header#*=}|/root/header|" \
"${tmpdir}/etc/tinyramfs/config" > "${tmpdir}/_"
mv "${tmpdir}/_" "${tmpdir}/etc/tinyramfs/config"
}
[ "$hostonly" = 1 ] &&
for _module in \
aes ecb xts lrw wp512 sha256 \
sha512 twofish serpent dm-crypt
do
copy_module "$_module"
done
copy_binary cryptsetup
# avoid possible issues with libgcc_s.so.1
# see https://bugs.archlinux.org/task/56771
[ -e /lib/libgcc_s.so.1 ] && copy_file /lib/libgcc_s.so.1 /lib/libgcc_s.so.1 755 1

View File

@@ -6,17 +6,16 @@
#
# word splitting is safe by design
# shellcheck disable=2068
{
[ "$break" = luks ] && { print "break before unlock_luks()"; sh; }
export DM_DISABLE_UDEV=1
mkdir -p /run/cryptsetup
[ "$break" = luks ] && { print "break before luks.init"; sh; }
resolve_device "$luks_root"
export DM_DISABLE_UDEV=1
mkdir -p /run/cryptsetup
set -- \
"${luks_discard:+--allow-discards}" "${luks_header:+--header $luks_header}" \
"${luks_key:+-d $luks_key}" "$device" "${luks_name:-crypt-${device##*/}}"
resolve_device "$luks_root"
cryptsetup open $@ || panic "failed to unlock LUKS"
}
set -- \
"${luks_discard:+--allow-discards}" "${luks_header:+--header $luks_header}" \
"${luks_key:+-d $luks_key}" "$device" "${luks_name:-crypt-${device##*/}}"
cryptsetup open $@ || panic "failed to unlock LUKS"

View File

@@ -3,33 +3,32 @@
#
# false positive
# shellcheck disable=2154
{
[ "$hostonly" = 1 ] &&
for _module in \
dm-log dm-cache dm-mirror \
dm-snapshot dm-multipath dm-thin-pool
do
copy_module "$_module"
done
copy_binary lvm
[ "$hostonly" = 1 ] &&
for _module in \
dm-log dm-cache dm-mirror \
dm-snapshot dm-multipath dm-thin-pool
do
copy_module "$_module"
done
lvm_config="
devices {
write_cache_state = 0
}
backup {
backup = 0
archive = 0
}
global {
use_lvmetad = 0
}"
copy_binary lvm
mkdir -p "${tmpdir}/etc/lvm"
lvm_config="
devices {
write_cache_state = 0
}
backup {
backup = 0
archive = 0
}
global {
use_lvmetad = 0
}"
lvm config \
--config "$lvm_config" \
${lvm_config:+--mergedconfig} \
> "${tmpdir}/etc/lvm/lvm.conf"
}
mkdir -p "${tmpdir}/etc/lvm"
lvm config \
--config "$lvm_config" \
${lvm_config:+--mergedconfig} \
> "${tmpdir}/etc/lvm/lvm.conf"

View File

@@ -6,22 +6,21 @@
#
# word splitting is safe by design
# shellcheck disable=2068
{
[ "$break" = lvm ] && { print "break before trigger_lvm()"; sh; }
export DM_DISABLE_UDEV=1
mkdir -p /run/lvm /run/lock/lvm
[ "$break" = lvm ] && { print "break before lvm.init"; sh; }
set -- \
--sysinit -qq -aay "${lvm_discard:+--config=devices{issue_discards=1}}"
export DM_DISABLE_UDEV=1
mkdir -p /run/lvm /run/lock/lvm
if [ "$lvm_group" ] && [ "$lvm_name" ]; then
lvm lvchange $@ "${lvm_group}/${lvm_name}"
elif [ "$lvm_group" ]; then
lvm vgchange $@ "$lvm_group"
elif [ "$lvm_tag" ]; then
lvm lvchange $@ "@${lvm_tag}"
else
lvm vgchange $@
fi || panic "failed to trigger LVM"
}
set -- \
--sysinit -qq -aay "${lvm_discard:+--config=devices{issue_discards=1}}"
if [ "$lvm_group" ] && [ "$lvm_name" ]; then
lvm lvchange $@ "${lvm_group}/${lvm_name}"
elif [ "$lvm_group" ]; then
lvm vgchange $@ "$lvm_group"
elif [ "$lvm_tag" ]; then
lvm lvchange $@ "@${lvm_tag}"
else
lvm vgchange $@
fi || panic "failed to trigger LVM"

View File

@@ -3,16 +3,15 @@
#
# false positive
# shellcheck disable=2154,2016
{
for _binary in mdev find; do
copy_binary "$_binary"
done
printf "%s\n" \
'SUBSYSTEM=block;.* 0:0 660 @device-helper' \
> "${tmpdir}/etc/mdev.conf"
for _binary in mdev find; do
copy_binary "$_binary"
done
[ "$monolith" = 1 ] || printf "%s\n" \
'$MODALIAS=.* 0:0 660 @modprobe "$MODALIAS"' \
>> "${tmpdir}/etc/mdev.conf"
}
printf "%s\n" \
'SUBSYSTEM=block;.* 0:0 660 @device-helper' \
> "${tmpdir}/etc/mdev.conf"
[ "$monolith" = 1 ] || printf "%s\n" \
'$MODALIAS=.* 0:0 660 @modprobe "$MODALIAS"' \
>> "${tmpdir}/etc/mdev.conf"

View File

@@ -3,15 +3,14 @@
#
# false positive
# shellcheck disable=2154,2034
{
[ "$break" = devmgr ] && { print "break before run_mdev()"; sh; }
mdev -s
mdev -df 2> /dev/null & mdev_pid="$!"
find /sys/devices -name uevent |
[ "$break" = mdev ] && { print "break before mdev.init"; sh; }
while read -r uevent; do
printf add > "$uevent"
done 2> /dev/null
}
mdev -s
mdev -df 2> /dev/null & mdev_pid="$!"
find /sys/devices -name uevent |
while read -r uevent; do
printf add > "$uevent"
done 2> /dev/null

View File

@@ -3,6 +3,5 @@
#
# false positive
# shellcheck disable=2154
{
kill "$mdev_pid"
}
kill "$mdev_pid"

View File

@@ -3,16 +3,15 @@
#
# false positive
# shellcheck disable=2154,2016
{
for _binary in mdevd mdevd-coldplug; do
copy_binary "$_binary"
done
printf "%s\n" \
'SUBSYSTEM=block;.* 0:0 660 @device-helper' \
> "${tmpdir}/etc/mdev.conf"
for _binary in mdevd mdevd-coldplug; do
copy_binary "$_binary"
done
[ "$monolith" = 1 ] || printf "%s\n" \
'$MODALIAS=.* 0:0 660 @modprobe "$MODALIAS"' \
>> "${tmpdir}/etc/mdev.conf"
}
printf "%s\n" \
'SUBSYSTEM=block;.* 0:0 660 @device-helper' \
> "${tmpdir}/etc/mdev.conf"
[ "$monolith" = 1 ] || printf "%s\n" \
'$MODALIAS=.* 0:0 660 @modprobe "$MODALIAS"' \
>> "${tmpdir}/etc/mdev.conf"

View File

@@ -3,9 +3,8 @@
#
# false positive
# shellcheck disable=2154,2034
{
[ "$break" = devmgr ] && { print "break before run_mdevd()"; sh; }
mdevd 2> /dev/null & mdevd_pid="$!"
mdevd-coldplug
}
[ "$break" = mdevd ] && { print "break before mdevd.init"; sh; }
mdevd 2> /dev/null & mdevd_pid="$!"
mdevd-coldplug

View File

@@ -3,6 +3,5 @@
#
# false positive
# shellcheck disable=2154
{
kill "$mdevd_pid"
}
kill "$mdevd_pid"

View File

@@ -1,5 +1,4 @@
# vim: set ft=sh:
# shellcheck shell=sh
{
copy_binary find
}
copy_binary find

View File

@@ -3,15 +3,14 @@
#
# false positive
# shellcheck disable=2154
{
[ "$break" = devmgr ] && { print "break before run_proc()"; sh; }
command -v device-helper > /proc/sys/kernel/hotplug
# get ready for fork bomb. kek
find /sys/devices -name uevent |
[ "$break" = proc ] && { print "break before proc.init"; sh; }
while read -r uevent; do
printf add > "$uevent"
done 2> /dev/null
}
command -v device-helper > /proc/sys/kernel/hotplug
# get ready for fork bomb. kek
find /sys/devices -name uevent |
while read -r uevent; do
printf add > "$uevent"
done 2> /dev/null

View File

@@ -1,5 +1,4 @@
# vim: set ft=sh:
# shellcheck shell=sh
{
printf '\n' > /proc/sys/kernel/hotplug
}
printf '\n' > /proc/sys/kernel/hotplug

View File

@@ -3,18 +3,17 @@
#
# false positive
# shellcheck disable=2154
{
for _binary in /lib/systemd/systemd-udevd udevadm; do
copy_binary "$_binary"
done
mkdir -p "${tmpdir}/lib/udev/rules.d"
for _binary in /lib/systemd/systemd-udevd udevadm; do
copy_binary "$_binary"
done
printf "%s\n" \
'SUBSYSTEMS=="block", ACTION=="add", RUN+="/bin/device-helper"' \
> "${tmpdir}/lib/udev/rules.d/device-helper.rules"
mkdir -p "${tmpdir}/lib/udev/rules.d"
[ "$monolith" = 1 ] || printf "%s\n" \
'ENV{MODALIAS}=="?*", ACTION=="add", RUN+="/bin/modprobe %E{MODALIAS}"' \
>> "${tmpdir}/lib/udev/rules.d/device-helper.rules"
}
printf "%s\n" \
'SUBSYSTEMS=="block", ACTION=="add", RUN+="/bin/device-helper"' \
> "${tmpdir}/lib/udev/rules.d/device-helper.rules"
[ "$monolith" = 1 ] || printf "%s\n" \
'ENV{MODALIAS}=="?*", ACTION=="add", RUN+="/bin/modprobe %E{MODALIAS}"' \
>> "${tmpdir}/lib/udev/rules.d/device-helper.rules"

View File

@@ -3,11 +3,10 @@
#
# false positive
# shellcheck disable=2154,2034
{
[ "$break" = devmgr ] && { print "break before run_systemd_udevd()"; sh; }
/lib/systemd/systemd-udevd -dN never
udevadm trigger -c add -t subsystems
udevadm trigger -c add -t devices
udevadm settle
}
[ "$break" = systemd-udevd ] && { print "break before systemd-udevd.init"; sh; }
/lib/systemd/systemd-udevd -dN never
udevadm trigger -c add -t subsystems
udevadm trigger -c add -t devices
udevadm settle

View File

@@ -3,6 +3,5 @@
#
# false positive
# shellcheck disable=2154
{
udevadm control -e
}
udevadm control -e