aboutsummaryrefslogtreecommitdiffstats
path: root/jsaccess/jstore.sh
diff options
context:
space:
mode:
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 c7f0c04..2492748 100755
--- a/jsaccess/jstore.sh
+++ b/jsaccess/jstore.sh
@@ -19,6 +19,8 @@
VERSION=0.2
+PROHIBITED_FILE_NAMES="index.html index.txt"
+
usage_exit() {
echo "jsaccess jstore.sh v$VERSION"
echo "usage: jstore.sh [-v] [action] [action arguments...] [store]"
@@ -137,17 +139,24 @@ _file_add() {
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
+ echo "CREATED file $enc_path/$enc_name"
else
- cp $clear_path $enc_path/$enc_name
+ cp $clear_path $enc_path/$clear_name
+ echo "CREATED file $enc_path/$clear_name"
fi
- echo "CREATED file $enc_path/$enc_name"
}
_file_rm() {
clear_name=$1
- __file_get_encname $clear_name
- rm $enc_path/$enc_name ||clean_exit 1
- echo "DELETED file $enc_path/$enc_name"
+ do_crypt=$2
+ if [ $do_crypt -eq 1 ]; then
+ __file_get_encname $clear_name
+ rm $enc_path/$enc_name ||clean_exit 1
+ echo "DELETED file $enc_path/$enc_name"
+ else
+ rm $enc_path/$clear_name ||clean_exit 1
+ echo "DELETED file $enc_path/$clear_name"
+ fi
}
_rset() {
@@ -180,6 +189,10 @@ action_add() {
clear_path=$1
do_crypt=$2
clear_name=`basename $clear_path`
+ [ `echo $PROHIBITED_FILE_NAMES |grep -c "\<$clear_name\>"` -ne 0 ] && \
+ echo "ERROR: file name $clear_name is prohibited, sorry" && \
+ echo -e "Prohibited names list : $PROHIBITED_FILE_NAMES" && \
+ clean_exit 1
_pass_read
_index_decrypt
if [ `egrep -c "^$clear_name .*$" $tmp` -ne 0 ]; then
@@ -201,11 +214,15 @@ action_rm() {
clear_name=$1
_pass_read
_index_decrypt
- if [ `egrep -c "^$clear_name .*$" $tmp` -eq 0 ]; then
+ index_entry=`egrep "^$clear_name .*$" $tmp 2>/dev/null`
+ if [ X"$index_entry" = X"" ]; then
echo "File does not exist for this passphrase"
clean_exit 1
fi
- _file_rm $clear_name
+ crypt=`echo $index_entry |awk '{ print $(NF) }'`
+ [ $crypt = "(nocrypt)" ] && do_crypt=0 || do_crypt=1
+ echo "XXX do_crypt=$do_crypt ($crypt)"
+ _file_rm $clear_name $do_crypt
_index_decrypt
sed -i /"^$clear_name .*$"/d $tmp
_index_encrypt