mirror of
https://github.com/Llewellynvdm/Tomb.git
synced 2024-11-10 23:20:57 +00:00
Shorten check_bin
Squashed commit of the following: commit 7c393ed0a0c8412203a6ee0ee5455f3008381da4 Author: hellekin <hellekin@cepheide.org> Date: Thu Dec 1 20:25:53 2011 +0100 use string tokenizer for mkfs too commit f37de5beae6b92af2834cd56b5109076693d3145 Author: hellekin <hellekin@cepheide.org> Date: Thu Dec 1 20:20:08 2011 +0100 use string tokenizer for wipe, not array commit fa035bfab1d7d1682d4edf2f6430f7da4483a3f3 Author: hellekin <hellekin@cepheide.org> Date: Thu Dec 1 20:18:46 2011 +0100 Shorten check_bin
This commit is contained in:
parent
10ea863c0a
commit
7aff877fda
87
src/tomb
87
src/tomb
@ -46,6 +46,7 @@ PATH=/sbin:/bin:/usr/sbin:/usr/bin
|
|||||||
# PATH=/usr/bin:/usr/sbin:/bin:/sbin
|
# PATH=/usr/bin:/usr/sbin:/bin:/sbin
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ HELPER FUNCTIONS
|
# {{{ HELPER FUNCTIONS
|
||||||
|
|
||||||
# {{{ - Standard output message routines
|
# {{{ - Standard output message routines
|
||||||
|
|
||||||
function _msg() {
|
function _msg() {
|
||||||
@ -115,57 +116,28 @@ function _failure die()
|
|||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ - CHECK BINARY DEPENDENCIES
|
# {{{ - CHECK BINARY DEPENDENCIES
|
||||||
|
|
||||||
check_bin() {
|
check_bin() {
|
||||||
|
# check for required programs
|
||||||
|
for req in cryptsetup pinentry sudo; do
|
||||||
|
which $req >/dev/null || die "Cannot find $req. Please install it." 1
|
||||||
|
done
|
||||||
|
|
||||||
# which dd command to use
|
# which dd command to use
|
||||||
which dcfldd > /dev/null
|
which dcfldd > /dev/null && DD=dcfldd || DD=dd
|
||||||
if [ $? = 0 ]; then
|
|
||||||
DD="dcfldd"
|
|
||||||
else
|
|
||||||
DD=dd
|
|
||||||
fi
|
|
||||||
|
|
||||||
# which wipe command to use
|
# which wipe command to use
|
||||||
which wipe > /dev/null
|
which wipe > /dev/null && WIPE="wipe -f -s" || WIPE="rm -f"
|
||||||
if [ $? = 0 ]; then
|
|
||||||
WIPE=(wipe -f -s)
|
|
||||||
else
|
|
||||||
WIPE=(rm -f)
|
|
||||||
fi
|
|
||||||
|
|
||||||
# check for filesystem creation progs
|
# check for filesystem creation progs
|
||||||
which mkfs.ext4 > /dev/null
|
which mkfs.ext4 > /dev/null && \
|
||||||
if [ $? = 0 ]; then
|
MKFS="mkfs.ext4 -q -F -j -L" || \
|
||||||
MKFS=(mkfs.ext4 -q -F -j -L)
|
MKFS="mkfs.ext3 -q -F -j -L"
|
||||||
else
|
|
||||||
MKFS=(mkfs.ext3 -q -F -j -L)
|
|
||||||
fi
|
|
||||||
|
|
||||||
# check for sudo
|
|
||||||
which sudo > /dev/null
|
|
||||||
if [ $? != 0 ]; then
|
|
||||||
die "Cannot find sudo. Please install it"
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
# check for mktemp
|
||||||
|
which mktemp > /dev/null || MKTEMP=0
|
||||||
# check for steghide
|
# check for steghide
|
||||||
which steghide > /dev/null
|
which steghide > /dev/null || STEGHIDE=0
|
||||||
if [ $? != 0 ]; then
|
|
||||||
STEGHIDE=0
|
|
||||||
fi
|
|
||||||
|
|
||||||
which cryptsetup > /dev/null
|
|
||||||
if [ $? != 0 ]; then
|
|
||||||
die "Cannot find cryptsetup. Please install it." 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
which pinentry > /dev/null
|
|
||||||
if [ $? != 0 ]; then
|
|
||||||
die "Cannot find pinentry. Please install it." 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
which mktemp > /dev/null
|
|
||||||
if [ $?! = 0 ]; then
|
|
||||||
MKTEMP=0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# check for tomb-open script
|
# check for tomb-open script
|
||||||
if [ "$0" = "./tomb" ]; then
|
if [ "$0" = "./tomb" ]; then
|
||||||
@ -174,6 +146,7 @@ check_bin() {
|
|||||||
TOMBOPENEXEC="`dirname $0`/tomb-open"
|
TOMBOPENEXEC="`dirname $0`/tomb-open"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ - "SAFE" FUNCTIONS
|
# {{{ - "SAFE" FUNCTIONS
|
||||||
# {{{ - Create a directory with caution
|
# {{{ - Create a directory with caution
|
||||||
@ -555,6 +528,7 @@ exec_safe_post_hooks() {
|
|||||||
}
|
}
|
||||||
# }}}
|
# }}}
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ TOMB SUB-COMMANDS
|
# {{{ TOMB SUB-COMMANDS
|
||||||
|
|
||||||
@ -708,14 +682,14 @@ create_tomb() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
cryptsetup --key-file ${keytmp}/tomb.tmp --cipher aes luksOpen ${nstloop} tomb.tmp
|
cryptsetup --key-file ${keytmp}/tomb.tmp --cipher aes luksOpen ${nstloop} tomb.tmp
|
||||||
${WIPE[@]} ${keytmp}/tomb.tmp
|
${=WIPE} ${keytmp}/tomb.tmp
|
||||||
umount ${keytmp}
|
umount ${keytmp}
|
||||||
rm -r ${keytmp}
|
rm -r ${keytmp}
|
||||||
|
|
||||||
# cryptsetup luksDump ${nstloop}
|
# cryptsetup luksDump ${nstloop}
|
||||||
|
|
||||||
_message "formatting your Tomb with Ext3/Ext4 filesystem"
|
_message "formatting your Tomb with Ext3/Ext4 filesystem"
|
||||||
${MKFS} ${tombname} /dev/mapper/tomb.tmp
|
${=MKFS} ${tombname} /dev/mapper/tomb.tmp
|
||||||
|
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
_warning "Tomb format returned an error:"
|
_warning "Tomb format returned an error:"
|
||||||
@ -852,7 +826,7 @@ mount_tomb() {
|
|||||||
|
|
||||||
# if key was from stdin delete temp file and dir
|
# if key was from stdin delete temp file and dir
|
||||||
if [ $tombkeydir ]; then
|
if [ $tombkeydir ]; then
|
||||||
${WIPE[@]} ${tombkey}
|
${=WIPE} ${tombkey}
|
||||||
rmdir $tombkeydir
|
rmdir $tombkeydir
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -1048,6 +1022,7 @@ umount_tomb() {
|
|||||||
# }}}
|
# }}}
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ - Change Password
|
# {{{ - Change Password
|
||||||
|
|
||||||
# change tomb key password
|
# change tomb key password
|
||||||
change_passwd() {
|
change_passwd() {
|
||||||
if ! option_is_set --ignore-swap && [[ `check_swap out` == 1 ]]; then
|
if ! option_is_set --ignore-swap && [[ `check_swap out` == 1 ]]; then
|
||||||
@ -1096,8 +1071,8 @@ change_passwd() {
|
|||||||
if [ "$tombpass" != "ok" ]; then
|
if [ "$tombpass" != "ok" ]; then
|
||||||
_warning "You typed an Invalid old password. Operation aborted."
|
_warning "You typed an Invalid old password. Operation aborted."
|
||||||
# /dev/null because the file cannot exists
|
# /dev/null because the file cannot exists
|
||||||
${WIPE[@]} "${tmpnewkey}" 2> /dev/null
|
${=WIPE} "${tmpnewkey}" 2> /dev/null
|
||||||
${WIPE[@]} "${tmpoldkey}" 2> /dev/null
|
${=WIPE} "${tmpoldkey}" 2> /dev/null
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -1120,8 +1095,8 @@ change_passwd() {
|
|||||||
if [ -z $tombpass ]; then
|
if [ -z $tombpass ]; then
|
||||||
_warning "You mistyped the new password. Operation aborted."
|
_warning "You mistyped the new password. Operation aborted."
|
||||||
# /dev/null because the file cannot exists
|
# /dev/null because the file cannot exists
|
||||||
${WIPE[@]} "${tmpnewkey}" 2> /dev/null
|
${=WIPE} "${tmpnewkey}" 2> /dev/null
|
||||||
${WIPE[@]} "${tmpoldkey}" 2> /dev/null
|
${=WIPE} "${tmpoldkey}" 2> /dev/null
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -1132,25 +1107,26 @@ change_passwd() {
|
|||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
_warning "Cannot change your key passphrase"
|
_warning "Cannot change your key passphrase"
|
||||||
# /dev/null because the file cannot exists
|
# /dev/null because the file cannot exists
|
||||||
${WIPE[@]} "${tmpnewkey}" 2> /dev/null
|
${=WIPE} "${tmpnewkey}" 2> /dev/null
|
||||||
${WIPE[@]} "${tmpoldkey}" 2> /dev/null
|
${=WIPE} "${tmpoldkey}" 2> /dev/null
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# wipe the previous, original, key
|
# wipe the previous, original, key
|
||||||
${WIPE[@]} "${keyfile}"
|
${=WIPE} "${keyfile}"
|
||||||
# copy the new key as the original keyfile name
|
# copy the new key as the original keyfile name
|
||||||
cp "${tmpnewkey}" "${keyfile}"
|
cp "${tmpnewkey}" "${keyfile}"
|
||||||
|
|
||||||
_message "Cleaning environment"
|
_message "Cleaning environment"
|
||||||
# wipe all temp file
|
# wipe all temp file
|
||||||
${WIPE[@]} "${tmpnewkey}"
|
${=WIPE} "${tmpnewkey}"
|
||||||
${WIPE[@]} "${tmpoldkey}"
|
${=WIPE} "${tmpoldkey}"
|
||||||
|
|
||||||
_success "Your passphrase was successfully updated."
|
_success "Your passphrase was successfully updated."
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ - List
|
# {{{ - List
|
||||||
# list all tombs mounted in a readable format
|
# list all tombs mounted in a readable format
|
||||||
@ -1589,3 +1565,4 @@ if [[ $? != 0 ]]; then #this "if" seems useless, but avoid source tomb source fr
|
|||||||
exit $?
|
exit $?
|
||||||
fi
|
fi
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user