Debian Codegraph @

debian/scripts/decrypt_derived

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2
3 # WARNING: If you use the decrypt_derived keyscript for devices with
4 # persistent data (i.e. not swap or temp devices), then you will lose
5 # access to that data permanently if something damages the LUKS header
6 # of the LUKS device you derive from. The same applies if you luksFormat
7 # the device, even if you use the same passphrase(s). A LUKS header
8 # backup, or better a backup of the data on the derived device may be
9 # a good idea. See the Cryptsetup FAQ on how to do this right.
10
11 if [scip-shell system . . `[`. -z "$1" ]; then
12 echoscip-shell system . . echo. "$0: must be executed with a crypto device as argument" >&2
13 exit 1
14 fi
15
16 unset -v keys count
17 keys="$(dmsetup table --target crypt --showkeys -- "$1" 2>/dev/nullscip-shell filesystem . . `/dev/null`. | cutscip-shell system . . cut. -s -d' ' -f5)"
18 count="$(printfscip-shell system . . printf. '%s' "$keys" | wcscip-shell system . . wc. -l)"
19
20 if [scip-shell system . . `[`. -n "$keys" ] && [scip-shell system . . `[`. $count -le 1 ]; then
21 if [scip-shell system . . `[`. "${keys#:}" = "$keys" ]; then
22 printfscip-shell system . . printf. '%s' "$keys"
23 exit 0
24 else
25 echoscip-shell system . . echo. "$0: device $1 uses the kernel keyring" >&2
26 fi
27 elif [scip-shell system . . `[`. $count -eq 0 ]; then
28 echoscip-shell system . . echo. "$0: device $1 doesn't exist or isn't a crypto device" >&2
29 else
30 echoscip-shell system . . echo. "$0: more than one device match" >&2
31 fi
32 exit 1