mirror of
https://github.com/Llewellynvdm/Tomb.git
synced 2024-11-26 14:56:33 +00:00
small fixes to tmpfile handling for key from stdin
This commit is contained in:
parent
7736cc97af
commit
772b731e5f
13
tomb
13
tomb
@ -58,6 +58,9 @@ typeset -A global_opts
|
|||||||
typeset -A opts
|
typeset -A opts
|
||||||
typeset -h username
|
typeset -h username
|
||||||
|
|
||||||
|
typeset -h tombkeydir # global used if key comes from stdin
|
||||||
|
tombkeydir=""
|
||||||
|
|
||||||
typeset -h _uid
|
typeset -h _uid
|
||||||
typeset -h _gid
|
typeset -h _gid
|
||||||
typeset -h _tty
|
typeset -h _tty
|
||||||
@ -100,7 +103,7 @@ safe_dir() {
|
|||||||
while (( $tries < 3 )) ; do
|
while (( $tries < 3 )) ; do
|
||||||
tries+=1
|
tries+=1
|
||||||
if _have_shm; then
|
if _have_shm; then
|
||||||
xxx "safe_dir creating directory in RAM"
|
xxx "safe_dir creating $1 dir in RAM"
|
||||||
if (( $MKTEMP )); then
|
if (( $MKTEMP )); then
|
||||||
mktemp -d /dev/shm/$1.$$.XXXXXXX
|
mktemp -d /dev/shm/$1.$$.XXXXXXX
|
||||||
else
|
else
|
||||||
@ -435,7 +438,6 @@ check_bin() {
|
|||||||
|
|
||||||
# {{{ Key operations
|
# {{{ Key operations
|
||||||
|
|
||||||
typeset -h tombkeydir # global used if key comes from stdin
|
|
||||||
|
|
||||||
# This function retrieves a tomb key specified on commandline or one
|
# This function retrieves a tomb key specified on commandline or one
|
||||||
# laying nearby the tomb if found, or from stdin if the option was
|
# laying nearby the tomb if found, or from stdin if the option was
|
||||||
@ -446,12 +448,14 @@ load_key() {
|
|||||||
# check if the key is set manually then use the one existing
|
# check if the key is set manually then use the one existing
|
||||||
local tombdir="$1"
|
local tombdir="$1"
|
||||||
local tombname="$2"
|
local tombname="$2"
|
||||||
|
local tombkey=""
|
||||||
if option_is_set -k ; then
|
if option_is_set -k ; then
|
||||||
if [[ "`option_value -k`" == "-" ]]; then
|
if [[ "`option_value -k`" == "-" ]]; then
|
||||||
# take key from stdin
|
# take key from stdin
|
||||||
tombkeydir=`safe_dir`
|
tombkeydir=`safe_dir tomb`
|
||||||
cat > ${tombkeydir}/stdin.tmp
|
cat > ${tombkeydir}/stdin.tmp
|
||||||
tombkey=${tombkeydir}/stdin.tmp
|
tombkey=${tombkeydir}/stdin.tmp
|
||||||
|
xxx " `ls -lh ${tombkey}`"
|
||||||
else
|
else
|
||||||
# take key from a file
|
# take key from a file
|
||||||
tombkey=`option_value -k`
|
tombkey=`option_value -k`
|
||||||
@ -1146,6 +1150,7 @@ mount_tomb() {
|
|||||||
tombname=${tombfile%%\.*}
|
tombname=${tombfile%%\.*}
|
||||||
xxx "tomb found: ${tombdir}/${tombfile}"
|
xxx "tomb found: ${tombdir}/${tombfile}"
|
||||||
|
|
||||||
|
# load_key called here
|
||||||
tombkey=`load_key ${tombdir} ${tombname}`
|
tombkey=`load_key ${tombdir} ${tombname}`
|
||||||
{ test $? = 0 } || {
|
{ test $? = 0 } || {
|
||||||
die "Aborting operations: error loading key $tombkey" }
|
die "Aborting operations: error loading key $tombkey" }
|
||||||
@ -1211,6 +1216,8 @@ mount_tomb() {
|
|||||||
get_lukskey "${tombpass}" ${tombkey} | \
|
get_lukskey "${tombpass}" ${tombkey} | \
|
||||||
cryptsetup --key-file - luksOpen ${nstloop} ${mapper}
|
cryptsetup --key-file - luksOpen ${nstloop} ${mapper}
|
||||||
|
|
||||||
|
|
||||||
|
# key dropped here
|
||||||
drop_key
|
drop_key
|
||||||
unset tombpass
|
unset tombpass
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user