aboutsummaryrefslogtreecommitdiffstats
path: root/jsaccess/jstore.sh
diff options
context:
space:
mode:
authorLaurent Ghigonis <laurent@p1sec.com>2013-06-18 22:18:24 +0200
committerLaurent Ghigonis <laurent@p1sec.com>2013-06-18 22:18:24 +0200
commitd34f168ab9e0f5a337f2153024312ba244da49c9 (patch)
tree5f3e7f4280335a6a5968ba0ba94cfb8774731e52 /jsaccess/jstore.sh
parentjsaccess: select first file by default (diff)
downloadlaurent-tools-d34f168ab9e0f5a337f2153024312ba244da49c9.tar.xz
laurent-tools-d34f168ab9e0f5a337f2153024312ba244da49c9.zip
jsaccess: hability to store and not encrypt some files
Diffstat (limited to 'jsaccess/jstore.sh')
-rwxr-xr-xjsaccess/jstore.sh31
1 files changed, 24 insertions, 7 deletions
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 <file_to_share> [store] # default action if one argument"
+ echo " add <file> [store] # default action if one argument"
+ echo " add-nocrypt <file> [store]"
echo " rm <file_in_store> [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