From: Steven Baltakatei Sandoval Date: Sun, 5 Jul 2020 17:31:07 +0000 (+0000) Subject: fix(bkgpslog):Add '-e'/'-R' checks in -R parse X-Git-Url: https://zdv2.bktei.com/gitweb/EVA-2020-02.git/commitdiff_plain/50324e94b0f929280c8a18fe63cd684decb84c4a?ds=inline;hp=6a2cd888e8ae624ddd3e885f4de2b40581adf387 fix(bkgpslog):Add '-e'/'-R' checks in -R parse Also add comments to magic functions in main() --- diff --git a/exec/bkgpslog b/exec/bkgpslog index f48818d..55eba3c 100755 --- a/exec/bkgpslog +++ b/exec/bkgpslog @@ -952,14 +952,15 @@ magicGatherWriteBuffer() { } # write buffer to disk magicParseRecipientDir() { # Desc: Updates recPubKeysValid with pubkeys in dir specified by '-R' option ("recipient directory") - # Inputs: vars: OPTION_RECDIR, argRecDir, - # arry: recPubKeysValid - # Outputs: arry: recPubKeysValid (modified with pubkeys in argRecDir if pubkeys valid) + # Inputs: vars: OPTION_RECDIR, argRecDir, OPTION_ENCRYPTION + # arry: recPubKeysValid + # Outputs: arry: recPubKeysValid # Depends: processArguments, local recFileLine updateRecipients recipientDir declare -a candRecPubKeysValid - - if [[ "$OPTION_RECDIR" = "true" ]]; then + + # Check that '-e' and '-R' set + if [[ "$OPTION_ENCRYPTION" = "true" ]] && [[ "$OPTION_RECDIR" = "true" ]]; then ### Check that argRecDir is a directory. if [[ -d "$argRecDir" ]]; then recipientDir="$argRecDir"; @@ -990,6 +991,12 @@ magicParseRecipientDir() { yell "ERROR:$0:Recipient directory $argRecDir does not exist. Exiting."; exit 1; fi; fi; + # Handle case if '-e' set but '-R' not set + if [[ "$OPTION_ENCRYPTION" = "true" ]] && [[ ! "$OPTION_RECDIR" = "true" ]]; then + yell "ERROR: \'-e\' set but \'-R\' is not set."; fi; + # Handle case if '-R' set but '-e' not set + if [[ ! "$OPTION_ENCRYPTION" = "true" ]] && [[ "$OPTION_RECDIR" = "true" ]]; then + yell "ERROR: \'-R\' is set but \'-e\' is not set."; fi; } # Update recPubKeysValid with argRecDir magicParseRecipientArgs() { # Desc: Parses recipient arguments specified by '-r' option @@ -1093,14 +1100,14 @@ main() { processArguments "$@"; ## Act upon arguments ### Determine working directory - magicInitWorkingDir; + magicInitWorkingDir; # Sets DIR_TMP ### Set output encryption and compression option strings #### React to "-r" ("encryption recipients") option - magicParseRecipientArgs; + magicParseRecipientArgs; # Updates recPubKeysValid, CMD_ENCRYPT[_SUFFIX] #### React to "-c" ("compression") option - magicParseCompressionArg; + magicParseCompressionArg; # Updates CMD_COMPRESS[_SUFFIX] #### React to "-R" ("recipient directory") option - magicParseRecipientDir; + magicParseRecipientDir; # Updates recPubKeysValid # Check that critical apps and dirs are available, display missing ones. if ! checkapp gpspipe tar && ! checkdir "$DIR_OUT" "DIR_TMP"; then