Lines 37-45
Link Here
|
37 |
|
37 |
|
38 |
modules_scan() { |
38 |
modules_scan() { |
39 |
local MODS |
39 |
local MODS |
40 |
[ -d /etc/modules/${1} ] || touch /etc/modules/${1} |
40 |
[ -d "/etc/modules/${1}" ] || touch /etc/modules/${1} |
41 |
|
41 |
|
42 |
[ -f /etc/modules/${1} ] && MODS=`cat /etc/modules/${1}` |
42 |
[ -f "/etc/modules/${1}" ] && MODS=`cat /etc/modules/${1}` |
43 |
for x in ${MODS} |
43 |
for x in ${MODS} |
44 |
do |
44 |
do |
45 |
MLOAD=`echo ${MLIST} | sed -e "s/.*${x}.*/${x}/"` |
45 |
MLOAD=`echo ${MLIST} | sed -e "s/.*${x}.*/${x}/"` |
Lines 63-69
Link Here
|
63 |
done |
63 |
done |
64 |
} |
64 |
} |
65 |
|
65 |
|
66 |
findcdmount() { |
66 |
findmediamount() { |
|
|
67 |
# $1 = mount dir name / media name |
68 |
# $2 = recognition file |
69 |
# $3 = variable to have the device path |
70 |
# args remaining are possible devices |
71 |
|
72 |
local media=$1 |
73 |
local recon=$2 |
74 |
local vrbl=$3 |
75 |
shift;shift;shift |
76 |
|
77 |
good_msg "Looking for the ${media}" ${CRYPT_SILENT} |
78 |
|
67 |
if [ "$#" -gt "0" ] |
79 |
if [ "$#" -gt "0" ] |
68 |
then |
80 |
then |
69 |
for x in $* |
81 |
for x in $* |
Lines 71-145
Link Here
|
71 |
# Check for a block device to mount |
83 |
# Check for a block device to mount |
72 |
if [ -b "${x}" ] |
84 |
if [ -b "${x}" ] |
73 |
then |
85 |
then |
74 |
good_msg "Attempting to mount media:- ${x}" |
86 |
good_msg "Attempting to mount media:- ${x}" ${CRYPT_SILENT} |
75 |
if [ -z "${CDROOT_DEV}" ] |
87 |
|
76 |
then |
88 |
mount -r -t auto ${x} ${NEW_ROOT}/mnt/${media} \ |
77 |
mount -r -t auto ${x} ${NEW_ROOT}/mnt/cdrom \ |
|
|
78 |
> /dev/null 2>&1 |
89 |
> /dev/null 2>&1 |
79 |
else |
90 |
|
80 |
mount -r -t iso9660 ${x} ${NEW_ROOT}/mnt/cdrom \ |
|
|
81 |
> /dev/null 2>&1 |
82 |
fi |
83 |
if [ "$?" = '0' ] |
91 |
if [ "$?" = '0' ] |
84 |
then |
92 |
then |
85 |
# Check for a LiveCD |
93 |
# Check for the media |
86 |
if [ -f ${NEW_ROOT}/mnt/cdrom/${SUBDIR}/livecd ] |
94 |
if [ -f "${NEW_ROOT}/mnt/${media}/${recon}" ] |
87 |
then |
95 |
then |
88 |
REAL_ROOT="${x}" |
96 |
#set REAL_ROOT, CRYPT_ROOT_KEYDEV or whatever ${vrbl} is |
|
|
97 |
eval ${vrbl}'='"${x}" |
98 |
good_msg "Media found on ${x}" ${CRYPT_SILENT} |
89 |
break |
99 |
break |
90 |
else |
100 |
else |
91 |
umount ${NEW_ROOT}/mnt/cdrom |
101 |
umount ${NEW_ROOT}/mnt/${media} |
92 |
fi |
102 |
fi |
93 |
fi |
103 |
fi |
94 |
fi |
104 |
fi |
95 |
done |
105 |
done |
96 |
if [ "${REAL_ROOT}" != '' ] |
|
|
97 |
then |
98 |
good_msg "Media found on ${x}" |
99 |
fi |
100 |
fi |
106 |
fi |
|
|
107 |
|
108 |
eval local result='$'${vrbl} |
109 |
|
110 |
[ -n "${result}" ] || bad_msg "Media not found" ${CRYPT_SILENT} |
101 |
} |
111 |
} |
102 |
|
112 |
|
103 |
findkeymount() { |
113 |
devicelist(){ |
104 |
if [ "$#" -gt "0" ] |
114 |
# Locate the cdrom device with our media on it. |
105 |
then |
115 |
# CDROM DEVICES |
106 |
for x in $* |
116 |
local DEVICES="/dev/cdroms/* /dev/ide/cd/* /dev/sr*" |
107 |
do |
117 |
# USB Keychain/Storage |
108 |
# Check for a block device to mount |
118 |
DEVICES="$DEVICES /dev/sd*" |
109 |
if [ -b "${x}" ] |
119 |
# IDE devices |
110 |
then |
120 |
DEVICES="$DEVICES /dev/hd*" |
111 |
if [ ${crypt_silent} = '' ] |
121 |
# USB using the USB Block Driver |
112 |
then |
122 |
DEVICES="$DEVICES /dev/ubd* /dev/ubd/*" |
113 |
good_msg "Attempting to mount key media:- ${x}" |
123 |
# iSeries devices |
114 |
fi |
124 |
DEVICES="$DEVICES /dev/iseries/vcd*" |
|
|
125 |
echo ${DEVICES} |
126 |
} |
115 |
|
127 |
|
116 |
mount -r -t auto ${x} ${NEW_ROOT}/mnt/keydev \ |
128 |
bootstrapCD() { |
117 |
> /dev/null 2>&1 |
129 |
|
118 |
if [ "$?" = '0' ] |
130 |
local DEVICES=`devicelist` |
119 |
then |
131 |
# The device was specified on the command line. Shold we even be doing a |
120 |
# Check for the key |
132 |
# scan at this point? I think not. |
121 |
if [ -e ${NEW_ROOT}/mnt/keydev/${LUKS_ROOT_KEY} ] |
133 |
[ -n "${CDROOT_DEV}" ] && DEVICES="$DEVICES ${CDROOT_DEV}" |
122 |
then |
134 |
|
123 |
LUKS_ROOT_KEYDEV="${x}" |
135 |
findmediamount "cdrom" "${SUBDIR}/livecd" "REAL_ROOT" ${DEVICES} |
124 |
umount ${NEW_ROOT}/mnt/keydev |
|
|
125 |
break |
126 |
else |
127 |
umount ${NEW_ROOT}/mnt/keydev |
128 |
fi |
129 |
fi |
130 |
fi |
131 |
done |
132 |
if [ "${LUKS_ROOT_KEYDEV}" != '' ] |
133 |
then |
134 |
if [ ${crypt_silent} = '' ] |
135 |
then |
136 |
good_msg "Key media found on ${x}" |
137 |
fi |
138 |
fi |
139 |
fi |
140 |
} |
136 |
} |
141 |
|
137 |
|
|
|
138 |
bootstrapKey() { |
139 |
local KEYDEVS=`devicelist` |
142 |
|
140 |
|
|
|
141 |
findmediamount "key" "${CRYPT_ROOT_KEY}" "CRYPT_ROOT_KEYDEV" ${KEYDEVS} |
142 |
} |
143 |
|
143 |
cache_cd_contents() { |
144 |
cache_cd_contents() { |
144 |
# Check loop file exists and cache to ramdisk if DO_cache is enabled |
145 |
# Check loop file exists and cache to ramdisk if DO_cache is enabled |
145 |
if [ "${LOOPTYPE}" != "noloop" ] && [ "${LOOPTYPE}" != "sgimips" ] |
146 |
if [ "${LOOPTYPE}" != "noloop" ] && [ "${LOOPTYPE}" != "sgimips" ] |
Lines 328-352
Link Here
|
328 |
fi |
329 |
fi |
329 |
} |
330 |
} |
330 |
|
331 |
|
331 |
good_msg() { |
332 |
|
|
|
333 |
# msg functions arguments |
334 |
# $1 string |
335 |
# $2 hide flag |
336 |
|
337 |
good_msg() { |
332 |
msg_string=$1 |
338 |
msg_string=$1 |
333 |
msg_string="${msg_string:-...}" |
339 |
msg_string="${msg_string:-...}" |
334 |
echo -e "${GOOD}>>${NORMAL}${BOLD} ${msg_string} ${NORMAL}" |
340 |
[ "$2" != 1 ] && echo -e "${GOOD}>>${NORMAL}${BOLD} ${msg_string} ${NORMAL}" |
335 |
} |
341 |
} |
336 |
|
342 |
|
337 |
bad_msg() { |
343 |
bad_msg() { |
338 |
msg_string=$1 |
344 |
msg_string=$1 |
339 |
msg_string="${msg_string:-...}" |
345 |
msg_string="${msg_string:-...}" |
340 |
splash 'verbose' > /dev/null & |
346 |
if [ "$2" != 1 ] |
341 |
echo -e "${BAD}!!${NORMAL}${BOLD} ${msg_string} ${NORMAL}" |
347 |
then |
|
|
348 |
splash 'verbose' > /dev/null & |
349 |
echo -e "${BAD}!!${NORMAL}${BOLD} ${msg_string} ${NORMAL}" |
350 |
fi |
342 |
} |
351 |
} |
343 |
|
352 |
|
344 |
warn_msg() { |
353 |
warn_msg() { |
345 |
msg_string=$1 |
354 |
msg_string=$1 |
346 |
msg_string="${msg_string:-...}" |
355 |
msg_string="${msg_string:-...}" |
347 |
echo -e "${WARN}**${NORMAL}${BOLD} ${msg_string} ${NORMAL}" |
356 |
[ "$2" != 1 ] && echo -e "${WARN}**${NORMAL}${BOLD} ${msg_string} ${NORMAL}" |
348 |
} |
357 |
} |
349 |
|
358 |
|
|
|
359 |
crypt_filter() { |
360 |
if [ ${CRYPT_SILENT} -eq 1 ] |
361 |
then |
362 |
eval $1 >/dev/null 2>/dev/null |
363 |
else |
364 |
eval $1 |
365 |
fi |
366 |
} |
367 |
|
368 |
whereis(){ |
369 |
# $1 = variable whose value is the path (examples: "REAL_ROOT", "LUKS_KEYDEV") |
370 |
# $2 = label |
371 |
# $3 = optional explanations for failure |
372 |
|
373 |
eval local oldvalue='$'${1} |
374 |
|
375 |
[ \( $# != 2 \) -a \( $# != 3 \) ] && \ |
376 |
bad_msg "Bad invocation of function whereis, please file a bug \ |
377 |
report with this message" && exit 1 |
378 |
[ -n "${3}" ] && local explnt=" or : ${3}" || local explnt="." |
379 |
|
380 |
bad_msg "Could not find the ${2} in ${oldvalue}${explnt}" |
381 |
echo ' Please specify another value or: press Enter for the same, type "shell" for a shell, or "q" to skip...' |
382 |
echo -n "${2}(${oldvalue}) :: " |
383 |
read ${1} |
384 |
case `eval echo '$'${1}` in |
385 |
'q') |
386 |
eval ${1}'='${oldvalue} |
387 |
warn_msg "Skipping step, this will likely cause a boot failure." |
388 |
break |
389 |
;; |
390 |
'shell') |
391 |
eval ${1}'='${oldvalue} |
392 |
echo "To leave and try again just press <Ctrl>+D" |
393 |
run_shell |
394 |
;; |
395 |
'') |
396 |
eval ${1}'='${oldvalue} |
397 |
;; |
398 |
esac |
399 |
} |
400 |
|
350 |
bind_mount_dev() { |
401 |
bind_mount_dev() { |
351 |
# bind-mount /dev/ so that loop devices can be found |
402 |
# bind-mount /dev/ so that loop devices can be found |
352 |
mount -o bind ${NEW_ROOT}/dev /dev |
403 |
mount -o bind ${NEW_ROOT}/dev /dev |
Lines 354-367
Link Here
|
354 |
|
405 |
|
355 |
start_dev_mgr() { |
406 |
start_dev_mgr() { |
356 |
# Check udev is available... |
407 |
# Check udev is available... |
357 |
if [ "${KV_2_6_OR_GREATER}" -a ! "${USE_UDEV_NORMAL}" -eq '0' ] |
408 |
if [ "${KV_2_6_OR_GREATER}" -a "${USE_UDEV_NORMAL}" != '0' ] |
358 |
then |
409 |
then |
359 |
USE_UDEV_NORMAL=1 |
410 |
USE_UDEV_NORMAL=1 |
360 |
else |
411 |
else |
361 |
USE_UDEV_NORMAL=0 |
412 |
USE_UDEV_NORMAL=0 |
362 |
fi |
413 |
fi |
363 |
|
414 |
|
364 |
if [ "${USE_UDEV_NORMAL}" -eq '1' ] |
415 |
if [ "${USE_UDEV_NORMAL}" = '1' ] |
365 |
then |
416 |
then |
366 |
cd /sys |
417 |
cd /sys |
367 |
[ "${DO_slowusb}" ] && sleep 10 |
418 |
[ "${DO_slowusb}" ] && sleep 10 |
Lines 378-419
Link Here
|
378 |
fi |
429 |
fi |
379 |
} |
430 |
} |
380 |
|
431 |
|
381 |
bootstrapCD() { |
|
|
382 |
# Locate the cdrom device with our media on it. |
383 |
# CDROM DEVICES |
384 |
DEVICES="/dev/cdroms/* /dev/ide/cd/* /dev/sr*" |
385 |
# USB Keychain/Storage |
386 |
DEVICES="$DEVICES /dev/sd*" |
387 |
# IDE devices |
388 |
DEVICES="$DEVICES /dev/hd*" |
389 |
# USB using the USB Block Driver |
390 |
DEVICES="$DEVICES /dev/ubd* /dev/ubd/*" |
391 |
# iSeries devices |
392 |
DEVICES="$DEVICES /dev/iseries/vcd*" |
393 |
# The device was specified on the command line. Shold we even be doing a |
394 |
# scan at this point? I think not. |
395 |
[ -n "${CDROOT_DEV}" ] && DEVICES="$DEVICES ${CDROOT_DEV}" |
396 |
|
397 |
findcdmount $DEVICES |
398 |
} |
399 |
|
400 |
bootstrapKey() { |
401 |
# Locate the device with our key on it. |
402 |
# USB Keychain/Storage |
403 |
KEYDEVS="/dev/sd*" |
404 |
# CDROM DEVICES |
405 |
KEYDEVS="${KEYDEVS} /dev/cdroms/* /dev/ide/cd/* /dev/sr*" |
406 |
# IDE devices |
407 |
KEYDEVS="${KEYDEVS} /dev/hd*" |
408 |
# USB using the USB Block Driver |
409 |
KEYDEVS="${KEYDEVS} /dev/ubd* /dev/ubd/*" |
410 |
# iSeries devices |
411 |
KEYDEVS="${KEYDEVs} /dev/iseries/vcd*" |
412 |
|
413 |
findkeymount ${KEYDEVS} |
414 |
} |
415 |
|
416 |
|
417 |
cmdline_hwopts() { |
432 |
cmdline_hwopts() { |
418 |
# Scan CMDLINE for any "doscsi" or "noscsi"-type arguments |
433 |
# Scan CMDLINE for any "doscsi" or "noscsi"-type arguments |
419 |
|
434 |
|
Lines 510-516
Link Here
|
510 |
|
525 |
|
511 |
chooseKeymap |
526 |
chooseKeymap |
512 |
|
527 |
|
513 |
[ "${DEVBIND}" -eq '1' ] && umount /dev |
528 |
[ "${DEVBIND}" = '1' ] && umount /dev |
514 |
|
529 |
|
515 |
if [ -e /etc/sysconfig/keyboard -a "${CDROOT}" -eq '1' ] |
530 |
if [ -e /etc/sysconfig/keyboard -a "${CDROOT}" -eq '1' ] |
516 |
then |
531 |
then |
Lines 602-608
Link Here
|
602 |
ln -sf /dev/device-mapper /dev/mapper/control |
617 |
ln -sf /dev/device-mapper /dev/mapper/control |
603 |
fi |
618 |
fi |
604 |
|
619 |
|
605 |
if [ "${USE_DMRAID_NORMAL}" -eq '1' ] |
620 |
if [ "${USE_DMRAID_NORMAL}" = '1' ] |
606 |
then |
621 |
then |
607 |
if [ -e '/sbin/dmraid' ] |
622 |
if [ -e '/sbin/dmraid' ] |
608 |
then |
623 |
then |
Lines 616-622
Link Here
|
616 |
fi |
631 |
fi |
617 |
fi |
632 |
fi |
618 |
|
633 |
|
619 |
if [ "${USE_LVM2_NORMAL}" -eq '1' ] |
634 |
if [ "${USE_LVM2_NORMAL}" = '1' ] |
620 |
then |
635 |
then |
621 |
if [ -e '/bin/vgscan' -a -e '/bin/vgchange' ] |
636 |
if [ -e '/bin/vgscan' -a -e '/bin/vgchange' ] |
622 |
then |
637 |
then |
Lines 631-637
Link Here
|
631 |
/bin/vgchange -ay --ignorelockingfailure 2>/dev/null |
646 |
/bin/vgchange -ay --ignorelockingfailure 2>/dev/null |
632 |
|
647 |
|
633 |
# Disable EVMS since lvm2 is activated and they dont work together. |
648 |
# Disable EVMS since lvm2 is activated and they dont work together. |
634 |
if [ "${USE_EVMS2_NORMAL}" -eq '1' ] |
649 |
if [ "${USE_EVMS2_NORMAL}" = '1' ] |
635 |
then |
650 |
then |
636 |
bad_msg "Disabling EVMS Support because LVM2 started" |
651 |
bad_msg "Disabling EVMS Support because LVM2 started" |
637 |
bad_msg "Do not add dolvm2 to the cmdline if this is not what you want" |
652 |
bad_msg "Do not add dolvm2 to the cmdline if this is not what you want" |
Lines 643-649
Link Here
|
643 |
fi |
658 |
fi |
644 |
fi |
659 |
fi |
645 |
|
660 |
|
646 |
if [ "${USE_EVMS2_NORMAL}" -eq '1' ] |
661 |
if [ "${USE_EVMS2_NORMAL}" = '1' ] |
647 |
then |
662 |
then |
648 |
if [ -e '/sbin/evms_activate' ] |
663 |
if [ -e '/sbin/evms_activate' ] |
649 |
then |
664 |
then |
Lines 656-713
Link Here
|
656 |
# Open a LUKS device |
671 |
# Open a LUKS device |
657 |
# $1 LUKS device |
672 |
# $1 LUKS device |
658 |
# $2 LUKS name |
673 |
# $2 LUKS name |
|
|
674 |
# $3 LUKS key (relative path on device) |
675 |
# $4 LUKS keydevice (containing the key) |
659 |
openLUKS() { |
676 |
openLUKS() { |
660 |
LUKS_DEVICE="$1" |
677 |
LUKS_DEVICE="$1" |
661 |
LUKS_NAME="$2" |
678 |
LUKS_NAME="$2" |
662 |
if [ -e /sbin/cryptsetup ] |
679 |
LUKS_KEY="$3" |
663 |
then |
680 |
LUKS_KEYDEV="$4" |
664 |
while [ 1 ] |
681 |
local DEV_ERROR=0; local KEY_ERROR=0; local KEYDEV_ERROR=0 |
665 |
do |
682 |
local mntkey=/mnt/key/; local cryptsetup_options='' |
666 |
if [ "${LUKS_DEVICE}" = '' ] |
683 |
|
|
|
684 |
[ ! -e /sbin/cryptsetup ] && bad_msg "The initrd does not support LUKS" && exit 1 |
685 |
while [ 1 ] |
686 |
do |
687 |
# if crypt_silent=1 and some error occurs, enter shell quietly |
688 |
if [ \( ${CRYPT_SILENT} -eq 1 \) -a \( \( \( ${DEV_ERROR} -eq 1 \) -o \( ${KEY_ERROR} -eq 1 \) \) -o \( ${KEYDEV_ERROR} -eq 1 \) \) ] |
689 |
then |
690 |
run_shell |
691 |
elif [ ${DEV_ERROR} -eq 1 ] |
692 |
then |
693 |
whereis "LUKS_DEVICE" "${LUKS_NAME}" |
694 |
DEV_ERROR=0 |
695 |
elif [ ${KEY_ERROR} -eq 1 ] |
696 |
then |
697 |
whereis "LUKS_KEY" "${LUKS_NAME} key" |
698 |
KEY_ERROR=0 |
699 |
elif [ ${KEYDEV_ERROR} -eq 1 ] |
700 |
then |
701 |
whereis "LUKS_KEYDEV" "${LUKS_NAME} key device" |
702 |
KEYDEV_ERROR=0 |
703 |
else |
704 |
setup_md_device ${LUKS_DEVICE} |
705 |
cryptsetup isLuks ${LUKS_DEVICE} |
706 |
if [ ! "$?" -eq '0' ] |
667 |
then |
707 |
then |
668 |
# LUKS device could not be opened. Prompt user for device. |
708 |
bad_msg "The LUKS device ${LUKS_DEVICE} does not contain a LUKS header" ${CRYPT_SILENT} |
669 |
bad_msg "The LUKS ${LUKS_NAME} block device is not detected." |
709 |
DEV_ERROR=1 |
670 |
echo " Please specify a ${LUKS_NAME} LUKS device to open, "q" to skip, or "shell" for a shell..." |
|
|
671 |
echo -n "LUKS ${LUKS_NAME}() :: " |
672 |
read LUKS_DEVICE |
673 |
continue |
710 |
continue |
674 |
elif [ "${LUKS_DEVICE}" = 'shell' ] |
|
|
675 |
then |
676 |
run_shell |
677 |
|
678 |
LUKS_DEVICE='' |
679 |
continue |
680 |
elif [ "${LUKS_DEVICE}" = 'q' ] |
681 |
then |
682 |
break |
683 |
else |
711 |
else |
684 |
setup_md_device ${LUKS_DEVICE} |
712 |
# Handle keys |
685 |
if cryptsetup isLuks ${LUKS_DEVICE} |
713 |
if [ -n "${LUKS_KEY}" ] |
686 |
then |
714 |
then |
687 |
good_msg "Opening LUKS device ${LUKS_DEVICE}" |
715 |
if [ ! -e "${mntkey}${LUKS_KEY}" ] |
688 |
|
|
|
689 |
cryptsetup luksOpen ${LUKS_DEVICE} ${LUKS_NAME} |
690 |
if [ ! "$?" -eq '0' ] |
691 |
then |
716 |
then |
692 |
bad_msg "Failed open LUKS device ${LUKS_DEVICE}" |
717 |
if [ -b "${LUKS_KEYDEV}" ] |
693 |
else |
718 |
then good_msg "Using key device ${LUKS_KEYDEV}." ${CRYPT_SILENT} |
694 |
break |
719 |
else |
|
|
720 |
good_msg "Please insert removable device ${LUKS_KEYDEV} for ${LUKS_NAME}" ${CRYPT_SILENT} |
721 |
# abort after 10 secs |
722 |
local count=10 |
723 |
while [ ${count} -gt 0 ] |
724 |
do |
725 |
count=$((count-1)) |
726 |
sleep 1 |
727 |
if [ -b "${LUKS_KEYDEV}" ] |
728 |
then |
729 |
good_msg "Removable device ${LUKS_KEYDEV} detected." ${CRYPT_SILENT} |
730 |
break |
731 |
fi |
732 |
done |
733 |
if [ ! -b "${LUKS_KEYDEV}" ] |
734 |
then |
735 |
CRYPT_ROOT_KEY=${LUKS_KEY} |
736 |
bootstrapKey |
737 |
LUKS_KEYDEV=${CRYPT_ROOT_KEYDEV} |
738 |
if [ ! -b "${LUKS_KEYDEV}" ]; then |
739 |
KEYDEV_ERROR=1 |
740 |
bad_msg "Removable device ${LUKS_KEYDEV} not found." ${CRYPT_SILENT} |
741 |
continue |
742 |
fi |
743 |
fi |
744 |
fi |
745 |
# At this point a device was recognized, now let's see if the key is there |
746 |
[ ! -d "$mntkey" ] && mkdir -p ${mntkey} 2>/dev/null >/dev/null |
747 |
|
748 |
mount -n -o ro ${LUKS_KEYDEV} ${mntkey} >/dev/null 2>/dev/null |
749 |
if [ "$?" != '0' ] |
750 |
then |
751 |
KEYDEV_ERROR=1 |
752 |
bad_msg "Mounting of device ${LUKS_KEYDEV} failed." ${CRYPT_SILENT} |
753 |
continue |
754 |
else |
755 |
good_msg "Removable device ${LUKS_KEYDEV} mounted." ${CRYPT_SILENT} |
756 |
sleep 2 |
757 |
# keyfile exists? |
758 |
if [ ! -e "${mntkey}${LUKS_KEY}" ]; then |
759 |
umount -n ${mntkey} 2>/dev/null >/dev/null |
760 |
KEY_ERROR=1 |
761 |
KEYDEV_ERROR=1 |
762 |
bad_msg "Key {LUKS_KEY} on device ${LUKS_KEYDEV} not found." ${CRYPT_SILENT} |
763 |
continue |
764 |
fi |
765 |
fi |
695 |
fi |
766 |
fi |
|
|
767 |
# At this point a candidate key exists (either mounted before or not) |
768 |
good_msg "${LUKS_KEY} on device ${LUKS_KEYDEV} found" ${CRYPT_SILENT} |
769 |
cryptsetup_options="-d ${mntkey}${LUKS_KEY}" |
770 |
fi |
771 |
# At this point, keyfile or not, we're ready! |
772 |
crypt_filter "cryptsetup ${cryptsetup_options} luksOpen ${LUKS_DEVICE} ${LUKS_NAME}" |
773 |
if [ $? -eq 0 ] |
774 |
then |
775 |
good_msg "LUKS device ${LUKS_DEVICE} opened" ${CRYPT_SILENT} |
776 |
break |
696 |
else |
777 |
else |
697 |
bad_msg "The LUKS device ${LUKS_DEVICE} does not contain a LUKS header" |
778 |
bad_msg "Failed to open LUKS device ${LUKS_DEVICE}" ${CRYPT_SILENT} |
|
|
779 |
DEV_ERROR=1 |
698 |
fi |
780 |
fi |
699 |
fi |
781 |
fi |
700 |
LUKS_DEVICE='' |
782 |
fi |
701 |
done |
783 |
done |
702 |
else |
784 |
umount ${mntkey} 2>/dev/null >/dev/null |
703 |
bad_msg "The initrd does not support LUKS" |
785 |
rmdir ${mntkey} 2>/dev/null >/dev/null |
704 |
fi |
|
|
705 |
} |
786 |
} |
706 |
|
787 |
|
707 |
startLUKS() { |
788 |
startLUKS() { |
708 |
if [ -n "${LUKS_ROOT}" ] |
789 |
|
|
|
790 |
# if key is set but key device isn't, find it |
791 |
|
792 |
[ -n "${CRYPT_ROOT}" ] && [ -n "${CRYPT_ROOT_KEY}" ] && [ -z "${CRYPT_ROOT_KEYDEV}" ] \ |
793 |
&& bootstrapKey |
794 |
|
795 |
if [ -n "${CRYPT_ROOT}" ] |
709 |
then |
796 |
then |
710 |
openLUKS "${LUKS_ROOT}" "root" |
797 |
openLUKS "${CRYPT_ROOT}" "root" "${CRYPT_ROOT_KEY}" "${CRYPT_ROOT_KEYDEV}" |
711 |
if [ -n "${REAL_ROOT}" ] |
798 |
if [ -n "${REAL_ROOT}" ] |
712 |
then |
799 |
then |
713 |
# Rescan volumes |
800 |
# Rescan volumes |
Lines 716-725
Link Here
|
716 |
REAL_ROOT="/dev/mapper/root" |
803 |
REAL_ROOT="/dev/mapper/root" |
717 |
fi |
804 |
fi |
718 |
fi |
805 |
fi |
719 |
if [ -n "${LUKS_SWAP}" ] |
806 |
if [ -n "${CRYPT_SWAP}" ] |
720 |
then |
807 |
then |
721 |
openLUKS "${LUKS_SWAP}" "swap" |
808 |
openLUKS "${CRYPT_SWAP}" "swap" "${CRYPT_ROOT_KEY}" "${CRYPT_ROOT_KEYDEV}" |
722 |
break |
809 |
if [ -z "${REAL_RESUME}" ] |
|
|
810 |
then |
811 |
# Resume from swap as default |
812 |
REAL_RESUME="/dev/mapper/swap" |
813 |
fi |
723 |
fi |
814 |
fi |
724 |
} |
815 |
} |
725 |
|
816 |
|
Lines 746-752
Link Here
|
746 |
|
837 |
|
747 |
|
838 |
|
748 |
cdupdate() { |
839 |
cdupdate() { |
749 |
if [ "${CDROOT}" -eq '1' ] |
840 |
if [ "${CDROOT}" = '1' ] |
750 |
then |
841 |
then |
751 |
if [ -x /${NEW_ROOT}/mnt/cdrom/cdupdate.sh ] |
842 |
if [ -x /${NEW_ROOT}/mnt/cdrom/cdupdate.sh ] |
752 |
then |
843 |
then |
Lines 792-798
Link Here
|
792 |
} |
883 |
} |
793 |
|
884 |
|
794 |
setup_unionfs() { |
885 |
setup_unionfs() { |
795 |
if [ "${USE_UNIONFS_NORMAL}" -eq '1' ] |
886 |
if [ "${USE_UNIONFS_NORMAL}" = '1' ] |
796 |
then |
887 |
then |
797 |
# Directory used for rw changes in union mount filesystem |
888 |
# Directory used for rw changes in union mount filesystem |
798 |
UNION=/union |
889 |
UNION=/union |
Lines 847-852
Link Here
|
847 |
fi |
938 |
fi |
848 |
} |
939 |
} |
849 |
|
940 |
|
|
|
941 |
|
942 |
swsusp_resume() { |
943 |
### determine swap resume partition |
944 |
local device=$(ls -l "${REAL_RESUME}" | sed 's/\ */ /g' | cut -d \ -f 6-7 | sed 's/,\ */:/') |
945 |
[ -f /sys/power/resume ] && echo "${device}" > /sys/power/resume |
946 |
return 0 |
947 |
} |
948 |
|
949 |
|
850 |
suspend_resume() { |
950 |
suspend_resume() { |
851 |
[ -x /sbin/resume ] || return 0 |
951 |
[ -x /sbin/resume ] || return 0 |
852 |
/sbin/resume |
952 |
/sbin/resume |