vmm.cfg: dealt with the most overdue section/option renaming. v0.6.x
authorPascal Volk <neverseen@users.sourceforge.net>
Wed, 13 Jan 2010 00:08:44 +0000
branchv0.6.x
changeset 166 b152ad5c7071
parent 165 7e50e4c49ed7
child 167 bb58aedefa3a
vmm.cfg: dealt with the most overdue section/option renaming. Added new options. Details: old new ------------------------------------------------------------ domdir.mode -> domain.directory_mode domdir.delete -> domain.delete_directory domdir.base -> misc.base_dir domdir -> _section domdir deleted_ maildir.mode -> account.directory_mode maildir.diskusage -> account.disk_usage maildir.delete -> account.delete_directory misc.forcedel -> domain.force_del misc.passwdscheme -> misc.password_scheme misc.dovecotvers -> misc.dovecot_vers services.smtp -> account.smtp services.pop3 -> account.pop3 services.imap -> account.imap services.sieve -> account.sieve services -> _section services deleted_ _NEW_.random_password -> account.random_password _NEW_.password_len -> account.password_len _NEW_.auto_postmaster -> domain.auto_postmaster
VirtualMailManager/Config.py
VirtualMailManager/VirtualMailManager.py
vmm
vmm.cfg
--- a/VirtualMailManager/Config.py	Mon Jan 04 22:35:07 2010 +0000
+++ b/VirtualMailManager/Config.py	Wed Jan 13 00:08:44 2010 +0000
@@ -26,8 +26,8 @@
         ConfigParser.__init__(self)
         self.__cfgFileName = filename
         self.__cfgFile = None
