Conflicts: INSTALL README.md gpg-mailgate.conf.sample gpg-mailgate.py
This commit is contained in:
commit
9ac151f438
|
@ -25,8 +25,8 @@ import random
|
||||||
import string
|
import string
|
||||||
|
|
||||||
def public_keys( keyhome ):
|
def public_keys( keyhome ):
|
||||||
cmd = '/usr/bin/gpg --homedir %s --list-keys --with-colons' % keyhome
|
cmd = ['/usr/bin/gpg', '--homedir', keyhome, '--list-keys', '--with-colons']
|
||||||
p = subprocess.Popen( cmd.split(' '), stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE )
|
p = subprocess.Popen( cmd, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE )
|
||||||
p.wait()
|
p.wait()
|
||||||
keys = list()
|
keys = list()
|
||||||
for line in p.stdout.readlines():
|
for line in p.stdout.readlines():
|
||||||
|
|
13
README.md
13
README.md
|
@ -7,8 +7,19 @@ For installation instructions, please refer to the included INSTALL file.
|
||||||
# Features
|
# Features
|
||||||
- Correctly displays attachments and general email content; currently will only display first part of multipart messages
|
- Correctly displays attachments and general email content; currently will only display first part of multipart messages
|
||||||
- Public keys can be stored in a dedicated gpg-home-directory (see Note 1 in INSTALL)
|
- Public keys can be stored in a dedicated gpg-home-directory (see Note 1 in INSTALL)
|
||||||
- Encrypts matching incoming and outgoing mode
|
- Encrypts both matching incoming and outgoing mail (this means gpg-mailgate can be used to encrypt outgoing mail for software that doesn't support PGP)
|
||||||
- Easy installation
|
- Easy installation
|
||||||
- gpg-mailgate-web extension is a web interface allowing any user to upload PGP keys so that emails sent to them from your mail server will be encrypted (see gpg-mailgate-web directory for details)
|
- gpg-mailgate-web extension is a web interface allowing any user to upload PGP keys so that emails sent to them from your mail server will be encrypted (see gpg-mailgate-web directory for details)
|
||||||
|
|
||||||
This is forked from the original project at http://code.google.com/p/gpg-mailgate/
|
This is forked from the original project at http://code.google.com/p/gpg-mailgate/
|
||||||
|
|
||||||
|
# Authors
|
||||||
|
|
||||||
|
This is a combined work of many developers:
|
||||||
|
|
||||||
|
* mcmaster <mcmaster@aphrodite.hurricanelabs.rsoc>
|
||||||
|
* Igor Rzegocki <ajgon@irgon.com> - [GitHub](https://github.com/ajgon/gpg-mailgate)
|
||||||
|
* perennate <admin@perennate.com> - [GitHub](https://github.com/uakfdotb/gpg-mailgate)
|
||||||
|
* Colin Moller <colin@unixarmy.com> - [GitHub](https://github.com/LeftyBC/gpg-mailgate)
|
||||||
|
* Taylor Hornby <havoc@defuse.ca> - [GitHub](https://github.com/defuse/gpg-mailgate)
|
||||||
|
* Martin (uragit) <uragit@telemage.com> - [GitHub](https://github.com/uragit/gpg-mailgate)
|
||||||
|
|
|
@ -14,8 +14,9 @@ keymap_only = no
|
||||||
keyhome = /var/gpg/.gnupg
|
keyhome = /var/gpg/.gnupg
|
||||||
|
|
||||||
[logging]
|
[logging]
|
||||||
# file to log to
|
# For logging to syslog. 'file = syslog', otherwise use path to the file.
|
||||||
file = /tmp/gpg-mailgate.log
|
file = /tmp/gpg-mailgate.log
|
||||||
|
#verbose = yes
|
||||||
|
|
||||||
[relay]
|
[relay]
|
||||||
# the relay settings to use for Postfix
|
# the relay settings to use for Postfix
|
||||||
|
|
|
@ -27,12 +27,7 @@ import re
|
||||||
import GnuPG
|
import GnuPG
|
||||||
import smtplib
|
import smtplib
|
||||||
import sys
|
import sys
|
||||||
|
import syslog
|
||||||
def appendLog(msg):
|
|
||||||
if cfg.has_key('logging') and cfg['logging'].has_key('file'):
|
|
||||||
log = open(cfg['logging']['file'], 'a')
|
|
||||||
log.write(msg + "\n")
|
|
||||||
log.close()
|
|
||||||
|
|
||||||
# Read configuration from /etc/gpg-mailgate.conf
|
# Read configuration from /etc/gpg-mailgate.conf
|
||||||
_cfg = RawConfigParser()
|
_cfg = RawConfigParser()
|
||||||
|
@ -43,6 +38,17 @@ for sect in _cfg.sections():
|
||||||
for (name, value) in _cfg.items(sect):
|
for (name, value) in _cfg.items(sect):
|
||||||
cfg[sect][name] = value
|
cfg[sect][name] = value
|
||||||
|
|
||||||
|
def log(msg):
|
||||||
|
if cfg.has_key('logging') and cfg['logging'].has_key('file'):
|
||||||
|
if cfg['logging']['file'] == "syslog":
|
||||||
|
syslog.syslog(syslog.LOG_INFO | syslog.LOG_MAIL, msg)
|
||||||
|
else:
|
||||||
|
logfile = open(cfg['logging']['file'], 'a')
|
||||||
|
logfile.write(msg + "\n")
|
||||||
|
logfile.close()
|
||||||
|
|
||||||
|
verbose=cfg.has_key('logging') and cfg['logging'].has_key('verbose') and cfg['logging']['verbose'] == 'yes'
|
||||||
|
|
||||||
# Read e-mail from stdin
|
# Read e-mail from stdin
|
||||||
raw = sys.stdin.read()
|
raw = sys.stdin.read()
|
||||||
raw_message = email.message_from_string( raw )
|
raw_message = email.message_from_string( raw )
|
||||||
|
@ -52,7 +58,7 @@ to_addrs = sys.argv[1:]
|
||||||
def send_msg( message, recipients = None ):
|
def send_msg( message, recipients = None ):
|
||||||
if recipients == None:
|
if recipients == None:
|
||||||
recipients = to_addrs
|
recipients = to_addrs
|
||||||
appendLog("Sending email to: <%s>" % '> <'.join( recipients ))
|
log("Sending email to: <%s>" % '> <'.join( recipients ))
|
||||||
relay = (cfg['relay']['host'], int(cfg['relay']['port']))
|
relay = (cfg['relay']['host'], int(cfg['relay']['port']))
|
||||||
smtp = smtplib.SMTP(relay[0], relay[1])
|
smtp = smtplib.SMTP(relay[0], relay[1])
|
||||||
smtp.sendmail( from_addr, recipients, message.as_string() )
|
smtp.sendmail( from_addr, recipients, message.as_string() )
|
||||||
|
@ -110,18 +116,22 @@ for to in to_addrs:
|
||||||
elif cfg.has_key('keymap') and cfg['keymap'].has_key(to):
|
elif cfg.has_key('keymap') and cfg['keymap'].has_key(to):
|
||||||
gpg_to.append( (to, cfg['keymap'][to]) )
|
gpg_to.append( (to, cfg['keymap'][to]) )
|
||||||
else:
|
else:
|
||||||
|
if verbose:
|
||||||
|
log("Recipient (%s) not in domain list." % to)
|
||||||
ungpg_to.append(to)
|
ungpg_to.append(to)
|
||||||
|
|
||||||
if gpg_to == list():
|
if gpg_to == list():
|
||||||
if cfg['default'].has_key('add_header') and cfg['default']['add_header'] == 'yes':
|
if cfg['default'].has_key('add_header') and cfg['default']['add_header'] == 'yes':
|
||||||
raw_message['X-GPG-Mailgate'] = 'Not encrypted, public key not found'
|
raw_message['X-GPG-Mailgate'] = 'Not encrypted, public key not found'
|
||||||
|
if verbose:
|
||||||
|
log("No encrypted recipients.")
|
||||||
send_msg( raw_message )
|
send_msg( raw_message )
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
if ungpg_to != list():
|
if ungpg_to != list():
|
||||||
send_msg( raw_message, ungpg_to )
|
send_msg( raw_message, ungpg_to )
|
||||||
|
|
||||||
appendLog("Encrypting email to: %s" % ' '.join( map(lambda x: x[0], gpg_to) ))
|
log("Encrypting email to: %s" % ' '.join( map(lambda x: x[0], gpg_to) ))
|
||||||
|
|
||||||
if cfg['default'].has_key('add_header') and cfg['default']['add_header'] == 'yes':
|
if cfg['default'].has_key('add_header') and cfg['default']['add_header'] == 'yes':
|
||||||
raw_message['X-GPG-Mailgate'] = 'Encrypted by GPG Mailgate'
|
raw_message['X-GPG-Mailgate'] = 'Encrypted by GPG Mailgate'
|
||||||
|
|
Loading…
Reference in New Issue