# HG changeset patch # User Pascal Volk # Date 1209418408 0 # Node ID 48ea255e8a85241e8e0deef4e192c751b7d5ed91 # Parent d5ad5432e9eb27660ad9005ca6bbb1f0fe1183a5 * 'vmm.cfg.5' - Added to repository * 'vmm.cfg' * 'update_config_0.3.x-0.4.py' * 'VirtualMailManager/VirtualMailManager.py' * 'VirtualMailManager/Config.py' - Moved option 'base' from section 'maildir' to section 'domdir' * 'VirtualMailManager/Account.py' - Removed parameter 'address' from Account._setAddr() * 'VirtualMailManager/Domain.py' - Added 'ORDER BY' clause in queries in Domain.getAccounts() and Domain.getAliases() * 'setup.py' - Adjusted trove classifiers. diff -r d5ad5432e9eb -r 48ea255e8a85 ChangeLog --- a/ChangeLog Sat Apr 26 02:49:34 2008 +0000 +++ b/ChangeLog Mon Apr 28 21:33:28 2008 +0000 @@ -1,4 +1,18 @@ -=== 0.0.0 === +=== 0.4 === +2008-04-28 Pascal Volk + + * vmm.cfg: + * update_config_0.3.x-0.4.py: + * VirtualMailManager/VirtualMailManager.py: + * VirtualMailManager/Config.py: + Moved option 'base' from section 'maildir' to section 'domdir' + * VirtualMailManager/Account.py (Account._setAddr()): + Removed parameter 'address' + * VirtualMailManager/Domain.py (Domain.getAccounts(), Domain.getAliases()): + Added 'ORDER BY' clause in queries. + + setup.py: + Adjusted trove classifiers. + 2008-04-21 Pascal Volk * create_tables.pgsql (table users): diff -r d5ad5432e9eb -r 48ea255e8a85 INSTALL --- a/INSTALL Sat Apr 26 02:49:34 2008 +0000 +++ b/INSTALL Mon Apr 28 21:33:28 2008 +0000 @@ -67,7 +67,7 @@ postmaster_address = postmaster@domain.tld } auth default { - mechanisms = cram-md5 + mechanisms = plain login cram-md5 digest-md5 passdb sql { args = /etc/dovecot/dovecot-sql.conf } @@ -92,7 +92,7 @@ * /etc/dovecot/dovecot-sql.conf driver = pgsql connect = host=localhost dbname=mailsys user=dovecot password=$Dovecot_PASS - default_pass_scheme = HMAC-MD5 + default_pass_scheme = PLAIN password_query = SELECT "user", password FROM dovecot_password WHERE "user"='%u' AND %Ls user_query = SELECT home, uid, gid, 'maildir:'||mail AS mail FROM dovecot_user WHERE userid = '%u' diff -r d5ad5432e9eb -r 48ea255e8a85 TODO --- a/TODO Sat Apr 26 02:49:34 2008 +0000 +++ b/TODO Mon Apr 28 21:33:28 2008 +0000 @@ -1,8 +1,5 @@ # $Id$ -- general - - write manpages - - vmm - add support for relocated_map diff -r d5ad5432e9eb -r 48ea255e8a85 VirtualMailManager/Account.py --- a/VirtualMailManager/Account.py Sat Apr 26 02:49:34 2008 +0000 +++ b/VirtualMailManager/Account.py Mon Apr 28 21:33:28 2008 +0000 @@ -32,7 +32,7 @@ self._mid = 0 self._tid = 0 self._passwd = password - self._setAddr(address) + self._setAddr() self._exists() if self._isAlias(): raise VMMAccountException( @@ -63,8 +63,8 @@ else: return False - def _setAddr(self, address): - self._localpart, d = address.split('@') + def _setAddr(self): + self._localpart, d = self._addr.split('@') dom = Domain(self._dbh, d) self._gid = dom.getID() if self._gid == 0: diff -r d5ad5432e9eb -r 48ea255e8a85 VirtualMailManager/Config.py --- a/VirtualMailManager/Config.py Sat Apr 26 02:49:34 2008 +0000 +++ b/VirtualMailManager/Config.py Mon Apr 28 21:33:28 2008 +0000 @@ -52,7 +52,6 @@ ['name', 'mailsys'] ] self.__mdopts = [ - ['base', '/home/mail'], ['folder', 'Maildir'], ['mode', 448], ['diskusage', 'false'], @@ -65,6 +64,7 @@ ['managesieve', 'true'] ] self.__domdopts = [ + ['base', '/home/mail'], ['mode', 504], ['delete', 'false'] ] @@ -73,7 +73,7 @@ ['du', '/usr/bin/du'] ] self.__miscopts = [ - ['passwdscheme', 'CRAM-MD5'], + ['passwdscheme', 'PLAIN'], ['gid_mail', 8], ['forcedel', 'false'], ['transport', 'dovecot:'] diff -r d5ad5432e9eb -r 48ea255e8a85 VirtualMailManager/Domain.py --- a/VirtualMailManager/Domain.py Sat Apr 26 02:49:34 2008 +0000 +++ b/VirtualMailManager/Domain.py Mon Apr 28 21:33:28 2008 +0000 @@ -214,7 +214,8 @@ def getAccounts(self): """Returns a list with all accounts from the domain.""" dbc = self._dbh.cursor() - dbc.execute("SELECT userid AS users FROM dovecot_user WHERE gid = %s", + dbc.execute("SELECT userid AS users FROM dovecot_user WHERE gid = %s\ + ORDER BY users", self._id) users = dbc.fetchall() dbc.close() @@ -227,7 +228,8 @@ def getAliases(self): """Returns a list with all aliases from the domain.""" dbc = self._dbh.cursor() - dbc.execute("SELECT DISTINCT address FROM postfix_alias WHERE gid=%s", + dbc.execute("SELECT DISTINCT address FROM postfix_alias WHERE gid=%s\ + ORDER BY address", self._id) addresses = dbc.fetchall() dbc.close() diff -r d5ad5432e9eb -r 48ea255e8a85 VirtualMailManager/VirtualMailManager.py --- a/VirtualMailManager/VirtualMailManager.py Sat Apr 26 02:49:34 2008 +0000 +++ b/VirtualMailManager/VirtualMailManager.py Mon Apr 28 21:33:28 2008 +0000 @@ -83,13 +83,13 @@ def __chkenv(self): """""" - if not os.path.exists(self.__Cfg.get('maildir', 'base')): + if not os.path.exists(self.__Cfg.get('domdir', 'base')): old_umask = os.umask(0007) - os.makedirs(self.__Cfg.get('maildir', 'base'), 0770) + os.makedirs(self.__Cfg.get('domdir', 'base'), 0770) os.umask(old_umask) - elif not os.path.isdir(self.__Cfg.get('maildir', 'base')): + elif not os.path.isdir(self.__Cfg.get('domdir', 'base')): raise VMMException(('%s is not a directory' % - self.__Cfg.get('maildir', 'base'), ERR.NO_SUCH_DIRECTORY)) + self.__Cfg.get('domdir', 'base'), ERR.NO_SUCH_DIRECTORY)) for opt, val in self.__Cfg.items('bin'): if not os.path.exists(val): raise VMMException(("%s doesn't exists." % val, @@ -215,7 +215,7 @@ transport = self.__Cfg.get('misc', 'transport') self.__dbConnect() return Domain(self.__dbh, domainname, - self.__Cfg.get('maildir', 'base'), transport) + self.__Cfg.get('domdir', 'base'), transport) def __getDiskUsage(self, directory): """Estimate file space usage for the given directory. @@ -239,7 +239,7 @@ def __domdirmake(self, domdir, gid): os.umask(0006) oldpwd = os.getcwd() - basedir = self.__Cfg.get('maildir', 'base') + basedir = self.__Cfg.get('domdir', 'base') domdirdirs = domdir.replace(basedir+'/', '').split('/') os.chdir(basedir) @@ -295,7 +295,7 @@ def __domdirdelete(self, domdir, gid): if gid > 0: - basedir = '%s' % self.__Cfg.get('maildir', 'base') + basedir = '%s' % self.__Cfg.get('domdir', 'base') domdirdirs = domdir.replace(basedir+'/', '').split('/') if basedir.count('..') or domdir.count('..'): raise VMMException( diff -r d5ad5432e9eb -r 48ea255e8a85 VirtualMailManager/constants/VERSION.py --- a/VirtualMailManager/constants/VERSION.py Sat Apr 26 02:49:34 2008 +0000 +++ b/VirtualMailManager/constants/VERSION.py Mon Apr 28 21:33:28 2008 +0000 @@ -4,4 +4,4 @@ # See COPYING for distribution information. # $Id$ -VERSION = '0.4-dev' +VERSION = '0.4' diff -r d5ad5432e9eb -r 48ea255e8a85 install.sh --- a/install.sh Sat Apr 26 02:49:34 2008 +0000 +++ b/install.sh Mon Apr 28 21:33:28 2008 +0000 @@ -29,6 +29,9 @@ [ -d ${MAN1DIR} ] || mkdir -m 0755 -p ${MAN1DIR} install -m 0644 ${INSTALL_OPTS} vmm.1 ${MAN1DIR} +[ -d ${MAN5DIR} ] || mkdir -m 0755 -p ${MAN5DIR} +install -m 0644 ${INSTALL_OPTS} vmm.cfg.5 ${MAN5DIR} + [ -d ${DOC_DIR} ] || mkdir -m 0755 -p ${DOC_DIR} for DOC in ${DOCS}; do install -m 0644 ${INSTALL_OPTS} ${DOC} ${DOC_DIR} diff -r d5ad5432e9eb -r 48ea255e8a85 setup.py --- a/setup.py Sat Apr 26 02:49:34 2008 +0000 +++ b/setup.py Mon Apr 28 21:33:28 2008 +0000 @@ -42,9 +42,8 @@ 'Operating System :: POSIX :: Linux', 'Operating System :: POSIX :: Other', 'Programming Language :: Python', - 'Topic :: Communications :: Email :: Mail Transport Agents', - 'Topic :: Communications :: Email :: Post-Office :: IMAP', - 'Topic :: Communications :: Email :: Post-Office :: POP3' + 'Topic :: Communications :: Email', + 'Topic :: System :: Systems Administration' ], requires=['pyPgSQL'] ) diff -r d5ad5432e9eb -r 48ea255e8a85 update_config_0.3.x-0.4.py --- a/update_config_0.3.x-0.4.py Sat Apr 26 02:49:34 2008 +0000 +++ b/update_config_0.3.x-0.4.py Mon Apr 28 21:33:28 2008 +0000 @@ -11,7 +11,8 @@ cf.readfp(cff) cff.close() -if not cf.has_option('misc', 'transport') or not cf.has_section('services'): +if not cf.has_option('misc', 'transport') or not cf.has_section('services') \ +or cf.has_option('maildir', 'base'): cff = file('/usr/local/etc/vmm.cfg', 'w') if not cf.has_option('misc', 'transport'): cf.set('misc', 'transport', 'dovecot:') @@ -19,5 +20,9 @@ cf.add_section('services') for service in ['smtp', 'pop3', 'imap', 'managesieve']: cf.set('services', service, 'true') + if cf.has_option('maildir', 'base'): + domdir = cf.get('maildir', 'base') + cf.remove_option('maildir', 'base') + cf.set('domdir', 'base', domdir) cf.write(cff) cff.close() diff -r d5ad5432e9eb -r 48ea255e8a85 vmm.1 --- a/vmm.1 Sat Apr 26 02:49:34 2008 +0000 +++ b/vmm.1 Mon Apr 28 21:33:28 2008 +0000 @@ -1,3 +1,4 @@ +.\" $Id$ .TH "VMM" "1" "26. April 2008" "Pascal Volk" "Virtual Mail Manager" .SH NAME vmm \- commandline tool to manage email domains/accounts/aliases diff -r d5ad5432e9eb -r 48ea255e8a85 vmm.cfg --- a/vmm.cfg Sat Apr 26 02:49:34 2008 +0000 +++ b/vmm.cfg Mon Apr 28 21:33:28 2008 +0000 @@ -20,9 +20,7 @@ # Mail directories # [maildir] -; The base directory for all domains/accounts (String) -base = /home/mail -; default name of the Maildir folder +; default name of the Maildir folder (String) folder = Maildir ; Permissions for maildirs (Int) ; octal 0700 -> decimal 448 @@ -49,6 +47,8 @@ # domain directory settings # [domdir] +; The base directory for all domains/accounts (String) +base = /home/mail ; Permissions for domain directories (Int) ; octal 0770 -> decimal 504 mode = 504 @@ -69,8 +69,8 @@ # [misc] ; Password scheme to use (see also: dovecotpw -l) (String) -passwdscheme = CRAM-MD5 -; numeric group ID of group mail (mail_extra_groups from dovecot.conf) (Int) +passwdscheme = 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 diff -r d5ad5432e9eb -r 48ea255e8a85 vmm.cfg.5 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vmm.cfg.5 Mon Apr 28 21:33:28 2008 +0000 @@ -0,0 +1,199 @@ +.\" $Id$ +.TH vmm.cfg 5 "28. April 2008" "Pascal Volk" +.SH NAME +vmm.cfg \- configuration file for vmm +.SH SYNOPSIS +/usr/local/etc/vmm.cfg +.SH DESCRIPTION +\fBvmm\fR(1) reads configuration data form \fI/usr/local/etc/vmm.cfg\fP. +.br +The configuration file is split in multiple sections. Sections begins with the +section name, enclosed in square brackets '[' and ']' (e.g. \fB[database]\fP), +followed by \'option=value' pairs (e.g. \fBhost = 127.0.0.1\fP). +.br +Whitespace around the '=' and at the end of a value is ignored. +.PP +Empty lines and lines starting with '#' or ';' will be ignored. +.PP +Each value uses one of the following data types: +.IP \(bu +.I Boolean +to indicate if something is enabled/activated (true) or disabled/deactivated +(false). Accepted values for \fBtrue\fP are: \fB1\fP, \fByes\fP, \fBtrue\fP and +\fBon\fP. +.br +Accepted values for \fBfalse\fP are: \fB0\fP, \fBno\fP, \fBfalse\fP and +\fBoff\fP. +.IP \(bu +.I Int +a integer number, written without a fractional or decimal component. For example +\fB1\fP, \fB50\fP or \fB321\fP are integers. +.IP \(bu +.I String +a sequence of characters and numbers. For example '\fBword\fP', '\fBhello +world\fP', or '\fB/usr/bin/strings\fP' +.\" ----- +.SH DATABASE SECTION +This section contains options required for the database connection. +.TP +\fBhost\fP (\fIString\fP) +Hostname or IP address of the database server. +.TP +\fBuser\fP (\fIString\fP) +Name of the database user. +.TP +\fBpass\fP (\fIString\fP) +Database password +.TP +\fBname\fP (\fIString\fP) +Name of the database. +.TP +\fBExample\fP: +[database] +.br +host = localhost +.br +user = vmm +.br +pass = T~_:L4OYyl]TU?) +.br +name = mailsys +.\" ----- +.SH MAILDIR SECTION +This section defines some options for the Maildirs. +.TP +\fBfolder\fP (\fIString\fP) +Default name of the maildir folder in users home directory. +.TP +\fBmode\fP (\fIInt\fP) +Access mode for the maildir in decimal (base 10) notation. For example: +\'drwx------' -> octal 0700 -> decimal 448 +.TP +\fBdiskusage\fP (\fIBoolean\fP) +Decides if the disk usage of users maildir always should be summarized an +displayed with account information. +.TP +\fBdelete\fP (\fIBoolean\fP) +Decides if the maildir should be deleted recursive when the account is deleted. +.TP +\fBExample\fP: +[maildir] +.br +folder = Maildir +.br +mode = 448 +.br +diskusage = false +.br +delete = false +.\" ----- +.SH SERVICES SECTION +This section specifies the default restrictions for each account. +.TP +\fBsmtp\fP (\fIBoolean\fP) +Decides if users can login via smtp by default. +.TP +\fBpop3\fP (\fIBoolean\fP) +Decides if users can login via pop3 by default. +.TP +\fBimap\fP (\fIBoolean\fP) +Decides if users can login via imap by default. +.TP +\fBmanagesieve\fP (\fIBoolean\fP) +Decides if users can login via managesieve by default. +.TP +\fBExample\fP: +[services] +.br +smtp = true +.br +pop3 = true +.br +imap = false +.br +managesieve = false +.\" ----- +.SH DOMDIR SECTION +This section defines some options for the directories of the domains. +.TP +\fBbase\fP (\fIString\fP) +All domain directories will be created inside this directory. +.TP +\fBmode\fP (\fIInt\fP) +Access mode for the domain directory in decimal (base 10) notation. For +example: 'drwxrwx---' -> octal 0770 -> decimal 504 +.TP +\fBdelete\fP (\fIBoolean\fP) +Decides if the domain directory and all user directories inside should be +deleted when a domain is deleted. +.TP +\fBExample\fP: +[domdir] +.br +base = /home/mail +.br +mode = 504 +.br +delete = false +.\" ----- +.SH BIN SECTION +This section contains some paths to some binaries. +.TP +\fBdovecotpw\fP (\fIString\fP) +The absolute path to the dovecotpw binary. This binary is used to generate a +password hash, if the \fIpasswdscheme\fP is one of 'SMD5', 'SSHA', 'CRAM-MD5', +\'HMAC-MD5', 'LANMAN', 'NTLM' or 'RPA'. +.TP +\fBdu\fP (\fIString\fP) +The absolute path to \fBdu\fR(1). This binary is used to summarize the disk +usage of a maildir. +.TP +\fBExample\fP: +[bin] +.br +dovecotpw = /usr/sbin/dovecotpw +.br +du = /usr/bin/du +.\" ----- +.SH MISC SECTION +This sections defines miscellaneous settings. +.TP +\fBpasswdscheme\fP (\fIString\fP) +Password scheme to use (see also: dovecotpw -l) +.TP +\fBgid_mail\fP (\fIInt\fP) +Numeric group ID of group mail (mail_privileged_group from dovecot.conf) +.TP +\fBforcedel\fP (\fIBoolean\fP) +Force deletion of accounts and aliases when a domain is deleted. +.TP +\fBtransport\fP (\fIString\fP) +Default transport for domains and accounts. +.TP +\fBExample\fP: +[misc] +.br +passwdscheme = CRAM-MD5 +.br +gid_mail = 8 +.br +forcedel = false +.br +transport = dovecot: +.\" ----- +.SH CONFIG SECTION +This section is a internal control section. +.TP +\fBdone\fP (\fIBoolean\fP) +This option is set to \fIfalse\fP when \fBvmm\fP is installed for the first +time. When you edit \fIvmm.cfg\fP, set this option to \fItrue\fP. This option is +also set to \fItrue\fP when you configure vmm with the command \fBvmm +configure\fP. +.br +If this option is set to \fIfalse\fP, \fBvmm\fP will start in the interactive +configurations mode. +.TP +\fBExample\fP: +[config] +.br +done = true