~siretart/cryptsetup/debian

« back to all changes in this revision

Viewing changes to debian/initramfs/cryptroot-hook

  • Committer: Reinhard Tartler
  • Date: 2008-06-13 19:34:53 UTC
  • Revision ID: siretart@tauware.de-20080613193453-ywl35m67ce8pzvp3
import cryptsetup_1.0.6-1.dsc

Show diffs side-by-side

added added

removed removed

Lines of Context:
123
123
        local node deps maj min depnode
124
124
        node="$1"
125
125
 
126
 
        uuid_resolv="/dev/disk/by-uuid/${node#UUID=}"
127
 
        if [ -L "$uuid_resolv" ]; then
128
 
                node=$(readlink -f "$uuid_resolv")
129
 
        fi
130
 
 
131
126
        if [ -z $node ]; then
132
127
                echo "cryptsetup: WARNING: get_lvm_deps - invalid arguments" >&2
133
128
                return 1
231
226
                                opt=$(basename "$opt")
232
227
                                OPTIONS="$OPTIONS,keyscript=/keyscripts/$opt"
233
228
                                ;;
 
229
                        tries=*)
 
230
                                OPTIONS="$OPTIONS,$opt"
 
231
                                ;;
234
232
                        luks)
235
233
                                LUKS_FOUND=1
236
234
                                ;;
281
279
        return 0
282
280
}
283
281
 
 
282
canonical_device() {
 
283
        local dev altdev
 
284
        dev="$1"
 
285
 
 
286
        altdev="${dev#LABEL=}"
 
287
        if [ "$altdev" != "$dev" ]; then
 
288
                dev="/dev/disk/by-label/$altdev"
 
289
        fi
 
290
 
 
291
        altdev="${dev#UUID=}"
 
292
        if [ "$altdev" != "$dev" ]; then
 
293
                dev="/dev/disk/by-uuid/$altdev"
 
294
        fi
 
295
 
 
296
        if [ -h "$dev" ]; then
 
297
                dev=$(readlink -e "$dev")
 
298
        fi
 
299
 
 
300
        altdev="${dev#/dev/mapper/}"
 
301
        if [ "$altdev" != "$dev" ]; then
 
302
                echo "$altdev"
 
303
                return 0
 
304
        fi
 
305
 
 
306
        return 1
 
307
}
 
308
 
284
309
add_device() {
285
310
        local node nodes opts lastopts i count
286
311
        nodes="$1"
292
317
        fi
293
318
 
294
319
        # Check that it is a node under /dev/mapper/
295
 
        nodes="${nodes#/dev/mapper/}"
296
 
        if [ "$nodes" = "$1" ]; then
297
 
                # check that it is a UUID
298
 
                if [ "${nodes#UUID=}" = "$nodes" ]; then
299
 
                        return 0
300
 
                fi
301
 
        fi
 
320
        nodes=$(canonical_device "$nodes") || return 0
302
321
 
303
322
        # Can we find this node in crypttab
304
323
        if ! node_is_in_crypttab "$nodes"; then
358
377
        return 0
359
378
}
360
379
 
 
380
add_crypto_modules() {
 
381
        local mod file altmod found genericfound
 
382
        mod="$1"
 
383
        found=""
 
384
        genericfound=""
 
385
 
 
386
        if [ -z "$mod" ]; then
 
387
                return 1
 
388
        fi
 
389
 
 
390
        # We have several potential sources of modules (in order of preference):
 
391
        #
 
392
        #   a) /lib/modules/$VERSION/kernel/arch/$ARCH/crypto/$mod-$specific.ko
 
393
        #   b) /lib/modules/$VERSION/kernel/crypto/$mod_generic.ko
 
394
        #   c) /lib/modules/$VERSION/kernel/crypto/$mod.ko
 
395
        #
 
396
        # and (currently ignored):
 
397
        #
 
398
        #   d) /lib/modules/$VERSION/kernel/drivers/crypto/$specific-$mod.ko
 
399
 
 
400
        for file in $(find "$MODULESDIR/kernel/arch/" -name "$mod-*.ko"); do
 
401
                altmod="${file##*/}"
 
402
                altmod="${altmod%.ko}"
 
403
                manual_add_modules "$altmod"
 
404
                found="yes"
 
405
        done
 
406
 
 
407
        for file in $(find "$MODULESDIR/kernel/crypto/" -name "${mod}_generic.ko"); do
 
408
                altmod="${file##*/}"
 
409
                altmod="${altmod%.ko}"
 
410
                manual_add_modules "$altmod"
 
411
                found="yes"
 
412
                genericfound="yes"
 
413
        done
 
414
 
 
415
        if [ -z "$genericfound" ]; then
 
416
                for file in $(find "$MODULESDIR/kernel/crypto/" -name "${mod}.ko"); do
 
417
                        altmod="${file##*/}"
 
418
                        altmod="${altmod%.ko}"
 
419
                        manual_add_modules "$altmod"
 
420
                        found="yes"
 
421
                done
 
422
        fi
 
423
 
 
424
        if [ -z "$found" ]; then
 
425
                return 1
 
426
        fi
 
427
 
 
428
        return 0
 
429
}
361
430
 
362
431
#
363
432
# Begin real processing
365
434
 
366
435
# Unless MODULES = "dep", we always add a basic subset of modules/tools
367
436
if [ "$MODULES" != "dep" ]; then
368
 
        for mod in dm_mod dm_crypt aes sha256 cbc; do
 
437
        for mod in dm_mod dm_crypt; do
369
438
                manual_add_modules $mod
370
439
        done
 
440
 
 
441
        for mod in aes sha256 cbc; do
 
442
                add_crypto_modules $mod
 
443
        done
 
444
 
371
445
        copy_exec /sbin/cryptsetup /sbin
372
446
        copy_exec /sbin/dmsetup /sbin
373
447
fi
395
469
        fi
396
470
 
397
471
        for mod in $modules; do
398
 
                manual_add_modules $mod
 
472
                add_crypto_modules $mod
399
473
        done
400
474
done
401
475
 
402
476
# Prepare the initramfs
403
477
copy_exec /sbin/cryptsetup /sbin
404
478
copy_exec /sbin/dmsetup /sbin
 
479
copy_exec /lib/cryptsetup/askpass /lib/cryptsetup
405
480
 
406
481
# Done
407
482
exit 0