Add a modified version of the two LUKS patches that made their way into bugzilla for bug #122421.

git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/genkernel/trunk@405 67a159dc-881f-0410-a524-ba9dfbe2cb84
cleanup-cruft
Chris Gianelloni 19 years ago
parent e4820423a3
commit 3186bfc54c

@ -81,6 +81,8 @@ longusage() {
echo " --linuxrc=<file> Specifies a user created linuxrc"
echo " --disklabel Include disk label and uuid support in your"
echo " initrd"
echo " --luks Include LUKS support"
echo " --> 'emerge cryptsetup-luks' with USE=-dynamic"
echo " Internals"
echo " --arch-override=<arch> Force to arch instead of autodetect"
echo " --cachedir=<dir> Override the default cache location"
@ -469,6 +471,10 @@ parse_cmdline() {
CMD_DISKLABEL=1
print_info 2 "CMD_DISKLABEL: $CMD_DISKLABEL"
;;
--luks)
CMD_LUKS=1
print_info 2 "CMD_LUKS: $CMD_LUKS"
;;
all)
BUILD_KERNEL=1
BUILD_MODULES=1

@ -60,6 +60,11 @@ get_KV() {
else
DISKLABEL=0
fi
if isTrue "${CMD_LUKS}"
then
LUKS=1
fi
}
determine_real_args() {

@ -323,6 +323,7 @@ create_gensplash(){
fi
fi
}
create_initramfs_overlay_cpio(){
cd ${INITRAMFS_OVERLAY}
find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-overlay.cpio.gz
@ -380,6 +381,12 @@ create_initramfs_modules() {
rm -r "${TEMP}/initramfs-modules-${KV}-temp/"
}
# check for static linked file with objdump
is_static() {
objdump -T $1 2>&1 | grep "not a dynamic object" > /dev/null
return $?
}
create_initramfs_aux() {
if [ -d "${TEMP}/initramfs-aux-temp" ]
then
@ -403,7 +410,8 @@ create_initramfs_aux() {
# Make sure it's executable
chmod 0755 "${TEMP}/initramfs-aux-temp/init"
# Make a symlink to init .. incase we are bundled inside the kernel as one big cpio.
# Make a symlink to init .. incase we are bundled inside the kernel as one
# big cpio.
cd ${TEMP}/initramfs-aux-temp
ln -s init linuxrc
# ln ${TEMP}/initramfs-aux-temp/init ${TEMP}/initramfs-aux-temp/linuxrc
@ -445,6 +453,19 @@ create_initramfs_aux() {
then
echo 'MY_HWOPTS="${MY_HWOPTS} slowusb"' >> ${TEMP}/initramfs-aux-temp/etc/initrd.defaults
fi
if isTrue ${LUKS}
then
if is_static /bin/cryptsetup
then
print_info "Including LUKS support"
rm -f ${TEMP}/initramfs-aux-temp/sbin/cryptsetup
cp /bin/cryptsetup ${TEMP}/initramfs-aux-temp/sbin/cryptsetup
chmod +x "${TEMP}/initramfs-aux-temp/sbin/cryptsetup"
else
print_info "LUKS support requires static cryptsetup at /bin/cryptsetup"
print_info "Not including LUKS support"
fi
fi
cd ${TEMP}/initramfs-aux-temp/sbin && ln -s ../init init
cd ${TEMP}

@ -27,6 +27,12 @@ move_initrd_to_loop()
mv * "${TEMP}/initrd-mount" >> ${DEBUGFILE} 2>&1
}
# check for static linked file with objdump
is_static() {
objdump -T $1 2>&1 | grep "not a dynamic object" > /dev/null
return $?
}
create_base_initrd_sys() {
rm -rf "${TEMP}/initrd-temp" > /dev/null
mkdir -p ${TEMP}/initrd-temp/dev
@ -227,10 +233,23 @@ create_base_initrd_sys() {
ln ${TEMP}/initrd-temp/bin/busybox ${TEMP}/initrd-temp/bin/$i ||
gen_die "Busybox error: could not link ${i}!"
done
if isTrue ${LUKS}
then
if is_static /bin/cryptsetup
then
print_info "Including LUKS support"
rm -f ${TEMP}/initrd-temp/sbin/cryptsetup
cp /bin/cryptsetup ${TEMP}/initrd-temp/sbin/cryptsetup
chmod +x "${TEMP}/initrd-temp/sbin/cryptsetup"
else
print_info "LUKS support requires static cryptsetup at /bin/cryptsetup"
print_info "Not including LUKS support"
fi
fi
}
print_list()
{
print_list() {
local x
for x in ${*}
do

@ -575,10 +575,10 @@ setup_md_device() {
[ -z "$1" ] && device="${REAL_ROOT}" || device="$1"
[ -z "${device}" ] && return # LiveCD
if [ `echo ${device}|sed -e 's#\(/dev/md\)[[:digit:]]\+#\1#'` = "/dev/md" ]
if [ `echo ${device}|sed -e 's#\(luks:\)\?\(/dev/md\)[[:digit:]]\+#\2#'` = "/dev/md" ]
then
good_msg 'Detected real_root as a md device. Setting up the device node...'
MD_NUMBER=`echo ${device}|sed -e 's#/dev/md\([[:digit:]]\+\)#\1#'`
MD_NUMBER=`echo ${device}|sed -e 's#\(luks:\)\?/dev/md\([[:digit:]]\+\)#\2#'`
if [ ! -e /dev/md${MD_NUMBER} ]
then
mknod /dev/md${MD_NUMBER} b 9 ${MD_NUMBER} >/dev/null 2>&1

@ -365,6 +365,27 @@ do
elif [ -b "${REAL_ROOT}" ] || [ "${REAL_ROOT}" = "/dev/nfs" ]
then
got_good_root=1
#check if LUKS setup is needed
elif [ `echo ${REAL_ROOT} | sed -e "s/\([^:]*\):.*/\1/"` = "luks" ]
then
LUKSdev=`echo ${REAL_ROOT} | sed -e "s/luks:\(.*\)/\1/"`
if [ -e /sbin/cryptsetup ]
then
if cryptsetup isLuks ${LUKSdev}
then
good_msg "LUKS partition - opening $LUKSdev"
cryptsetup luksOpen ${LUKSdev} root &&
REAL_ROOT=/dev/mapper/root &&
got_good_root=1
else
bad_msg "${LUKSDEV} is not a LUKS partition"
REAL_ROOT=""
fi
else
bad_msg "This initrd does not support LUKS"
REAL_ROOT=""
fi
else
bad_msg "Block device ${REAL_ROOT} is not a valid root device..."
REAL_ROOT=""

Loading…
Cancel
Save