mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
libzfs: add keylocation=https://, backed by fetch(3) or libcurl
Add support for http and https to the keylocation properly to allow encryption keys to be fetched from the specified URL. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Ryan Moeller <ryan@ixsystems.com> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Issue #9543 Closes #9947 Closes #11956
This commit is contained in:
@@ -60,6 +60,11 @@ install() {
|
||||
# Fallback: Guess the path and include all matches
|
||||
dracut_install /usr/lib*/gcc/**/libgcc_s.so*
|
||||
fi
|
||||
if [ @LIBFETCH_DYNAMIC@ != 0 ]; then
|
||||
for d in $libdirs; do
|
||||
[ -e "$d"/@LIBFETCH_SONAME@ ] && dracut_install "$d"/@LIBFETCH_SONAME@
|
||||
done
|
||||
fi
|
||||
dracut_install @mounthelperdir@/mount.zfs
|
||||
dracut_install @udevdir@/vdev_id
|
||||
dracut_install awk
|
||||
|
||||
@@ -8,7 +8,7 @@ Before=zfs-import.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/bin/sh -c "systemctl set-environment BOOTFS=$(@sbindir@/zpool list -H -o bootfs | grep -m1 -v '^-$')"
|
||||
ExecStart=/bin/sh -c "exec systemctl set-environment BOOTFS=$(@sbindir@/zpool list -H -o bootfs | grep -m1 -v '^-$')"
|
||||
|
||||
[Install]
|
||||
WantedBy=zfs-import.target
|
||||
|
||||
@@ -43,13 +43,14 @@ if [ "$(zpool list -H -o feature@encryption "${BOOTFS%%/*}")" = 'active' ]; then
|
||||
|
||||
KEYLOCATION="$(zfs get -H -o value keylocation "${ENCRYPTIONROOT}")"
|
||||
if ! [ "${KEYLOCATION}" = "prompt" ]; then
|
||||
if ! [ "${KEYLOCATION#http}" = "${KEYLOCATION}" ]; then
|
||||
systemctl start network-online.target
|
||||
fi
|
||||
zfs load-key "${ENCRYPTIONROOT}"
|
||||
else
|
||||
# decrypt them
|
||||
TRY_COUNT=5
|
||||
while [ $TRY_COUNT -gt 0 ]; do
|
||||
for _ in 1 2 3 4 5; do
|
||||
systemd-ask-password "Encrypted ZFS password for ${BOOTFS}" --no-tty | zfs load-key "${ENCRYPTIONROOT}" && break
|
||||
TRY_COUNT=$((TRY_COUNT - 1))
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -10,5 +10,5 @@ ConditionKernelCommandLine=bootfs.rollback
|
||||
# ${BOOTFS} should have been set by zfs-env-bootfs.service
|
||||
Type=oneshot
|
||||
ExecStartPre=/bin/sh -c 'test -n "${BOOTFS}"'
|
||||
ExecStart=/bin/sh -c '. /lib/dracut-lib.sh; SNAPNAME="$(getarg bootfs.rollback)"; @sbindir@/zfs rollback -Rf "${BOOTFS}@${SNAPNAME:-%v}"'
|
||||
ExecStart=/bin/sh -c '. /lib/dracut-lib.sh; SNAPNAME="$(getarg bootfs.rollback)"; exec @sbindir@/zfs rollback -Rf "${BOOTFS}@${SNAPNAME:-%v}"'
|
||||
RemainAfterExit=yes
|
||||
|
||||
@@ -10,5 +10,5 @@ ConditionKernelCommandLine=bootfs.snapshot
|
||||
# ${BOOTFS} should have been set by zfs-env-bootfs.service
|
||||
Type=oneshot
|
||||
ExecStartPre=/bin/sh -c 'test -n "${BOOTFS}"'
|
||||
ExecStart=-/bin/sh -c '. /lib/dracut-lib.sh; SNAPNAME="$(getarg bootfs.snapshot)"; @sbindir@/zfs snapshot "${BOOTFS}@${SNAPNAME:-%v}"'
|
||||
ExecStart=-/bin/sh -c '. /lib/dracut-lib.sh; SNAPNAME="$(getarg bootfs.snapshot)"; exec @sbindir@/zfs snapshot "${BOOTFS}@${SNAPNAME:-%v}"'
|
||||
RemainAfterExit=yes
|
||||
|
||||
@@ -30,6 +30,13 @@ find /lib/ -type f -name "libgcc_s.so.[1-9]" | while read -r libgcc; do
|
||||
copy_exec "$libgcc"
|
||||
done
|
||||
|
||||
# shellcheck disable=SC2050
|
||||
if [ @LIBFETCH_DYNAMIC@ != 0 ]; then
|
||||
find /lib/ -name @LIBFETCH_SONAME@ | while read -r libfetch; do
|
||||
copy_exec "$libfetch"
|
||||
done
|
||||
fi
|
||||
|
||||
copy_file config "/etc/hostid"
|
||||
copy_file cache "@sysconfdir@/zfs/zpool.cache"
|
||||
copy_file config "@initconfdir@/zfs"
|
||||
|
||||
@@ -403,28 +403,25 @@ decrypt_fs()
|
||||
KEYSTATUS="$(get_fs_value "${ENCRYPTIONROOT}" keystatus)"
|
||||
# Continue only if the key needs to be loaded
|
||||
[ "$KEYSTATUS" = "unavailable" ] || return 0
|
||||
TRY_COUNT=3
|
||||
|
||||
# If key is stored in a file, do not prompt
|
||||
# Do not prompt if key is stored noninteractively,
|
||||
if ! [ "${KEYLOCATION}" = "prompt" ]; then
|
||||
$ZFS load-key "${ENCRYPTIONROOT}"
|
||||
|
||||
# Prompt with plymouth, if active
|
||||
elif [ -e /bin/plymouth ] && /bin/plymouth --ping 2>/dev/null; then
|
||||
elif /bin/plymouth --ping 2>/dev/null; then
|
||||
echo "plymouth" > /run/zfs_console_askpwd_cmd
|
||||
while [ $TRY_COUNT -gt 0 ]; do
|
||||
for _ in 1 2 3; do
|
||||
plymouth ask-for-password --prompt "Encrypted ZFS password for ${ENCRYPTIONROOT}" | \
|
||||
$ZFS load-key "${ENCRYPTIONROOT}" && break
|
||||
TRY_COUNT=$((TRY_COUNT - 1))
|
||||
done
|
||||
|
||||
# Prompt with systemd, if active
|
||||
elif [ -e /run/systemd/system ]; then
|
||||
echo "systemd-ask-password" > /run/zfs_console_askpwd_cmd
|
||||
while [ $TRY_COUNT -gt 0 ]; do
|
||||
for _ in 1 2 3; do
|
||||
systemd-ask-password "Encrypted ZFS password for ${ENCRYPTIONROOT}" --no-tty | \
|
||||
$ZFS load-key "${ENCRYPTIONROOT}" && break
|
||||
TRY_COUNT=$((TRY_COUNT - 1))
|
||||
done
|
||||
|
||||
# Prompt with ZFS tty, otherwise
|
||||
|
||||
Reference in New Issue
Block a user