diff options
Diffstat (limited to 'scripts/testlib_dovecot.py')
| -rwxr-xr-x | scripts/testlib_dovecot.py | 64 |
1 files changed, 59 insertions, 5 deletions
diff --git a/scripts/testlib_dovecot.py b/scripts/testlib_dovecot.py index e5c203c0..658cbb04 100755 --- a/scripts/testlib_dovecot.py +++ b/scripts/testlib_dovecot.py @@ -44,10 +44,14 @@ class Dovecot: user is set up, and /var/mail/$user contains an unread and a read mail. ''' + # This is insane, we should just use lsb_release here self.new_version = False with open("/etc/dovecot/dovecot.conf", "r") as f: - if f.read().find('!include_try /usr/share/dovecot/protocols.d/*.protocol')>0: + contents = f.read() + if contents.find('!include_try /usr/share/dovecot/protocols.d/*.protocol')>0: self.new_version = True + if contents.find('dovecot_config_version = 2.4.0')>0: + self.even_newer_version = True # Stop dovecot before we make any changes to the config file self.pidfile = "/var/run/dovecot/master.pid" @@ -93,6 +97,38 @@ auth_passdb = pam auth_user = root ''' + elif self.even_newer_version: + # dovecot 2.4.x + config=''' + +dovecot_config_version = 2.4.0 +dovecot_storage_version = 2.4.0 + +auth_mechanisms = plain cram-md5 +log_timestamp = "%Y-%m-%d %H:%M:%S " +mail_path = ~/mail:INBOX=/var/mail/%u +mail_driver = mbox +mail_privileged_group = mail +# Yuck, the following makes dovecot vulnerable to +# CVE-2008-1199 but if not enabled, it fails due to +# http://wiki2.dovecot.org/Errors/ChgrpNoPerm when +# when using postfix/procmail for an MDA +mail_access_groups = mail +passdb { + args = /etc/dovecot/test.passwd + driver = passwd-file +} +passdb { + driver = pam +} +protocols = imap pop3 +service auth { + user = root +} +userdb { + driver = passwd +} +''' elif self.new_version: # dovecot 2.0.x config=''' @@ -145,7 +181,23 @@ auth default { user = root } ''' - if self.new_version: + + if self.even_newer_version: + key_config_str = 'ssl_server_key_file = %s\n' + cert_config_str = 'ssl_server_cert_file = %s\n' + # ssl_key and ssl_cert need to be defined in dovecot 2.0.x + # Raring+ uses snakeoil by default + if cert_key == None: + if os.path.exists('/etc/ssl/private/dovecot.pem'): + cert_key = '/etc/ssl/private/dovecot.pem' + else: + cert_key = '/etc/ssl/private/ssl-cert-snakeoil.key' + if cert_pub == None: + if os.path.exists('/etc/ssl/certs/dovecot.pem'): + cert_pub = '/etc/ssl/certs/dovecot.pem' + else: + cert_pub = '/etc/ssl/certs/ssl-cert-snakeoil.pem' + elif self.new_version: key_config_str = 'ssl_key = <%s\n' cert_config_str = 'ssl_cert = <%s\n' # ssl_key and ssl_cert need to be defined in dovecot 2.0.x @@ -166,10 +218,10 @@ auth default { self.cert_key = cert_key if self.cert_key: - config = key_config_str % (self.cert_key) + config + config = config + key_config_str % (self.cert_key) self.cert_pub = cert_pub if self.cert_pub: - config = cert_config_str % (self.cert_pub) + config + config = config + cert_config_str % (self.cert_pub) with open("/etc/dovecot/conf.d/10-ssl.conf", "r") as f: if f.read().find('ssl_dh = </usr/share/dovecot/dh.pem')>0: @@ -277,7 +329,8 @@ Get cracking! os.unlink(socket) # restore original configuration - os.rename('/etc/dovecot/dovecot.conf.autotest', '/etc/dovecot/dovecot.conf') + if os.path.exists('/etc/dovecot/dovecot.conf.autotest'): + os.rename('/etc/dovecot/dovecot.conf.autotest', '/etc/dovecot/dovecot.conf') if os.path.exists('/etc/dovecot/dovecot-postfix.conf.autotest'): os.rename('/etc/dovecot/dovecot-postfix.conf.autotest', '/etc/dovecot/dovecot-postfix.conf') @@ -290,6 +343,7 @@ Get cracking! # reload the daemon if os.path.exists('/etc/init.d/dovecot'): subprocess.call(['/etc/init.d/dovecot', 'reload'], stdout=subprocess.PIPE) + time.sleep(1) else: subprocess.call(['reload', 'dovecot'], stdout=subprocess.PIPE) |
