Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 186650
Collapse All | Expand All

(-)a/ChangeLog (+6 lines)
Lines 2-7 Link Here
2
# Copyright 2006-2007 Gentoo Foundation; Distributed under the GPL v2
2
# Copyright 2006-2007 Gentoo Foundation; Distributed under the GPL v2
3
# $Header: $
3
# $Header: $
4
4
5
  24 Jul 2007; Robin H. Johnson <robbat2@gentoo.org> generic/initrd.scripts,
6
  generic/linuxrc:
7
  The previous patch from bug #174294 still contained some bugs in the linuxrc
8
  and scripts, that caused a failure during boot. Clean them up with one more
9
  patch from Nelson Batalha <nelson_batalha@hotmail.com>, again on bug #174294.
10
5
  21 Jun 2007; Chris Gianelloni <wolf31o2@gentoo.org> gen_initrd.sh:
11
  21 Jun 2007; Chris Gianelloni <wolf31o2@gentoo.org> gen_initrd.sh:
6
  Fixed lvm/evms code for initrd generation. Thanks to Vinny
12
  Fixed lvm/evms code for initrd generation. Thanks to Vinny
7
  <vfuria@gmail.com> on bug #179480 for pointing it out.
13
  <vfuria@gmail.com> on bug #179480 for pointing it out.
(-)a/generic/initrd.scripts (-8 / +15 lines)
Lines 108-133 findkeymount() { Link Here
108
                        # Check for a block device to mount
108
                        # Check for a block device to mount
109
                        if [ -b "${x}" ]
109
                        if [ -b "${x}" ]
110
                        then
110
                        then
111
                                good_msg "Attempting to mount key media:- ${x}"
111
				if [ ${crypt_silent} = '' ]
112
                                mount -r -t auto ${x} ${NEW_ROOT}/mnt/key \
112
				then
113
	                                good_msg "Attempting to mount key media:- ${x}"
114
				fi
115
116
                                mount -r -t auto ${x} ${NEW_ROOT}/mnt/keydev \
113
                                                > /dev/null 2>&1
117
                                                > /dev/null 2>&1
114
                                fi
115
                                if [ "$?" = '0' ]
118
                                if [ "$?" = '0' ]
116
                                then
119
                                then
117
                                        # Check for the key
120
                                        # Check for the key
118
                                        if [ -e ${NEW_ROOT}/mnt/key/${SUBDIR}/${KEYNAME} ]
121
                                        if [ -e ${NEW_ROOT}/mnt/keydev/${LUKS_ROOT_KEY} ]
119
                                        then
122
                                        then
120
                                                KEY_ROOT="${x}"
123
                                                LUKS_ROOT_KEYDEV="${x}"
124
						umount ${NEW_ROOT}/mnt/keydev
121
                                                break
125
                                                break
122
                                        else
126
                                        else
123
                                                umount ${NEW_ROOT}/mnt/key
127
                                                umount ${NEW_ROOT}/mnt/keydev
124
                                        fi
128
                                        fi
125
                                fi
129
                                fi
126
                        fi
130
                        fi
127
                done
131
                done
128
                if [ "${KEY_ROOT}" != '' ]
132
                if [ "${LUKS_ROOT_KEYDEV}" != '' ]
129
                then
133
                then
130
                        good_msg "Key media found on ${x}"
134
			if [ ${crypt_silent} = '' ]
135
			then
136
	                        good_msg "Key media found on ${x}"
137
			fi
131
                fi
138
                fi
132
        fi
139
        fi
133
}
140
}
(-)a/generic/linuxrc (-30 / +36 lines)
Lines 72-87 do Link Here
72
			CDROOT=1
72
			CDROOT=1
73
			CDROOT_DEV=`parse_opt "${x}"`
73
			CDROOT_DEV=`parse_opt "${x}"`
74
		;;
74
		;;
75
		# Start livecd loop, looptype options and encryption
75
		# Start livecd loop, looptype options
76
		loop\=*)
76
		loop\=*)
77
			LOOP=`parse_opt "${x}"`
77
			LOOP=`parse_opt "${x}"`
78
		;;
78
		;;
79
		looptype\=*)
79
		looptype\=*)
80
			LOOPTYPE=`parse_opt "${x}"`
80
			LOOPTYPE=`parse_opt "${x}"`
81
		;;
81
		;;
82
		loop_crypt\=*)
83
			LOOP_CRYPT=`parse_opt "${x}"`
84
		;;
85
		# Start Device Manager options 
82
		# Start Device Manager options 
86
		devfs)
83
		devfs)
87
			USE_DEVFS_NORMAL=1
84
			USE_DEVFS_NORMAL=1
Lines 182-187 do Link Here
182
		crypt_swap\=*)
179
		crypt_swap\=*)
183
			LUKS_SWAP=`parse_opt "${x}"`
180
			LUKS_SWAP=`parse_opt "${x}"`
184
		;;
181
		;;
182
		crypt_silent\=*)
183
			LUKS_SILENT=`parse_opt "${x}"`
184
		;;
