commit 127919f664f6131e0db15e92922ce683c07658b4 parent 2442a0eeb6436f0db82134ddc377b7170f599e99 Author: lash <dev@holbrook.no> Date: Wed, 5 Oct 2022 15:32:28 +0000 Use tmpfiles to avoid corruption of input and output data Diffstat:
M | clortho.sh | | | 16 | +++++++++++----- |
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/clortho.sh b/clortho.sh @@ -55,23 +55,29 @@ hash_key() { } do_set_ccrypt() { - vc=$(echo -n $vp | ccrypt -k $passfile) + echo -n "$vp" > $t + ccrypt -k $passfile $t if [ "$?" -gt "0" ]; then >&2 echo set key fail exit 1 fi hash_key - echo -n $vc > $data_dir/$kc + cp $t.cpt $data_dir/$kc + shred $t.cpt } do_get_ccrypt() { hash_key - #vp=$(ccrypt -k $passfile $data_dir/$kc 2> /dev/null) - vp=$(ccrypt -k $passfile $data_dir/$kc -c) + cp $data_dir/$kc $t if [ "$?" -gt "0" ]; then exit 1; fi - echo $vp + ccrypt -d -k $passfile $t + if [ "$?" -gt "0" ]; then + exit 1; + fi + cat $t + shred $t } do_${mode}_$(basename ${cryptbin})