mirror of
https://github.com/Llewellynvdm/Tomb.git
synced 2024-11-23 04:52:08 +00:00
Simplify patch
This commit is contained in:
parent
a5ab84fdac
commit
02dead6c9d
45
tomb
45
tomb
@ -282,8 +282,15 @@ _tmp_create() {
|
|||||||
# Return 0 if it is an encrypted block device
|
# Return 0 if it is an encrypted block device
|
||||||
_is_encrypted_block() {
|
_is_encrypted_block() {
|
||||||
local b=$1 # Path to a block device
|
local b=$1 # Path to a block device
|
||||||
|
local s="" # lsblk option -s (if available)
|
||||||
|
|
||||||
sudo lsblk -s -o TYPE -n $b 2>/dev/null \
|
# Issue #163
|
||||||
|
# lsblk --inverse appeared in util-linux 2.22
|
||||||
|
# but --version is not consistent...
|
||||||
|
lsblk --help | grep -q '\-\-inverse'
|
||||||
|
[[ $? -eq 0 ]] && s="--inverse"
|
||||||
|
|
||||||
|
sudo lsblk $s -o type -n $b 2>/dev/null \
|
||||||
| egrep -q '^crypt$'
|
| egrep -q '^crypt$'
|
||||||
|
|
||||||
return $?
|
return $?
|
||||||
@ -306,42 +313,11 @@ _ensure_safe_swap() {
|
|||||||
|
|
||||||
_message "An active swap partition is detected..."
|
_message "An active swap partition is detected..."
|
||||||
|
|
||||||
# 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
|
if [[ $? -eq 0 ]]; then
|
||||||
for s in $=swaps; do
|
for s in $=swaps; do
|
||||||
{ _is_encrypted_block $s } \
|
{ _is_encrypted_block $s } \
|
||||||
&& { r=2 } || { r=1; break }
|
&& { r=2 } || { r=1; break }
|
||||||
done
|
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
|
fi
|
||||||
|
|
||||||
if [[ $r -eq 2 ]]; then
|
if [[ $r -eq 2 ]]; then
|
||||||
@ -350,11 +326,8 @@ _ensure_safe_swap() {
|
|||||||
_warning "This poses a security risk."
|
_warning "This poses a security risk."
|
||||||
_warning "You can deactivate all swap partitions using the command:"
|
_warning "You can deactivate all swap partitions using the command:"
|
||||||
_warning " swapoff -a"
|
_warning " swapoff -a"
|
||||||
|
_warning "[#163] I may not detect plain swaps on an encrypted volume."
|
||||||
_warning "But if you want to proceed like this, use the -f (force) flag."
|
_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
|
fi
|
||||||
return $r
|
return $r
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user