Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion usr/lib/tik/lib/tik-core-helper
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
17 changes: 12 additions & 5 deletions usr/lib/tik/lib/tik-functions-helper
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -122,31 +125,35 @@ tik_crypt_open() {

while true; do
local pw
local prompt_retval
local cancel_label="Cancel"

if [ "${mode}" = "optional" ]; then
cancel_label="Skip"
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
}
Expand Down
2 changes: 1 addition & 1 deletion usr/lib/tik/modules/pre/05-setup-gnome-env
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 5 additions & 2 deletions usr/lib/tik/modules/pre/20-mig
Original file line number Diff line number Diff line change
Expand Up @@ -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=""
Expand All @@ -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
Expand Down