diff --git a/usr/lib/tik/lib/tik-core-helper b/usr/lib/tik/lib/tik-core-helper index fb4e6a9..a2daa9d 100644 --- a/usr/lib/tik/lib/tik-core-helper +++ b/usr/lib/tik/lib/tik-core-helper @@ -245,7 +245,7 @@ probe_partitions() { create_keyfile() { tik_keyfile=$(prun mktemp /tmp/tik.XXXXXXXXXX) log "[create_keyfile] Creating keyfile ${tik_keyfile}" - /usr/bin/base64 -w 0 /dev/urandom | head -c 1k | prun tee "${tik_keyfile}" + /usr/bin/base64 -w 0 /dev/urandom | head -c 1k | prun tee "${tik_keyfile}" >/dev/null prun /usr/bin/chmod 400 "${tik_keyfile}" tik_keyid=$(prun cat "${tik_keyfile}" | prun keyctl padd user cryptenroll @u) } diff --git a/usr/lib/tik/lib/tik-functions-helper b/usr/lib/tik/lib/tik-functions-helper index a85e3b1..bc7539a 100644 --- a/usr/lib/tik/lib/tik-functions-helper +++ b/usr/lib/tik/lib/tik-functions-helper @@ -7,15 +7,18 @@ tik_prompt_passphrase() { local title="$1" local cancel_label="${2:-Cancel}" local passphrase="" + local prompt_retval=0 if $gui; then - passphrase="$(zenity --password --title="${title}" --cancel-label="${cancel_label}")" || true + passphrase="$(zenity --password --title="${title}" --cancel-label="${cancel_label}")" || prompt_retval=$? else - cenity result --password --title="${title}" --cancel-label="${cancel_label}" || true + local result="" + cenity result --password --title="${title}" --cancel-label="${cancel_label}" || prompt_retval=$? passphrase="${result}" fi echo -n "${passphrase}" + return "${prompt_retval}" } tik_mount_prepare() { @@ -122,6 +125,7 @@ tik_crypt_open() { while true; do local pw + local prompt_retval local cancel_label="Cancel" if [ "${mode}" = "optional" ]; then @@ -129,24 +133,27 @@ tik_crypt_open() { fi pw="$(tik_prompt_passphrase "Encrypted partition (${crypt_part}) detected" "${cancel_label}")" + prompt_retval=$? - if [ -z "${pw}" ]; then + if [ "${prompt_retval}" -ne 0 ]; then if [ "${mode}" = "optional" ]; then log "[tik_crypt_open] user skipped unlocking" return 0 fi - error "Encrypted system detected but no passphrase provided" + error "Encrypted system detected but unlocking was cancelled" fi - echo -n "${pw}" | prun /usr/sbin/cryptsetup luksOpen "${crypt_byid}" "${mapper_name}" + prun-opt /usr/sbin/cryptsetup luksOpen "${crypt_byid}" "${mapper_name}" <<<"${pw}" if [ "${retval}" = "0" ]; then TIK_ROOT_DEV="/dev/mapper/${mapper_name}" export TIK_ROOT_DEV TIK_OPENED_MAPPER="${mapper_name}" export TIK_OPENED_MAPPER + log "[tik_crypt_open] successfully unlocked ${TIK_CRYPT_PART}" return 0 fi + log "[tik_crypt_open] failed to unlock ${TIK_CRYPT_PART}" d --warning --no-wrap --title="Incorrect passphrase" --text="Failed to unlock encrypted partition ${crypt_part}." done } diff --git a/usr/lib/tik/modules/pre/05-setup-gnome-env b/usr/lib/tik/modules/pre/05-setup-gnome-env index a96eb33..4fdf004 100644 --- a/usr/lib/tik/modules/pre/05-setup-gnome-env +++ b/usr/lib/tik/modules/pre/05-setup-gnome-env @@ -23,7 +23,7 @@ setup_env() { gsettings set org.gnome.software download-updates 'false' gsettings set org.gnome.software download-updates-notify 'false' # Resize btrfs to max - prun-opt btrfs filesystem resize max /var + prun-opt /usr/sbin/btrfs filesystem resize max /var } setup_env diff --git a/usr/lib/tik/modules/pre/20-mig b/usr/lib/tik/modules/pre/20-mig index c1ea37e..1aa390f 100644 --- a/usr/lib/tik/modules/pre/20-mig +++ b/usr/lib/tik/modules/pre/20-mig @@ -68,7 +68,7 @@ if [ -z "${skipbackup}" ]; then tik_progress_step "Scanning existing /home (btrfs quotas)" 10 prun-opt /usr/sbin/btrfs quota rescan -w "${TIK_ROOT_MNT}/home" >/dev/null 2>&1 if [ "${retval}" -eq 0 ]; then - home_size="$(prun-opt /usr/sbin/btrfs qgroup show --raw -f "${TIK_ROOT_MNT}/home" | awk 'NR==2{print $2}')" + home_size="$(prun-opt /usr/sbin/btrfs qgroup show --raw -f "${TIK_ROOT_MNT}/home" | awk '$1 ~ /^[0-9]+\/[0-9]+$/ {print $2; exit}')" fi else home_size="" @@ -81,14 +81,17 @@ if [ -z "${skipbackup}" ]; then fi tik_progress_step "Checking available space" 25 - tik_stick_size=$(prun /usr/sbin/btrfs fi usage --raw ${mig_dir} | grep estimated | awk '{print $3}') + tik_stick_size="$(prun /usr/bin/df --output=avail --block-size=1 "${mig_dir}" | awk 'NR==2 {print $1}')" + log "[mig] backup size check: home_size=${home_size:-unknown}, available=${tik_stick_size:-unknown}" if [ -n "${home_size}" ] && [ -n "${tik_stick_size}" ]; then if [ "${home_size}" -gt "${tik_stick_size}" ]; then # Not enough space to offer migration + log "[mig] migration disabled: /home requires ${home_size} bytes but only ${tik_stick_size} bytes are available" migrate=0 fi if [ "${home_size}" -le 16384 ]; then # /home subvolume is empty + log "[mig] migration disabled: /home appears empty (${home_size} bytes)" migrate=0 fi else