5 Commits

Author SHA1 Message Date
5d16b77bdb Decouple LVM2 stage1 scripts to its own package 2018-05-09 07:22:56 +07:00
cea6a58cba Decouple cryptsetup initscripts to its own package 2018-05-09 07:16:43 +07:00
d2ebd92f24 Further fix for binfmt
Skip if directory doesn't exist or directory is empty.
Previous implementation was actually successful, but it always returns
1, probably because the loop expects all directories to exist.
2018-05-07 20:58:31 +07:00
4908b26a2d Enable btrfs only if USEBTRFS=yes 2018-05-07 14:24:37 +07:00
fdb0488f1e Fix issues with listing binfmt files 2018-05-07 11:08:52 +07:00
10 changed files with 7 additions and 151 deletions

View File

@@ -89,7 +89,6 @@ install-rc:
install -m755 $(RC) $(DESTDIR)$(RCDIR) install -m755 $(RC) $(DESTDIR)$(RCDIR)
install -m644 rc/sysinit.d/* $(DESTDIR)$(RCDIR)/sysinit.d install -m644 rc/sysinit.d/* $(DESTDIR)$(RCDIR)/sysinit.d
install -m644 rc/shutdown.d/* $(DESTDIR)$(RCDIR)/shutdown.d install -m644 rc/shutdown.d/* $(DESTDIR)$(RCDIR)/shutdown.d
install -m644 rc/crypt.awk $(DESTDIR)$(RCDIR)
install -d $(DESTDIR)$(RUNITDIR) install -d $(DESTDIR)$(RUNITDIR)
install -m755 $(STAGES) $(DESTDIR)$(RUNITDIR) install -m755 $(STAGES) $(DESTDIR)$(RUNITDIR)

View File

@@ -1,103 +0,0 @@
/^#/ || /^$/ { next }
NF>4 { print "a valid crypttab has max 4 cols not " NF >"/dev/stderr"; next }
{
# decode the src variants
split($2, o_src, "=")
if (o_src[1] == "UUID") ("blkid -l -o device -t " $2) | getline src;
else src=o_src[1];
# no password or none is given, ask fo it
if ( NF == 2 ) {
ccmd="cryptsetup luksOpen " src " " $1;
system(ccmd);
ccmd="";
}
else if (NF == 3 ) {
dest=$1
key=$3
split($3, po, "=");
if ( po[1] == "none") ccmd="cryptsetup luksOpen " src " " dest;
else ccmd="cryptsetup luksOpen -d " key " " src" " dest;
system(ccmd);
ccmd="";
}
else {
# the option field is not empty parse the options
dest=$1
key=$3
split($4, opts, ",");
commonopts="";
swapopts="";
luksopts="";
for(i in opts) {
split(opts[i], para, "=");
par=para[1];
val=para[2];
if ( par == "readonly" || par == "read-only") commonopts=commonopts "-r ";
else if ( par == "discard" ) commonopts=commonopts "--allow-discards ";
else if ( par == "tries" ) commonopts=commonopts "-T " val " ";
else if ( par == "swap" ) makeswap="y";
else if ( par == "cipher" ) swapopts=swapopts "-c " val " ";
else if ( par == "size" ) swapopts=swapopts "-s " val " ";
else if ( par == "hash" ) swapopts=swapopts "-h " val " ";
else if ( par == "offset" ) swapopts=swapopts "-o " val " ";
else if ( par == "skip" ) swapopts=swapopts "-p " val " ";
else if ( par == "verify" ) swapopts=swapopts "-y ";
#else if ( par == "noauto" )
#else if ( par == "nofail" )
#else if ( par == "plain" )
#else if ( par == "timeout" )
#else if ( par == "tmp" )
else if ( par == "luks" ) use_luks="y";
else if ( par == "keyscript" ) {use_keyscript="y"; keyscript=val;}
else if ( par == "keyslot" || par == "key-slot" ) luksopts=luksopts "-S " val " ";
else if ( par == "keyfile-size" ) luksopts=luksopts "-l " val " ";
else if ( par == "keyfile-offset" ) luksopts=luksopts "-keyfile-offset=" val " ";
else if ( par == "header" ) luksopts=luksopts "--header=" val " ";
else {
print "option: " par " not supported " >"/dev/stderr";
makeswap="";
use_luks="";
use_keyscript="";
next;
}
}
if ( makeswap == "y" && use_luks != "y" ) {
ccmd="cryptsetup " swapopts commonopts "-d " key " create " dest " " src;
ccmd_2="mkswap /dev/mapper/" dest;
makeswap="";
use_luks="";
use_keyscript="";
system(ccmd);
system(ccmd_2);
ccmd="";
ccmd_2="";
next;
}
if ( use_luks == "y" && makeswap != "y" ){
if ( use_keyscript == "y") {
ccmd=keyscript " | cryptsetup " luksopts commonopts "luksOpen -d - " src " " dest;
use_keyscript="";
}
else {
if ( key == "none" ){
ccmd="cryptsetup " luksopts commonopts "luksOpen " src " " dest;
}
else {
ccmd="cryptsetup " luksopts commonopts "luksOpen -d " key " " src " " dest;
}
}
}
else {
print "use swap OR luks as option" >"/dev/stderr";
ccmd="";
}
makeswap="";
use_luks="";
use_keyscript="";
if ( ccmd != ""){
system(ccmd);
ccmd=""
}
}
}

View File

@@ -173,13 +173,6 @@ udevd_modprobe() {
calc_columns calc_columns
} }
activate_vgs() {
[[ $USELVM = [yY][eE][sS] && -x $(type -P lvm) && -d /sys/block ]] || return 0
stat_busy "Activating LVM2 groups"
vgchange --sysinit -a y >/dev/null
(( $? == 0 )) && stat_done || stat_fail
}
do_unlock_legacy() { do_unlock_legacy() {
# $1 = requested name # $1 = requested name
# $2 = source device # $2 = source device
@@ -276,14 +269,6 @@ do_unlock() {
return $? return $?
} }
deactivate_crypt() {
if [[ -x /usr/bin/dmsetup ]]; then
for v in $(dmsetup ls --target crypt --exec "dmsetup info -c --noheadings -o open,name"); do
[[ ${v%%:*} == "0" ]] && cryptsetup close ${v##*:}
done
fi
}
set_timezone() { set_timezone() {
local tz=$1 zonefile=/usr/share/zoneinfo/$1 local tz=$1 zonefile=/usr/share/zoneinfo/$1
@@ -306,13 +291,12 @@ run_binfmt() {
mount -t binfmt_misc binfmt /proc/sys/fs/binfmt_misc mount -t binfmt_misc binfmt /proc/sys/fs/binfmt_misc
for path in /usr/lib/binfmt.d /etc/binfmt.d /run/binfmt.d; do for path in /usr/lib/binfmt.d /etc/binfmt.d /run/binfmt.d; do
[[ ! -d $path ]] && continue; [[ ! -d $path ]] && continue
for file in $(ls -1 $path); do [[ -z "$(ls $path)" ]] && continue
grep "^:" $file | \ grep "^:" $path/* | \
while read -r line; do while read -r line; do
printf "%s" "$line" > /proc/sys/fs/binfmt_misc/register printf "%s" "$line" > /proc/sys/fs/binfmt_misc/register
done done
done
done done
} }

View File

@@ -1,3 +0,0 @@
# stop monitoring of LVM2 groups before unmounting filesystems
[[ $USELVM = [Yy][Ee][Ss] && -x $(type -P lvm) ]] &&
status "Deactivating monitoring of LVM2 groups" vgchange --monitor n

View File

@@ -1,7 +0,0 @@
# Kill non-root encrypted partition mappings
if [[ -f /etc/crypttab ]] && type -p cryptsetup >/dev/null; then
# Maybe someone has LVM on an encrypted block device
# executing an extra vgchange is errorless
[[ $USELVM = [Yy][Ee][Ss] ]] && vgchange --sysinit -a n &>/dev/null
deactivate_crypt
fi

View File

@@ -1,2 +0,0 @@
[[ $USELVM = [Yy][Ee][Ss] && -x $(type -P lvm) ]] &&
status "Deactivating LVM2 groups" vgchange --sysinit -an &>/dev/null

View File

@@ -1,2 +0,0 @@
# Activate LVM2 groups, if any
activate_vgs

View File

@@ -1 +1 @@
status "Activating btrfs devices" btrfs device scan [[ $USEBTRFS == [Yy][Ee][Ss] ]] && status "Activating btrfs devices" btrfs device scan

View File

@@ -1,6 +0,0 @@
# Set up non-root encrypted partition mappings
if [[ -f /etc/crypttab ]] && type -p cryptsetup >/dev/null; then
status "Activating encrypted devices" awk -f /etc/rc/crypt.awk /etc/crypttab
# Maybe someone has LVM on an encrypted block device
activate_vgs
fi

View File

@@ -1,4 +0,0 @@
# Enable monitoring of LVM2 groups, now that the filesystems are mounted rw
[[ $USELVM = [Yy][Ee][Ss] && -x $(type -P lvm) && -d /sys/block ]] &&
status "Activating monitoring of LVM2 groups" \
vgchange --monitor y >/dev/null