Require exact return code of 0 - postreich - Unnamed repository; edit this file 'description' to name the repository. DIR Log DIR Files DIR Refs DIR README --- DIR commit c02d3b4753c25201983768431317d356dd7ac178 DIR parent e675715f30aa480af109ec1d46877a51d9a7af9c HTML Author: Scarlett McAllister <no+reply@roygbyte.com> Date: Sun, 28 Jan 2024 20:18:22 -0400 Require exact return code of 0 Diffstat: M src/geomyidae/api/common | 12 ++++++------ M src/geomyidae/api/create-mailbox | 4 ++-- M src/geomyidae/api/send-mail | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) --- DIR diff --git a/src/geomyidae/api/common b/src/geomyidae/api/common @@ -44,20 +44,20 @@ find_value_in_args() { decode_and_verify_pubkey() { if [ -z "$1" ]; then - printf "No input provided\n" + printf "No pubkey input provided\n" return 1 fi - decoded_payload=$( printf "$1" "$base64_payload" \ - | base64 -d --ignore-garbage ) + decoded_payload=$( printf "$1" \ + | base64 -d --ignore-garbage 2> /dev/null ) # test result of `base64` invocation. - if [ ! $? ]; then - printf "Invalid input given. Payload was not base 64.\n" + if [ ! $? -eq 0 ]; then + printf "Invalid pubkey input given. Payload was not base 64.\n" return 1 fi printf "%s" "$decoded_payload" \ | openssl pkey -pubcheck -pubin 2> /dev/null # test result of `openssl` invocation. - if [ ! $? ]; then + if [ ! $? -eq 0 ]; then printf "Key is not valid.\n" return 1 fi DIR diff --git a/src/geomyidae/api/create-mailbox b/src/geomyidae/api/create-mailbox @@ -9,8 +9,8 @@ handle=$( sanitize_handle "$1" ) base64_payload=$( sanitize_base64 "$2" ) result=$( decode_and_verify_pubkey "$base64_payload" ) -if [ ! $? ]; then - printf "$result" +if [ ! $? -eq 0 ]; then + printf "$result\n" return 1 fi pubkey_content="$result" DIR diff --git a/src/geomyidae/api/send-mail b/src/geomyidae/api/send-mail @@ -46,7 +46,7 @@ mailbox="$result" result=$( printf "%s" "$message" \ | encrypt_with_key_and_encode "$pubkey" ) -if [ ! $? ]; then +if [ ! $? -eq 0 ]; then printf "Encryption or encoding failed.\n" return 1 fi