Skip to content

Commit

Permalink
Changed GPGEncryptor.encrypt() to also give PGP return code. Write rc…
Browse files Browse the repository at this point in the history
… to logfile in encrypt_payload().
  • Loading branch information
uragit committed Nov 22, 2013
1 parent 2419156 commit 779e712
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion GnuPG/__init__.py
Expand Up @@ -30,7 +30,7 @@ def update(self, message):
def encrypt(self):
p = subprocess.Popen( self._command(), stdin=subprocess.PIPE, stdout=subprocess.PIPE,stderr=subprocess.PIPE )
encdata = p.communicate(input=self._message)[0]
return encdata
return (encdata, p.returncode)

def _command(self):
cmd = ["/usr/bin/gpg", "--trust-model", "always", "--homedir", self._keyhome, "--batch", "--yes", "--pgp7", "--no-secmem-warning", "--armor", "--encrypt"]
Expand Down
5 changes: 4 additions & 1 deletion gpg-mailgate.py
Expand Up @@ -60,7 +60,10 @@ def encrypt_payload( payload, gpg_to_cmdline ):
return payload
gpg = GnuPG.GPGEncryptor( cfg['gpg']['keyhome'], gpg_to_cmdline, payload.get_content_charset() )
gpg.update( raw_payload )
payload.set_payload( gpg.encrypt() )
encrypted_data, returncode =gpg.encrypt()
if verbose:
log("Return code from encryption=%d (0 indicates success)." % returncode)
payload.set_payload( encrypted_data )

isAttachment = payload.get_param( 'attachment', None, 'Content-Disposition' ) is not None

Expand Down

0 comments on commit 779e712

Please sign in to comment.