+2017-05-26 - develop - Silvio Rhatto <rhatto@riseup.net>
+
+ Do not abort when keys are expired on actions that are
+ not supposed to write in the database (#72)
+
2017-01-15 - develop - Silvio Rhatto <rhatto@riseup.net>
Adds "delete" alias to "del" action.
# Load functions
LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" readwrite $* || exit 1
+exit
# Get file
keyringer_get_file "$2"
# Load functions
LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" maintenance $* || exit 1
# The following should run automatically from keyringer_check_recipients
# and keyringer_check_repository:
# Load functions
LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" maintenance $* || exit 1
# Dispatch
keyringer_show_actions
# Load functions
LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" maintenance $* || exit 1
# Fix positional arguments
shift
# Load functions
LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" maintenance $* || exit 1
# Aditional parameters
CWD="`pwd`"
# Load functions
LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" read $* || exit 1
# Get file
keyringer_get_file "$2"
# Load functions
LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" maintenance $* || exit 1
# Get file
keyringer_get_file "$2"
#!/usr/bin/env bash
#
-# Edit keys.
+# Edit secrets
#
# Load functions
LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" readwrite $* || exit 1
# Get file
keyringer_get_file "$2"
# Load functions
LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" write $* || exit 1
# Usage
function keyringer_usage_encrypt {
# Load functions
LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" maintenance $* || exit 1
# Aditional parameters
CWD="`pwd`"
# Load functions
LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" write $* || exit 1
# Aditional parameters
KEYTYPE="$2"
# Load functions
LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" maintenance $* || exit 1
# Aditional parameters
CWD="`pwd`"
# Load functions
LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" maintenance $* || exit 1
# Aditional parameters
CWD="`pwd`"
# Load functions
LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" maintenance $* || exit 1
# Aditional parameters
CWD="`pwd`"
# Load functions
LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" maintenance $* || exit 1
# Avoid leading slash
ORIG="$(keyringer_filename `echo "$2" | sed -e "s|^/*||"`)"
# Load functions
LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" maintenance $* || exit 1
# Command parser
keyringer_get_command "$2"
# Load functions
LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" maintenance $* || exit 1
# Options
COMMAND="$2"
# Load functions
LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" write $* || exit 1
# Parameters
SIZE="$3"
# Load functions
LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" maintenance $* || exit 1
# Command parser
keyringer_get_command "$2"
# Load functions
LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" readwrite $* || exit 1
# Recrypt a single secret
function keyringer_recrypt {
# Load functions
LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" maintenance $* || exit 1
# Aditional parameters
CWD="`pwd`"
# Load functions
LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" read $* || exit 1
# Clip password
shift
# Load functions
LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" maintenance $* || exit 1
# Basic parameters
SHELLPATH="/"
# Load functions
LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" maintenance $* || exit 1
# Options
CONFIRM="$2"
# Load functions
LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" maintenance $* || exit 1
# Aditional parameters
CWD="`pwd`"
# Load functions
LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" maintenance $* || exit 1
# Dispatch
keyringer_usage $KEYRING
# Load functions
LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" read $* || exit 1
# Check for xclip
if ! which xclip &> /dev/null; then
exit 1
fi
+ # The first argument tells what the action plans to do with the
+ # keyring database: either read, write, readwrite or maintenance.
+ if [ "$1" != "read" ] && [ "$1" != "write" ] && [ "$1" != "readwrite" ] && [ "$1" != "maintenance" ]; then
+ echo "Error: first keyringer_set_env argument must be either read, write or readwrite"
+ exit 1
+ fi
+
ACTIONS="`dirname $0`"
BASENAME="`basename $0`"
- BASEDIR="$1"
- SUBCOMMAND="$2"
+ KEYRINGER_MODE="$1"
+ BASEDIR="$2"
+ SUBCOMMAND="$3"
KEYDIR="$BASEDIR/keys"
RECIPIENTS_BASE="config/recipients"
RECIPIENTS="$BASEDIR/$RECIPIENTS_BASE"
sed -i -e 's/ XXXXXXXX$/ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/' "$RECIPIENTS"/*
fi
- if [ "$1" == "edit" ]; then
- # Don't do the other checks at edit mode.
- return
- fi
+ #if [ "$1" == "edit" ]; then
+ # # Don't do the other checks at edit mode.
+ # return
+ #fi
for recipient in $(cat "$RECIPIENTS"/* | grep -v '^#' | awk '{ print $2 }'); do
# Process a recipient just once
# Check if key is expired
if [ ! -z "$expiry" ] && [[ "$seconds" -gt "$expiry" ]]; then
- echo "Fatal: primary key for $recipient expired on `date --date="@$expiry"`"
- exit 1
+ echo -n "Warning: primary key for $recipient expired on `date --date="@$expiry"`"
+
+ if [ "$KEYRINGER_MODE" == "write" ] || [ "$KEYRINGER_MODE" == "readwrite" ]; then
+ echo ", aborting."
+ exit 1
+ fi
+
+ echo ""
+ return 1
fi
# Check if key is about to expire
# All subkeys are expired
if [ ! -z "$subkey" ] && [ "$not_expired" != "1" ]; then
- echo "Fatal: key $recipient has no keys suitable for encryption: all subkeys expired."
- exit 1
+ echo -n "Warning: key $recipient has no keys suitable for encryption: all subkeys expired."
+
+ if [ "$KEYRINGER_MODE" == "write" ] || [ "$KEYRINGER_MODE" == "readwrite" ]; then
+ echo ", aborting."
+ exit 1
+ fi
+
+ echo ""
+ return 1
fi
}