-        self.__VMMsections = ['database', 'maildir', 'services', 'domdir',
-                'bin', 'misc', 'config']
+        self.__VMMsections = ('account', 'bin', 'database', 'domain',
+                              'maildir', 'misc', 'config')
         self.__changes = False
         self.__missing = {}
         self.__dbopts = [
@@ -39,20 +39,23 @@
         self.__mdopts = [
                 ['name', 'Maildir'],
                 ['folders', 'Drafts:Sent:Templates:Trash'],
-                ['mode', 448],
-                ['diskusage', 'false'],
-                ['delete', 'false']
                 ]
-        self.__serviceopts = [
+        self.__accountopts = [
+                ['delete_directory', 'false'],
+                ['directory_mode', 448],
+                ['disk_usage', 'false'],
+                ['password_len', 8],
+                ['random_password', 'false'],
                 ['smtp', 'true'],
                 ['pop3', 'true'],
                 ['imap', 'true'],
                 ['sieve', 'true']
                 ]
         self.__domdopts = [
-                ['base', '/srv/mail'],
-                ['mode', 504],
-                ['delete', 'false']
+                ['auto_postmaster', 'true'],
+                ['delete_directory', 'false'],
+                ['directory_mode', 504],
+                ['force_del', 'false'],
                 ]
         self.__binopts = [
                 ['dovecotpw', '/usr/sbin/dovecotpw'],
@@ -60,11 +63,11 @@
                 ['postconf', '/usr/sbin/postconf']
                 ]
         self.__miscopts = [
-                ['passwdscheme', 'PLAIN'],
+                ['base_dir', '/srv/mail'],
+                ['dovecot_vers', '11'],
                 ['gid_mail', 8],
-                ['forcedel', 'false'],
+                ['password_scheme', 'PLAIN'],
                 ['transport', 'dovecot:'],
-                ['dovecotvers', '11']
                 ]
 
     def load(self):
@@ -167,9 +170,9 @@
             opts = self.__dbopts
         elif section == 'maildir':
             opts = self.__mdopts
-        elif section == 'services':
-            opts = self.__serviceopts
-        elif section == 'domdir':
+        elif section == 'account':
+            opts = self.__accountopts
+        elif section == 'domain':
             opts = self.__domdopts
         elif section == 'bin':
             opts = self.__binopts
--- a/VirtualMailManager/VirtualMailManager.py	Mon Jan 04 22:35:07 2010 +0000
+++ b/VirtualMailManager/VirtualMailManager.py	Wed Jan 13 00:08:44 2010 +0000
@@ -51,7 +51,7 @@
             self.__Cfg.load()
             self.__Cfg.check()
             self.__cfgSections = self.__Cfg.getsections()
-            self.__scheme = self.__Cfg.get('misc', 'passwdscheme')
+            self.__scheme = self.__Cfg.get('misc', 'password_scheme')
             self._postconf = Postconf(self.__Cfg.get('bin', 'postconf'))
         if not os.sys.argv[1] in ['cf', 'configure']:
             self.__chkenv()
@@ -83,16 +83,16 @@
 
     def __chkenv(self):
         """"""
-        if not os.path.exists(self.__Cfg.get('domdir', 'base')):
+        if not os.path.exists(self.__Cfg.get('misc', 'base_dir')):
             old_umask = os.umask(0006)
-            os.makedirs(self.__Cfg.get('domdir', 'base'), 0771)
-            os.chown(self.__Cfg.get('domdir', 'base'), 0,
+            os.makedirs(self.__Cfg.get('misc', 'base_dir'), 0771)
+            os.chown(self.__Cfg.get('misc', 'base_dir'), 0,
                     self.__Cfg.getint('misc', 'gid_mail'))
             os.umask(old_umask)
-        elif not os.path.isdir(self.__Cfg.get('domdir', 'base')):
+        elif not os.path.isdir(self.__Cfg.get('misc', 'base_dir')):
             raise VMMException(_(u'“%s” is not a directory.\n\
-(vmm.cfg: section "domdir", option "base")') %
-                self.__Cfg.get('domdir', 'base'), ERR.NO_SUCH_DIRECTORY)
+(vmm.cfg: section "misc", option "base_dir")') %
+                self.__Cfg.get('misc', 'base_dir'), ERR.NO_SUCH_DIRECTORY)
         for opt, val in self.__Cfg.items('bin'):
             if not os.path.exists(val):
                 raise VMMException(_(u'“%(binary)s” doesn\'t exist.\n\
@@ -237,7 +237,7 @@
             transport = self.__Cfg.get('misc', 'transport')
         self.__dbConnect()
         return Domain(self.__dbh, domainname,
-                self.__Cfg.get('domdir', 'base'), transport)
+                self.__Cfg.get('misc', 'base_dir'), transport)
 
     def __getDiskUsage(self, directory):
         """Estimate file space usage for the given directory.
@@ -259,7 +259,7 @@
 
     def __makedir(self, directory, mode=None, uid=None, gid=None):
         if mode is None:
-            mode = self.__Cfg.getint('maildir', 'mode')
+            mode = self.__Cfg.getint('account', 'directory_mode')
         if uid is None:
             uid = 0
         if gid is None:
@@ -270,17 +270,17 @@
     def __domDirMake(self, domdir, gid):
         os.umask(0006)
         oldpwd = os.getcwd()
-        basedir = self.__Cfg.get('domdir', 'base')
+        basedir = self.__Cfg.get('misc', 'base_dir')
         domdirdirs = domdir.replace(basedir+'/', '').split('/')
 
         os.chdir(basedir)
         if not os.path.isdir(domdirdirs[0]):
             self.__makedir(domdirdirs[0], 489, 0,
-                    self.__Cfg.getint('misc', 'gid_mail'))
+                           self.__Cfg.getint('misc', 'gid_mail'))
         os.chdir(domdirdirs[0])
         os.umask(0007)
-        self.__makedir(domdirdirs[1], self.__Cfg.getint('domdir', 'mode'), 0,
-                gid)
+        self.__makedir(domdirdirs[1],
+                       self.__Cfg.getint('domain', 'directory_mode'), 0, gid)
         os.chdir(oldpwd)
 
     def __subscribeFL(self, folderlist, uid, gid):
@@ -313,7 +313,7 @@
             and re.match(RE_MBOX_NAMES, folder):
                 folders.append('%s/.%s' % (maildir, folder))
         subdirs = ['cur', 'new', 'tmp']
-        mode = self.__Cfg.getint('maildir', 'mode')
+        mode = self.__Cfg.getint('account', 'directory_mode')
 
         self.__makedir('%s' % uid, mode, uid, gid)
         os.chdir('%s' % uid)
@@ -348,7 +348,7 @@
         if gid > 0:
             if not self.__isdir(domdir):
                 return
-            basedir = self.__Cfg.get('domdir', 'base')
+            basedir = self.__Cfg.get('misc', 'base_dir')
             domdirdirs = domdir.replace(basedir+'/', '').split('/')
             domdirparent = os.path.join(basedir, domdirdirs[0])
             if basedir.count('..') or domdir.count('..'):
@@ -487,7 +487,7 @@
         dom = self.__getDomain(domainname)
         gid = dom.getID()
         domdir = dom.getDir()
-        if self.__Cfg.getboolean('misc', 'forcedel') or force == 'delall':
+        if self.__Cfg.getboolean('domain', 'force_del') or force == 'delall':
             dom.delete(True, True)
         elif force == 'deluser':
             dom.delete(delUser=True)
@@ -495,7 +495,7 @@
             dom.delete(delAlias=True)
         else:
             dom.delete()
-        if self.__Cfg.getboolean('domdir', 'delete'):
+        if self.__Cfg.getboolean('domain', 'delete_directory'):
             self.__domDirDelete(domdir, gid)
 
     def domainInfo(self, domainname, details=None):
@@ -589,11 +589,11 @@
             password = self._readpass()
             acc.setPassword(self.__pwhash(password))
         acc.save(self.__Cfg.get('maildir', 'name'),
-                self.__Cfg.getint('misc', 'dovecotvers'),
-                self.__Cfg.getboolean('services', 'smtp'),
-                self.__Cfg.getboolean('services', 'pop3'),
-                self.__Cfg.getboolean('services', 'imap'),
-                self.__Cfg.getboolean('services', 'sieve'))
+                self.__Cfg.getint('misc', 'dovecot_vers'),
+                self.__Cfg.getboolean('account', 'smtp'),
+                self.__Cfg.getboolean('account', 'pop3'),
+                self.__Cfg.getboolean('account', 'imap'),
+                self.__Cfg.getboolean('account', 'sieve'))
         self.__mailDirMake(acc.getDir('domain'), acc.getUID(), acc.getGID())
 
     def aliasAdd(self, aliasaddress, targetaddress):
@@ -615,7 +615,7 @@
         uid = acc.getUID()
         gid = acc.getGID()
         acc.delete(force)
-        if self.__Cfg.getboolean('maildir', 'delete'):
+        if self.__Cfg.getboolean('account', 'delete_directory'):
             try:
                 self.__userDirDelete(acc.getDir('domain'), uid, gid)
             except VMMException, e:
@@ -643,8 +643,8 @@
             raise VMMException(_(u'Invalid argument: “%s”') % details,
                     ERR.INVALID_AGUMENT)
         acc = self.__getAccount(emailaddress)
-        info = acc.getInfo(self.__Cfg.getint('misc', 'dovecotvers'))
-        if self.__Cfg.getboolean('maildir', 'diskusage')\
+        info = acc.getInfo(self.__Cfg.getint('misc', 'dovecot_vers'))
+        if self.__Cfg.getboolean('account', 'disk_usage')\
         or details in ['du', 'full']:
             info['disk usage'] = self.__getDiskUsage('%(maildir)s' % info)
             if details in [None, 'du']:
@@ -682,7 +682,7 @@
    in a future release.\n\
    Please use the service name “sieve” instead.'))
         acc = self.__getAccount(emailaddress)
-        acc.disable(self.__Cfg.getint('misc', 'dovecotvers'), service)
+        acc.disable(self.__Cfg.getint('misc', 'dovecot_vers'), service)
 
     def userEnable(self, emailaddress, service=None):
         if service == 'managesieve':
@@ -692,7 +692,7 @@
    in a future release.\n\
    Please use the service name “sieve” instead.'))
         acc = self.__getAccount(emailaddress)
-        acc.enable(self.__Cfg.getint('misc', 'dovecotvers'), service)
+        acc.enable(self.__Cfg.getint('misc', 'dovecot_vers'), service)
 
     def relocatedAdd(self, emailaddress, targetaddress):
         relocated = self.__getRelocated(emailaddress, targetaddress)
--- a/vmm	Mon Jan 04 22:35:07 2010 +0000
+++ b/vmm	Wed Jan 13 00:08:44 2010 +0000
@@ -77,7 +77,7 @@
 
 def _getOrder():
     order = ()
-    if vmm.cfgGetInt('misc', 'dovecotvers') > 11:
+    if vmm.cfgGetInt('misc', 'dovecot_vers') > 11:
         sieve_name = u'sieve'
     else:
         sieve_name = u'managesieve'
@@ -87,7 +87,7 @@
                 (u'aliases', 0), (u'relocated', 0))
     elif argv[1] in (u'ui', u'userinfo'):
         if argc == 4 and argv[3] != u'aliases'\
-        or vmm.cfgGetBoolean('maildir', 'diskusage'):
+        or vmm.cfgGetBoolean('account', 'disk_usage'):
             order = ((u'address', 0), (u'name', 0), (u'uid', 1), (u'gid', 1),
                     (u'transport', 0), (u'maildir', 0), (u'disk usage', 0),
                     (u'smtp', 1), (u'pop3', 1), (u'imap', 1), (sieve_name, 1))
--- a/vmm.cfg	Mon Jan 04 22:35:07 2010 +0000
+++ b/vmm.cfg	Wed Jan 13 00:08:44 2010 +0000
@@ -12,52 +12,60 @@
 user = dbuser
 ; Database password (String)
 pass = dbpassword
-; database name (String)
+; Database name (String)
 name = mailsys
 
 #
-# Mail directories
+# Maildir folder
 #
 [maildir]
 ; Default name of the Maildir folder (String)
 name = Maildir
 ; A colon separated list of folder names, that should be created (String)
-; e.g.: folders = Drafts:Sent:Templates:Trash
+; e.g.: folders = Drafts:Sent:Templates:Trash:Lists.Dovecot:Lists.Postfix
 folders = Drafts:Sent:Templates:Trash
-; Permissions for maildirs (Int)
-; octal 0700 -> decimal 448
-mode = 448
-; Display disk usage in account info by default? (Boolean)
-diskusage = false
-; Delete maildir recursive when deleting an account? (Boolean)
-delete = false
+
+#
+# Domain settings
+#
+[domain]
+; Should vmm create the postmaster account when a new domain is created?
+; (Boolean)
+auto_postmaster = true
+; Delete domain directory recursive when deleting a domain? (Boolean)
+delete_directory = false
+; Permissions for domain directories (Int)
+; octal 0770 -> decimal 504
+directory_mode = 504
+; Force deletion of accounts and aliases when deleting a domain (Boolean)
+force_del = false
 
 #
-# Services per user
+# Account settings
 #
-[services]
-; allow smtp by default? (Boolean)
+[account]
+; Delete the user's home directory recursive when deleting an account? (Boolean)
+delete_directory = false
+; Permissions for the user's home directory and mail directories (Int)
+; octal 0700 -> decimal 448
+directory_mode = 448
+; Display disk usage in account info by default? (Boolean)
+disk_usage = false
+; Should vmm generate a random password when no password was given for the
+; useradd subcommand? (Boolean)
+random_password = false
+; How many characters to include in the generated passwords? (Int)
+password_len = 8
+; Allow smtp by default? (Boolean)
 smtp = true
-; allow pop3 by default? (Boolean)
+; Allow pop3 by default? (Boolean)
 pop3 = true
-; allow imap by default? (Boolean)
+; Allow imap by default? (Boolean)
 imap = true
-; allow managesieve by default? (Boolean)
+; Allow managesieve by default? (Boolean)
 sieve = true
 
 #
-# domain directory settings
-#
-[domdir]
-; The base directory for all domains/accounts (String)
-base = /srv/mail
-; Permissions for domain directories (Int)
-; octal 0770 -> decimal 504
-mode = 504
-; Delete domain directory recursive when deleting a domain? (Boolean)
-delete = false
-
-#
 # external binaries
 #
 [bin]
@@ -72,17 +80,17 @@
 # misc settings
 #
 [misc]
+; The base directory for all domains/accounts (String)
+base_dir = /srv/mail
 ; Password scheme to use (see also: dovecotpw -l) (String)
-passwdscheme = PLAIN
+password_scheme = PLAIN
 ; numeric group ID of group mail (mail_privileged_group from dovecot.conf) (Int)
 gid_mail = 8
-; force deletion of accounts and aliases (Boolean)
-forcedel = false
-; default transport for domains and accounts
+; 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
-dovecotvers = 11
+dovecot_vers = 11
 
 #
 # Configuration state