Use the complete Dovecot version, not only the concatenated major
and minor parts. (1.2.11 instead of 12).
--- a/VirtualMailManager/Account.py Sun Apr 25 03:03:09 2010 +0000
+++ b/VirtualMailManager/Account.py Sun Apr 25 04:51:14 2010 +0000
@@ -94,7 +94,7 @@
self._chk_state()
if service not in (None, 'all', 'imap', 'pop3', 'sieve', 'smtp'):
raise AErr(_(u"Unknown service: '%s'.") % service, UNKNOWN_SERVICE)
- if dcvers > 11:
+ if dcvers > 0x10100f0:
sieve_col = 'sieve'
else:
sieve_col = 'managesieve'
@@ -230,7 +230,7 @@
ACCOUNT_MISSING_PASSWORD)
assert all(isinstance(service, bool) for service in (smtp, pop3, imap,
sieve))
- if dcvers > 11:
+ if dcvers > 0x10100f0:
sieve_col = 'sieve'
else:
sieve_col = 'managesieve'
@@ -291,7 +291,7 @@
`dovecot --version`.
"""
self._chk_state()
- if dcvers > 11:
+ if dcvers > 0x10100f0:
sieve_col = 'sieve'
else:
sieve_col = 'managesieve'
--- a/VirtualMailManager/Config.py Sun Apr 25 03:03:09 2010 +0000
+++ b/VirtualMailManager/Config.py Sun Apr 25 04:51:14 2010 +0000
@@ -8,13 +8,14 @@
VMM's configuration module for simplified configuration access.
"""
+import re
from ConfigParser import \
Error, MissingSectionHeaderError, NoOptionError, NoSectionError, \
ParsingError, RawConfigParser
from cStringIO import StringIO# TODO: move interactive stff to cli
-from VirtualMailManager.common import exec_ok, get_unicode, is_dir
+from VirtualMailManager.common import exec_ok, get_unicode, is_dir, version_hex
from VirtualMailManager.constants.ERROR import CONF_ERROR
from VirtualMailManager.errors import ConfigError
@@ -121,7 +122,7 @@
"""
sect_opt = section_option.lower().split('.')
# TODO: cache it
- if len(sect_opt) != 2:# do we need a regexp to check the format?
+ if len(sect_opt) != 2: # do we need a regexp to check the format?
raise BadOptionError(
_(u"Bad format: '%s' - expected: section.option") %
get_unicode(section_option))
@@ -136,7 +137,7 @@
the given ``section``.
"""
- if section in self._sections:# check if the section was parsed
+ if section in self._sections: # check if the section was parsed
sect = self._sections[section]
elif not section in self._cfg:
raise NoSectionError(section)
@@ -171,7 +172,7 @@
try:
return self._cfg[section][option].getter(section, option)
except (NoSectionError, NoOptionError):
- if not self._cfg[section][option].default is None:# may be False
+ if not self._cfg[section][option].default is None: # may be False
return self._cfg[section][option].default
else:
raise NoDefaultError(section, option)
@@ -250,7 +251,7 @@
"""
self.__cls = cls
- if not default is None:# enforce the type of the default value
+ if not default is None: # enforce the type of the default value
self.__default = self.__cls(default)
else:
self.__default = default
@@ -342,7 +343,8 @@
},
'misc': {
'base_directory': LCO(str, '/srv/mail', self.get, is_dir),
- 'dovecot_version': LCO(int, 12, self.getint),
+ 'dovecot_version': LCO(str, '1.2.11', self.hexversion,
+ check_version_format),
'gid_mail': LCO(int, 8, self.getint),
'password_scheme': LCO(str, 'CRAM-MD5', self.get,
self.known_scheme),
@@ -369,8 +371,9 @@
def check(self):
"""Performs a configuration check.
- Raises a ConfigError if the check fails.
-
+ Raises a ConfigError if settings w/o a default value are missed.
+ Or a ConfigValueError if 'misc.dovecot_version' has the wrong
+ format.
"""
# TODO: There are only two settings w/o defaults.
# So there is no need for cStringIO
@@ -384,6 +387,10 @@
for option in options:
errmsg.write((u' %s\n') % option)
raise ConfigError(errmsg.getvalue(), CONF_ERROR)
+ check_version_format(self.get('misc', 'dovecot_version'))
+
+ def hexversion(self, section, option):
+ return version_hex(self.get(section, option))
def known_scheme(self, scheme):
"""Converts `scheme` to upper case and checks if is known by
@@ -423,4 +430,15 @@
return not errors
+def check_version_format(version_string):
+ """Check if the *version_string* has the proper format, e.g.: '1.2.3'.
+ Returns the validated version string if it has the expected format.
+ Otherwise a `ConfigValueError` will be raised.
+ """
+ version_re = r'^\d+\.\d+\.(?:\d+|(?:alpha|beta|rc)\d+)$'
+ if not re.match(version_re, version_string):
+ raise ConfigValueError(_(u"Not a valid Dovecot version: '%s'") %
+ get_unicode(version_string))
+ return version_string
+
del _
--- a/VirtualMailManager/Handler.py Sun Apr 25 03:03:09 2010 +0000
+++ b/VirtualMailManager/Handler.py Sun Apr 25 04:51:14 2010 +0000
@@ -381,7 +381,7 @@
'LANMAN', 'NTLM', 'RPA']:
cmd_args = [self._Cfg.dget('bin.dovecotpw'), '-s', self._scheme,
'-p', password]
- if self._Cfg.dget('misc.dovecot_version') >= 20:
+ if self._Cfg.dget('misc.dovecot_version') >= 0x20000a1:
cmd_args.insert(1, 'pw')
return Popen(cmd_args, stdout=PIPE).communicate()[0][:-1]
else:
--- a/VirtualMailManager/maillocation.py Sun Apr 25 03:03:09 2010 +0000
+++ b/VirtualMailManager/maillocation.py Sun Apr 25 04:51:14 2010 +0000
@@ -26,13 +26,14 @@
SDBOX_NAME = 'dbox'
_storage = {
- MAILDIR_ID: dict(dovecot_version=10, postfix=True, prefix='maildir:',
- directory=MAILDIR_NAME, mid=MAILDIR_ID),
- MBOX_ID: dict(dovecot_version=10, postfix=True, prefix='mbox:',
+ MAILDIR_ID: dict(dovecot_version=0x10000f0, postfix=True,
+ prefix='maildir:', directory=MAILDIR_NAME,
+ mid=MAILDIR_ID),
+ MBOX_ID: dict(dovecot_version=0x10000f0, postfix=True, prefix='mbox:',
directory=MBOX_NAME, mid=MBOX_ID),
- MDBOX_ID: dict(dovecot_version=20, postfix=False, prefix='mdbox:',
+ MDBOX_ID: dict(dovecot_version=0x20000a1, postfix=False, prefix='mdbox:',
directory=MDBOX_NAME, mid=MDBOX_ID),
- SDBOX_ID: dict(dovecot_version=12, postfix=False, prefix='dbox:',
+ SDBOX_ID: dict(dovecot_version=0x10000f0, postfix=False, prefix='dbox:',
directory=SDBOX_NAME, mid=SDBOX_ID),
}
--- a/man/de/man5/vmm.cfg.5.rst Sun Apr 25 03:03:09 2010 +0000
+++ b/man/de/man5/vmm.cfg.5.rst Sun Apr 25 04:51:14 2010 +0000
@@ -364,12 +364,12 @@
.. _misc.dovecot_version:
-``dovecot_version (Vorgabe: 12)`` : *Int*
- Die verketteten Major- und Minor-Teile der eingesetzten Dovecot-Version
- (siehe: **dovecot --version**).
+``dovecot_version (Vorgabe: 1.2.11)`` : *String*
+ Die eingesetzten Dovecot-Version. (siehe: **dovecot --version**).
- Wenn das Kommando **dovecot --version** zum Beispiel *1.1.18* ausgibt, ist
- dieser Option der Wert **11** zuzuweisen.
+ Wenn das Kommando **dovecot --version** zum Beispiel
+ *2.0.beta4 (8818db00d347)* ausgibt, ist dieser Option der Wert
+ **2.0.beta4** zuzuweisen.
Beispiel::
@@ -378,7 +378,7 @@
password_scheme = PLAIN
gid_mail = 8
transport = dovecot:
- dovecot_version = 11
+ dovecot_version = 2.0.beta4
DATEIEN
--- a/man/man5/vmm.cfg.5.rst Sun Apr 25 03:03:09 2010 +0000
+++ b/man/man5/vmm.cfg.5.rst Sun Apr 25 04:51:14 2010 +0000
@@ -349,12 +349,12 @@
.. _misc.dovecot_version:
-``dovecot_version (default: 12)`` : *Int*
- The concatenated major and minor version number of the currently used
- Dovecot version. (see: **dovecot --version**).
+``dovecot_version (default: 1.2.11)`` : *String*
+ The version number of the currently used Dovecot version.
+ (see: **dovecot --version**).
- When, for example, the command **dovecot --version** prints *1.1.18*, set
- the value of this option to **11**.
+ When, for example, the command **dovecot --version** prints
+ *2.0.beta4 (8818db00d347)*, set the value of this option to **2.0.beta4**.
Example::
@@ -363,7 +363,7 @@
password_scheme = PLAIN
gid_mail = 8
transport = dovecot:
- dovecot_version = 11
+ dovecot_version = 2.0.beta4
FILES
--- a/update_config.py Sun Apr 25 03:03:09 2010 +0000
+++ b/update_config.py Sun Apr 25 04:51:14 2010 +0000
@@ -67,6 +67,18 @@
cp.set(ds, do, val)
sect_opt.append((dst, 'N'))
+
+def set_dovecot_version(cp):
+ if len(os.sys.argv) > 1:
+ dovecot_version = os.sys.argv[1].strip()
+ if not dovecot_version:
+ dovecot_version = '1.2.11'
+ else:
+ dovecot_version = '1.2.11'
+ cp.set('misc', 'dovecot_version', dovecot_version)
+ sect_opt.append(('misc.dovecot_version', 'M'))
+
+
def get_option(cp, src):
ss, so = src.split('.')
return cp.get(ss, so)
@@ -95,6 +107,8 @@
('misc.dovecotvers', 'misc.dovecot_version')):
move_option(cp, src, dst)
cp.remove_section('maildir')
+ set_dovecot_version(cp)
+
# def main():
if __name__ == '__main__':
@@ -108,7 +122,7 @@
update_cfg_file(cp, cf)
sect_opt.sort()
print 'Please have a look at your configuration: %s' %cf
- print 'This are your Renamed/New settings:'
+ print 'This are your Modified/Renamed/New settings:'
for s_o, st in sect_opt:
print '%s %s = %s' % (st, s_o, get_option(cp, s_o))
if had_config:
--- a/upgrade.sh Sun Apr 25 03:03:09 2010 +0000
+++ b/upgrade.sh Sun Apr 25 04:51:14 2010 +0000
@@ -10,7 +10,7 @@
PF_CONFDIR=$(postconf -h config_directory)
PF_GID=$(id -g $(postconf -h mail_owner))
POSTCONF=$(which postconf)
-DOVECOT_VERS=$(dovecot --version | awk -F . '{print $1 $2}')
+DOVECOT_VERS=$(dovecot --version | awk '{print $1}')
LOCALE_DIR=${PREFIX}/share/locale
DOC_DIR=${PREFIX}/share/doc/vmm
if [ ${PREFIX} = "/usr" ]; then
@@ -29,7 +29,7 @@
fi
# update config file before installing the new files.
-./update_config.py
+./update_config.py ${DOVECOT_VERS:-'1.2.11'}
rv=$?
if [ $rv -eq 2 ]; then
echo "please run the install.sh script"
--- a/vmm.cfg Sun Apr 25 03:03:09 2010 +0000
+++ b/vmm.cfg Sun Apr 25 04:51:14 2010 +0000
@@ -96,9 +96,9 @@
gid_mail = 8
; default transport for domains and accounts (String)
transport = dovecot:
-; the concatenated major and minor version number from `dovecot --version` (Int)
-; e.g. 1.0.15 -> 10; 1.1.18 -> 11; 1.2.3 -> 12
-dovecot_version = 12
+; the version number from `dovecot --version` (String)
+; e.g. 1.1.18; 1.2.11; 2.0.beta4
+dovecot_version = 1.2.11
#
# Configuration state