summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2016-11-09 10:27:57 -0200
committerSilvio Rhatto <rhatto@riseup.net>2016-11-09 10:27:57 -0200
commite19c2219a9a4b1962151cd886ef025826e2838c7 (patch)
tree53c4eaba89b3b564a778f4ec299b6fb19e48bf3d /lib
parent84319a2c2806f623adbff33a804a3338905ebd3e (diff)
parent321be0df19d4443a4f13ca9870782f7c4ece049f (diff)
downloadkeyringer-e19c2219a9a4b1962151cd886ef025826e2838c7.tar.gz
keyringer-e19c2219a9a4b1962151cd886ef025826e2838c7.tar.bz2
Merge tag 'upstream_keyringer_0.4.0' into debian
Upstream version 0.4.0
Diffstat (limited to 'lib')
-rwxr-xr-xlib/keyringer/actions/mv3
-rwxr-xr-xlib/keyringer/actions/sclip23
-rwxr-xr-xlib/keyringer/functions29
3 files changed, 44 insertions, 11 deletions
diff --git a/lib/keyringer/actions/mv b/lib/keyringer/actions/mv
index 2324145..e31eb85 100755
--- a/lib/keyringer/actions/mv
+++ b/lib/keyringer/actions/mv
@@ -24,5 +24,8 @@ if ! echo "$ORIG" | grep -q '*' && [ ! -e "$KEYDIR/$RELATIVE_PATH/$ORIG" ]; then
exit 1
fi
+# Ensure destination path exists
+mkdir -p "`dirname $KEYDIR/$RELATIVE_PATH/$DEST`"
+
# Run move command
keyringer_exec git "$BASEDIR" mv "keys/$RELATIVE_PATH/$ORIG" "keys/$FILE"
diff --git a/lib/keyringer/actions/sclip b/lib/keyringer/actions/sclip
new file mode 100755
index 0000000..e4c88fa
--- /dev/null
+++ b/lib/keyringer/actions/sclip
@@ -0,0 +1,23 @@
+#!/usr/bin/env bash
+#
+# Decrypt secret header to clipboard, sleep and cleanup.
+#
+
+# Load functions
+LIB="`dirname $0`/../functions"
+source "$LIB" || exit 1
+
+# Clip password
+shift
+keyringer $KEYRING xclip $*
+
+# Move to the next window
+if which xdotool &> /dev/null; then
+ xdotool key alt+Tab
+fi
+
+# Sleep
+sleep 5
+
+# Overwrite clipboard
+cat $RANDOM | sha256sum | base64 -d | xclip
diff --git a/lib/keyringer/functions b/lib/keyringer/functions
index ab519b2..09b004d 100755
--- a/lib/keyringer/functions
+++ b/lib/keyringer/functions
@@ -430,16 +430,18 @@ function keyringer_get_option {
function keyringer_get_file {
FILE="$(keyringer_filename "$RELATIVE_PATH/$1")"
- if [ -z "$FILE" ]; then
- keyringer_action_usage
- exit 1
- elif [ ! -f "$KEYDIR/$FILE" ]; then
+ if [ ! -f "$KEYDIR/$FILE" ]; then
# Try to find a similar file
+ FILE=""
count=0
candidates=(`keyringer_exec find "$BASEDIR" | grep -i "$1" | grep -e '.asc$'`)
if [ ! -z "$candidates" ]; then
- echo "Could not find exact match for \"$1\", please choose one of the following secrets:"
+ if [ ! -z "$1" ]; then
+ echo "Could not find exact match for \"$1\""
+ fi
+
+ echo "Choose one of the following or type a pattern:"
echo ""
for candidate in ${candidates[@]}; do
@@ -452,15 +454,20 @@ function keyringer_get_file {
if [[ "$option" =~ ^[0-9]+$ ]] && [ ! -z "${candidates[$option]}" ]; then
FILE="$(keyringer_filename "$RELATIVE_PATH/${candidates[$option]}")"
- else
- echo "Invalid option"
- exit 1
+ elif [ ! -z "$option" ]; then
+ keyringer_get_file $option
fi
else
- echo "File not found: $KEYDIR/$FILE"
- exit 1
+ echo "Nothing matches $option, try again."
+ keyringer_get_file
fi
fi
+
+ # Probably Ctrl-D was hit
+ if [ -z "$FILE" ]; then
+ echo ""
+ exit
+ fi
}
# Get a new file argument
@@ -473,7 +480,7 @@ function keyringer_get_new_file {
fi
# Sanitize and complete file name
- FILE="`echo $FILE | sed -e 's/[^A-Za-z0-9.\/\-]/_/g'`"
+ FILE="`echo $FILE | sed -e 's/[^A-Za-z0-9@.\/\-]/_/g'`"
# Warn user about file name change
if [ "`basename "$*"`" != "`basename $FILE`" ]; then