cryptroot 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #!/bin/sh
  2. PREREQ=""
  3. prereqs()
  4. {
  5. echo "$PREREQ"
  6. }
  7. case $1 in
  8. prereqs)
  9. prereqs
  10. exit 0
  11. ;;
  12. esac
  13. . /usr/share/initramfs-tools/hook-functions
  14. add_crypto_modules() {
  15. local mod file altmod found genericfound
  16. mod="$1"
  17. found=""
  18. genericfound=""
  19. if [ -z "$mod" ]; then
  20. return 1
  21. fi
  22. # We have several potential sources of modules (in order of preference):
  23. #
  24. # a) /lib/modules/$VERSION/kernel/arch/$ARCH/crypto/$mod-$specific.ko
  25. # b) /lib/modules/$VERSION/kernel/crypto/$mod_generic.ko
  26. # c) /lib/modules/$VERSION/kernel/crypto/$mod.ko
  27. #
  28. # and (currently ignored):
  29. #
  30. # d) /lib/modules/$VERSION/kernel/drivers/crypto/$specific-$mod.ko
  31. for file in $(find "$MODULESDIR/kernel/arch/" -name "$mod-*.ko" 2>/dev/null); do
  32. altmod="${file##*/}"
  33. altmod="${altmod%.ko}"
  34. manual_add_modules "$altmod"
  35. found="yes"
  36. done
  37. for file in $(find "$MODULESDIR/kernel/crypto/" -name "${mod}_generic.ko" 2>/dev/null); do
  38. altmod="${file##*/}"
  39. altmod="${altmod%.ko}"
  40. manual_add_modules "$altmod"
  41. found="yes"
  42. genericfound="yes"
  43. done
  44. if [ -z "$genericfound" ]; then
  45. for file in $(find "$MODULESDIR/kernel/crypto/" -name "${mod}.ko" 2>/dev/null); do
  46. altmod="${file##*/}"
  47. altmod="${altmod%.ko}"
  48. manual_add_modules "$altmod"
  49. found="yes"
  50. done
  51. fi
  52. if [ -z "$found" ]; then
  53. return 1
  54. fi
  55. return 0
  56. }
  57. for mod in aes cbc chainiv cryptomgr krng sha256 xts; do
  58. add_crypto_modules $mod
  59. done
  60. for mod in dm_mod dm_crypt; do
  61. manual_add_modules $mod
  62. done
  63. copy_exec /sbin/cryptsetup
  64. copy_exec /sbin/dmsetup
  65. copy_exec /lib/cryptsetup/askpass
  66. copy_exec /bin/sed
  67. exit 0