summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rwxr-xr-xlib/keyringer/actions/encrypt22
-rwxr-xr-xlib/keyringer/functions14
2 files changed, 27 insertions, 9 deletions
diff --git a/lib/keyringer/actions/encrypt b/lib/keyringer/actions/encrypt
index 6b9c061..d9d8f96 100755
--- a/lib/keyringer/actions/encrypt
+++ b/lib/keyringer/actions/encrypt
@@ -7,11 +7,27 @@
LIB="`dirname $0`/../functions"
source "$LIB" || exit 1
+# Usage
+function keyringer_usage_encrypt {
+ echo "Usage: keyringer <keyring> $BASENAME <secret> [file]"
+}
+
+# Alias for keyringer_usage_encrypt
+function keyringer_usage_encrypt_batch {
+ keyringer_usage_encrypt $*
+}
+
+# Usage
+if [ -z "$2" ]; then
+ keyringer_action_usage
+ exit 1
+fi
+
# Aditional parameters
if [ ! -z "$3" ]; then
- shift 1
+ keyringer_get_new_file $2
+ shift 2
UNENCRYPTED_FILE="$*"
- keyringer_get_new_file $*
if [ ! -f "$UNENCRYPTED_FILE" ]; then
echo "Error: cannot encrypt $UNENCRYPTED_FILE: file not found."
@@ -45,7 +61,7 @@ if [ "$err" != "0" ]; then
fi
if [ "$UNENCRYPTED_FILE" != "-" ]; then
- echo "Now make to wipe the non-encrypted $UNENCRYPTED_FILE."
+ echo "Done. PLEASE WIPE the non-encrypted $UNENCRYPTED_FILE."
fi
# Stage
diff --git a/lib/keyringer/functions b/lib/keyringer/functions
index 67b5122..bf2977d 100755
--- a/lib/keyringer/functions
+++ b/lib/keyringer/functions
@@ -347,14 +347,16 @@ function keyringer_get_new_file {
fi
# Sanitize and complete file name
- FILE="`echo $FILE | sed -e s/[^A-Za-z0-9.\/]/_/g`"
- FILE="$(keyringer_filename "$FILE")"
+ FILE="`echo $FILE | sed -e s/[^A-Za-z0-9.\/\-]/_/g`"
- # Warn user about file name change:w
- if [ "`basename "$*"`" != "$FILE" ]; then
+ # Warn user about file name change
+ if [ "`basename $*`" != "`basename $FILE`" ]; then
echo "Sanitizing destination filename to `basename $FILE`"
fi
-
+
+ # Complete file name
+ FILE="$(keyringer_filename "$FILE")"
+
if [ -z "$*" ]; then
keyringer_action_usage
exit 1
@@ -365,7 +367,7 @@ function keyringer_get_new_file {
function keyringer_get_command {
# Aditional parameters
COMMAND="$1"
-
+
if [ -z "$COMMAND" ]; then
keyringer_action_usage command
exit 1