From e646c47f1336553114c50ee7c7d2150abeb529e6 Mon Sep 17 00:00:00 2001 From: D Harithamma Date: Thu, 14 Nov 2024 23:37:05 -0500 Subject: [PATCH] displaying gpg output --- bin/zopen-build | 6 +++--- bin/zopen-install | 34 ++++++++++++++-------------------- 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/bin/zopen-build b/bin/zopen-build index 27b78128c..6e2e640f4 100755 --- a/bin/zopen-build +++ b/bin/zopen-build @@ -516,7 +516,7 @@ signPaxFile() # Import the private key into the specified keyring files printInfo "Importing private key..." - gpg --no-default-keyring --keyring "$TMP_GPG_DIR/pubring.kbx" --secret-keyring "$TMP_GPG_DIR/secring.gpg" --batch --yes --import "$PRIVATE_KEY" > /dev/null 2>&1 + gpg --no-default-keyring --keyring "$TMP_GPG_DIR/pubring.kbx" --secret-keyring "$TMP_GPG_DIR/secring.gpg" --batch --yes --import "$PRIVATE_KEY" if [ $? -ne 0 ]; then extractPax=false printError "Importing private key failed. Signing aborted." @@ -524,7 +524,7 @@ signPaxFile() # Verify that the key was imported successfully printInfo "Checking if secret key is imported..." - gpg --no-default-keyring --keyring "$TMP_GPG_DIR/pubring.kbx" --secret-keyring "$TMP_GPG_DIR/secring.gpg" --list-secret-keys > /dev/null 2>&1 + gpg --no-default-keyring --keyring "$TMP_GPG_DIR/pubring.kbx" --secret-keyring "$TMP_GPG_DIR/secring.gpg" --list-secret-keys if [ $? -ne 0 ]; then extractPax=false printError "No secret key found. Signing aborted." @@ -533,7 +533,7 @@ signPaxFile() # Sign the file printInfo "Signing the file..." - gpg --armor --no-default-keyring --keyring "$TMP_GPG_DIR/pubring.kbx" --batch --verbose --pinentry-mode loopback --passphrase-file "$PASSPHRASE_FILE" --output "$OUTPUT_SIGNATURE" --detach-sig "$FILE_TO_SIGN" > /dev/null 2>&1 + gpg --armor --no-default-keyring --keyring "$TMP_GPG_DIR/pubring.kbx" --batch --verbose --pinentry-mode loopback --passphrase-file "$PASSPHRASE_FILE" --output "$OUTPUT_SIGNATURE" --detach-sig "$FILE_TO_SIGN" if [ $? -ne 0 ]; then extractPax=false diff --git a/bin/zopen-install b/bin/zopen-install index f31a5a96a..8104de53d 100755 --- a/bin/zopen-install +++ b/bin/zopen-install @@ -23,21 +23,16 @@ checkWritable startGPGAgent() { - # Check if gpg-agent is running - if ps -ef | grep -v grep | grep "gpg-agent" ; then #> /dev/null; then - printInfo "gpg-agent is already running." - else - printInfo "gpg-agent is not running. Starting gpg-agent..." - gpg-agent --daemon - # Wait a moment to ensure the gpg-agent has time to start - sleep 2 - # Check again to confirm if gpg-agent started successfully - if ps -ef | grep -v grep | grep "gpg-agent" > /dev/null; then - printInfo "gpg-agent started successfully." - else - printError "Failed to start gpg-agent. Install GPG using \"zopen install gpg -y\" command." - fi - fi + printInfo "Starting gpg-agent..." + gpg-agent --daemon + # Wait a moment to ensure the gpg-agent has time to start + sleep 2 + # Check again to confirm if gpg-agent started successfully + if ps -ef | grep -v grep | grep "gpg-agent" > /dev/null; then + printInfo "gpg-agent started successfully." + else + printError "Failed to start gpg-agent. Install GPG using \"zopen install gpg -y\" command." + fi } verifySignatureOfPax() @@ -65,11 +60,9 @@ verifySignatureOfPax() PUBLIC_KEY_FILE="$zopen_tmp_dir/scriptpubkey.$LOGNAME.$$.asc" printf "%b" "$SIGNATURE" | tr -d '"' > "$SIGNATURE_FILE" printf "%b" "$PUBLIC_KEY" | tr -d '"' > "$PUBLIC_KEY_FILE" - startGPGAgent - printVerbose "Importing public key..." - [ -f "$PUBLIC_KEY_FILE" ] && gpg --no-default-keyring --keyring "$TMP_GPG_DIR/pubring.kbx" --batch --yes --import "$PUBLIC_KEY_FILE" > /dev/null 2>&1 + [ -f "$PUBLIC_KEY_FILE" ] && gpg --no-default-keyring --keyring "$TMP_GPG_DIR/pubring.kbx" --batch --yes --import "$PUBLIC_KEY_FILE" if [ $? -ne 0 ]; then [ -e "${TMP_GPG_DIR}" ] && rm -rf "$TMP_GPG_DIR" printError "Importing public key failed. Verification aborted." @@ -77,7 +70,7 @@ verifySignatureOfPax() # Verify that the key was imported successfully printVerbose "Checking if public key is imported..." - gpg --no-default-keyring --keyring "$TMP_GPG_DIR/pubring.kbx" --list-keys > /dev/null 2>&1 + gpg --no-default-keyring --keyring "$TMP_GPG_DIR/pubring.kbx" --list-keys if [ $? -ne 0 ]; then [ -e "${TMP_GPG_DIR}" ] && rm -rf "$TMP_GPG_DIR" printError "No public key found. Verification aborted." @@ -86,7 +79,8 @@ verifySignatureOfPax() # Verify the signature printInfo "Verifying the gpg signature..." if [ -f "$SIGNATURE_FILE" ]; then - if gpg --no-default-keyring --keyring "$TMP_GPG_DIR/pubring.kbx" --verify "$SIGNATURE_FILE" "$FILE_TO_VERIFY" 2>&1 | grep -q "Good signature from"; then + gpg_output=$(gpg --no-default-keyring --keyring "$TMP_GPG_DIR/pubring.kbx" --verify "$SIGNATURE_FILE" "$FILE_TO_VERIFY" 2>&1) + if echo "$gpg_output" | grep -q "Good signature from"; then printInfo "${NC}${GREEN}Signature verified successfully: ${name}${NC}" return 0 else