]> gitweb.fluxo.info Git - keyringer.git/commitdiff
Do not abort when keys are expired on some actions (#72)
authorSilvio Rhatto <rhatto@riseup.net>
Fri, 26 May 2017 20:52:59 +0000 (17:52 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Fri, 26 May 2017 20:52:59 +0000 (17:52 -0300)
29 files changed:
ChangeLog
lib/keyringer/actions/append
lib/keyringer/actions/check
lib/keyringer/actions/commands
lib/keyringer/actions/commit
lib/keyringer/actions/cp
lib/keyringer/actions/decrypt
lib/keyringer/actions/del
lib/keyringer/actions/edit
lib/keyringer/actions/encrypt
lib/keyringer/actions/find
lib/keyringer/actions/genkeys
lib/keyringer/actions/git
lib/keyringer/actions/ls
lib/keyringer/actions/mkdir
lib/keyringer/actions/mv
lib/keyringer/actions/options
lib/keyringer/actions/preferences
lib/keyringer/actions/pwgen
lib/keyringer/actions/recipients
lib/keyringer/actions/recrypt
lib/keyringer/actions/rmdir
lib/keyringer/actions/sclip
lib/keyringer/actions/shell
lib/keyringer/actions/teardown
lib/keyringer/actions/tree
lib/keyringer/actions/usage
lib/keyringer/actions/xclip
lib/keyringer/functions

index ff881b8f1ecf22b6f81074f73650d28365a3236d..430f909d42667d2bd5990c430ed8e0ee1316a0a8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+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.
index df21e03ed845124f6b26c769f753f4a28e6ce91e..905867a976fedd741392d7b225983fcc3a32eef3 100755 (executable)
@@ -5,7 +5,8 @@
 
 # Load functions
 LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" readwrite $* || exit 1
+exit
 
 # Get file
 keyringer_get_file "$2"
index a647e95e4a0f2e20e9a4217912589a0b32e3b9d3..872238177c87366d7fb43a1bab80c6317162c434 100755 (executable)
@@ -15,7 +15,7 @@
 
 # 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:
index 488831786e55d20dc2818c855cb3811aa436a265..c40f726f223bf1dc733dc16330877304492b25ac 100755 (executable)
@@ -5,7 +5,7 @@
 
 # Load functions
 LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" maintenance $* || exit 1
 
 # Dispatch
 keyringer_show_actions
index 84ead14f7ab77743fff5f6d1384746ed7a908af5..e8e72b6ca56e9b81bfd67f620349f5fd4404dbcf 100755 (executable)
@@ -5,7 +5,7 @@
 
 # Load functions
 LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" maintenance $* || exit 1
 
 # Fix positional arguments
 shift
index 1f4cceefdf45d097e5b250ee5ba74ceba3bcc0c4..af3a52b92a9fb94be9fea88b9e16e71ee5ea7666 100755 (executable)
@@ -5,7 +5,7 @@
 
 # Load functions
 LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" maintenance $* || exit 1
 
 # Aditional parameters
 CWD="`pwd`"
index c6510eea62ca38a57d2ba8b1d0e5fff461c409ba..e17f0e087f373bbb245c6327927fa125a3478b16 100755 (executable)
@@ -5,7 +5,7 @@
 
 # Load functions
 LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" read $* || exit 1
 
 # Get file
 keyringer_get_file "$2"
index 2abc4145e1ba578453daee197e955ba0795fdb79..61a68da50fd06a9599687cd5af5d68c44efc484f 100755 (executable)
@@ -5,7 +5,7 @@
 
 # Load functions
 LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" maintenance $* || exit 1
 
 # Get file
 keyringer_get_file "$2"
index 4338518475b8b340debbeb577be3b9c8e5aef845..a480eea5d2210e0d0d7e2920ee671a6975d48515 100755 (executable)
@@ -1,11 +1,11 @@
 #!/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"
index 3818fa35e5100020c855c6f4aec201297d7944aa..11db62cf296783fe1e6a256f7016113debe3934e 100755 (executable)
@@ -5,7 +5,7 @@
 
 # Load functions
 LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" write $* || exit 1
 
 # Usage
 function keyringer_usage_encrypt {
index dc9d6d12ab6fe4cb727e4a8db546f38dbd7a2a1a..043e80d6fa3e03b7ea0d0d74dcf250f81a8db5c9 100755 (executable)
@@ -5,7 +5,7 @@
 
 # Load functions
 LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" maintenance $* || exit 1
 
 # Aditional parameters
 CWD="`pwd`"
index f49d6d050a038578023c058b0f355a50134639a7..634c847f3f9be897d6fdabc638868a9cded19fdd 100755 (executable)
@@ -185,7 +185,7 @@ EOF
 
 # Load functions
 LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" write $* || exit 1
 
 # Aditional parameters
 KEYTYPE="$2"
index 218273f729a71eb6830242484650f121ee33f27d..f2cb68461cdc35c359ade2bb5769db6ef0bacd73 100755 (executable)
@@ -5,7 +5,7 @@
 
 # Load functions
 LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" maintenance $* || exit 1
 
 # Aditional parameters
 CWD="`pwd`"
index b992ad4be620344ef07c9d1757d7c0ddc4570a50..e7610d7b7eddaeb85ba9f5eba92d91b3eef4d7c0 100755 (executable)
@@ -5,7 +5,7 @@
 
 # Load functions
 LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" maintenance $* || exit 1
 
 # Aditional parameters
 CWD="`pwd`"
index 63442a482eb7f300ba22e7860b639c34ef5e7716..882bbb0b260653173babf1d6b8a472d1766b07df 100755 (executable)
@@ -5,7 +5,7 @@
 
 # Load functions
 LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" maintenance $* || exit 1
 
 # Aditional parameters
 CWD="`pwd`"
index e31eb8503c581aad29854b9f0d862c6c96b813d9..b8cb7977f56cda8a2ff06361efad8175b198918e 100755 (executable)
@@ -5,7 +5,7 @@
 
 # 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|^/*||"`)"
index eea73e812c4f0f5a97eff719c4c7258695b5a3dd..0161e633d488d13b6ec5ee9f29083205beb80498 100755 (executable)
@@ -5,7 +5,7 @@
 
 # Load functions
 LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" maintenance $* || exit 1
 
 # Command parser
 keyringer_get_command "$2"
index ffabc4c893de1985e9f9ed345e2f5be5a2658497..a840fd7de7ea0f3bd91d39b8b45334231ea77fc8 100755 (executable)
@@ -5,7 +5,7 @@
 
 # Load functions
 LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" maintenance $* || exit 1
 
 # Options
 COMMAND="$2"
index 45d2bf96514f4fe8d672ef79dd69f7cd59bc5336..1ca3829453628476df3b1afac5df5cd7a103a0c0 100755 (executable)
@@ -5,7 +5,7 @@
 
 # Load functions
 LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" write $* || exit 1
 
 # Parameters
 SIZE="$3"
index 29f9d3836e15d3b414e762461cdaec03ca3ecf17..3c185160566b93fb5429219b047fe3ae575c6cef 100755 (executable)
@@ -5,7 +5,7 @@
 
 # Load functions
 LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" maintenance $* || exit 1
 
 # Command parser
 keyringer_get_command "$2"
index 5dce1ba3e197bfcb53f698e34982a6574422f20f..d88a749468121e405200feed2474bb9c9b7f8de2 100755 (executable)
@@ -5,7 +5,7 @@
 
 # Load functions
 LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" readwrite $* || exit 1
 
 # Recrypt a single secret
 function keyringer_recrypt {
index da7abe5a2fa414d66bdc714460e56c94da9a5ebd..410eb55509350943d6c0d28b31b612d4ad6ab226 100755 (executable)
@@ -5,7 +5,7 @@
 
 # Load functions
 LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" maintenance $* || exit 1
 
 # Aditional parameters
 CWD="`pwd`"
index 6016f2b65e5cd1b1a1f611c6bcc8e2fbcf1febac..156762a71d05edd4b9d6a9ae34a52aa6a5e4e024 100755 (executable)
@@ -5,7 +5,7 @@
 
 # Load functions
 LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" read $* || exit 1
 
 # Clip password
 shift
index 491fe0a7437a04775b8139a3d1a4c8e25cf39042..3b98d6844ac4b5a9eff9f5a3f2cee827989e9b57 100755 (executable)
@@ -5,7 +5,7 @@
 
 # Load functions
 LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" maintenance $* || exit 1
 
 # Basic parameters
 SHELLPATH="/"
index 5bfb12101596ce26c8b8e1e8675815c5ccbcdcc2..2e8725b001645f338975b421684a5f0352559c22 100755 (executable)
@@ -5,7 +5,7 @@
 
 # Load functions
 LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" maintenance $* || exit 1
 
 # Options
 CONFIRM="$2"
index 9c09bfcd7024882d3d46d4ffdb409f321478ea5e..7bf173d1e5163ff83ae2f027af179c8ab6f4582d 100755 (executable)
@@ -10,7 +10,7 @@ function keyringer_tree {
 
 # Load functions
 LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" maintenance $* || exit 1
 
 # Aditional parameters
 CWD="`pwd`"
index 15096a0b2e446dae9133103432293efe7193aef4..9fd36baee3bb82d6d40d9a8af57264608c8230e3 100755 (executable)
@@ -5,7 +5,7 @@
 
 # Load functions
 LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" maintenance $* || exit 1
 
 # Dispatch
 keyringer_usage $KEYRING
index 0e60bbd4d5558ad48d2dcff2bb2578b21b678087..da86315677c587d13f09c552e2e70c508cdee033 100755 (executable)
@@ -38,7 +38,7 @@ clip() {
 
 # Load functions
 LIB="`dirname $0`/../functions"
-source "$LIB" || exit 1
+source "$LIB" read $* || exit 1
 
 # Check for xclip
 if ! which xclip &> /dev/null; then
index bd87fd621e00e33b71a63e82fd8e6b9a14f3d965..0d96288a0b242a578aec8933ce76467e9e76b1b7 100755 (executable)
@@ -253,10 +253,18 @@ function keyringer_set_env {
     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"
@@ -640,10 +648,10 @@ function keyringer_check_recipients {
     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
@@ -710,8 +718,15 @@ function keyringer_check_expiration {
 
   # 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
@@ -741,8 +756,15 @@ function keyringer_check_expiration {
 
   # 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
 }