mirror of
https://github.com/Llewellynvdm/Tomb.git
synced 2024-11-12 07:46:28 +00:00
Recover legacy code for systems using util-linux < 2.22
This commit is contained in:
parent
1e5820fbd3
commit
a5ab84fdac
46
tomb
46
tomb
@ -305,10 +305,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."
|
||||
@ -317,6 +351,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