From 60603e9479414a67f96849f99851ef2749693f49 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Tue, 10 Dec 2013 12:52:56 -0200 Subject: Initial implementation for keyringer shell (#34) --- keyringer | 1 + 1 file changed, 1 insertion(+) (limited to 'keyringer') diff --git a/keyringer b/keyringer index 11b8aa1..e65bef0 100755 --- a/keyringer +++ b/keyringer @@ -135,6 +135,7 @@ set -f export PREFERENCES="`dirname $CONFIG`/$KEYRING" export KEYRINGER_VERSION export CONFIG_VERSION +export KEYRING # Set functions location if [ -e "`dirname $(readlink -f $0)`/lib/$NAME/functions" ]; then -- cgit v1.2.3 From a8c1608fee73578358c3c17f76b44f0857c38ac0 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Tue, 10 Dec 2013 14:15:51 -0200 Subject: Integrating shell with all commands (#34) --- keyringer | 3 ++- lib/keyringer/actions/append | 4 ++-- lib/keyringer/actions/decrypt | 2 +- lib/keyringer/actions/del | 2 +- lib/keyringer/actions/edit | 2 +- lib/keyringer/actions/encrypt | 4 ++-- lib/keyringer/actions/genpair | 2 +- lib/keyringer/actions/help | 1 + lib/keyringer/actions/ls | 2 +- lib/keyringer/actions/recrypt | 2 +- lib/keyringer/actions/shell | 4 +++- lib/keyringer/actions/tree | 2 +- lib/keyringer/actions/usage | 2 +- lib/keyringer/functions | 5 +++-- 14 files changed, 21 insertions(+), 16 deletions(-) create mode 120000 lib/keyringer/actions/help (limited to 'keyringer') diff --git a/keyringer b/keyringer index e65bef0..33d19ff 100755 --- a/keyringer +++ b/keyringer @@ -131,11 +131,12 @@ ACTION="$2" # Turn off pathname expansion so expansion can work properly set -f -# Export preferences and version for other scripts +# Export globals for other scripts export PREFERENCES="`dirname $CONFIG`/$KEYRING" export KEYRINGER_VERSION export CONFIG_VERSION export KEYRING +export CONFIG # Set functions location if [ -e "`dirname $(readlink -f $0)`/lib/$NAME/functions" ]; then 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 [arguments]\n\n" "$BASENAME" printf "Available commands: \n\n" keyringer_show_actions | sed -e 's/^/\t/' - printf "\tinit [remote]\n\n" $BASENAME - if [ ! -z "$keyrings" ]; then + # Display only when not in a keyring context + if [ ! -z "$keyrings" ] && [ -z "$1" ]; then + printf "\tinit [remote]\n\n" $BASENAME printf "Available keyrings: %s \n" "$keyrings" fi } -- cgit v1.2.3 From f58aac98a069c694d2a5791eb96a7554af6b798f Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Tue, 10 Dec 2013 17:36:04 -0200 Subject: Run shell by default (#34) --- keyringer | 10 ++++++---- lib/keyringer/actions/shell | 3 +++ 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'keyringer') diff --git a/keyringer b/keyringer index 33d19ff..9c45d97 100755 --- a/keyringer +++ b/keyringer @@ -162,12 +162,14 @@ source "$LIB" || exit 1 # Setup main configuration and load preferences keyringer_config_load -if [ -z "$ACTION" ]; then +# Dispatch +if [ -z "$KEYRING" ]; then keyringer_usage exit 1 -fi - -if [ "$ACTION" == "init" ]; then +elif [ -z "$ACTION" ]; then + # Run shell if no action were given + keyringer $KEYRING shell +elif [ "$ACTION" == "init" ]; then keyringer_init $* elif keyringer_has_action "$ACTION"; then keyringer_dispatch $* diff --git a/lib/keyringer/actions/shell b/lib/keyringer/actions/shell index 955dfe8..ab170b1 100755 --- a/lib/keyringer/actions/shell +++ b/lib/keyringer/actions/shell @@ -10,6 +10,9 @@ source "$LIB" || exit 1 # Basic parameters SHELLPATH="/" +# Show usage +keyringer_usage $KEYRING + # While a "quit" command isn't entered, read STDIN while read -rep "keyringer:/${KEYRING}${SHELLPATH}> " STDIN; do if [ "$STDIN" == "quit" ] || [ "$STDIN" == "exit" ] || [ "$STDIN" == "bye" ]; then -- cgit v1.2.3 From f31528e4044e9eac74cf1b256c4c57bc3a065424 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sat, 28 Dec 2013 13:44:18 -0200 Subject: Removing trailing spaces from copyright notice --- keyringer | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'keyringer') diff --git a/keyringer b/keyringer index 9c45d97..ca47062 100755 --- a/keyringer +++ b/keyringer @@ -3,17 +3,17 @@ # Keyringer key management system. # # Copyright (C) 2010 Silvio Rhatto - rhatto at riseup.net -# +# # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published # by the Free Software Foundation, either version 3 of the License, # or any later version. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program. If not, see . # -- cgit v1.2.3 From 65f63e1b889a9f0e5e9a0b1646ddcee3b4b44242 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sat, 28 Dec 2013 13:45:27 -0200 Subject: Adds missing comments --- keyringer | 2 ++ 1 file changed, 2 insertions(+) (limited to 'keyringer') diff --git a/keyringer b/keyringer index ca47062..cc8378f 100755 --- a/keyringer +++ b/keyringer @@ -18,6 +18,7 @@ # along with this program. If not, see . # +# Initialize a new keyring function keyringer_init { BASEDIR="$3" URL="$4" @@ -104,6 +105,7 @@ function keyringer_init { fi } +# Action dispatcher function keyringer_dispatch { BASEDIR="`keyringer_config $KEYRING`" -- cgit v1.2.3 From 013726598e074399344c0bf435e057bc8049959a Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Thu, 20 Feb 2014 11:09:18 -0300 Subject: Keyringer 0.3 --- ChangeLog | 4 +--- keyringer | 2 +- share/man/keyringer.1 | 55 ++++++++++++++++++++++++++++++++++++++++++++++ share/man/keyringer.1.mdwn | 5 ++++- 4 files changed, 61 insertions(+), 5 deletions(-) (limited to 'keyringer') diff --git a/ChangeLog b/ChangeLog index 16617c9..e7f7cf7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,4 @@ -2014-02-19 - Silvio Rhatto +2014-02-20 - 0.3 - Silvio Rhatto Try to find a similar file at keyringer_get_file @@ -12,8 +12,6 @@ Support for RELATIVE_FOLDER at git action -2013-12-10 - Silvio Rhatto - New actions: shell (#34), help, mkdir, teardown 2013-11-26 - 0.2.9 Silvio Rhatto diff --git a/keyringer b/keyringer index cc8378f..0930637 100755 --- a/keyringer +++ b/keyringer @@ -122,7 +122,7 @@ function keyringer_dispatch { # Config NAME="keyringer" -KEYRINGER_VERSION="0.2.9" +KEYRINGER_VERSION="0.3" CONFIG_VERSION="0.1" CONFIG_BASE="$HOME/.$NAME" CONFIG="$CONFIG_BASE/config" diff --git a/share/man/keyringer.1 b/share/man/keyringer.1 index c0fed1c..8402b9c 100644 --- a/share/man/keyringer.1 +++ b/share/man/keyringer.1 @@ -31,6 +31,11 @@ and other read/write operations on secrets. Configuration actions, handling repository metadata. .SH REPOSITORY LOOKUP AND MANIPULATION ACTIONS .TP +.B find <\f[I]expression\f[]> +Find secrets in the repository. +.RS +.RE +.TP .B init <\f[I]path\f[]> [\f[I]remote\f[]] Initialize a new keyringer repository. If a \f[I]remote\f[] URL is specified, keyringer will clone an existing @@ -60,6 +65,16 @@ command. .RS .RE .TP +.B mkdir <\f[I]path\f[]> +Create a directory inside the repository \f[I]keys\f[] folder. +.RS +.RE +.TP +.B :rmdir <\f[I]path\f[]> +Remove an empty folder inside the repository \f[I]keys\f[] folder. +.RS +.RE +.TP .B tree <\f[I]path\f[]> List contents from the toplevel repository \f[I]keys\f[] folder or from relative paths if \f[I]path\f[] is specified using a tree-like format. @@ -67,6 +82,25 @@ Like the ls wrapper, this is a wrapper around the \f[I]TREE(1)\f[] command. .RS .RE +.TP +.B shell +Run keyringer on interactive mode from a built-in command-line prompt +where all other actions can be called and are operated from the current +selected keyring. +.RS +.PP +An additional "cd" internal command is available for directory +navigation. +.PP +All <\f[I]secret\f[]> parameters from actions invoked from the shell are +called relatively from the current selected directory. +.RE +.TP +.B teardown +Remove permanently a local copy of a repository, very dangerous if you +have just a single copy. +.RS +.RE .SH SECRET MANIPULATION ACTIONS .PP All secret manipulation actions operate upon a \f[I]secret\f[] which is @@ -115,6 +149,11 @@ Alias for \f[I]del\f[] action. .RS .RE .TP +.B mv <\f[I]secret\f[]> <\f[I]dest\f[]> +Rename a secret. +.RS +.RE +.TP .B edit <\f[I]secret\f[]> Edit a secret by temporarily decrypting it, opening the decrypted copy into the text editor defined by the \f[I]$EDITOR\f[] environment @@ -162,6 +201,17 @@ If no \f[I]secret\f[] is given, all secrets in the repository are re-encrypted. .RS .RE +.TP +.B clip <\f[I]secret\f[]> +Copy the first line of a secret to the clipboard, following +password-store convention. +.RS +.RE +.TP +.B xclip <\f[I]secret\f[]> +Alis to clip action. +.RS +.RE .SH CONFIGURATION ACTIONS .TP .B commands @@ -200,6 +250,11 @@ Show keyringer usage information. .RS .RE .TP +.B help +Alias for usage action. +.RS +.RE +.TP .B recipients <\f[I]ls\f[]|\f[I]edit\f[]> <\f[I]recipients-file\f[]> List, create or edit recipients configuration. .RS diff --git a/share/man/keyringer.1.mdwn b/share/man/keyringer.1.mdwn index ccaabdf..e8df829 100644 --- a/share/man/keyringer.1.mdwn +++ b/share/man/keyringer.1.mdwn @@ -150,9 +150,12 @@ recrypt <*secret*> into the recipient configuration. If no *secret* is given, all secrets in the repository are re-encrypted. -clip <*secret*>, xclip <*secret*> +clip <*secret*> : Copy the first line of a secret to the clipboard, following password-store convention. +xclip <*secret*> +: Alis to clip action. + # CONFIGURATION ACTIONS commands -- cgit v1.2.3