From 77361307addc164bf6470f62d376629f3eeb940e Mon Sep 17 00:00:00 2001 From: Steven Baltakatei Sandoval Date: Mon, 29 Jun 2020 19:46:35 +0000 Subject: [PATCH] test(bkgpslog):Add age recipient string processing code --- exec/bkgpslog | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/exec/bkgpslog b/exec/bkgpslog index b97f250..21c5fc0 100755 --- a/exec/bkgpslog +++ b/exec/bkgpslog @@ -15,6 +15,7 @@ declare -Ag appRollCall # Associative array for storing app status declare -Ag fileRollCall # Associative array for storing file status declare -Ag dirRollCall # Associative array for storing dir status declare -a recPubKeys # for processArguments function +declare recipients # for main function #===BEGIN Declare local script functions=== checkapp() { @@ -192,7 +193,7 @@ processArguments() { -o | --output) if [ -d "$2" ]; then DIROUT="$2"; vbm "DEBUG:DIROUT:$DIROUT"; shift; fi ;; # Define output directory. -e | --encrypt) OPTION_ENCRYPT="true"; vbm "DEBUG:Encrypted output mode enabled.";; -r | --recipient) # Add 'age' recipient via public key string - recPubKeys+=("$2"); shift;; + recPubKeys+=("$2"); vbm "pubkey added:""$2"; shift;; *) echoerr "ERROR: Unrecognized argument."; exit 1;; # Handle unrecognized options. esac shift @@ -276,8 +277,15 @@ main() { for pubkey in "${recPubKeys[@]}"; do # Validate recipient pubkey strings by forming test message vbm "DEBUG:Testing pubkey string:$pubkey" if ! echo "butts" | age -a -r "$pubkey" 1>/dev/null; then - yell "ERROR:Exit code ""$?"". Invalid recipient pubkey string. Exiting."; exit 1; fi + yell "ERROR:Exit code ""$?"". Invalid recipient pubkey string. Exiting."; exit 1; + else + # Form age recipient string + recipients="$recipients""-r $pubkey "; + vbm "Added pubkey:""$pubkey"; + vbm "DEBUG:recipients:""$recipients"; + fi done + vbm "DEBUG:Finished processing recPubKeys array"; else yell "ERROR:Encryption enabled but \"age\" not found. Exiting."; exit 1; fi -- 2.30.2