Changeset - 49636b8721b9
[Not reviewed]
0 1 0
Branko Majic (branko) - 4 years ago 2020-06-29 04:17:51
branko@majic.rs
Renamed the recipients variable. Added one more variable that contains recipients solely.
1 file changed with 3 insertions and 2 deletions:
0 comments (0 inline, 0 general) First comment
openpgp/gitprotect.sh
Show inline comments
 
@@ -292,13 +292,14 @@ elif [[ $command = "encrypt" ]]; then
 

	
 
    # Set-up the list of recipients. Read the information about each public
 
    # sub-key from the local keyring.
 
    while read key_validity key_id key_capabilities; do
 
        # Only use non-expired sub-keys that have encryption capability.
 
        if [[ $key_validity != e && $key_capabilities =~ .*e.* ]]; then
 
            recipients+=("-r" "$key_id")
 
            recipients+=("$key_id")
 
            recipientArgs+=("-r" "$key_id")
 
        fi
 
    done < <(gpg2 "${gnupgArgs[@]}" --list-public-keys --with-colons | grep '^sub' | awk 'BEGIN { FS = ":" } ; { print $2, $5, $12 }')
 

	
 
    # Make sure that we have at least a single recipient.
 
    if [[ "${#recipients[@]}" == 0 ]]; then
 
        echo "ERROR: No suitable recipients were found in the keyring." >&2
 
@@ -315,13 +316,13 @@ elif [[ $command = "encrypt" ]]; then
 
        # decrypted. We should skip unchanged files.
 
        if [[ -f $checksumFile ]] && sha256sum --quiet -c "$checksumFile" > /dev/null 2>&1; then
 
            echo "INFO: File decrypted/$filename doesn't seem to have been changed. Skipping."
 
        # The file was changed, so we need to encrypt new version of it.
 
        else
 
            cat "$filePath" | gpg2 --trust-model always "${gnupgArgs[@]}" \
 
                --armor "${recipients[@]}" --encrypt > "${filename}.gpg"
 
                --armor "${recipientArgs[@]}" --encrypt > "${filename}.gpg"
 
            sha256sum "decrypted/$filename" > "decrypted/.${filename}.sha256"
 
        fi
 
    done < <(find "decrypted/" -maxdepth 1 -type f ! -name '.*.sha256')
 
elif [[ $command = "decrypt" ]]; then
 
    gitprotectConfigured || exit "$ERR_NOCONFIG"
 

	
0 comments (0 inline, 0 general) First comment
You need to be logged in to comment. Login now