summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2013-12-10 14:15:51 -0200
committerSilvio Rhatto <rhatto@riseup.net>2013-12-10 14:15:51 -0200
commita8c1608fee73578358c3c17f76b44f0857c38ac0 (patch)
tree0888d5264a0fc1064b4930842e69475a00850b0c /lib
parentf695f7810ac91d9cd3f576dcb58f41e75e720129 (diff)
downloadkeyringer-a8c1608fee73578358c3c17f76b44f0857c38ac0.tar.gz
keyringer-a8c1608fee73578358c3c17f76b44f0857c38ac0.tar.bz2
Integrating shell with all commands (#34)
Diffstat (limited to 'lib')
-rwxr-xr-xlib/keyringer/actions/append4
-rwxr-xr-xlib/keyringer/actions/decrypt2
-rwxr-xr-xlib/keyringer/actions/del2
-rwxr-xr-xlib/keyringer/actions/edit2
-rwxr-xr-xlib/keyringer/actions/encrypt4
-rwxr-xr-xlib/keyringer/actions/genpair2
l---------lib/keyringer/actions/help1
-rwxr-xr-xlib/keyringer/actions/ls2
-rwxr-xr-xlib/keyringer/actions/recrypt2
-rwxr-xr-xlib/keyringer/actions/shell4
-rwxr-xr-xlib/keyringer/actions/tree2
-rwxr-xr-xlib/keyringer/actions/usage2
-rwxr-xr-xlib/keyringer/functions5
13 files changed, 19 insertions, 15 deletions
diff --git a/lib/keyringer/actions/append b/lib/keyringer/actions/append
index e307056..818a7ac 100755
--- a/lib/keyringer/actions/append
+++ b/lib/keyringer/actions/append
@@ -8,7 +8,7 @@ LIB="`dirname $0`/../functions"
source "$LIB" || exit 1
# Get file
-keyringer_get_file "$2"
+keyringer_get_file "$RELATIVE_PATH/$2"
# Only display directions if we're running append, not append-batch
if [ "$BASENAME" == "append" ]; then
@@ -17,4 +17,4 @@ fi
# Append content to an existing secret
( keyringer_exec decrypt "$BASEDIR" "$FILE" && cat ) | \
- keyringer_exec encrypt-batch $BASEDIR $FILE
+ keyringer_exec encrypt-batch "$BASEDIR" "$FILE"
diff --git a/lib/keyringer/actions/decrypt b/lib/keyringer/actions/decrypt
index 2b1401c..aab7881 100755
--- a/lib/keyringer/actions/decrypt
+++ b/lib/keyringer/actions/decrypt
@@ -8,7 +8,7 @@ LIB="`dirname $0`/../functions"
source "$LIB" || exit 1
# Get file
-keyringer_get_file "$2"
+keyringer_get_file "$RELATIVE_PATH/$2"
# Decrypt
$GPG --quiet --use-agent -d "$KEYDIR/$FILE"
diff --git a/lib/keyringer/actions/del b/lib/keyringer/actions/del
index d160ac4..a2514d7 100755
--- a/lib/keyringer/actions/del
+++ b/lib/keyringer/actions/del
@@ -8,7 +8,7 @@ LIB="`dirname $0`/../functions"
source "$LIB" || exit 1
# Get file
-keyringer_get_file "$2"
+keyringer_get_file "$RELATIVE_PATH/$2"
# Set options
if [ ! -z "$3" ]; then
diff --git a/lib/keyringer/actions/edit b/lib/keyringer/actions/edit
index 9a3e488..d303bd5 100755
--- a/lib/keyringer/actions/edit
+++ b/lib/keyringer/actions/edit
@@ -8,7 +8,7 @@ LIB="`dirname $0`/../functions"
source "$LIB" || exit 1
# Get file
-keyringer_get_file "$2"
+keyringer_get_file "$RELATIVE_PATH/$2"
# Set recipients file
keyringer_set_recipients "$FILE"
diff --git a/lib/keyringer/actions/encrypt b/lib/keyringer/actions/encrypt
index 0a40bc1..526eaa1 100755
--- a/lib/keyringer/actions/encrypt
+++ b/lib/keyringer/actions/encrypt
@@ -65,7 +65,7 @@ if [ ! -z "$3" ]; then
FILE="$BASEPATH"
fi
- keyringer_get_new_file $FILE
+ keyringer_get_new_file $RELATIVE_PATH/$FILE
if [ ! -e "$UNENCRYPTED_FILE" ]; then
echo "Error: cannot encrypt $UNENCRYPTED_FILE: path not found."
@@ -74,7 +74,7 @@ if [ ! -z "$3" ]; then
else
UNENCRYPTED_FILE="-"
shift
- keyringer_get_new_file $*
+ keyringer_get_new_file $RELATIVE_PATH/$*
fi
# Set recipients file
diff --git a/lib/keyringer/actions/genpair b/lib/keyringer/actions/genpair
index f048bc7..6898b0f 100755
--- a/lib/keyringer/actions/genpair
+++ b/lib/keyringer/actions/genpair
@@ -184,7 +184,7 @@ source "$LIB" || exit 1
# Aditional parameters
KEYTYPE="$2"
-FILE="$3"
+FILE="$RELATIVE_PATH/$3"
NODE="$4"
OUTFILE="$5"
CWD="`pwd`"
diff --git a/lib/keyringer/actions/help b/lib/keyringer/actions/help
new file mode 120000
index 0000000..ae18295
--- /dev/null
+++ b/lib/keyringer/actions/help
@@ -0,0 +1 @@
+usage \ No newline at end of file
diff --git a/lib/keyringer/actions/ls b/lib/keyringer/actions/ls
index bb66263..93f5f75 100755
--- a/lib/keyringer/actions/ls
+++ b/lib/keyringer/actions/ls
@@ -15,5 +15,5 @@ shift
ARGS="`echo "$*" | sed -e "s|^/*||"`"
# Run list command
-cd "$KEYDIR" && ls $ARGS
+cd "$KEYDIR/$RELATIVE_PATH" && ls $ARGS
cd "$CWD"
diff --git a/lib/keyringer/actions/recrypt b/lib/keyringer/actions/recrypt
index 014fef7..7d5c6ae 100755
--- a/lib/keyringer/actions/recrypt
+++ b/lib/keyringer/actions/recrypt
@@ -9,7 +9,7 @@ source "$LIB" || exit 1
function keyringer_recrypt {
# Get file
- keyringer_get_file "$1"
+ keyringer_get_file "$RELATIVE_PATH/$1"
# Set recipients file
keyringer_set_recipients "$FILE"
diff --git a/lib/keyringer/actions/shell b/lib/keyringer/actions/shell
index d9a3e07..955dfe8 100755
--- a/lib/keyringer/actions/shell
+++ b/lib/keyringer/actions/shell
@@ -12,8 +12,10 @@ SHELLPATH="/"
# While a "quit" command isn't entered, read STDIN
while read -rep "keyringer:/${KEYRING}${SHELLPATH}> " STDIN; do
- if [ "$STDIN" == "quit" ]; then
+ if [ "$STDIN" == "quit" ] || [ "$STDIN" == "exit" ] || [ "$STDIN" == "bye" ]; then
break
+ elif [ "$STDIN" == "shell" ]; then
+ echo "Why you need nesting?"
elif [[ "$STDIN" == "cd"* ]]; then
# Update current path
diff --git a/lib/keyringer/actions/tree b/lib/keyringer/actions/tree
index 8e94cb0..a2e272d 100755
--- a/lib/keyringer/actions/tree
+++ b/lib/keyringer/actions/tree
@@ -27,5 +27,5 @@ else
fi
# Run list command
-cd "$KEYDIR" && $TREE $ARGS
+cd "$KEYDIR/$RELATIVE_PATH" && $TREE $ARGS
cd "$CWD"
diff --git a/lib/keyringer/actions/usage b/lib/keyringer/actions/usage
index f4ac0fa..e3369cc 100755
--- a/lib/keyringer/actions/usage
+++ b/lib/keyringer/actions/usage
@@ -7,4 +7,4 @@
LIB="`dirname $0`/../functions"
source "$LIB" || exit 1
-keyringer_usage
+keyringer_usage $KEYRING
diff --git a/lib/keyringer/functions b/lib/keyringer/functions
index bef00d9..f387c46 100755
--- a/lib/keyringer/functions
+++ b/lib/keyringer/functions
@@ -474,9 +474,10 @@ function keyringer_usage {
printf "Usage: %s <keyring> <action> [arguments]\n\n" "$BASENAME"
printf "Available commands: \n\n"
keyringer_show_actions | sed -e 's/^/\t/'
- printf "\tinit <path> [remote]\n\n" $BASENAME
- if [ ! -z "$keyrings" ]; then
+ # Display only when not in a keyring context
+ if [ ! -z "$keyrings" ] && [ -z "$1" ]; then
+ printf "\tinit <path> [remote]\n\n" $BASENAME
printf "Available keyrings: %s \n" "$keyrings"
fi
}