mirror of
https://github.com/Llewellynvdm/Tomb.git
synced 2024-12-23 02:28:58 +00:00
Recover legacy code for systems using util-linux < 2.22
This commit is contained in:
parent
de418d00c9
commit
e4afe6aefa
46
tomb
46
tomb
@ -306,10 +306,44 @@ _ensure_safe_swap() {
|
||||
[[ -z "$swaps" ]] && return 0 # No swap partition is active
|
||||
|
||||
_message "An active swap partition is detected..."
|
||||
for s in $=swaps; do
|
||||
{ _is_encrypted_block $s } \
|
||||
&& { r=2 } || { r=1; break }
|
||||
done
|
||||
|
||||
# Issue #163
|
||||
# lsblk --inverse appeared in util-linux 2.22
|
||||
# but --version is not consistent...
|
||||
local bug_163=0
|
||||
lsblk --help | grep -q '\-\-inverse'
|
||||
if [[ $? -eq 0 ]]; then
|
||||
for s in $=swaps; do
|
||||
{ _is_encrypted_block $s } \
|
||||
&& { r=2 } || { r=1; break }
|
||||
done
|
||||
else
|
||||
# Use legacy code that does not detect plain swaps on
|
||||
# encrypted volumes. On such systems -f must be used.
|
||||
bug_163=1
|
||||
for s in $=swaps; do
|
||||
bone=$(sudo file $s)
|
||||
if [[ "$bone" =~ "swap file" ]]; then
|
||||
# It's a regular (unencrypted) swap file
|
||||
r=1
|
||||
break
|
||||
|
||||
elif [[ "$bone" =~ "symbolic link" ]]; then
|
||||
# Might link to a block
|
||||
r=1
|
||||
[[ "/dev/mapper" == "${s%/*}" ]] || { break }
|
||||
is_crypt=$(sudo dmsetup status "$s" | awk '/crypt/ {print $3}')
|
||||
[[ $is_crypt == "crypt" ]] && { r=2 }
|
||||
|
||||
elif [[ "$bone" =~ "block special" ]]; then
|
||||
# It's a block
|
||||
r=1
|
||||
is_crypt=`sudo dmsetup status "$s" | awk '/crypt/ {print $3}'`
|
||||
[[ $is_crypt == "crypt" ]] && { r=2 } || { break }
|
||||
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ $r -eq 2 ]]; then
|
||||
_success "All your swaps are belong to crypt. Good."
|
||||
@ -318,6 +352,10 @@ _ensure_safe_swap() {
|
||||
_warning "You can deactivate all swap partitions using the command:"
|
||||
_warning " swapoff -a"
|
||||
_warning "But if you want to proceed like this, use the -f (force) flag."
|
||||
if [[ $bug_163 -eq 1 ]]; then
|
||||
_warning "[#163] I cannot detect plain swaps on an encrypted volume."
|
||||
_warning "[#163] Use -f, or upgrade util-linux to 2.22+."
|
||||
fi
|
||||
fi
|
||||
return $r
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user