From d34f168ab9e0f5a337f2153024312ba244da49c9 Mon Sep 17 00:00:00 2001 From: Laurent Ghigonis Date: Tue, 18 Jun 2013 22:18:24 +0200 Subject: jsaccess: hability to store and not encrypt some files --- jsaccess/jstore.sh | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'jsaccess/jstore.sh') diff --git a/jsaccess/jstore.sh b/jsaccess/jstore.sh index 4bb40df..72e9550 100755 --- a/jsaccess/jstore.sh +++ b/jsaccess/jstore.sh @@ -25,7 +25,8 @@ usage_exit() { echo echo "actions on local store for a given passphrase:" echo " ls [store] # default action if no arguments" - echo " add [store] # default action if one argument" + echo " add [store] # default action if one argument" + echo " add-nocrypt [store]" echo " rm [store]" echo " rmall [store]" echo @@ -126,14 +127,19 @@ __file_get_encname() { _file_add() { clear_path=$1 clear_name=$2 + do_crypt=$3 __file_get_encname $clear_name if [ ! -d $enc_path ]; then mkdir -p $enc_path touch $enc_path/index.html echo "CREATED directory $enc_path (new passphrase)" fi - base64 -w0 $clear_path > $tmp ||clean_exit 2 - echo -n $pass |openssl enc -e -a -aes-256-cbc -in $tmp -out $enc_path/$enc_name -pass stdin ||clean_exit 2 + if [ $do_crypt -eq 1 ]; then + base64 -w0 $clear_path > $tmp ||clean_exit 2 + echo -n $pass |openssl enc -e -a -aes-256-cbc -in $tmp -out $enc_path/$enc_name -pass stdin ||clean_exit 2 + else + cp $clear_path $enc_path/$enc_name + fi echo "CREATED file $enc_path/$enc_name" } @@ -172,16 +178,22 @@ action_ls() { action_add() { clear_path=$1 + do_crypt=$2 clear_name=`basename $clear_path` _pass_read _index_decrypt if [ `egrep -c "^$clear_name$" $tmp` -ne 0 ]; then - echo "File already encrypted with this passphrase" + echo "File already present with this passphrase" clean_exit 1 fi - _file_add $clear_path $clear_name + _file_add $clear_path $clear_name $do_crypt _index_decrypt - echo $clear_name >> $tmp + if [ $do_crypt -eq 0 ]; then + index_text="$clear_name (nocrypt)" + else + index_text="$clear_name (base64+aes256)" + fi + echo $index_text >> $tmp _index_encrypt } @@ -273,7 +285,12 @@ ls) add) [ $# -ne 2 -a $# -ne 3 ] && usage_exit _store_get $3 - action_add $2 + action_add $2 1 + ;; +add-nocrypt) + [ $# -ne 2 -a $# -ne 3 ] && usage_exit + _store_get $3 + action_add $2 0 ;; rm) [ $# -ne 2 -a $# -ne 3 ] && usage_exit -- cgit v1.2.3-59-g8ed1b