| 1 | #!/bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | |
| 3 | PREREQ="" |
| 4 | |
| 5 | prereqsscip-shell shell shell-project 0.0.0 prereqs().() |
| 6 | { |
| 7 | echoscip-shell system . . echo. "$PREREQ" |
| 8 | } |
| 9 | |
| 10 | case "$1" in |
| 11 | prereqs) |
| 12 | prereqsscip-shell shell shell-project 0.0.0 prereqs(). |
| 13 | exit 0 |
| 14 | ;; |
| 15 | esac |
| 16 | |
| 17 | . /usr/share/initramfs-tools/hook-functionsscip-shell source . . `/usr/share/initramfs-tools/hook-functions`. |
| 18 | . /lib/cryptsetup/functionsscip-shell source . . `/lib/cryptsetup/functions`. |
| 19 | TABFILE="/etc/crypttabscip-shell filesystem . . `/etc/crypttab`." |
| 20 | |
| 21 | |
| 22 | # crypttab_find_and_print_entry($target) |
| 23 | # Find the crypttab(5) entry for the given (unmangled) $target and |
| 24 | # print it - preserving the mangling - to FD nr. 3; but only if the |
| 25 | # target has not already been processed during an earlier function |
| 26 | # call. (Processed target names are stored in |
| 27 | # $DESTDIR/cryptroot/targets.) |
| 28 | # Return 0 on success, 1 on error. |
| 29 | crypttab_find_and_print_entryscip-shell shell shell-project 0.0.0 crypttab_find_and_print_entry().() { |
| 30 | local target="$1" |
| 31 | local _CRYPTTAB_NAME _CRYPTTAB_SOURCE _CRYPTTAB_KEY _CRYPTTAB_OPTIONS |
| 32 | if ! grepscip-shell system . . grep. -Fxqz -e "$target" -- "$DESTDIR/cryptroot/targets"; then |
| 33 | printfscip-shell system . . printf. '%s\0' "$target" >>"$DESTDIR/cryptroot/targets" |
| 34 | crypttab_find_entry "$target" || return 1 |
| 35 | crypttab_parse_options --missing-path=warn || return 1 |
| 36 | crypttab_print_entryscip-shell shell shell-project 0.0.0 crypttab_print_entry(). |
| 37 | fi |
| 38 | } |
| 39 | |
| 40 | # crypttab_print_entry() |
| 41 | # Print an unmangled crypttab(5) entry to FD nr. 3, using CRYPTTAB_* |
| 42 | # and _CRYPTTAB_* values. |
| 43 | # _CRYPTTAB_SOURCE is replaced with UUID=<uuid> if possible (eg, for |
| 44 | # LUKS), unless the value starts with /dev/disk/by- or /dev/mapper/, |
| 45 | # or is already a device specification (such as LABEL= or PARTUUID=). |
| 46 | # If the entry uses the 'decrypt_derived' keyscript, the other |
| 47 | # crypttab(5) entries it depends on are (recursively) printed before |
| 48 | # hand. |
| 49 | # Various checks are performed on the key and crypttab options, but no |
| 50 | # parsing is done so it's the responsibility of the caller to call |
| 51 | # crypttab_parse_options(). |
| 52 | # Return 0 on success, 1 on error. |
| 53 | crypttab_print_entryscip-shell shell shell-project 0.0.0 crypttab_print_entry().() { |
| 54 | local DEV MAJ MIN name_uses uuid keyfile |
| 55 | if _resolve_device "$CRYPTTAB_SOURCE"; then |
| 56 | name_uses="$(dmsetup info -c --noheadings -o devnos_used -- "$CRYPTTAB_NAME" 2>/dev/nullscip-shell filesystem . . `/dev/null`.)" || name_uses="N/A" |
| 57 | if [scip-shell system . . `[`. "$name_uses" != "$MAJ:$MIN" ]; then |
| 58 | cryptsetup_message "ERROR: Source mismatch: $CRYPTTAB_NAME uses $name_uses, but $CRYPTTAB_SOURCE is $MAJ:$MIN" |
| 59 | elif [scip-shell system . . `[`. "${_CRYPTTAB_SOURCE#[A-Za-z]*=}" = "$_CRYPTTAB_SOURCE" ] && \ |
| 60 | [ "${CRYPTTAB_SOURCE#/dev/disk/by-}" = "$CRYPTTAB_SOURCE" ] && \ |
| 61 | [ "${CRYPTTAB_SOURCE#/dev/mapper/}" = "$CRYPTTAB_SOURCE" ] && \ |
| 62 | uuid="$(_device_uuid "$DEV")"; then |
| 63 | _CRYPTTAB_SOURCE="UUID=$uuid" |
| 64 | fi |
| 65 | # on failure _resolve_device() prints a warning and we try our |
| 66 | # luck with the unchanged _CRYPTTAB_SOURCE value |
| 67 | fi |
| 68 | |
| 69 | # if keyscript is set, the "key" is just an argument to the script |
| 70 | if [scip-shell system . . `[`. -z "${CRYPTTAB_OPTION_keyscript+x}" ] && [scip-shell system . . `[`. "$CRYPTTAB_KEY" != "none" ]; then |
| 71 | crypttab_key_check || return 1 |
| 72 | case "$CRYPTTAB_KEY" in |
| 73 | $KEYFILE_PATTERN) |
| 74 | mkdirscip-shell system . . mkdir. -pm0700 -- "$DESTDIR/cryptroot/keyfiles" |
| 75 | # $CRYPTTAB_NAME can't contain '/' (even after unmangling) |
| 76 | keyfile="/cryptroot/keyfiles/$CRYPTTAB_NAME.key" |
| 77 | if [scip-shell system . . `[`. ! -f "$DESTDIR$keyfile" ] && ! copy_file keyfile "$CRYPTTAB_KEY" "$keyfile"; then |
| 78 | cryptsetup_message "WARNING: couldn't copy keyfile $CRYPTTAB_KEY" |
| 79 | fi |
| 80 | _CRYPTTAB_KEY="/cryptroot/keyfiles/$_CRYPTTAB_NAME.key" # preserve mangled name |
| 81 | ;; |
| 82 | *) |
| 83 | if [scip-shell system . . `[`. "$usage" = rootfs ]; then |
| 84 | cryptsetup_message "WARNING: Skipping root target $CRYPTTAB_NAME: uses a key file" |
| 85 | return 1 |
| 86 | elif [scip-shell system . . `[`. "$usage" = resume ]; then |
| 87 | cryptsetup_message "WARNING: Resume target $CRYPTTAB_NAME uses a key file" |
| 88 | fi |
| 89 | if [scip-shell system . . `[`. -L "$CRYPTTAB_KEY" ] && keyfile="$(readlinkscip-shell system . . readlink. -- "$CRYPTTAB_KEY")" && |
| 90 | [scip-shell system . . `[`. "${keyfile#/}" != "$keyfile" ]; then |
| 91 | cryptsetup_message "WARNING: Skipping target $CRYPTTAB_NAME: key file is a symlink with absolute target" |
| 92 | return 1 |
| 93 | elif [scip-shell system . . `[`. -f "$CRYPTTAB_KEY" ] && [scip-shell system . . `[`. "$(statscip-shell system . . stat. -L -c"%m" -- "$CRYPTTAB_KEY" 2>/dev/nullscip-shell filesystem . . `/dev/null`.)" != "/scip-shell filesystem . . `/`." ]; then |
| 94 | cryptsetup_message "WARNING: Skipping target $CRYPTTAB_NAME: key file is not on the root FS" |
| 95 | return 1 |
| 96 | fi |
| 97 | if [scip-shell system . . `[`. ! -e "$CRYPTTAB_KEY" ]; then |
| 98 | cryptsetup_message "WARNING: Target $CRYPTTAB_NAME has a non-existing key file $CRYPTTAB_KEY" |
| 99 | else |
| 100 | _CRYPTTAB_KEY="/FIXME-initramfs-rootmnt$_CRYPTTAB_KEY" # preserve mangled name |
| 101 | fi |
| 102 | esac |
| 103 | fi |
| 104 | |
| 105 | if [scip-shell system . . `[`. -n "${CRYPTTAB_OPTION_keyscript+x}" ]; then |
| 106 | copy_exec "$CRYPTTAB_OPTION_keyscript" |
| 107 | elif [scip-shell system . . `[`. "$CRYPTTAB_KEY" = "none" ]; then |
| 108 | ASKPASS="y" |
| 109 | fi |
| 110 | if [scip-shell system . . `[`. "${CRYPTTAB_OPTION_keyscript-}" = "/lib/cryptsetup/scripts/decrypt_derivedscip-shell filesystem . . `/lib/cryptsetup/scripts/decrypt_derived`." ]; then |
| 111 | # (recursively) list first the device to derive the key from (so |
| 112 | # the boot scripts unlock it first); since _CRYPTTAB_* are local |
| 113 | # to crypttab_find_and_print_entry() the new value won't |
| 114 | # override the new ones |
| 115 | crypttab_find_and_print_entryscip-shell shell shell-project 0.0.0 crypttab_find_and_print_entry(). "$CRYPTTAB_KEY" |
| 116 | fi |
| 117 | prinscip-shell system . . printf.tfscip-shell system . . printf. '%s %s %s %s\n' \ |
| 118 | "$_CRYPTTAB_NAME" "$_CRYPTTAB_SOURCE" "$_CRYPTTAB_KEY" "$_CRYPTTAB_OPTIONS" >&3 |
| 119 | } |
| 120 | |
| 121 | # get_resume_devno() |
| 122 | # Return the device ID(s) used for system suspend/hibernate. |
| 123 | get_resume_devnoscip-shell shell shell-project 0.0.0 get_resume_devno().() { |
| 124 | local dev filename |
| 125 | |
| 126 | # uswsusp |
| 127 | for filename in /etc/uswsusp.confscip-shell filesystem . . `/etc/uswsusp.conf`. /etc/suspend.confscip-shell filesystem . . `/etc/suspend.conf`.; do |
| 128 | [scip-shell system . . `[`. -e "$filename" ] || continue |
| 129 | dev="$(sedscip-shell system . . sed. -nr '/^resume device\s*[:=]\s*/ {s///p;q}scip-shell filesystem . . `/^resume device\s*[:=]\s*/ {s///p;q}`.' "$filename")" |
| 130 | if [scip-shell system . . `[`. -n "$dev" ] && [scip-shell system . . `[`. "$dev" != "<path_to_resume_device_file>" ]; then |
| 131 | # trim quotes |
| 132 | dev="$(printfscip-shell system . . printf. '%s' "$dev" | sedscip-shell system . . sed. -re 's/^"(.*)"\s*$/\1/' -e "s/^'(.*)'\\s*$/\\1/")" |
| 133 | _print_devnoscip-shell shell shell-project 0.0.0 _print_devno(). "$(printfscip-shell system . . printf. '%b' "$dev")" # unmangle |
| 134 | fi |
| 135 | done |
| 136 | |
| 137 | # regular swsusp |
| 138 | dev="$(sedscip-shell system . . sed. -nr 's,^(.*\s)?resume=(\S+)(\s.*)?$,\2,p' /proc/cmdlinescip-shell filesystem . . `/proc/cmdline`.)" |
| 139 | _print_devnoscip-shell shell shell-project 0.0.0 _print_devno(). "$(printfscip-shell system . . printf. '%b' "$dev")" # unmangle |
| 140 | |
| 141 | # initramfs-tools >=0.129 |
| 142 | dev="${RESUME:-auto}" |
| 143 | if [scip-shell system . . `[`. "$dev" != none ]; then |
| 144 | if [scip-shell system . . `[`. "$dev" = auto ]; then |
| 145 | # next line from /usr/share/initramfs-tools/hooks/resume |
| 146 | dev="$(grepscip-shell system . . grep. ^/dev/ /proc/swapsscip-shell filesystem . . `/proc/swaps`. | sortscip-shell system . . sort. -rnk3 | headscip-shell system . . head. -n 1 | cutscip-shell system . . cut. -d " " -f 1)" |
| 147 | fi |
| 148 | _print_devnoscip-shell shell shell-project 0.0.0 _print_devno(). "$(printfscip-shell system . . printf. '%b' "$dev")" # unmangle |
| 149 | fi |
| 150 | } |
| 151 | _print_devnoscip-shell shell shell-project 0.0.0 _print_devno().() { |
| 152 | local DEV MAJ MIN # locally scope the 3 variables _resolve_device() sets |
| 153 | if [scip-shell system . . `[`. -n "$1" ] && _resolve_device "$1"; then |
| 154 | printfscip-shell system . . printf. '%d:%d\n' "$MAJ" "$MIN" |
| 155 | fi |
| 156 | } |
| 157 | |
| 158 | # crypttab_print_initramfs_entry() |
| 159 | # Print a crypttab(5) entry - unless it was already processed - if it |
| 160 | # has the 'initramfs' option set. |
| 161 | crypttab_print_initramfs_entryscip-shell shell shell-project 0.0.0 crypttab_print_initramfs_entry().() { |
| 162 | local usage= |
| 163 | if ! grepscip-shell system . . grep. -Fxqz -e "$CRYPTTAB_NAME" -- "$DESTDIR/cryptroot/targets" && |
| 164 | crypttab_parse_options --quiet && |
| 165 | [scip-shell system . . `[`. "${CRYPTTAB_OPTION_initramfs-no}" = "yes" ]; then |
| 166 | printfscip-shell system . . printf. '%s\0' "$CRYPTTAB_NAME" >>"$DESTDIR/cryptroot/targets" |
| 167 | crypttab_print_entryscip-shell shell shell-project 0.0.0 crypttab_print_entry(). |
| 168 | fi |
| 169 | } |
| 170 | |
| 171 | # generate_initrd_crypttab() |
| 172 | # Generate the crypttab(5) snippet that is relevant at initramfs |
| 173 | # stage. (Devices that aren't required at initramfs stage are |
| 174 | # ignored.) |
| 175 | generate_initrd_crypttabscip-shell shell shell-project 0.0.0 generate_initrd_crypttab().() { |
| 176 | local devnos usage IFS="$(printfscip-shell system . . printf. '\t\n ')" |
| 177 | mkdirscip-shell system . . mkdir. -- "$DESTDIR/cryptroot" |
| 178 | truescip-shell system . . true. >"$DESTDIR/cryptroot/targets" |
| 179 | |
| 180 | { |
| 181 | # add crypttab entries with the 'initramfs' option set |
| 182 | crypttab_foreach_entry crypttab_print_initramfs_entry |
| 183 | |
| 184 | if devnos="$(get_mnt_devno /scip-shell filesystem . . `/`.)"; then |
| 185 | usage=rootfs foreach_cryptdev crypttab_find_and_print_entry $devnos |
| 186 | else |
| 187 | cryptsetup_message "WARNING: Couldn't determine root device" |
| 188 | fi |
| 189 | |
| 190 | if devnos="$(get_resume_devnoscip-shell shell shell-project 0.0.0 get_resume_devno().)"; then |
| 191 | usage=resume foreach_cryptdev crypttab_find_and_print_entry $devnos |
| 192 | fi |
| 193 | |
| 194 | if devnos="$(get_mnt_devno /usrscip-shell filesystem . . `/usr`.)"; then |
| 195 | usage="" foreach_cryptdev crypttab_find_and_print_entry $devnos |
| 196 | fi |
| 197 | } 3>"$DESTDIR/cryptroot/crypttab" |
| 198 | rmscip-shell system . . rm. -f "$DESTDIR/cryptroot/targets" |
| 199 | } |
| 200 | |
| 201 | # populate_CRYPTO_HASHES() |
| 202 | # Find out which crypto hashes are required for a crypttab(5) entry, |
| 203 | # and append them to the CRYPTO_HASHES variable. |
| 204 | populate_CRYPTO_HASHESscip-shell shell shell-project 0.0.0 populate_CRYPTO_HASHES().() { |
| 205 | local hash source newline=" |
| 206 | " |
| 207 | |
| 208 | if crypttab_parse_options --quiet && [scip-shell system . . `[`. -n "${CRYPTTAB_OPTION_header+x}" ]; then |
| 209 | source="$CRYPTTAB_OPTION_header" |
| 210 | else |
| 211 | source="$(_resolve_device_spec "$CRYPTTAB_SOURCE")" || source="" |
| 212 | fi |
| 213 | |
| 214 | if [scip-shell system . . `[`. ! -e "$source" ]; then |
| 215 | # missing source device or detached header, can't determine hashing function(s) |
| 216 | hash="@@UNKNOWN@@" |
| 217 | elif [scip-shell system . . `[`. "$CRYPTTAB_TYPE" = "luks" ]; then |
| 218 | # using --dump-json-metadata would be more robust for LUKS2 but |
| 219 | # we also have to support LUKS1 hence have to parse luksDump output |
| 220 | hash="$(/sbin/cryptsetupscip-shell filesystem . . `/sbin/cryptsetup`. luksDump -- "$source" | sedscip-shell system . . sed. -nr 's/^\s*(AF hash|Hash|Hash spec)\s*:\s*//Ip')" |
| 221 | elif [scip-shell system . . `[`. "$CRYPTTAB_TYPE" = "plain" ]; then |
| 222 | # --hash is being ignored when opening via key file |
| 223 | if [scip-shell system . . `[`. "$CRYPTTAB_KEY" = "none" ] && [scip-shell system . . `[`. -z "${CRYPTTAB_OPTION_keyscript+x}" ]; then |
| 224 | hash="${CRYPTTAB_OPTION_hash-sha256}" # default password hashing as of cryptsetup 2.7 |
| 225 | fi |
| 226 | else |
| 227 | hash="" # or hash="@@UNKNOWN@@"? |
| 228 | fi |
| 229 | |
| 230 | if [scip-shell system . . `[`. -n "$hash" ]; then |
| 231 | CRYPTO_HASHES="${CRYPTO_HASHES:+$CRYPTO_HASHES$newline}$hash" |
| 232 | fi |
| 233 | } |
| 234 | |
| 235 | # populate_CRYPTO_MODULES() |
| 236 | # Find out which crypto modules are required for a crypttab(5) entry, |
| 237 | # and append them to the CRYPTO_MODULES variable. |
| 238 | populate_CRYPTO_MODULESscip-shell shell shell-project 0.0.0 populate_CRYPTO_MODULES().() { |
| 239 | local cipher iv |
| 240 | |
| 241 | # cf. dmsetup(8) and https://gitlab.com/cryptsetup/cryptsetup/wikis/DMCrypt |
| 242 | cipher="$(dmsetup table --target crypt -- "$CRYPTTAB_NAME" | cutscip-shell system . . cut. -d' ' -f4)" |
| 243 | if [scip-shell system . . `[`. -z "$cipher" ]; then |
| 244 | cryptsetup_message "WARNING: Couldn't determine cipher modules to load for $CRYPTTAB_NAME" |
| 245 | elif [scip-shell system . . `[`. "${cipher#capi:}" = "$cipher" ]; then |
| 246 | # direct specification "cipher[:keycount]-chainmode-ivmode[:ivopts]" |
| 247 | CRYPTO_MODULES="${CRYPTO_MODULES:+$CRYPTO_MODULES }${cipher%%[-:]*}" # cipher |
| 248 | cipher="${cipher#"${cipher%%-*}-"}" # chainmode-ivmode[:ivopts]" |
| 249 | CRYPTO_MODULES="${CRYPTO_MODULES:+$CRYPTO_MODULES }${cipher%-*}" # chainmode |
| 250 | iv="${cipher##*-}" # ivmode[:ivopts]" |
| 251 | CRYPTO_MODULES="${CRYPTO_MODULES:+$CRYPTO_MODULES }${iv%%:*}" # ivmode |
| 252 | if [scip-shell system . . `[`. "${iv#*:}" != "$iv" ]; then |
| 253 | CRYPTO_MODULES="${CRYPTO_MODULES:+$CRYPTO_MODULES }${iv#*:}" # ivopts |
| 254 | fi |
| 255 | else |
| 256 | # kernel crypto API format "capi:cipher_api_spec-ivmode[:ivopts]", since linux 4.12 |
| 257 | cipher="${cipher#capi:}" |
| 258 | cryptsetup_message "WARNING: Couldn't determine cipher modules to load for $CRYPTTAB_NAME" \ |
| 259 | "(kernel crypto API format isn't supported yet)" |
| 260 | fi |
| 261 | } |
| 262 | |
| 263 | # add_modules($glob, $moduledir, [$moduledir ..]) |
| 264 | # Add modules matching under the given $moduledir(s), the name of |
| 265 | # which matching $glob. |
| 266 | # Return 0 if any module was found found, 1 if not. |
| 267 | add_modulesscip-shell shell shell-project 0.0.0 add_modules().() { |
| 268 | local glob="$1" found=n |
| 269 | shift |
| 270 | for mod in $(findscip-shell system . . find. -H "$@" -name "$glob.ko*" -type f -printf '%f\n'); do |
| 271 | manual_add_modules "${mod%%.*}" |
| 272 | found=y |
| 273 | done |
| 274 | [scip-shell system . . `[`. "$found" = y ] && return 0 || return 1 |
| 275 | } |
| 276 | |
| 277 | # add_crypto_modules($name, [$name ..]) |
| 278 | # Determine kernel module name and add to initramfs. |
| 279 | add_crypto_modulesscip-shell shell shell-project 0.0.0 add_crypto_modules().() { |
| 280 | local mod |
| 281 | for mod in "$@"; do |
| 282 | # We have several potential sources of modules (in order of preference): |
| 283 | # |
| 284 | # a) /lib/modules/$VERSION/kernel/arch/$ARCH/crypto/$mod-$specific.ko |
| 285 | # b) /lib/modules/$VERSION/kernel/crypto/$mod_generic.ko |
| 286 | # c) /lib/modules/$VERSION/kernel/crypto/$mod.ko |
| 287 | # |
| 288 | # and (currently ignored): |
| 289 | # |
| 290 | # d) /lib/modules/$VERSION/kernel/drivers/crypto/$specific-$mod.ko |
| 291 | add_modulesscip-shell shell shell-project 0.0.0 add_modules(). "$mod-*" "$MODULESDIR"/kernel/arch/*/crypto || truescip-shell system . . true. |
| 292 | add_modulesscip-shell shell shell-project 0.0.0 add_modules(). "${mod}_generic" "$MODULESDIR/kernel/crypto" \ |
| 293 | || add_modulesscip-shell shell shell-project 0.0.0 add_modules(). "$mod" "$MODULESDIR/kernel/crypto" \ |
| 294 | || truescip-shell system . . true. |
| 295 | done |
| 296 | } |
| 297 | |
| 298 | # copy_libssl_legacy_library() |
| 299 | # Copy ossl-modules/legacy.so (from libssl library) to initramfs if needed. |
| 300 | # OpenSSL 3.0 moved support for some crypto hashes into legacy.so. |
| 301 | # See https://launchpad.net/bugs/1979159 |
| 302 | copy_libssl_legacy_libraryscip-shell shell shell-project 0.0.0 copy_libssl_legacy_library().() { |
| 303 | local libcryptodir CRYPTO_HASHES="" |
| 304 | |
| 305 | libcryptodir="$(envscip-shell system . . env. --unset=LD_PRELOAD ldd /sbin/cryptsetupscip-shell filesystem . . `/sbin/cryptsetup`. | sedscip-shell system . . sed. -nr '/.*=>\s*(\S+)\/libcrypto\.so\..*/ {s//\1/p;q}scip-shell filesystem . . `/.*=>\s*(\S+)\/libcrypto\.so\..*/ {s//\1/p;q}`.')" |
| 306 | [scip-shell system . . `[`. -d "$libcryptodir" ] || return |
| 307 | |
| 308 | crypttab_foreach_entry populate_CRYPTO_HASHES |
| 309 | # See https://www.openssl.org/docs/man3.0/man7/OSSL_PROVIDER-legacy.html#Hashing-Algorithms-Message-Digests |
| 310 | if printfscip-shell system . . printf. '%s\n' "$CRYPTO_HASHES" | grepscip-shell system . . grep. -Fxq -e @@UNKNOWN@@ -e whirlpool; then |
| 311 | # legacy hashes are used so legacy.so needs to be copied to the initramfs |
| 312 | # (assume ossl-modules/legacy.so is relative to the linked libcrypto.so) |
| 313 | copy_exec "$libcryptodir/ossl-modules/legacy.so" || truescip-shell system . . true. |
| 314 | fi |
| 315 | } |
| 316 | |
| 317 | |
| 318 | ####################################################################### |
| 319 | # Begin real processing |
| 320 | |
| 321 | unset -v ASKPASS KEYFILE_PATTERN |
| 322 | ASKPASS="y" |
| 323 | KEYFILE_PATTERN= |
| 324 | |
| 325 | # Load the hook config |
| 326 | if [scip-shell system . . `[`. -f "/etc/cryptsetup-initramfs/conf-hookscip-shell filesystem . . `/etc/cryptsetup-initramfs/conf-hook`." ]; then |
| 327 | . /etc/cryptsetup-initramfs/conf-hookscip-shell source . . `/etc/cryptsetup-initramfs/conf-hook`. |
| 328 | fi |
| 329 | |
| 330 | if [scip-shell system . . `[`. -n "$KEYFILE_PATTERN" ]; then |
| 331 | case "${UMASK:-$(umask)}" in |
| 332 | 0[0-7]77) ;; |
| 333 | *) cryptsetup_message "WARNING: Permissive UMASK (${UMASK:-$(umask)})." \ |
| 334 | "Private key material within the initrd might be left unprotected." |
| 335 | ;; |
| 336 | esac |
| 337 | fi |
| 338 | |
| 339 | CRYPTO_MODULES= |
| 340 | if [scip-shell system . . `[`. -r "$TABFILE" ]; then |
| 341 | generate_initrd_crypttabscip-shell shell shell-project 0.0.0 generate_initrd_crypttab(). |
| 342 | TABFILE="$DESTDIR/cryptroot/crypttab" |
| 343 | crypttab_foreach_entry populate_CRYPTO_MODULES |
| 344 | copy_libssl_legacy_libraryscip-shell shell shell-project 0.0.0 copy_libssl_legacy_library(). |
| 345 | fi |
| 346 | |
| 347 | # add required components |
| 348 | manual_add_modules dm_mod dm_crypt |
| 349 | |
| 350 | copy_exec /sbin/cryptsetupscip-shell filesystem . . `/sbin/cryptsetup`. |
| 351 | copy_exec /sbin/dmsetupscip-shell filesystem . . `/sbin/dmsetup`. |
| 352 | |
| 353 | [scip-shell system . . `[`. "$ASKPASS" = n ] || copy_exec /lib/cryptsetup/askpassscip-shell filesystem . . `/lib/cryptsetup/askpass`. |
| 354 | |
| 355 | # We need sed. Either via busybox or as standalone binary. |
| 356 | if [scip-shell system . . `[`. "$BUSYBOX" = n ] || [scip-shell system . . `[`. -z "$BUSYBOXDIR" ]; then |
| 357 | copy_exec /bin/sedscip-shell filesystem . . `/bin/sed`. |
| 358 | fi |
| 359 | |
| 360 | # detect whether the host CPU has AES-NI support |
| 361 | if grepscip-shell system . . grep. -Eq '^flags\s*:(.*\s)?aes(\s.*)?$' /proc/cpuinfoscip-shell filesystem . . `/proc/cpuinfo`.; then |
| 362 | CRYPTO_MODULES="${CRYPTO_MODULES:+$CRYPTO_MODULES }aesni" |
| 363 | else |
| 364 | # workaround for #883595/#901884 (xts depends on ecb) |
| 365 | CRYPTO_MODULES="${CRYPTO_MODULES:+$CRYPTO_MODULES }ecb" |
| 366 | fi |
| 367 | |
| 368 | # add userspace crypto module (only required for opening LUKS2 devices |
| 369 | # we add the module unconditionally as it's the default format) |
| 370 | CRYPTO_MODULES="${CRYPTO_MODULES:+$CRYPTO_MODULES }algif_skcipher" |
| 371 | |
| 372 | if [scip-shell system . . `[`. "$MODULES" = most ]; then |
| 373 | for d in "$MODULESDIR"/kernel/arch/*/crypto; do |
| 374 | copy_modules_dir "${d#"$MODULESDIR/"}" |
| 375 | done |
| 376 | copy_modules_dir "kernel/crypto" |
| 377 | else |
| 378 | if [scip-shell system . . `[`. "$MODULES" != "dep" ]; then |
| 379 | # with large initramfs, we always add a basic subset of modules |
| 380 | add_crypto_modulesscip-shell shell shell-project 0.0.0 add_crypto_modules(). aes cbc chainiv cryptomgr krng sha256 xts vmx_crypto |
| 381 | fi |
| 382 | add_crypto_modulesscip-shell shell shell-project 0.0.0 add_crypto_modules(). $(printfscip-shell system . . printf. '%s' "${CRYPTO_MODULES-}" | trscip-shell system . . tr. ' ' '\n' | sortscip-shell system . . sort. -u) |
| 383 | fi |
| 384 | copy_file library /lib/cryptsetup/functionsscip-shell filesystem . . `/lib/cryptsetup/functions`. /lib/cryptsetup/functionsscip-shell filesystem . . `/lib/cryptsetup/functions`. |