185
		real_rootflags\=*)
185
		real_rootflags\=*)
186
			REAL_ROOTFLAGS=`parse_opt "${x}"`
186
			REAL_ROOTFLAGS=`parse_opt "${x}"`
187
		;;
187
		;;
Lines 236-243 setup_md_device Link Here
236
# Scan volumes
236
# Scan volumes
237
startVolumes
237
startVolumes
238
238
239
# Initialize LUKS root device
239
# Initialize LUKS root device except for livecd's
240
startLUKS
240
if [ "${CDROOT}" -ne '1' ]
241
then
242
	startLUKS
243
fi
241
244
242
# Set up unionfs
245
# Set up unionfs
243
mkdir -p ${NEW_ROOT}
246
mkdir -p ${NEW_ROOT}
Lines 264-270 then Link Here
264
		mount -t tmpfs tmpfs ${NEW_ROOT}
267
		mount -t tmpfs tmpfs ${NEW_ROOT}
265
	fi
268
	fi
266
	
269
	
267
	for i in dev mnt mnt/cdrom mnt/livecd mnt/key tmp tmp/.initrd mnt/gentoo sys
270
	for i in dev mnt mnt/cdrom mnt/livecd mnt/keydev tmp tmp/.initrd mnt/gentoo sys
268
	do
271
	do
269
		mkdir -p ${NEW_ROOT}/$i
272
		mkdir -p ${NEW_ROOT}/$i
270
		chmod 755 ${NEW_ROOT}/$i
273
		chmod 755 ${NEW_ROOT}/$i
Lines 496-532 then Link Here
496
	
499
	
497
500
498
        # If encrypted, find key and mount, otherwise mount as usual
501
        # If encrypted, find key and mount, otherwise mount as usual
499
	if [ "${LOOP_CRYPT}" != '' ] 
502
	if [ "${LUKS_ROOT}" != '' ] 
500
	then
503
	then
501
		good_msg 'You booted an encrypted livecd'
504
		if [ "${LUKS_SILENT}" = '' ]
502
		KEYNAME=$(head -n 1 ${NEW_ROOT}/mnt/cdrom/livecd)
505
		then
506
			good_msg 'You booted an encrypted livecd'
507
		fi
503
508
504
		if [ "${KEYNAME}" = '' ]
509
		LUKS_ROOT_KEY=$(head -n 1 ${NEW_ROOT}/mnt/cdrom/livecd)
505
		then 
506
			good_msg 'It's not locked with a gpg key, attempting to decrypt manually'
507
			losetup -e ${LOOP_CRYPT} /dev/loop1 ${NEW_ROOT}/mnt/cdrom/${LOOPEXT}${LOOP}
508
			
509
510
510
		else 
511
		if [ "${LUKS_ROOT_KEY}" ]
511
			good_msg 'Livecd locked with gpg key'
512
		then
512
			bootstrapKey
513
			bootstrapKey
513
			good_msg 'Attempting to decrypt with key'
514
			losetup -K ${NEW_ROOT}/mnt/key/${SUBDIR}/${KEYNAME} -e ${LOOP_CRYPT} /dev/loop1 \
515
				${NEW_ROOT}/mnt/cdrom/${LOOPEXT}${LOOP}
516
		fi
514
		fi
517
515
		
518
		test_success 'Unencrypting loop'
516
		losetup /dev/loop0 ${NEW_ROOT}/mnt/cdrom/${LOOPEXT}${LOOP}
517
		
518
		test_success 'Preparing loop filesystem'
519
		
520
		LUKS_ROOT='/dev/loop0'
521
		
522
		startLUKS
519
		
523
		
520
		case ${LOOPTYPE} in
524
		case ${LOOPTYPE} in
521
			squashfs)
522
				MOUNTTYPE="squashfs"
523
			normal)
525
			normal)
524
				MOUNTTYPE="ext2"
526
				MOUNTTYPE="ext2"
525
		esac
527
				;;
528
			*)
529
				MOUNTTYPE="${LOOPTYPE}"
530
				;;
531
		esac		
526
532
527
		mount -t ${MOUNTTYPE} -o ro /dev/loop1 ${NEW_ROOT}/mnt/livecd 
533
528
				
534
		mount -t ${MOUNTTYPE} -o ro /dev/mapper/root ${NEW_ROOT}/mnt/livecd 
529
		test_success 'Mount filesystem, checking key'	
535
		
536
		test_success 'Mount filesystem'	
530
		FS_LOCATION='mnt/livecd'
537
		FS_LOCATION='mnt/livecd'
531
538
532
539
Lines 590-596 then Link Here
590
			test_success 'mount /dev/loop0 /'
597
			test_success 'mount /dev/loop0 /'
591
			FS_LOCATION='mnt/livecd'
598
			FS_LOCATION='mnt/livecd'
592
		fi
599
		fi
593
	
600
	fi
594
#
601
#
595
# End cdrom looptype determination and mounting if necessary
602
# End cdrom looptype determination and mounting if necessary
596
#
603
#
597
- 

Return to bug 186650