mirror of
https://github.com/Llewellynvdm/Tomb.git
synced 2024-09-24 18:59:01 +00:00
fixes to indentation and whitespace cleanup
This commit is contained in:
parent
449d6ae61a
commit
a42567432d
124
src/tomb
124
src/tomb
@ -40,43 +40,43 @@ check_bin() {
|
|||||||
# which dd command to use
|
# which dd command to use
|
||||||
which dcfldd > /dev/null
|
which dcfldd > /dev/null
|
||||||
if [ $? = 0 ]; then
|
if [ $? = 0 ]; then
|
||||||
DD="dcfldd"
|
DD="dcfldd"
|
||||||
else
|
else
|
||||||
DD=dd
|
DD=dd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# which wipe command to use
|
# which wipe command to use
|
||||||
which wipe > /dev/null
|
which wipe > /dev/null
|
||||||
if [ $? = 0 ]; then
|
if [ $? = 0 ]; then
|
||||||
WIPE=(wipe -f -s)
|
WIPE=(wipe -f -s)
|
||||||
else
|
else
|
||||||
WIPE=(rm -f)
|
WIPE=(rm -f)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# check for filesystem creation progs
|
# check for filesystem creation progs
|
||||||
which mkfs.ext4 > /dev/null
|
which mkfs.ext4 > /dev/null
|
||||||
if [ $? = 0 ]; then
|
if [ $? = 0 ]; then
|
||||||
MKFS=(mkfs.ext4 -q -F -j -L)
|
MKFS=(mkfs.ext4 -q -F -j -L)
|
||||||
else
|
else
|
||||||
MKFS=(mkfs.ext3 -q -F -j -L)
|
MKFS=(mkfs.ext3 -q -F -j -L)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# check for sudo
|
# check for sudo
|
||||||
which sudo > /dev/null
|
which sudo > /dev/null
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
error "Cannot find sudo. Please install it"
|
error "Cannot find sudo. Please install it"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# check for steghide
|
# check for steghide
|
||||||
which steghide > /dev/null
|
which steghide > /dev/null
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
STEGHIDE=0
|
STEGHIDE=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# check for tomb-open script
|
# check for tomb-open script
|
||||||
if [ "$0" = "./tomb" ]; then
|
if [ "$0" = "./tomb" ]; then
|
||||||
TOMBOPENEXEC="./tomb-open"
|
TOMBOPENEXEC="./tomb-open"
|
||||||
elif [ "$0" != "tomb" ]; then
|
elif [ "$0" != "tomb" ]; then
|
||||||
TOMBOPENEXEC="`dirname $0`/tomb-open"
|
TOMBOPENEXEC="`dirname $0`/tomb-open"
|
||||||
fi
|
fi
|
||||||
@ -130,7 +130,7 @@ exec_as_user() {
|
|||||||
check_priv() {
|
check_priv() {
|
||||||
if [ $UID != 0 ]; then
|
if [ $UID != 0 ]; then
|
||||||
func "Using sudo for root execution of 'tomb ${(f)ARGS}'"
|
func "Using sudo for root execution of 'tomb ${(f)ARGS}'"
|
||||||
# check if sudo has a timestamp active
|
# check if sudo has a timestamp active
|
||||||
sudok=false
|
sudok=false
|
||||||
sudo -n ${TOMBEXEC} 2> /dev/null
|
sudo -n ${TOMBEXEC} 2> /dev/null
|
||||||
if [ $? != 0 ]; then # if not then ask a password
|
if [ $? != 0 ]; then # if not then ask a password
|
||||||
@ -244,9 +244,9 @@ create_tomb() {
|
|||||||
tombfile=${tombname}.tomb
|
tombfile=${tombname}.tomb
|
||||||
|
|
||||||
if [ -e ${tombdir}/${tombfile} ]; then
|
if [ -e ${tombdir}/${tombfile} ]; then
|
||||||
error "tomb exists already. I'm not digging here:"
|
error "tomb exists already. I'm not digging here:"
|
||||||
ls -lh ${tombdir}/${tombfile}
|
ls -lh ${tombdir}/${tombfile}
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
notice "Creating a new tomb in ${tombdir}/${tombfile}"
|
notice "Creating a new tomb in ${tombdir}/${tombfile}"
|
||||||
@ -282,7 +282,7 @@ create_tomb() {
|
|||||||
keytmp=`safe_dir tomb`
|
keytmp=`safe_dir tomb`
|
||||||
if [ "$keytmp" = "-1" ]; then
|
if [ "$keytmp" = "-1" ]; then
|
||||||
error "error creating temp dir"
|
error "error creating temp dir"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
#rm -f $keytmp
|
#rm -f $keytmp
|
||||||
# ?????? creo, cancello e ricreo ??????
|
# ?????? creo, cancello e ricreo ??????
|
||||||
@ -346,8 +346,8 @@ create_tomb() {
|
|||||||
# fi
|
# fi
|
||||||
|
|
||||||
act "formatting Luks mapped device"
|
act "formatting Luks mapped device"
|
||||||
# we use aes-cbc-essiv with sha256
|
# we use aes-cbc-essiv with sha256
|
||||||
# for security, performance and compatibility
|
# for security, performance and compatibility
|
||||||
cryptsetup --batch-mode \
|
cryptsetup --batch-mode \
|
||||||
--cipher aes-cbc-essiv:sha256 --key-size 256 \
|
--cipher aes-cbc-essiv:sha256 --key-size 256 \
|
||||||
luksFormat ${nstloop} ${keytmp}/tomb.tmp
|
luksFormat ${nstloop} ${keytmp}/tomb.tmp
|
||||||
@ -411,7 +411,7 @@ mount_tomb() {
|
|||||||
|
|
||||||
nstloop=`losetup -f`
|
nstloop=`losetup -f`
|
||||||
if [ $? = 255 ]; then
|
if [ $? = 255 ]; then
|
||||||
error "too many tomb opened. Please close any of them to open another tomb"
|
error "too many tomb opened. Please close any of them to open another tomb"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
losetup -f ${tombdir}/${tombfile}
|
losetup -f ${tombdir}/${tombfile}
|
||||||
@ -419,7 +419,7 @@ mount_tomb() {
|
|||||||
act "check for a valid LUKS encrypted device"
|
act "check for a valid LUKS encrypted device"
|
||||||
cryptsetup isLuks ${nstloop}
|
cryptsetup isLuks ${nstloop}
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
# is it a LUKS encrypted nest? see cryptsetup(1)
|
# is it a LUKS encrypted nest? see cryptsetup(1)
|
||||||
error "$tombfile is not a valid Luks encrypted storage file"
|
error "$tombfile is not a valid Luks encrypted storage file"
|
||||||
$norm || rmdir $tombmount 2>/dev/null
|
$norm || rmdir $tombmount 2>/dev/null
|
||||||
return 1
|
return 1
|
||||||
@ -441,7 +441,7 @@ mount_tomb() {
|
|||||||
fi
|
fi
|
||||||
echo "${tombpass}" \
|
echo "${tombpass}" \
|
||||||
| gpg --batch --passphrase-fd 0 --no-tty --no-options \
|
| gpg --batch --passphrase-fd 0 --no-tty --no-options \
|
||||||
-d "${tombkey}" 2> /dev/null \
|
-d "${tombkey}" 2> /dev/null \
|
||||||
| cryptsetup --key-file - luksOpen ${nstloop} ${mapper}
|
| cryptsetup --key-file - luksOpen ${nstloop} ${mapper}
|
||||||
|
|
||||||
unset tombpass
|
unset tombpass
|
||||||
@ -484,7 +484,7 @@ encode_key() {
|
|||||||
|
|
||||||
file $tombkey | grep PGP > /dev/null
|
file $tombkey | grep PGP > /dev/null
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
error "encode failed: $tombkey is not a tomb key"
|
error "encode failed: $tombkey is not a tomb key"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
file $imagefile | grep JPEG > /dev/null
|
file $imagefile | grep JPEG > /dev/null
|
||||||
@ -603,12 +603,12 @@ exec_safe_bind_hooks() {
|
|||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
if [ "${${maps[$dir]}[1]}" = "/" -o "${${maps[$dir]}[1,2]}" = ".." ]; then
|
if [ "${${maps[$dir]}[1]}" = "/" -o "${${maps[$dir]}[1,2]}" = ".." ]; then
|
||||||
error "bind-hooks map format: local/to/tomb local/to/\$HOME. Rolling back"
|
error "bind-hooks map format: local/to/tomb local/to/\$HOME. Rolling back"
|
||||||
for dir in ${mounted}; do umount $dir; done
|
for dir in ${mounted}; do umount $dir; done
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
if [ ! -r "$HOME/${maps[$dir]}" ]; then
|
if [ ! -r "$HOME/${maps[$dir]}" ]; then
|
||||||
error "bind-hook target not existent, skipping $HOME/${maps[$dir]}"
|
error "bind-hook target not existent, skipping $HOME/${maps[$dir]}"
|
||||||
elif [ ! -r "$MOUNTPOINT/$dir" ]; then
|
elif [ ! -r "$MOUNTPOINT/$dir" ]; then
|
||||||
error "bind-hook source not found in tomb, skipping ${MOUNTPOINT}/${dir}"
|
error "bind-hook source not found in tomb, skipping ${MOUNTPOINT}/${dir}"
|
||||||
else
|
else
|
||||||
@ -691,7 +691,7 @@ umount_tomb() {
|
|||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
tombmount="$1" # argument should be the mount
|
tombmount="$1" # argument should be the mount
|
||||||
mapper=`mount | awk -vmnt="$tombmount" '/^\/dev\/mapper\/tomb/ { if($3==mnt) print $1 }'`
|
mapper=`mount | awk -vmnt="$tombmount" '/^\/dev\/mapper\/tomb/ { if($3==mnt) print $1 }'`
|
||||||
tombname="`echo $mapper | cut -d. -f2`"
|
tombname="`echo $mapper | cut -d. -f2`"
|
||||||
|
|
||||||
@ -837,7 +837,7 @@ application/x-tomb-volume:
|
|||||||
open="${TOMBOPENEXEC}" %f
|
open="${TOMBOPENEXEC}" %f
|
||||||
view=tomb-open %f
|
view=tomb-open %f
|
||||||
icon-filename=monmort.xpm
|
icon-filename=monmort.xpm
|
||||||
short_list_application_ids_for_novice_user_level=tomb
|
short_list_application_ids_for_novice_user_level=tomb
|
||||||
EOF
|
EOF
|
||||||
cat <<EOF > /usr/share/mime-info/tomb.mime
|
cat <<EOF > /usr/share/mime-info/tomb.mime
|
||||||
# mime type for encrypted tomb storage
|
# mime type for encrypted tomb storage
|
||||||
@ -845,7 +845,7 @@ application/x-tomb-volume
|
|||||||
ext: tomb
|
ext: tomb
|
||||||
|
|
||||||
application/x-tomb-key
|
application/x-tomb-key
|
||||||
ext: tomb.key
|
ext: tomb.key
|
||||||
EOF
|
EOF
|
||||||
cat <<EOF > /usr/lib/mime/packages/tomb
|
cat <<EOF > /usr/lib/mime/packages/tomb
|
||||||
application/x-tomb-volume; tomb-open '%s'; priority=8
|
application/x-tomb-volume; tomb-open '%s'; priority=8
|
||||||
@ -856,12 +856,12 @@ EOF
|
|||||||
|
|
||||||
cat <<EOF > /usr/share/application-registry/tomb.applications
|
cat <<EOF > /usr/share/application-registry/tomb.applications
|
||||||
tomb
|
tomb
|
||||||
command=tomb-open
|
command=tomb-open
|
||||||
name=Tomb - Crypto Undertaker
|
name=Tomb - Crypto Undertaker
|
||||||
can_open_multiple_files=false
|
can_open_multiple_files=false
|
||||||
expects_uris=false
|
expects_uris=false
|
||||||
requires_terminal=true
|
requires_terminal=true
|
||||||
mime-types=application/x-tomb-volume,application/x-tomb-key
|
mime-types=application/x-tomb-volume,application/x-tomb-key
|
||||||
EOF
|
EOF
|
||||||
act "Tomb is now installed."
|
act "Tomb is now installed."
|
||||||
}
|
}
|
||||||
@ -876,32 +876,32 @@ main () {
|
|||||||
|
|
||||||
OPTS=`getopt -o hvqDs:k:n -n 'tomb' -- "$@"`
|
OPTS=`getopt -o hvqDs:k:n -n 'tomb' -- "$@"`
|
||||||
while true; do
|
while true; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-h)
|
-h)
|
||||||
usage
|
usage
|
||||||
exit 0 ;;
|
exit 0 ;;
|
||||||
-v)
|
-v)
|
||||||
notice "Tomb - simple commandline tool for encrypted storage"
|
notice "Tomb - simple commandline tool for encrypted storage"
|
||||||
act "version $VERSION ($DATE) by Jaromil @ dyne.org"
|
act "version $VERSION ($DATE) by Jaromil @ dyne.org"
|
||||||
# print out the GPL license in this file
|
# print out the GPL license in this file
|
||||||
act ""
|
act ""
|
||||||
cat $0 | awk 'BEGIN { license=0 } /^# This source/ { license=1 } { if(license==1) print " " $0 }
|
cat $0 | awk 'BEGIN { license=0 } /^# This source/ { license=1 } { if(license==1) print " " $0 }
|
||||||
/MA 02139, USA.$/ { license=0 }'
|
/MA 02139, USA.$/ { license=0 }'
|
||||||
act ""
|
act ""
|
||||||
exit 0 ;;
|
exit 0 ;;
|
||||||
-q) QUIET=1; shift 1 ;;
|
-q) QUIET=1; shift 1 ;;
|
||||||
-D)
|
-D)
|
||||||
echo "[D] Tomb invoked with args \"${(f)@}\" "
|
echo "[D] Tomb invoked with args \"${(f)@}\" "
|
||||||
echo "[D] running on `date`"
|
echo "[D] running on `date`"
|
||||||
DEBUG=1; shift 1 ;;
|
DEBUG=1; shift 1 ;;
|
||||||
-s) SIZE=$2; shift 2 ;;
|
-s) SIZE=$2; shift 2 ;;
|
||||||
-k) KEY=$2; shift 2 ;;
|
-k) KEY=$2; shift 2 ;;
|
||||||
-n) NOBIND=1; shift 1 ;;
|
-n) NOBIND=1; shift 1 ;;
|
||||||
--) shift; break ;;
|
--) shift; break ;;
|
||||||
*) CMD=$1;
|
*) CMD=$1;
|
||||||
FILE=$2; MOUNT=$3; # compat with old args
|
FILE=$2; MOUNT=$3; # compat with old args
|
||||||
CMD2=${2}; CMD3=${3}; break ;;
|
CMD2=${2}; CMD3=${3}; break ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if ! [ $CMD ]; then
|
if ! [ $CMD ]; then
|
||||||
@ -912,30 +912,30 @@ main () {
|
|||||||
func "Tomb command: $CMD $CMD2 $CMD3"
|
func "Tomb command: $CMD $CMD2 $CMD3"
|
||||||
|
|
||||||
case "$CMD" in
|
case "$CMD" in
|
||||||
create) check_priv ; create_tomb ;;
|
create) check_priv ; create_tomb ;;
|
||||||
mount) check_priv ; mount_tomb ;;
|
mount) check_priv ; mount_tomb ;;
|
||||||
open) check_priv ; mount_tomb ;;
|
open) check_priv ; mount_tomb ;;
|
||||||
umount) check_priv ; umount_tomb ${CMD2} ;;
|
umount) check_priv ; umount_tomb ${CMD2} ;;
|
||||||
unmount) check_priv ; umount_tomb ${CMD2} ;;
|
unmount) check_priv ; umount_tomb ${CMD2} ;;
|
||||||
close) check_priv ; umount_tomb ${CMD2} ;;
|
close) check_priv ; umount_tomb ${CMD2} ;;
|
||||||
slam) chack_priv ; SLAM=1; umount_tomb ${CMD2} ;;
|
slam) chack_priv ; SLAM=1; umount_tomb ${CMD2} ;;
|
||||||
bury) if [ "$STEGHIDE" = 0 ]; then
|
bury) if [ "$STEGHIDE" = 0 ]; then
|
||||||
error "steghide not installed. Cannot bury your key"
|
error "steghide not installed. Cannot bury your key"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
encode_key ${CMD2} ${CMD3} ;;
|
encode_key ${CMD2} ${CMD3} ;;
|
||||||
exhume) if [ "$STEGHIDE" = 0 ]; then
|
exhume) if [ "$STEGHIDE" = 0 ]; then
|
||||||
error "steghide not installed. Cannot exhume your key"
|
error "steghide not installed. Cannot exhume your key"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
decode_key ${CMD2} ;;
|
decode_key ${CMD2} ;;
|
||||||
install) check_priv ; install_tomb ;;
|
install) check_priv ; install_tomb ;;
|
||||||
askpass) ask_password $CMD2 ;;
|
askpass) ask_password $CMD2 ;;
|
||||||
status) tomb-status ;;
|
status) tomb-status ;;
|
||||||
*) error "command \"$CMD\" not recognized"
|
*) error "command \"$CMD\" not recognized"
|
||||||
act "try -h for help"
|
act "try -h for help"
|
||||||
return 1
|
return 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user