--- a/.hgignore Thu Jan 13 12:48:30 2011 +0000
+++ b/.hgignore Thu Jan 13 12:54:53 2011 +0000
@@ -5,3 +5,4 @@
*.py?
.*.swp
.swp
+doc/build
--- a/INSTALL Thu Jan 13 12:48:30 2011 +0000
+++ b/INSTALL Thu Jan 13 12:54:53 2011 +0000
@@ -1,21 +1,41 @@
Installation Prerequisites
You should already have installed and configured Postfix, Dovecot and
PostgreSQL.
-You have to install Python and pyPgSQL* to use the Virtual Mail Manager.
-If you want to store the passwords as PLAIN-MD4 digest you have also to install
-python-crypto <http://www.amk.ca/python/code/crypto.html>.
+
+The Virtual Mail Manager depends on:
+ - Python (>= 2.4.0)
+ - Psycopg 2¹ or pyPgSQL²
-* = http://pypgsql.sourceforge.net/ (Debian: python-pgsql)
+If you are using Python <= 2.5.0:
+ - if you want to store your users' passwords as PLAIN-MD4 digest in
+ the database, vmm will try to use Crypto.Hash.MD4 from PyCrypto³.
+ - if you are using Dovecot >= v1.1.0 and you want to store your users'
+ passwords as SHA256 or SSHA256 hashes, vmm will try to use
+ Crypto.Hash.SHA256 from PyCrypto². For SHA256/SSHA256 you should have
+ at least use PyCrypto in version 2.1.0alpha1.
+
+ When the Crypto.Hash module couldn't be imported, vmm will use
+ dovecotpw/doveadm, if the misc.password_scheme setting in the vmm.cfg
+ is set to PLAIN-MD4, SHA256 or SSHA256
+
+[1] Psycopg: <http://initd.org/psycopg/> (Debian: python-psycopg2)
+[2] pyPgSQL: <http://pypgsql.sourceforge.net/> (Debian: python-pgsql)
+[3] PyCrypto: <http://www.pycrypto.org/> (Debian: python-crypto)
Configuring PostgreSQL
+(for more details see: http://vmm.localdomain.org/PreparingPostgreSQL)
-* /etc/postgresql/8.2/main/pg_hba.conf
+* /etc/postgresql/8.4/main/pg_hba.conf
+ [ if you prefer to connect via TCP/IP ]
# IPv4 local connections:
host mailsys +mailsys 127.0.0.1/32 md5
+ [ if you want to connect through a local Unix-domain socket ]
+ # "local" is for Unix domain socket connections only
+ local mailsys +mailsys md5
# reload configuration
- /etc/init.d/postgresql-8.2 force-reload
+ /etc/init.d/postgresql-8.4 force-reload
* Create a DB user if necessary:
DB Superuser:
@@ -23,24 +43,25 @@
DB User:
createuser -d -E -e -P $USERNAME
-* Create Database and db users for Postfix and Dovecot
+* Create Database and db users for vmm, Postfix and Dovecot
connecting to PostgreSQL:
psql template1
- # create database
- CREATE DATABASE mailsys ENCODING 'UTF8';
+ # create users, group and the database
+ CREATE USER vmm ENCRYPTED PASSWORD 'DB PASSWORD for vmm';
+ CREATE USER dovecot ENCRYPTED password 'DB PASSWORD for Dovecot';
+ CREATE USER postfix ENCRYPTED password 'DB PASSWORD for Postfix';
+ CREATE ROLE mailsys WITH USER postfix, dovecot, vmm;
+ CREATE DATABASE mailsys WITH OWNER vmm ENCODING 'UTF8';
+ \q
+
# connect to the new database
- \c mailsys
+ psql mailsys vmm -W -h 127.0.0.1
# either import the database structure for Dovecot v1.0.x/v1.1.x
\i /path/to/create_tables.pgsql
# or import the database structure for Dovecot v1.2.x
\i /path/to/create_tables-dovecot-1.2.x.pgsql
- # create users and group
- CREATE USER postfix ENCRYPTED password 'DB PASSWORD for Postfix';
- CREATE USER dovecot ENCRYPTED password 'DB PASSWORD for Dovecot';
- CREATE ROLE mailsys WITH USER postfix, dovecot;
-
# set permissions
GRANT SELECT ON dovecot_password, dovecot_user TO dovecot;
GRANT SELECT ON postfix_alias, postfix_gid, postfix_maildir,
@@ -54,7 +75,6 @@
cd /srv/mail/
mkdir 0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v w x y z
chmod 771 /srv/mail
- chgrp -R mail /srv/mail
chmod 751 /srv/mail/*
Configuring Dovecot
@@ -63,7 +83,6 @@
# all your other settings
#disable_plaintext_auth = no
mail_location = maildir:~/Maildir
- mail_privileged_group = mail
first_valid_uid = 70000
first_valid_gid = 70000
protocol lda {
@@ -159,9 +178,9 @@
Installing the Virtual Mail Manager and configure the rest
- Installing from SVN or vmm-x.y.z.tar.bz2
- after checking out from svn or extracting the archive change into the new
- directory and type:
+ Installing from Mercurial or vmm-x.y.z.tar.bz2
+ after cloning from the hg repo or extracting the archive change into the
+ new directory and type:
./install.sh
edit all the pgsql-*.cf files in /etc/postfix
--- a/TODO Thu Jan 13 12:48:30 2011 +0000
+++ b/TODO Thu Jan 13 12:54:53 2011 +0000
@@ -1,3 +1,12 @@
+Config
+ cfs - configset sect.opt val
+ cfg - configget sect.opt
+
+ ds - domainservices: smtp pop imap sieve???
+
+
+subcommand for displaying support crypt algorithms.
+
- Aliases
- avoid looping aliases
@@ -8,3 +17,7 @@
+ aliases
+ destinations/alias
+ alias domains
+
+Database:
+ public.users.digestmd5: add "character varying(48)"
+ Outlook will love it. (`doveadm pw -s DIGEST-MD5.hex -p 1 -u 0`)
--- a/UPGRADE Thu Jan 13 12:48:30 2011 +0000
+++ b/UPGRADE Thu Jan 13 12:54:53 2011 +0000
@@ -38,7 +38,7 @@
In prior setups the service dovecot was configured slightly different.
If you have set the command attribute 'user' to 'nobody:mail', so
either remove the group mail or replace it with the group nobody
- or nogroup.
+ or nogroup. (see command output from: id -ng nobody)
e.g.: flags=DRhu user=nobody argv=/usr/local/lib/dovecot/deliver …
--- a/VirtualMailManager/Account.py Thu Jan 13 12:48:30 2011 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,267 +0,0 @@
-# -*- coding: UTF-8 -*-
-# Copyright (c) 2007 - 2010, Pascal Volk
-# See COPYING for distribution information.
-
-"""Virtual Mail Manager's Account class to manage e-mail accounts."""
-
-from __main__ import ERR
-from Exceptions import VMMAccountException as AccE
-from Domain import Domain
-from Transport import Transport
-from MailLocation import MailLocation
-from EmailAddress import EmailAddress
-import VirtualMailManager as VMM
-
-class Account(object):
- """Class to manage e-mail accounts."""
- __slots__ = ('_addr','_base','_gid','_mid','_passwd','_tid','_uid','_dbh')
- def __init__(self, dbh, address, password=None):
- self._dbh = dbh
- self._base = None
- if isinstance(address, EmailAddress):
- self._addr = address
- else:
- raise TypeError("Argument 'address' is not an EmailAddress")
- self._uid = 0
- self._gid = 0
- self._mid = 0
- self._tid = 0
- self._passwd = password
- self._setAddr()
- self._exists()
- if self._uid < 1 and VMM.VirtualMailManager.aliasExists(self._dbh,
- self._addr):
- # TP: Hm, what quotation marks should be used?
- # If you are unsure have a look at:
- # http://en.wikipedia.org/wiki/Quotation_mark,_non-English_usage
- raise AccE(_(u"There is already an alias with the address “%s”.") %\
- self._addr, ERR.ALIAS_EXISTS)
- if self._uid < 1 and VMM.VirtualMailManager.relocatedExists(self._dbh,
- self._addr):
- raise AccE(
- _(u"There is already a relocated user with the address “%s”.") %\
- self._addr, ERR.RELOCATED_EXISTS)
-
- def _exists(self):
- dbc = self._dbh.cursor()
- dbc.execute("SELECT uid, mid, tid FROM users \
-WHERE gid=%s AND local_part=%s",
- self._gid, self._addr._localpart)
- result = dbc.fetchone()
- dbc.close()
- if result is not None:
- self._uid, self._mid, self._tid = result
- return True
- else:
- return False
-
- def _setAddr(self):
- dom = Domain(self._dbh, self._addr._domainname)
- self._gid = dom.getID()
- if self._gid == 0:
- raise AccE(_(u"The domain “%s” doesn't exist.") %\
- self._addr._domainname, ERR.NO_SUCH_DOMAIN)
- self._base = dom.getDir()
- self._tid = dom.getTransportID()
-
- def _setID(self):
- dbc = self._dbh.cursor()
- dbc.execute("SELECT nextval('users_uid')")
- self._uid = dbc.fetchone()[0]
- dbc.close()
-
- def _prepare(self, maillocation):
- self._setID()
- self._mid = MailLocation(self._dbh, maillocation=maillocation).getID()
-
- def _switchState(self, state, dcvers, service):
- if not isinstance(state, bool):
- return False
- if not service in (None, 'all', 'imap', 'pop3', 'sieve', 'smtp'):
- raise AccE(_(u"Unknown service “%s”.") % service,
- ERR.UNKNOWN_SERVICE)
- if self._uid < 1:
- raise AccE(_(u"The account “%s” doesn't exist.") % self._addr,
- ERR.NO_SUCH_ACCOUNT)
- if dcvers > 11:
- sieve_col = 'sieve'
- else:
- sieve_col = 'managesieve'
- if service in ('smtp', 'pop3', 'imap'):
- sql = 'UPDATE users SET %s = %s WHERE uid = %d' % (service, state,
- self._uid)
- elif service == 'sieve':
- sql = 'UPDATE users SET %s = %s WHERE uid = %d' % (sieve_col,
- state, self._uid)
- else:
- sql = 'UPDATE users SET smtp = %(s)s, pop3 = %(s)s, imap = %(s)s,\
- %(col)s = %(s)s WHERE uid = %(uid)d' % {
- 's': state, 'col': sieve_col, 'uid': self._uid}
- dbc = self._dbh.cursor()
- dbc.execute(sql)
- if dbc.rowcount > 0:
- self._dbh.commit()
- dbc.close()
-
- def __aliaseCount(self):
- dbc = self._dbh.cursor()
- q = "SELECT COUNT(destination) FROM alias WHERE destination = '%s'"\
- %self._addr
- dbc.execute(q)
- a_count = dbc.fetchone()[0]
- dbc.close()
- return a_count
-
- def setPassword(self, password):
- self._passwd = password
-
- def getUID(self):
- return self._uid
-
- def getGID(self):
- return self._gid
-
- def getDir(self, directory):
- if directory == 'domain':
- return '%s' % self._base
- elif directory == 'home':
- return '%s/%i' % (self._base, self._uid)
-
- def enable(self, dcvers, service=None):
- self._switchState(True, dcvers, service)
-
- def disable(self, dcvers, service=None):
- self._switchState(False, dcvers, service)
-
- def save(self, maillocation, dcvers, smtp, pop3, imap, sieve):
- if self._uid < 1:
- if dcvers > 11:
- sieve_col = 'sieve'
- else:
- sieve_col = 'managesieve'
- self._prepare(maillocation)
- sql = "INSERT INTO users (local_part, passwd, uid, gid, mid, tid,\
- smtp, pop3, imap, %s) VALUES ('%s', '%s', %d, %d, %d, %d, %s, %s, %s, %s)" % (
- sieve_col, self._addr._localpart, self._passwd, self._uid,
- self._gid, self._mid, self._tid, smtp, pop3, imap, sieve)
- dbc = self._dbh.cursor()
- dbc.execute(sql)
- self._dbh.commit()
- dbc.close()
- else:
- raise AccE(_(u'The account “%s” already exists.') % self._addr,
- ERR.ACCOUNT_EXISTS)
-
- def modify(self, what, value):
- if self._uid == 0:
- raise AccE(_(u"The account “%s” doesn't exist.") % self._addr,
- ERR.NO_SUCH_ACCOUNT)
- if what not in ['name', 'password', 'transport']:
- return False
- dbc = self._dbh.cursor()
- if what == 'password':
- dbc.execute('UPDATE users SET passwd = %s WHERE uid = %s',
- value, self._uid)
- elif what == 'transport':
- self._tid = Transport(self._dbh, transport=value).getID()
- dbc.execute('UPDATE users SET tid = %s WHERE uid = %s',
- self._tid, self._uid)
- else:
- dbc.execute('UPDATE users SET name = %s WHERE uid = %s',
- value, self._uid)
- if dbc.rowcount > 0:
- self._dbh.commit()
- dbc.close()
-
- def getInfo(self, dcvers):
- if dcvers > 11:
- sieve_col = 'sieve'
- else:
- sieve_col = 'managesieve'
- sql = 'SELECT name, uid, gid, mid, tid, smtp, pop3, imap, %s\
- FROM users WHERE uid = %d' % (sieve_col, self._uid)
- dbc = self._dbh.cursor()
- dbc.execute(sql)
- info = dbc.fetchone()
- dbc.close()
- if info is None:
- raise AccE(_(u"The account “%s” doesn't exist.") % self._addr,
- ERR.NO_SUCH_ACCOUNT)
- else:
- keys = ['name', 'uid', 'gid', 'maildir', 'transport', 'smtp',
- 'pop3', 'imap', sieve_col]
- info = dict(zip(keys, info))
- for service in ('smtp', 'pop3', 'imap', sieve_col):
- if bool(info[service]):
- # TP: A service (pop3/imap/…) is enabled/usable for a user
- info[service] = _('enabled')
- else:
- # TP: A service (pop3/imap) isn't enabled/usable for a user
- info[service] = _('disabled')
- info['address'] = self._addr
- info['maildir'] = '%s/%s/%s' % (self._base, info['uid'],
- MailLocation(self._dbh,
- mid=info['maildir']).getMailLocation())
- info['transport'] = Transport(self._dbh,
- tid=info['transport']).getTransport()
- return info
-
- def getAliases(self):
- dbc = self._dbh.cursor()
- dbc.execute("SELECT address ||'@'|| domainname FROM alias, domain_name\
- WHERE destination = %s AND domain_name.gid = alias.gid\
- AND domain_name.is_primary ORDER BY address", str(self._addr))
- addresses = dbc.fetchall()
- dbc.close()
- aliases = []
- if len(addresses) > 0:
- aliases = [alias[0] for alias in addresses]
- return aliases
-
- def delete(self, delalias):
- if self._uid < 1:
- raise AccE(_(u"The account “%s” doesn't exist.") % self._addr,
- ERR.NO_SUCH_ACCOUNT)
- dbc = self._dbh.cursor()
- if delalias == 'delalias':
- dbc.execute('DELETE FROM users WHERE uid= %s', self._uid)
- u_rc = dbc.rowcount
- # delete also all aliases where the destination address is the same
- # as for this account.
- dbc.execute("DELETE FROM alias WHERE destination = %s",
- str(self._addr))
- if u_rc > 0 or dbc.rowcount > 0:
- self._dbh.commit()
- else: # check first for aliases
- a_count = self.__aliaseCount()
- if a_count == 0:
- dbc.execute('DELETE FROM users WHERE uid = %s', self._uid)
- if dbc.rowcount > 0:
- self._dbh.commit()
- else:
- dbc.close()
- raise AccE(
- _(u"There are %(count)d aliases with the destination address\
- “%(address)s”.") %{'count': a_count, 'address': self._addr}, ERR.ALIAS_PRESENT)
- dbc.close()
-
-def getAccountByID(uid, dbh):
- try:
- uid = long(uid)
- except ValueError:
- raise AccE(_(u'uid must be an int/long.'), ERR.INVALID_AGUMENT)
- if uid < 1:
- raise AccE(_(u'uid must be greater than 0.'), ERR.INVALID_AGUMENT)
- dbc = dbh.cursor()
- dbc.execute("SELECT local_part||'@'|| domain_name.domainname AS address,\
- uid, users.gid FROM users LEFT JOIN domain_name ON (domain_name.gid \
- = users.gid AND is_primary) WHERE uid = %s;", uid)
- info = dbc.fetchone()
- dbc.close()
- if info is None:
- raise AccE(_(u"There is no account with the UID “%d”.") % uid,
- ERR.NO_SUCH_ACCOUNT)
- keys = ['address', 'uid', 'gid']
- info = dict(zip(keys, info))
- return info
-
--- a/VirtualMailManager/Alias.py Thu Jan 13 12:48:30 2011 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,122 +0,0 @@
-# -*- coding: UTF-8 -*-
-# Copyright (c) 2007 - 2010, Pascal Volk
-# See COPYING for distribution information.
-
-"""Virtual Mail Manager's Alias class to manage e-mail aliases."""
-
-from __main__ import ERR
-from Exceptions import VMMAliasException as VMMAE
-from Domain import Domain
-from EmailAddress import EmailAddress
-import VirtualMailManager as VMM
-
-class Alias(object):
- """Class to manage e-mail aliases."""
- __slots__ = ('_addr', '_dest', '_gid', '_isNew', '_dbh')
- def __init__(self, dbh, address, destination=None):
- if isinstance(address, EmailAddress):
- self._addr = address
- else:
- raise TypeError("Argument 'address' is not an EmailAddress")
- if destination is None:
- self._dest = None
- elif isinstance(destination, EmailAddress):
- self._dest = destination
- else:
- raise TypeError("Argument 'destination' is not an EmailAddress")
- if address == destination:
- raise VMMAE(_(u"Address and destination are identical."),
- ERR.ALIAS_ADDR_DEST_IDENTICAL)
- self._dbh = dbh
- self._gid = 0
- self._isNew = False
- self._setAddr()
- if not self._dest is None:
- self._exists()
- if VMM.VirtualMailManager.accountExists(self._dbh, self._addr):
- raise VMMAE(_(u"There is already an account with address “%s”.") %\
- self._addr, ERR.ACCOUNT_EXISTS)
- if VMM.VirtualMailManager.relocatedExists(self._dbh, self._addr):
- raise VMMAE(
- _(u"There is already a relocated user with the address “%s”.") %\
- self._addr, ERR.RELOCATED_EXISTS)
-
- def _exists(self):
- dbc = self._dbh.cursor()
- dbc.execute("SELECT gid FROM alias WHERE gid=%s AND address=%s\
- AND destination=%s", self._gid, self._addr._localpart, str(self._dest))
- gid = dbc.fetchone()
- dbc.close()
- if gid is None:
- self._isNew = True
-
- def _setAddr(self):
- dom = Domain(self._dbh, self._addr._domainname)
- self._gid = dom.getID()
- if self._gid == 0:
- raise VMMAE(_(u"The domain “%s” doesn't exist.") %\
- self._addr._domainname, ERR.NO_SUCH_DOMAIN)
-
- def _checkExpansion(self, limit):
- dbc = self._dbh.cursor()
- dbc.execute('SELECT count(gid) FROM alias where gid=%s AND address=%s',
- self._gid, self._addr._localpart)
- curEx = dbc.fetchone()[0]
- dbc.close()
- if curEx == limit:
- errmsg = _(u"""Can't add new destination to alias “%(address)s”.
-Currently this alias expands into %(count)i recipients.
-One more destination will render this alias unusable.
-Hint: Increase Postfix' virtual_alias_expansion_limit
-""") % {'address': self._addr, 'count': curEx}
- raise VMMAE(errmsg, ERR.ALIAS_EXCEEDS_EXPANSION_LIMIT)
-
- def save(self, expansion_limit):
- if self._dest is None:
- raise VMMAE(_(u"No destination address specified for alias."),
- ERR.ALIAS_MISSING_DEST)
- if self._isNew:
- self._checkExpansion(expansion_limit)
- dbc = self._dbh.cursor()
- dbc.execute("INSERT INTO alias (gid, address, destination) VALUES\
- (%s, %s, %s)", self._gid, self._addr._localpart, str(self._dest))
- self._dbh.commit()
- dbc.close()
- else:
- raise VMMAE(
- _(u"The alias “%(a)s” with destination “%(d)s” already exists.")\
- % {'a': self._addr, 'd': self._dest}, ERR.ALIAS_EXISTS)
-
- def getInfo(self):
- dbc = self._dbh.cursor()
- dbc.execute('SELECT destination FROM alias WHERE gid=%s AND address=%s',
- self._gid, self._addr._localpart)
- destinations = dbc.fetchall()
- dbc.close()
- if len(destinations) > 0:
- targets = [destination[0] for destination in destinations]
- return targets
- else:
- raise VMMAE(_(u"The alias “%s” doesn't exist.") % self._addr,
- ERR.NO_SUCH_ALIAS)
-
- def delete(self):
- dbc = self._dbh.cursor()
- if self._dest is None:
- dbc.execute("DELETE FROM alias WHERE gid=%s AND address=%s",
- self._gid, self._addr._localpart)
- else:
- dbc.execute("DELETE FROM alias WHERE gid=%s AND address=%s AND \
- destination=%s", self._gid, self._addr._localpart, str(self._dest))
- rowcount = dbc.rowcount
- dbc.close()
- if rowcount > 0:
- self._dbh.commit()
- else:
- if self._dest is None:
- msg = _(u"The alias “%s” doesn't exist.") % self._addr
- else:
- msg = _(u"The alias “%(a)s” with destination “%(d)s” doesn't\
- exist.") % {'a': self._addr, 'd': self._dest}
- raise VMMAE(msg, ERR.NO_SUCH_ALIAS)
-
--- a/VirtualMailManager/AliasDomain.py Thu Jan 13 12:48:30 2011 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,99 +0,0 @@
-# -*- coding: UTF-8 -*-
-# Copyright (c) 2008 - 2010, Pascal Volk
-# See COPYING for distribution information.
-
-"""Virtual Mail Manager's AliasDomain class to manage alias domains."""
-
-from __main__ import ERR
-from Exceptions import VMMAliasDomainException as VADE
-import VirtualMailManager as VMM
-
-class AliasDomain(object):
- """Class to manage e-mail alias domains."""
- __slots__ = ('__gid', '__name', '_domain', '_dbh')
- def __init__(self, dbh, domainname, targetDomain=None):
- self._dbh = dbh
- self.__name = VMM.VirtualMailManager.chkDomainname(domainname)
- self.__gid = 0
- self._domain = targetDomain
- self._exists()
-
- def _exists(self):
- dbc = self._dbh.cursor()
- dbc.execute('SELECT gid, is_primary FROM domain_name WHERE domainname\
- = %s', self.__name)
- alias = dbc.fetchone()
- dbc.close()
- if alias is not None:
- self.__gid, primary = alias
- if primary:
- raise VADE(_(u"The domain “%s” is a primary domain.") %
- self.__name, ERR.ALIASDOMAIN_ISDOMAIN)
-
- def save(self):
- if self.__gid > 0:
- raise VADE(_(u'The alias domain “%s” already exists.') %self.__name,
- ERR.ALIASDOMAIN_EXISTS)
- if self._domain is None:
- raise VADE(_(u'No destination domain specified for alias domain.'),
- ERR.ALIASDOMAIN_NO_DOMDEST)
- if self._domain._id < 1:
- raise VADE (_(u"The target domain “%s” doesn't exist.") %
- self._domain._name, ERR.NO_SUCH_DOMAIN)
- dbc = self._dbh.cursor()
- dbc.execute('INSERT INTO domain_name (domainname, gid, is_primary)\
- VALUES (%s, %s, FALSE)', self.__name, self._domain._id)
- self._dbh.commit()
- dbc.close()
-
- def info(self):
- if self.__gid > 0:
- dbc = self._dbh.cursor()
- dbc.execute('SELECT domainname FROM domain_name WHERE gid = %s\
- AND is_primary', self.__gid)
- domain = dbc.fetchone()
- dbc.close()
- if domain is not None:
- return {'alias': self.__name, 'domain': domain[0]}
- else:# an almost unlikely case, isn't it?
- raise VADE(
- _(u'There is no primary domain for the alias domain “%s”.')\
- % self.__name, ERR.NO_SUCH_DOMAIN)
- else:
- raise VADE(_(u"The alias domain “%s” doesn't exist.") %
- self.__name, ERR.NO_SUCH_ALIASDOMAIN)
-
- def switch(self):
- if self._domain is None:
- raise VADE(_(u'No destination domain specified for alias domain.'),
- ERR.ALIASDOMAIN_NO_DOMDEST)
- if self._domain._id < 1:
- raise VADE (_(u"The target domain “%s” doesn't exist.") %
- self._domain._name, ERR.NO_SUCH_DOMAIN)
- if self.__gid < 1:
- raise VADE(_(u"The alias domain “%s” doesn't exist.") %
- self.__name, ERR.NO_SUCH_ALIASDOMAIN)
- if self.__gid == self._domain._id:
- raise VADE(_(u"The alias domain “%(alias)s” is already assigned to\
- the domain “%(domain)s”.") %
- {'alias': self.__name, 'domain': self._domain._name},
- ERR.ALIASDOMAIN_EXISTS)
- dbc = self._dbh.cursor()
- dbc.execute('UPDATE domain_name SET gid = %s WHERE gid = %s\
- AND domainname = %s AND NOT is_primary',
- self._domain._id, self.__gid, self.__name)
- self._dbh.commit()
- dbc.close()
-
- def delete(self):
- if self.__gid > 0:
- dbc = self._dbh.cursor()
- dbc.execute('DELETE FROM domain_name WHERE domainname = %s \
- AND NOT is_primary', self.__name)
- if dbc.rowcount > 0:
- self._dbh.commit()
- else:
- raise VADE(
- _(u"The alias domain “%s” doesn't exist.") % self.__name,
- ERR.NO_SUCH_ALIASDOMAIN)
-
--- a/VirtualMailManager/Config.py Thu Jan 13 12:48:30 2011 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,187 +0,0 @@
-# -*- coding: UTF-8 -*-
-# Copyright (c) 2007 - 2010, Pascal Volk
-# See COPYING for distribution information.
-
-"""Configuration class for read, modify and write the
-configuration from Virtual Mail Manager.
-
-"""
-
-from shutil import copy2
-from ConfigParser import ConfigParser, MissingSectionHeaderError, ParsingError
-from cStringIO import StringIO
-
-from __main__ import ENCODING, ERR, w_std
-from Exceptions import VMMConfigException
-
-class Config(ConfigParser):
- """This class is for reading and modifying vmm's configuration file."""
-
- def __init__(self, filename):
- """Creates a new Config instance
-
- Arguments:
- filename -- path to the configuration file
- """
- ConfigParser.__init__(self)
- self.__cfgFileName = filename
- self.__cfgFile = None
- self.__VMMsections = ['database', 'maildir', 'services', 'domdir',
- 'bin', 'misc', 'config']
- self.__changes = False
- self.__missing = {}
- self.__dbopts = [
- ['host', 'localhot'],
- ['user', 'vmm'],
- ['pass', 'your secret password'],
- ['name', 'mailsys']
- ]
- self.__mdopts = [
- ['name', 'Maildir'],
- ['folders', 'Drafts:Sent:Templates:Trash'],
- ['mode', 448],
- ['diskusage', 'false'],
- ['delete', 'false']
- ]
- self.__serviceopts = [
- ['smtp', 'true'],
- ['pop3', 'true'],
- ['imap', 'true'],
- ['sieve', 'true']
- ]
- self.__domdopts = [
- ['base', '/srv/mail'],
- ['mode', 504],
- ['delete', 'false']
- ]
- self.__binopts = [
- ['dovecotpw', '/usr/sbin/dovecotpw'],
- ['du', '/usr/bin/du'],
- ['postconf', '/usr/sbin/postconf']
- ]
- self.__miscopts = [
- ['passwdscheme', 'PLAIN'],
- ['gid_mail', 8],
- ['forcedel', 'false'],
- ['transport', 'dovecot:'],
- ['dovecotvers', '11']
- ]
-
- def load(self):
- """Loads the configuration, read only.
-
- Raises a VMMConfigException if the configuration syntax is invalid.
- """
- try:
- self.__cfgFile = file(self.__cfgFileName, 'r')
- self.readfp(self.__cfgFile)
- except (MissingSectionHeaderError, ParsingError), e:
- self.__cfgFile.close()
- raise VMMConfigException(str(e), ERR.CONF_ERROR)
- self.__cfgFile.close()
-
- def check(self):
- """Performs a configuration check.
-
- Raises a VMMConfigException if the check fails.
- """
- if not self.__chkSections():
- errmsg = StringIO()
- errmsg.write(_("Using configuration file: %s\n") %\
- self.__cfgFileName)
- for k,v in self.__missing.items():
- if v[0] is True:
- errmsg.write(_(u"missing section: %s\n") % k)
- else:
- errmsg.write(_(u"missing options in section %s:\n") % k)
- for o in v:
- errmsg.write(" * %s\n" % o)
- raise VMMConfigException(errmsg.getvalue(), ERR.CONF_ERROR)
-
- def getsections(self):
- """Return a list with all configurable sections."""
- return self.__VMMsections[:-1]
-
- def get(self, section, option, raw=False, vars=None):
- return unicode(ConfigParser.get(self, section, option, raw, vars),
- ENCODING, 'replace')
-
- def configure(self, sections):
- """Interactive method for configuring all options in the given sections
-
- Arguments:
- sections -- list of strings with section names
- """
- if not isinstance(sections, list):
- raise TypeError("Argument 'sections' is not a list.")
- # if [config] done = false (default at 1st run),
- # then set changes true
- try:
- if not self.getboolean('config', 'done'):
- self.__changes = True
- except ValueError:
- self.set('config', 'done', 'False')
- self.__changes = True
- w_std(_(u'Using configuration file: %s\n') % self.__cfgFileName)
- for s in sections:
- if s != 'config':
- w_std(_(u'* Config section: “%s”') % s )
- for opt, val in self.items(s):
- newval = raw_input(
- _('Enter new value for option %(opt)s [%(val)s]: ').encode(
- ENCODING, 'replace') % {'opt': opt, 'val': val})
- if newval and newval != val:
- self.set(s, opt, newval)
- self.__changes = True
- print
- if self.__changes:
- self.__saveChanges()
-
- def __saveChanges(self):
- """Writes changes to the configuration file."""
- self.set('config', 'done', 'true')
- copy2(self.__cfgFileName, self.__cfgFileName+'.bak')
- self.__cfgFile = file(self.__cfgFileName, 'w')
- self.write(self.__cfgFile)
- self.__cfgFile.close()
-
- def __chkSections(self):
- """Checks if all configuration sections are existing."""
- errors = False
- for s in self.__VMMsections:
- if not self.has_section(s):
- self.__missing[s] = [True]
- errors = True
- elif not self.__chkOptions(s):
- errors = True
- return not errors
-
- def __chkOptions(self, section):
- """Checks if all configuration options in section are existing.
-
- Arguments:
- section -- the section to be checked
- """
- retval = True
- missing = []
- if section == 'database':
- opts = self.__dbopts
- elif section == 'maildir':
- opts = self.__mdopts
- elif section == 'services':
- opts = self.__serviceopts
- elif section == 'domdir':
- opts = self.__domdopts
- elif section == 'bin':
- opts = self.__binopts
- elif section == 'misc':
- opts = self.__miscopts
- elif section == 'config':
- opts = [['done', 'false']]
- for o, v in opts:
- if not self.has_option(section, o):
- missing.append(o)
- retval = False
- if len(missing):
- self.__missing[section] = missing
- return retval
--- a/VirtualMailManager/Domain.py Thu Jan 13 12:48:30 2011 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,313 +0,0 @@
-# -*- coding: UTF-8 -*-
-# Copyright (c) 2007 - 2010, Pascal Volk
-# See COPYING for distribution information.
-
-"""Virtual Mail Manager's Domain class to manage e-mail domains."""
-
-from random import choice
-
-from __main__ import ERR
-from Exceptions import VMMDomainException as VMMDE
-import VirtualMailManager as VMM
-from Transport import Transport
-
-MAILDIR_CHARS = '0123456789abcdefghijklmnopqrstuvwxyz'
-
-class Domain(object):
- """Class to manage e-mail domains."""
- __slots__ = ('_basedir','_domaindir','_id','_name','_transport','_dbh')
- def __init__(self, dbh, domainname, basedir=None, transport=None):
- """Creates a new Domain instance.
-
- Keyword arguments:
- dbh -- a pyPgSQL.PgSQL.connection
- domainname -- name of the domain (str)
- transport -- default vmm.cfg/misc/transport (str)
- """
- self._dbh = dbh
- self._name = VMM.VirtualMailManager.chkDomainname(domainname)
- self._basedir = basedir
- if transport is not None:
- self._transport = Transport(self._dbh, transport=transport)
- else:
- self._transport = transport
- self._id = 0
- self._domaindir = None
- if not self._exists() and self._isAlias():
- raise VMMDE(_(u"The domain “%s” is an alias domain.") %self._name,
- ERR.DOMAIN_ALIAS_EXISTS)
-
- def _exists(self):
- """Checks if the domain already exists.
-
- If the domain exists _id will be set and returns True, otherwise False
- will be returned.
- """
- dbc = self._dbh.cursor()
- dbc.execute("SELECT gid, tid, domaindir FROM domain_data WHERE gid =\
- (SELECT gid FROM domain_name WHERE domainname = %s AND is_primary)",
- self._name)
- result = dbc.fetchone()
- dbc.close()
- if result is not None:
- self._id, self._domaindir = result[0], result[2]
- self._transport = Transport(self._dbh, tid=result[1])
- return True
- else:
- return False
-
- def _isAlias(self):
- """Checks if self._name is known for an alias domain."""
- dbc = self._dbh.cursor()
- dbc.execute('SELECT is_primary FROM domain_name WHERE domainname = %s',
- self._name)
- result = dbc.fetchone()
- dbc.close()
- if result is not None and not result[0]:
- return True
- else:
- return False
-
- def _setID(self):
- """Sets the ID of the domain."""
- dbc = self._dbh.cursor()
- dbc.execute("SELECT nextval('domain_gid')")
- self._id = dbc.fetchone()[0]
- dbc.close()
-
- def _prepare(self):
- self._setID()
- self._domaindir = "%s/%s/%i" % (self._basedir, choice(MAILDIR_CHARS),
- self._id)
-
- def _has(self, what):
- """Checks if aliases or accounts are assigned to the domain.
-
- If there are assigned accounts or aliases True will be returned,
- otherwise False will be returned.
-
- Keyword arguments:
- what -- 'alias' or 'users' (strings)
- """
- if what not in ['alias', 'users']:
- return False
- dbc = self._dbh.cursor()
- if what == 'users':
- dbc.execute("SELECT count(gid) FROM users WHERE gid=%s", self._id)
- else:
- dbc.execute("SELECT count(gid) FROM alias WHERE gid=%s", self._id)
- count = dbc.fetchone()
- dbc.close()
- if count[0] > 0:
- return True
- else:
- return False
-
- def _chkDelete(self, delUser, delAlias):
- """Checks dependencies for deletion.
-
- Keyword arguments:
- delUser -- ignore available accounts (bool)
- delAlias -- ignore available aliases (bool)
- """
- if not delUser:
- hasUser = self._has('users')
- else:
- hasUser = False
- if not delAlias:
- hasAlias = self._has('alias')
- else:
- hasAlias = False
- if hasUser and hasAlias:
- raise VMMDE(_(u'There are accounts and aliases.'),
- ERR.ACCOUNT_AND_ALIAS_PRESENT)
- elif hasUser:
- raise VMMDE(_(u'There are accounts.'),
- ERR.ACCOUNT_PRESENT)
- elif hasAlias:
- raise VMMDE(_(u'There are aliases.'),
- ERR.ALIAS_PRESENT)
-
- def save(self):
- """Stores the new domain in the database."""
- if self._id < 1:
- self._prepare()
- dbc = self._dbh.cursor()
- dbc.execute("INSERT INTO domain_data (gid, tid, domaindir)\
- VALUES (%s, %s, %s)", self._id, self._transport.getID(), self._domaindir)
- dbc.execute("INSERT INTO domain_name (domainname, gid, is_primary)\
- VALUES (%s, %s, %s)", self._name, self._id, True)
- self._dbh.commit()
- dbc.close()
- else:
- raise VMMDE(_(u'The domain “%s” already exists.') % self._name,
- ERR.DOMAIN_EXISTS)
-
- def delete(self, delUser=False, delAlias=False):
- """Deletes the domain.
-
- Keyword arguments:
- delUser -- force deletion of available accounts (bool)
- delAlias -- force deletion of available aliases (bool)
- """
- if self._id > 0:
- self._chkDelete(delUser, delAlias)
- dbc = self._dbh.cursor()
- for t in ('alias','users','relocated','domain_name','domain_data'):
- dbc.execute("DELETE FROM %s WHERE gid = %d" % (t, self._id))
- self._dbh.commit()
- dbc.close()
- else:
- raise VMMDE(_(u"The domain “%s” doesn't exist.") % self._name,
- ERR.NO_SUCH_DOMAIN)
-
- def updateTransport(self, transport, force=False):
- """Sets a new transport for the domain.
-
- Keyword arguments:
- transport -- the new transport (str)
- force -- True/False force new transport for all accounts (bool)
- """
- if self._id > 0:
- if transport == self._transport.getTransport():
- return
- trsp = Transport(self._dbh, transport=transport)
- dbc = self._dbh.cursor()
- dbc.execute("UPDATE domain_data SET tid = %s WHERE gid = %s",
- trsp.getID(), self._id)
- if dbc.rowcount > 0:
- self._dbh.commit()
- if force:
- dbc.execute("UPDATE users SET tid = %s WHERE gid = %s",
- trsp.getID(), self._id)
- if dbc.rowcount > 0:
- self._dbh.commit()
- dbc.close()
- else:
- raise VMMDE(_(u"The domain “%s” doesn't exist.") % self._name,
- ERR.NO_SUCH_DOMAIN)
-
- def getID(self):
- """Returns the ID of the domain."""
- return self._id
-
- def getDir(self):
- """Returns the directory of the domain."""
- return self._domaindir
-
- def getTransport(self):
- """Returns domain's transport."""
- return self._transport.getTransport()
-
- def getTransportID(self):
- """Returns the ID from the domain's transport."""
- return self._transport.getID()
-
- def getInfo(self):
- """Returns a dictionary with information about the domain."""
- sql = """\
-SELECT gid, domainname, transport, domaindir, aliasdomains, accounts,
- aliases, relocated
- FROM vmm_domain_info
- WHERE gid = %i""" % self._id
- dbc = self._dbh.cursor()
- dbc.execute(sql)
- info = dbc.fetchone()
- dbc.close()
- if info is None:
- raise VMMDE(_(u"The domain “%s” doesn't exist.") % self._name,
- ERR.NO_SUCH_DOMAIN)
- else:
- keys = ['gid', 'domainname', 'transport', 'domaindir',
- 'aliasdomains', 'accounts', 'aliases', 'relocated']
- return dict(zip(keys, info))
-
- def getAccounts(self):
- """Returns a list with all accounts from the domain."""
- dbc = self._dbh.cursor()
- dbc.execute("SELECT local_part from users where gid = %s ORDER BY\
- local_part", self._id)
- users = dbc.fetchall()
- dbc.close()
- accounts = []
- if len(users) > 0:
- addr = u'@'.join
- _dom = self._name
- accounts = [addr((account[0], _dom)) for account in users]
- return accounts
-
- def getAliases(self):
- """Returns a list with all aliases from the domain."""
- dbc = self._dbh.cursor()
- dbc.execute("SELECT DISTINCT address FROM alias WHERE gid = %s\
- ORDER BY address", self._id)
- addresses = dbc.fetchall()
- dbc.close()
- aliases = []
- if len(addresses) > 0:
- addr = u'@'.join
- _dom = self._name
- aliases = [addr((alias[0], _dom)) for alias in addresses]
- return aliases
-
- def getRelocated(self):
- """Returns a list with all addresses from relocated users."""
- dbc = self._dbh.cursor()
- dbc.execute("SELECT address FROM relocated WHERE gid = %s\
- ORDER BY address", self._id)
- addresses = dbc.fetchall()
- dbc.close()
- relocated = []
- if len(addresses) > 0:
- addr = u'@'.join
- _dom = self._name
- relocated = [addr((address[0], _dom)) for address in addresses]
- return relocated
-
- def getAliaseNames(self):
- """Returns a list with all alias names from the domain."""
- dbc = self._dbh.cursor()
- dbc.execute("SELECT domainname FROM domain_name WHERE gid = %s\
- AND NOT is_primary ORDER BY domainname", self._id)
- anames = dbc.fetchall()
- dbc.close()
- aliasdomains = []
- if len(anames) > 0:
- aliasdomains = [aname[0] for aname in anames]
- return aliasdomains
-
-def search(dbh, pattern=None, like=False):
- if pattern is not None and like is False:
- pattern = VMM.VirtualMailManager.chkDomainname(pattern)
- sql = 'SELECT gid, domainname, is_primary FROM domain_name'
- if pattern is None:
- pass
- elif like:
- sql += " WHERE domainname LIKE '%s'" % pattern
- else:
- sql += " WHERE domainname = '%s'" % pattern
- sql += ' ORDER BY is_primary DESC, domainname'
- dbc = dbh.cursor()
- dbc.execute(sql)
- result = dbc.fetchall()
- dbc.close()
-
- gids = [domain[0] for domain in result if domain[2]]
- domains = {}
- for gid, domain, is_primary in result:
- if is_primary:
- if not gid in domains:
- domains[gid] = [domain]
- else:
- domains[gid].insert(0, domain)
- else:
- if gid in gids:
- if gid in domains:
- domains[gid].append(domain)
- else:
- domains[gid] = [domain]
- else:
- gids.append(gid)
- domains[gid] = [None, domain]
- return gids, domains
-
--- a/VirtualMailManager/EmailAddress.py Thu Jan 13 12:48:30 2011 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-# -*- coding: UTF-8 -*-
-# Copyright (c) 2008 - 2010, Pascal Volk
-# See COPYING for distribution information.
-
-"""Virtual Mail Manager's EmailAddress class to handle e-mail addresses."""
-
-from __main__ import re, ERR
-from Exceptions import VMMEmailAddressException as VMMEAE
-import VirtualMailManager as VMM
-
-RE_LOCALPART = """[^\w!#$%&'\*\+-\.\/=?^_`{\|}~]"""
-
-class EmailAddress(object):
- __slots__ = ('_localpart', '_domainname')
- def __init__(self, address):
- self._localpart = None
- self._domainname = None
- self.__chkAddress(address)
-
- def __eq__(self, other):
- if isinstance(other, self.__class__):
- return self._localpart == other._localpart\
- and self._domainname == other._domainname
- return NotImplemented
-
- def __ne__(self, other):
- if isinstance(other, self.__class__):
- return self._localpart != other._localpart\
- or self._domainname != other._domainname
- return NotImplemented
-
- def __repr__(self):
- return "EmailAddress('%s@%s')" % (self._localpart, self._domainname)
-
- def __str__(self):
- return "%s@%s" % (self._localpart, self._domainname)
-
- def __chkAddress(self, address):
- try:
- localpart, domain = address.split('@')
- except ValueError:
- raise VMMEAE(_(u"Missing '@' sign in e-mail address “%s”.") %
- address, ERR.INVALID_ADDRESS)
- except AttributeError:
- raise VMMEAE(_(u"“%s” doesn't look like an e-mail address.") %
- address, ERR.INVALID_ADDRESS)
- if len(domain) > 0:
- domain = VMM.VirtualMailManager.chkDomainname(domain)
- else:
- raise VMMEAE(_(u"Missing domain name after “%s@”.") %
- localpart, ERR.DOMAIN_NO_NAME)
- localpart = self.__chkLocalpart(localpart)
- self._localpart, self._domainname = localpart, domain
-
- def __chkLocalpart(self, localpart):
- """Validates the local-part of an e-mail address.
-
- Arguments:
- localpart -- local-part of the e-mail address that should be validated (str)
- """
- if len(localpart) < 1:
- raise VMMEAE(_(u'No local-part specified.'),
- ERR.LOCALPART_INVALID)
- if len(localpart) > 64:
- raise VMMEAE(_(u'The local-part “%s” is too long') %
- localpart, ERR.LOCALPART_TOO_LONG)
- ic = set(re.findall(RE_LOCALPART, localpart))
- if len(ic):
- ichrs = ''
- for c in ic:
- ichrs += u"“%s” " % c
- raise VMMEAE(_(u"The local-part “%(lpart)s” contains invalid\
- characters: %(ichrs)s") % {'lpart': localpart, 'ichrs': ichrs},
- ERR.LOCALPART_INVALID)
- return localpart
-
--- a/VirtualMailManager/Exceptions.py Thu Jan 13 12:48:30 2011 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-# -*- coding: UTF-8 -*-
-# Copyright (c) 2007 - 2010, Pascal Volk
-# See COPYING for distribution information.
-
-"""Exception classes for Virtual Mail Manager"""
-
-class VMMException(Exception):
- """Exception class for VirtualMailManager exceptions"""
- def __init__(self, msg, code):
- Exception.__init__(self, msg)
- self._code = int(code)
- ### for older python versions, like py 2.4.4 on OpenBSD 4.2
- if not hasattr(self, 'message'):
- self.message = msg
-
- def msg(self):
- """Returns the exception message."""
- return self.message
-
- def code(self):
- """Returns the numeric exception error code."""
- return self._code
-
-class VMMConfigException(VMMException):
- """Exception class for Configurtion exceptions"""
- def __init__(self, msg, code):
- VMMException.__init__(self, msg, code)
-
-class VMMPermException(VMMException):
- """Exception class for permissions exceptions"""
- def __init__(self, msg, code):
- VMMException.__init__(self, msg, code)
-
-class VMMNotRootException(VMMException):
- """Exception class for non-root exceptions"""
- def __init__(self, msg, code):
- VMMException.__init__(self, msg, code)
-
-class VMMDomainException(VMMException):
- """Exception class for Domain exceptions"""
- def __init__(self, msg, code):
- VMMException.__init__(self, msg, code)
-
-class VMMAliasDomainException(VMMException):
- """Exception class for AliasDomain exceptions"""
- def __init__(self, msg, code):
- VMMException.__init__(self, msg, code)
-
-class VMMAccountException(VMMException):
- """Exception class for Account exceptions"""
- def __init__(self, msg, code):
- VMMException.__init__(self, msg, code)
-
-class VMMAliasException(VMMException):
- """Exception class for Alias exceptions"""
- def __init__(self, msg, code):
- VMMException.__init__(self, msg, code)
-
-class VMMEmailAddressException(VMMException):
- """Exception class for EmailAddress exceptions"""
- def __init__(self, msg, code):
- VMMException.__init__(self, msg, code)
-
-class VMMMailLocationException(VMMException):
- """Exception class for MailLocation exceptions"""
- def __init__(self, msg, code):
- VMMException.__init__(self, msg, code)
-
-class VMMRelocatedException(VMMException):
- """Exception class for Relocated exceptions"""
- def __init__(self, msg, code):
- VMMException.__init__(self, msg, code)
-
-class VMMTransportException(VMMException):
- """Exception class for Transport exceptions"""
- def __init__(self, msg, code):
- VMMException.__init__(self, msg, code)
--- a/VirtualMailManager/MailLocation.py Thu Jan 13 12:48:30 2011 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,84 +0,0 @@
-# -*- coding: UTF-8 -*-
-# Copyright (c) 2008 - 2010, Pascal Volk
-# See COPYING for distribution information.
-
-"""Virtual Mail Manager's MailLocation class to manage the mail_location
-for accounts."""
-
-from __main__ import re, ERR
-from Exceptions import VMMMailLocationException as MLE
-
-RE_MAILLOCATION = """^\w{1,20}$"""
-
-class MailLocation(object):
- """A wrapper class thats provide access to the maillocation table"""
- __slots__ = ('__id', '__maillocation', '_dbh')
- def __init__(self, dbh, mid=None, maillocation=None):
- """Creates a new MailLocation instance.
-
- Either mid or maillocation must be specified.
-
- Keyword arguments:
- dbh -- a pyPgSQL.PgSQL.connection
- mid -- the id of a maillocation (long)
- maillocation -- the value of the maillocation (str)
- """
- self._dbh = dbh
- if mid is None and maillocation is None:
- raise MLE(_('Either mid or maillocation must be specified.'),
- ERR.MAILLOCATION_INIT)
- elif mid is not None:
- try:
- self.__id = long(mid)
- except ValueError:
- raise MLE(_('mid must be an int/long.'), ERR.MAILLOCATION_INIT)
- self._loadByID()
- else:
- if re.match(RE_MAILLOCATION, maillocation):
- self.__maillocation = maillocation
- self._loadByName()
- else:
- raise MLE(
- _(u'Invalid folder name “%s”, it may consist only of\n\
-1 - 20 single byte characters (A-Z, a-z, 0-9 and _).') % maillocation,
- ERR.MAILLOCATION_INIT)
-
- def _loadByID(self):
- dbc = self._dbh.cursor()
- dbc.execute('SELECT maillocation FROM maillocation WHERE mid = %s',
- self.__id)
- result = dbc.fetchone()
- dbc.close()
- if result is not None:
- self.__maillocation = result[0]
- else:
- raise MLE(_('Unknown mid specified.'), ERR.UNKNOWN_MAILLOCATION_ID)
-
- def _loadByName(self):
- dbc = self._dbh.cursor()
- dbc.execute('SELECT mid FROM maillocation WHERE maillocation = %s',
- self.__maillocation)
- result = dbc.fetchone()
- dbc.close()
- if result is not None:
- self.__id = result[0]
- else:
- self._save()
-
- def _save(self):
- dbc = self._dbh.cursor()
- dbc.execute("SELECT nextval('maillocation_id')")
- self.__id = dbc.fetchone()[0]
- dbc.execute('INSERT INTO maillocation(mid,maillocation) VALUES(%s,%s)',
- self.__id, self.__maillocation)
- self._dbh.commit()
- dbc.close()
-
- def getID(self):
- """Returns the unique ID of the maillocation."""
- return self.__id
-
- def getMailLocation(self):
- """Returns the value of maillocation, ex: 'Maildir'"""
- return self.__maillocation
-
--- a/VirtualMailManager/Relocated.py Thu Jan 13 12:48:30 2011 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,103 +0,0 @@
-# -*- coding: UTF-8 -*-
-# Copyright (c) 2008 - 2010, Pascal Volk
-# See COPYING for distribution information.
-
-"""Virtual Mail Manager's Relocated class to manage relocated users."""
-
-from __main__ import ERR
-from Exceptions import VMMRelocatedException as VMMRE
-from Domain import Domain
-from EmailAddress import EmailAddress
-import VirtualMailManager as VMM
-
-class Relocated(object):
- """Class to manage e-mail addresses of relocated users."""
- __slots__ = ('_addr', '_dest', '_gid', '_isNew', '_dbh')
- def __init__(self, dbh, address, destination=None):
- if isinstance(address, EmailAddress):
- self._addr = address
- else:
- raise TypeError("Argument 'address' is not an EmailAddress")
- if destination is None:
- self._dest = None
- elif isinstance(destination, EmailAddress):
- self._dest = destination
- else:
- raise TypeError("Argument 'destination' is not an EmailAddress")
- if address == destination:
- raise VMMRE(_(u"Address and destination are identical."),
- ERR.RELOCATED_ADDR_DEST_IDENTICAL)
- self._dbh = dbh
- self._gid = 0
- self._isNew = False
- self._setAddr()
- self._exists()
- if self._isNew and VMM.VirtualMailManager.accountExists(self._dbh,
- self._addr):
- raise VMMRE(_(u"There is already an account with address “%s”.") %\
- self._addr, ERR.ACCOUNT_EXISTS)
- if self._isNew and VMM.VirtualMailManager.aliasExists(self._dbh,
- self._addr):
- raise VMMRE(
- _(u"There is already an alias with the address “%s”.") %\
- self._addr, ERR.ALIAS_EXISTS)
-
- def _exists(self):
- dbc = self._dbh.cursor()
- dbc.execute("SELECT gid FROM relocated WHERE gid = %s AND address = %s",
- self._gid, self._addr._localpart)
- gid = dbc.fetchone()
- dbc.close()
- if gid is None:
- self._isNew = True
-
- def _setAddr(self):
- dom = Domain(self._dbh, self._addr._domainname)
- self._gid = dom.getID()
- if self._gid == 0:
- raise VMMRE(_(u"The domain “%s” doesn't exist.") %\
- self._addr._domainname, ERR.NO_SUCH_DOMAIN)
-
- def save(self):
- if self._dest is None:
- raise VMMRE(
- _(u"No destination address specified for relocated user."),
- ERR.RELOCATED_MISSING_DEST)
- if self._isNew:
- dbc = self._dbh.cursor()
- dbc.execute("INSERT INTO relocated VALUES (%s, %s, %s)",
- self._gid, self._addr._localpart, str(self._dest))
- self._dbh.commit()
- dbc.close()
- else:
- raise VMMRE(
- _(u"The relocated user “%s” already exists.") % self._addr,
- ERR.RELOCATED_EXISTS)
-
- def getInfo(self):
- dbc = self._dbh.cursor()
- dbc.execute('SELECT destination FROM relocated WHERE gid=%s\
- AND address=%s',
- self._gid, self._addr._localpart)
- destination = dbc.fetchone()
- dbc.close()
- if destination is not None:
- return destination[0]
- else:
- raise VMMRE(
- _(u"The relocated user “%s” doesn't exist.") % self._addr,
- ERR.NO_SUCH_RELOCATED)
-
- def delete(self):
- dbc = self._dbh.cursor()
- dbc.execute("DELETE FROM relocated WHERE gid = %s AND address = %s",
- self._gid, self._addr._localpart)
- rowcount = dbc.rowcount
- dbc.close()
- if rowcount > 0:
- self._dbh.commit()
- else:
- raise VMMRE(
- _(u"The relocated user “%s” doesn't exist.") % self._addr,
- ERR.NO_SUCH_RELOCATED)
-
--- a/VirtualMailManager/Transport.py Thu Jan 13 12:48:30 2011 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,90 +0,0 @@
-# -*- coding: UTF-8 -*-
-# Copyright (c) 2008 - 2010, Pascal Volk
-# See COPYING for distribution information.
-
-"""Virtual Mail Manager's Transport class to manage the transport for
-domains and accounts."""
-
-from __main__ import ERR
-from Exceptions import VMMTransportException
-
-class Transport(object):
- """A wrapper class that provides access to the transport table"""
- __slots__ = ('__id', '__transport', '_dbh')
- def __init__(self, dbh, tid=None, transport=None):
- """Creates a new Transport instance.
-
- Either tid or transport must be specified.
-
- Keyword arguments:
- dbh -- a pyPgSQL.PgSQL.connection
- tid -- the id of a transport (long)
- transport -- the value of the transport (str)
- """
- self._dbh = dbh
- if tid is None and transport is None:
- raise VMMTransportException(
- _('Either tid or transport must be specified.'),
- ERR.TRANSPORT_INIT)
- elif tid is not None:
- try:
- self.__id = long(tid)
- except ValueError:
- raise VMMTransportException(_('tid must be an int/long.'),
- ERR.TRANSPORT_INIT)
- self._loadByID()
- else:
- self.__transport = transport
- self._loadByName()
-
- def __eq__(self, other):
- if isinstance(other, self.__class__):
- return self.__id == other.getID()
- return NotImplemented
-
- def __ne__(self, other):
- if isinstance(other, self.__class__):
- return self.__id != other.getID()
- return NotImplemented
-
- def __str__(self):
- return self.__transport
-
- def _loadByID(self):
- dbc = self._dbh.cursor()
- dbc.execute('SELECT transport FROM transport WHERE tid = %s', self.__id)
- result = dbc.fetchone()
- dbc.close()
- if result is not None:
- self.__transport = result[0]
- else:
- raise VMMTransportException(_('Unknown tid specified.'),
- ERR.UNKNOWN_TRANSPORT_ID)
-
- def _loadByName(self):
- dbc = self._dbh.cursor()
- dbc.execute('SELECT tid FROM transport WHERE transport = %s',
- self.__transport)
- result = dbc.fetchone()
- dbc.close()
- if result is not None:
- self.__id = result[0]
- else:
- self._save()
-
- def _save(self):
- dbc = self._dbh.cursor()
- dbc.execute("SELECT nextval('transport_id')")
- self.__id = dbc.fetchone()[0]
- dbc.execute('INSERT INTO transport (tid, transport) VALUES (%s, %s)',
- self.__id, self.__transport)
- self._dbh.commit()
- dbc.close()
-
- def getID(self):
- """Returns the unique ID of the transport."""
- return self.__id
-
- def getTransport(self):
- """Returns the value of transport, ex: 'dovecot:'"""
- return self.__transport
--- a/VirtualMailManager/VirtualMailManager.py Thu Jan 13 12:48:30 2011 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,709 +0,0 @@
-# -*- coding: UTF-8 -*-
-# Copyright (c) 2007 - 2010, Pascal Volk
-# See COPYING for distribution information.
-
-"""The main class for vmm."""
-
-
-from encodings.idna import ToASCII, ToUnicode
-from getpass import getpass
-from shutil import rmtree
-from subprocess import Popen, PIPE
-
-from pyPgSQL import PgSQL # python-pgsql - http://pypgsql.sourceforge.net
-
-from __main__ import os, re, ENCODING, ERR, w_std
-from ext.Postconf import Postconf
-from Account import Account
-from Alias import Alias
-from AliasDomain import AliasDomain
-from Config import Config as Cfg
-from Domain import Domain
-from EmailAddress import EmailAddress
-from Exceptions import *
-from Relocated import Relocated
-
-SALTCHARS = './0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
-RE_ASCII_CHARS = """^[\x20-\x7E]*$"""
-RE_DOMAIN = """^(?:[a-z0-9-]{1,63}\.){1,}[a-z]{2,6}$"""
-RE_DOMAIN_SRCH = """^[a-z0-9-\.]+$"""
-RE_LOCALPART = """[^\w!#$%&'\*\+-\.\/=?^_`{\|}~]"""
-RE_MBOX_NAMES = """^[\x20-\x25\x27-\x7E]*$"""
-
-class VirtualMailManager(object):
- """The main class for vmm"""
- __slots__ = ('__Cfg', '__cfgFileName', '__cfgSections', '__dbh', '__scheme',
- '__warnings', '_postconf')
- def __init__(self):
- """Creates a new VirtualMailManager instance.
- Throws a VMMNotRootException if your uid is greater 0.
- """
- self.__cfgFileName = ''
- self.__warnings = []
- self.__Cfg = None
- self.__dbh = None
-
- if os.geteuid():
- raise VMMNotRootException(_(u"You are not root.\n\tGood bye!\n"),
- ERR.CONF_NOPERM)
- if self.__chkCfgFile():
- self.__Cfg = Cfg(self.__cfgFileName)
- self.__Cfg.load()
- self.__Cfg.check()
- self.__cfgSections = self.__Cfg.getsections()
- self.__scheme = self.__Cfg.get('misc', 'passwdscheme')
- self._postconf = Postconf(self.__Cfg.get('bin', 'postconf'))
- if not os.sys.argv[1] in ['cf', 'configure']:
- self.__chkenv()
-
- def __findCfgFile(self):
- for path in ['/root', '/usr/local/etc', '/etc']:
- tmp = os.path.join(path, 'vmm.cfg')
- if os.path.isfile(tmp):
- self.__cfgFileName = tmp
- break
- if not len(self.__cfgFileName):
- raise VMMException(
- _(u"No “vmm.cfg” found in: /root:/usr/local/etc:/etc"),
- ERR.CONF_NOFILE)
-
- def __chkCfgFile(self):
- """Checks the configuration file, returns bool"""
- self.__findCfgFile()
- fstat = os.stat(self.__cfgFileName)
- fmode = int(oct(fstat.st_mode & 0777))
- if fmode % 100 and fstat.st_uid != fstat.st_gid \
- or fmode % 10 and fstat.st_uid == fstat.st_gid:
- raise VMMPermException(_(
- u'fix permissions (%(perms)s) for “%(file)s”\n\
-`chmod 0600 %(file)s` would be great.') % {'file':
- self.__cfgFileName, 'perms': fmode}, ERR.CONF_WRONGPERM)
- else:
- return True
-
- def __chkenv(self):
- """"""
- if not os.path.exists(self.__Cfg.get('domdir', 'base')):
- old_umask = os.umask(0006)
- os.makedirs(self.__Cfg.get('domdir', 'base'), 0771)
- os.chown(self.__Cfg.get('domdir', 'base'), 0,
- self.__Cfg.getint('misc', 'gid_mail'))
- os.umask(old_umask)
- elif not os.path.isdir(self.__Cfg.get('domdir', 'base')):
- raise VMMException(_(u'“%s” is not a directory.\n\
-(vmm.cfg: section "domdir", option "base")') %
- 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(_(u'“%(binary)s” doesn\'t exist.\n\
-(vmm.cfg: section "bin", option "%(option)s")') %{'binary': val,'option': opt},
- ERR.NO_SUCH_BINARY)
- elif not os.access(val, os.X_OK):
- raise VMMException(_(u'“%(binary)s” is not executable.\n\
-(vmm.cfg: section "bin", option "%(option)s")') %{'binary': val,'option': opt},
- ERR.NOT_EXECUTABLE)
-
- def __dbConnect(self):
- """Creates a pyPgSQL.PgSQL.connection instance."""
- if self.__dbh is None or not self.__dbh._isOpen:
- try:
- self.__dbh = PgSQL.connect(
- database=self.__Cfg.get('database', 'name'),
- user=self.__Cfg.get('database', 'user'),
- host=self.__Cfg.get('database', 'host'),
- password=self.__Cfg.get('database', 'pass'),
- client_encoding='utf8', unicode_results=True)
- dbc = self.__dbh.cursor()
- dbc.execute("SET NAMES 'UTF8'")
- dbc.close()
- except PgSQL.libpq.DatabaseError, e:
- raise VMMException(str(e), ERR.DATABASE_ERROR)
-
- def idn2ascii(domainname):
- """Converts an idn domainname in punycode.
-
- Arguments:
- domainname -- the domainname to convert (unicode)
- """
- return '.'.join([ToASCII(lbl) for lbl in domainname.split('.') if lbl])
- idn2ascii = staticmethod(idn2ascii)
-
- def ace2idna(domainname):
- """Convertis a domainname from ACE according to IDNA
-
- Arguments:
- domainname -- the domainname to convert (str)
- """
- return u'.'.join([ToUnicode(lbl) for lbl in domainname.split('.')\
- if lbl])
- ace2idna = staticmethod(ace2idna)
-
- def chkDomainname(domainname):
- """Validates the domain name of an e-mail address.
-
- Keyword arguments:
- domainname -- the domain name that should be validated
- """
- if not re.match(RE_ASCII_CHARS, domainname):
- domainname = VirtualMailManager.idn2ascii(domainname)
- if len(domainname) > 255:
- raise VMMException(_(u'The domain name is too long.'),
- ERR.DOMAIN_TOO_LONG)
- if not re.match(RE_DOMAIN, domainname):
- raise VMMException(_(u'The domain name “%s” is invalid.') %\
- domainname, ERR.DOMAIN_INVALID)
- return domainname
- chkDomainname = staticmethod(chkDomainname)
-
- def _exists(dbh, query):
- dbc = dbh.cursor()
- dbc.execute(query)
- gid = dbc.fetchone()
- dbc.close()
- if gid is None:
- return False
- else:
- return True
- _exists = staticmethod(_exists)
-
- def accountExists(dbh, address):
- sql = "SELECT gid FROM users WHERE gid = (SELECT gid FROM domain_name\
- WHERE domainname = '%s') AND local_part = '%s'" % (address._domainname,
- address._localpart)
- return VirtualMailManager._exists(dbh, sql)
- accountExists = staticmethod(accountExists)
-
- def aliasExists(dbh, address):
- sql = "SELECT DISTINCT gid FROM alias WHERE gid = (SELECT gid FROM\
- domain_name WHERE domainname = '%s') AND address = '%s'" %\
- (address._domainname, address._localpart)
- return VirtualMailManager._exists(dbh, sql)
- aliasExists = staticmethod(aliasExists)
-
- def relocatedExists(dbh, address):
- sql = "SELECT gid FROM relocated WHERE gid = (SELECT gid FROM\
- domain_name WHERE domainname = '%s') AND address = '%s'" %\
- (address._domainname, address._localpart)
- return VirtualMailManager._exists(dbh, sql)
- relocatedExists = staticmethod(relocatedExists)
-
- def _readpass(self):
- # TP: Please preserve the trailing space.
- readp_msg0 = _(u'Enter new password: ').encode(ENCODING, 'replace')
- # TP: Please preserve the trailing space.
- readp_msg1 = _(u'Retype new password: ').encode(ENCODING, 'replace')
- mismatched = True
- flrs = 0
- while mismatched:
- if flrs > 2:
- raise VMMException(_(u'Too many failures - try again later.'),
- ERR.VMM_TOO_MANY_FAILURES)
- clear0 = getpass(prompt=readp_msg0)
- clear1 = getpass(prompt=readp_msg1)
- if clear0 != clear1:
- flrs += 1
- w_std(_(u'Sorry, passwords do not match'))
- continue
- if len(clear0) < 1:
- flrs += 1
- w_std(_(u'Sorry, empty passwords are not permitted'))
- continue
- mismatched = False
- return clear0
-
- def __getAccount(self, address, password=None):
- self.__dbConnect()
- address = EmailAddress(address)
- if not password is None:
- password = self.__pwhash(password)
- return Account(self.__dbh, address, password)
-
- def __getAlias(self, address, destination=None):
- self.__dbConnect()
- address = EmailAddress(address)
- if destination is not None:
- destination = EmailAddress(destination)
- return Alias(self.__dbh, address, destination)
-
- def __getRelocated(self,address, destination=None):
- self.__dbConnect()
- address = EmailAddress(address)
- if destination is not None:
- destination = EmailAddress(destination)
- return Relocated(self.__dbh, address, destination)
-
- def __getDomain(self, domainname, transport=None):
- if transport is None:
- transport = self.__Cfg.get('misc', 'transport')
- self.__dbConnect()
- return Domain(self.__dbh, domainname,
- self.__Cfg.get('domdir', 'base'), transport)
-
- def __getDiskUsage(self, directory):
- """Estimate file space usage for the given directory.
-
- Keyword arguments:
- directory -- the directory to summarize recursively disk usage for
- """
- if self.__isdir(directory):
- return Popen([self.__Cfg.get('bin', 'du'), "-hs", directory],
- stdout=PIPE).communicate()[0].split('\t')[0]
- else:
- return 0
-
- def __isdir(self, directory):
- isdir = os.path.isdir(directory)
- if not isdir:
- self.__warnings.append(_('No such directory: %s') % directory)
- return isdir
-
- def __makedir(self, directory, mode=None, uid=None, gid=None):
- if mode is None:
- mode = self.__Cfg.getint('maildir', 'mode')
- if uid is None:
- uid = 0
- if gid is None:
- gid = 0
- os.makedirs(directory, mode)
- os.chown(directory, uid, gid)
-
- def __domDirMake(self, domdir, gid):
- os.umask(0006)
- oldpwd = os.getcwd()
- basedir = self.__Cfg.get('domdir', 'base')
- 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'))
- os.chdir(domdirdirs[0])
- os.umask(0007)
- self.__makedir(domdirdirs[1], self.__Cfg.getint('domdir', 'mode'), 0,
- gid)
- os.chdir(oldpwd)
-
- def __subscribeFL(self, folderlist, uid, gid):
- fname = os.path.join(self.__Cfg.get('maildir','name'), 'subscriptions')
- sf = file(fname, 'w')
- for f in folderlist:
- sf.write(f+'\n')
- sf.flush()
- sf.close()
- os.chown(fname, uid, gid)
- os.chmod(fname, 384)
-
- def __mailDirMake(self, domdir, uid, gid):
- """Creates maildirs and maildir subfolders.
-
- Keyword arguments:
- domdir -- the path to the domain directory
- uid -- user id from the account
- gid -- group id from the account
- """
- os.umask(0007)
- oldpwd = os.getcwd()
- os.chdir(domdir)
-
- maildir = self.__Cfg.get('maildir', 'name')
- folders = [maildir]
- for folder in self.__Cfg.get('maildir', 'folders').split(':'):
- folder = folder.strip()
- if len(folder) and not folder.count('..')\
- and re.match(RE_MBOX_NAMES, folder):
- folders.append('%s/.%s' % (maildir, folder))
- subdirs = ['cur', 'new', 'tmp']
- mode = self.__Cfg.getint('maildir', 'mode')
-
- self.__makedir('%s' % uid, mode, uid, gid)
- os.chdir('%s' % uid)
- for folder in folders:
- self.__makedir(folder, mode, uid, gid)
- for subdir in subdirs:
- self.__makedir(os.path.join(folder, subdir), mode, uid, gid)
- self.__subscribeFL([f.replace(maildir+'/.', '') for f in folders[1:]],
- uid, gid)
- os.chdir(oldpwd)
-
- def __userDirDelete(self, domdir, uid, gid):
- if uid > 0 and gid > 0:
- userdir = '%s' % uid
- if userdir.count('..') or domdir.count('..'):
- raise VMMException(_(u'Found ".." in home directory path.'),
- ERR.FOUND_DOTS_IN_PATH)
- if os.path.isdir(domdir):
- os.chdir(domdir)
- if os.path.isdir(userdir):
- mdstat = os.stat(userdir)
- if (mdstat.st_uid, mdstat.st_gid) != (uid, gid):
- raise VMMException(
- _(u'Detected owner/group mismatch in home directory.'),
- ERR.MAILDIR_PERM_MISMATCH)
- rmtree(userdir, ignore_errors=True)
- else:
- raise VMMException(_(u"No such directory: %s") %
- os.path.join(domdir, userdir), ERR.NO_SUCH_DIRECTORY)
-
- def __domDirDelete(self, domdir, gid):
- if gid > 0:
- if not self.__isdir(domdir):
- return
- basedir = self.__Cfg.get('domdir', 'base')
- domdirdirs = domdir.replace(basedir+'/', '').split('/')
- domdirparent = os.path.join(basedir, domdirdirs[0])
- if basedir.count('..') or domdir.count('..'):
- raise VMMException(_(u'Found ".." in domain directory path.'),
- ERR.FOUND_DOTS_IN_PATH)
- if os.path.isdir(domdirparent):
- os.chdir(domdirparent)
- if os.lstat(domdirdirs[1]).st_gid != gid:
- raise VMMException(_(
- u'Detected group mismatch in domain directory.'),
- ERR.DOMAINDIR_GROUP_MISMATCH)
- rmtree(domdirdirs[1], ignore_errors=True)
-
- def __getSalt(self):
- from random import choice
- salt = None
- if self.__scheme == 'CRYPT':
- salt = '%s%s' % (choice(SALTCHARS), choice(SALTCHARS))
- elif self.__scheme in ['MD5', 'MD5-CRYPT']:
- salt = '$1$%s$' % ''.join([choice(SALTCHARS) for x in xrange(8)])
- return salt
-
- def __pwCrypt(self, password):
- # for: CRYPT, MD5 and MD5-CRYPT
- from crypt import crypt
- return crypt(password, self.__getSalt())
-
- def __pwSHA1(self, password):
- # for: SHA/SHA1
- import sha
- from base64 import standard_b64encode
- sha1 = sha.new(password)
- return standard_b64encode(sha1.digest())
-
- def __pwMD5(self, password, emailaddress=None):
- import md5
- _md5 = md5.new(password)
- if self.__scheme == 'LDAP-MD5':
- from base64 import standard_b64encode
- return standard_b64encode(_md5.digest())
- elif self.__scheme == 'PLAIN-MD5':
- return _md5.hexdigest()
- elif self.__scheme == 'DIGEST-MD5' and emailaddress is not None:
- # use an empty realm - works better with usenames like user@dom
- _md5 = md5.new('%s::%s' % (emailaddress, password))
- return _md5.hexdigest()
-
- def __pwMD4(self, password):
- # for: PLAIN-MD4
- from Crypto.Hash import MD4
- _md4 = MD4.new(password)
- return _md4.hexdigest()
-
- def __pwhash(self, password, scheme=None, user=None):
- if scheme is not None:
- self.__scheme = scheme
- if self.__scheme in ['CRYPT', 'MD5', 'MD5-CRYPT']:
- return '{%s}%s' % (self.__scheme, self.__pwCrypt(password))
- elif self.__scheme in ['SHA', 'SHA1']:
- return '{%s}%s' % (self.__scheme, self.__pwSHA1(password))
- elif self.__scheme in ['PLAIN-MD5', 'LDAP-MD5', 'DIGEST-MD5']:
- return '{%s}%s' % (self.__scheme, self.__pwMD5(password, user))
- elif self.__scheme == 'PLAIN-MD4':
- return '{%s}%s' % (self.__scheme, self.__pwMD4(password))
- elif self.__scheme in ['SMD5', 'SSHA', 'CRAM-MD5', 'HMAC-MD5',
- 'LANMAN', 'NTLM', 'RPA']:
- cmd_args = [self.__Cfg.get('bin', 'dovecotpw'), '-s',
- self.__scheme, '-p', password]
- if self.__Cfg.getint('misc', 'dovecotvers') >= 20:
- cmd_args.insert(1, 'pw')
- return Popen(cmd_args, stdout=PIPE).communicate()[0][:-1]
- else:
- return '{%s}%s' % (self.__scheme, password)
-
- def hasWarnings(self):
- """Checks if warnings are present, returns bool."""
- return bool(len(self.__warnings))
-
- def getWarnings(self):
- """Returns a list with all available warnings."""
- return self.__warnings
-
- def cfgGetBoolean(self, section, option):
- return self.__Cfg.getboolean(section, option)
-
- def cfgGetInt(self, section, option):
- return self.__Cfg.getint(section, option)
-
- def cfgGetString(self, section, option):
- return self.__Cfg.get(section, option)
-
- def setupIsDone(self):
- """Checks if vmm is configured, returns bool"""
- try:
- return self.__Cfg.getboolean('config', 'done')
- except ValueError, e:
- raise VMMConfigException(_(u"""Configuration error: "%s"
-(in section "config", option "done") see also: vmm.cfg(5)\n""") % str(e),
- ERR.CONF_ERROR)
-
- def configure(self, section=None):
- """Starts interactive configuration.
-
- Configures in interactive mode options in the given section.
- If no section is given (default) all options from all sections
- will be prompted.
-
- Keyword arguments:
- section -- the section to configure (default None):
- 'database', 'maildir', 'bin' or 'misc'
- """
- if section is None:
- self.__Cfg.configure(self.__cfgSections)
- elif section in self.__cfgSections:
- self.__Cfg.configure([section])
- else:
- raise VMMException(_(u"Invalid section: “%s”") % section,
- ERR.INVALID_SECTION)
-
- def domainAdd(self, domainname, transport=None):
- dom = self.__getDomain(domainname, transport)
- dom.save()
- self.__domDirMake(dom.getDir(), dom.getID())
-
- def domainTransport(self, domainname, transport, force=None):
- if force is not None and force != 'force':
- raise VMMDomainException(_(u"Invalid argument: “%s”") % force,
- ERR.INVALID_OPTION)
- dom = self.__getDomain(domainname, None)
- if force is None:
- dom.updateTransport(transport)
- else:
- dom.updateTransport(transport, force=True)
-
- def domainDelete(self, domainname, force=None):
- if not force is None and force not in ['deluser','delalias','delall']:
- raise VMMDomainException(_(u"Invalid argument: “%s”") % force,
- ERR.INVALID_OPTION)
- dom = self.__getDomain(domainname)
- gid = dom.getID()
- domdir = dom.getDir()
- if self.__Cfg.getboolean('misc', 'forcedel') or force == 'delall':
- dom.delete(True, True)
- elif force == 'deluser':
- dom.delete(delUser=True)
- elif force == 'delalias':
- dom.delete(delAlias=True)
- else:
- dom.delete()
- if self.__Cfg.getboolean('domdir', 'delete'):
- self.__domDirDelete(domdir, gid)
-
- def domainInfo(self, domainname, details=None):
- if details not in [None, 'accounts', 'aliasdomains', 'aliases', 'full',
- 'relocated', 'detailed']:
- raise VMMException(_(u'Invalid argument: “%s”') % details,
- ERR.INVALID_AGUMENT)
- if details == 'detailed':
- details = 'full'
- self.__warnings.append(_(u'\
-The keyword “detailed” is deprecated and will be removed in a future release.\n\
- Please use the keyword “full” to get full details.'))
- dom = self.__getDomain(domainname)
- dominfo = dom.getInfo()
- if dominfo['domainname'].startswith('xn--'):
- dominfo['domainname'] += ' (%s)'\
- % VirtualMailManager.ace2idna(dominfo['domainname'])
- if details is None:
- return dominfo
- elif details == 'accounts':
- return (dominfo, dom.getAccounts())
- elif details == 'aliasdomains':
- return (dominfo, dom.getAliaseNames())
- elif details == 'aliases':
- return (dominfo, dom.getAliases())
- elif details == 'relocated':
- return(dominfo, dom.getRelocated())
- else:
- return (dominfo, dom.getAliaseNames(), dom.getAccounts(),
- dom.getAliases(), dom.getRelocated())
-
- def aliasDomainAdd(self, aliasname, domainname):
- """Adds an alias domain to the domain.
-
- Keyword arguments:
- aliasname -- the name of the alias domain (str)
- domainname -- name of the target domain (str)
- """
- dom = self.__getDomain(domainname)
- aliasDom = AliasDomain(self.__dbh, aliasname, dom)
- aliasDom.save()
-
- def aliasDomainInfo(self, aliasname):
- self.__dbConnect()
- aliasDom = AliasDomain(self.__dbh, aliasname, None)
- return aliasDom.info()
-
- def aliasDomainSwitch(self, aliasname, domainname):
- """Modifies the target domain of an existing alias domain.
-
- Keyword arguments:
- aliasname -- the name of the alias domain (str)
- domainname -- name of the new target domain (str)
- """
- dom = self.__getDomain(domainname)
- aliasDom = AliasDomain(self.__dbh, aliasname, dom)
- aliasDom.switch()
-
- def aliasDomainDelete(self, aliasname):
- """Deletes the specified alias domain.
-
- Keyword arguments:
- aliasname -- the name of the alias domain (str)
- """
- self.__dbConnect()
- aliasDom = AliasDomain(self.__dbh, aliasname, None)
- aliasDom.delete()
-
- def domainList(self, pattern=None):
- from Domain import search
- like = False
- if pattern is not None:
- if pattern.startswith('%') or pattern.endswith('%'):
- like = True
- domain = pattern.strip('%')
- if not re.match(RE_DOMAIN_SRCH, domain):
- raise VMMException(
- _(u"The pattern “%s” contains invalid characters.") %
- pattern, ERR.DOMAIN_INVALID)
- self.__dbConnect()
- return search(self.__dbh, pattern=pattern, like=like)
-
- def userAdd(self, emailaddress, password):
- acc = self.__getAccount(emailaddress, password)
- if password is None:
- 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.__mailDirMake(acc.getDir('domain'), acc.getUID(), acc.getGID())
-
- def aliasAdd(self, aliasaddress, targetaddress):
- alias = self.__getAlias(aliasaddress, targetaddress)
- alias.save(long(self._postconf.read('virtual_alias_expansion_limit')))
- gid = self.__getDomain(alias._dest._domainname).getID()
- if gid > 0 and not VirtualMailManager.accountExists(self.__dbh,
- alias._dest) and not VirtualMailManager.aliasExists(self.__dbh,
- alias._dest):
- self.__warnings.append(
- _(u"The destination account/alias “%s” doesn't exist.")%\
- alias._dest)
-
- def userDelete(self, emailaddress, force=None):
- if force not in [None, 'delalias']:
- raise VMMException(_(u"Invalid argument: “%s”") % force,
- ERR.INVALID_AGUMENT)
- acc = self.__getAccount(emailaddress)
- uid = acc.getUID()
- gid = acc.getGID()
- acc.delete(force)
- if self.__Cfg.getboolean('maildir', 'delete'):
- try:
- self.__userDirDelete(acc.getDir('domain'), uid, gid)
- except VMMException, e:
- if e.code() in [ERR.FOUND_DOTS_IN_PATH,
- ERR.MAILDIR_PERM_MISMATCH, ERR.NO_SUCH_DIRECTORY]:
- warning = _(u"""\
-The account has been successfully deleted from the database.
- But an error occurred while deleting the following directory:
- “%(directory)s”
- Reason: %(reason)s""") % {'directory': acc.getDir('home'),'reason': e.msg()}
- self.__warnings.append(warning)
- else:
- raise e
-
- def aliasInfo(self, aliasaddress):
- alias = self.__getAlias(aliasaddress)
- return alias.getInfo()
-
- def aliasDelete(self, aliasaddress, targetaddress=None):
- alias = self.__getAlias(aliasaddress, targetaddress)
- alias.delete()
-
- def userInfo(self, emailaddress, details=None):
- if details not in [None, 'du', 'aliases', 'full']:
- 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')\
- or details in ['du', 'full']:
- info['disk usage'] = self.__getDiskUsage('%(maildir)s' % info)
- if details in [None, 'du']:
- return info
- if details in ['aliases', 'full']:
- return (info, acc.getAliases())
- return info
-
- def userByID(self, uid):
- from Account import getAccountByID
- self.__dbConnect()
- return getAccountByID(uid, self.__dbh)
-
- def userPassword(self, emailaddress, password):
- acc = self.__getAccount(emailaddress)
- if acc.getUID() == 0:
- raise VMMException(_(u"Account doesn't exist"), ERR.NO_SUCH_ACCOUNT)
- if password is None:
- password = self._readpass()
- acc.modify('password', self.__pwhash(password, user=emailaddress))
-
- def userName(self, emailaddress, name):
- acc = self.__getAccount(emailaddress)
- acc.modify('name', name)
-
- def userTransport(self, emailaddress, transport):
- acc = self.__getAccount(emailaddress)
- acc.modify('transport', transport)
-
- def userDisable(self, emailaddress, service=None):
- if service == 'managesieve':
- service = 'sieve'
- self.__warnings.append(_(u'\
-The service name “managesieve” is deprecated and will be removed\n\
- in a future release.\n\
- Please use the service name “sieve” instead.'))
- acc = self.__getAccount(emailaddress)
- acc.disable(self.__Cfg.getint('misc', 'dovecotvers'), service)
-
- def userEnable(self, emailaddress, service=None):
- if service == 'managesieve':
- service = 'sieve'
- self.__warnings.append(_(u'\
-The service name “managesieve” is deprecated and will be removed\n\
- in a future release.\n\
- Please use the service name “sieve” instead.'))
- acc = self.__getAccount(emailaddress)
- acc.enable(self.__Cfg.getint('misc', 'dovecotvers'), service)
-
- def relocatedAdd(self, emailaddress, targetaddress):
- relocated = self.__getRelocated(emailaddress, targetaddress)
- relocated.save()
-
- def relocatedInfo(self, emailaddress):
- relocated = self.__getRelocated(emailaddress)
- return relocated.getInfo()
-
- def relocatedDelete(self, emailaddress):
- relocated = self.__getRelocated(emailaddress)
- relocated.delete()
-
- def __del__(self):
- if not self.__dbh is None and self.__dbh._isOpen:
- self.__dbh.close()
--- a/VirtualMailManager/__init__.py Thu Jan 13 12:48:30 2011 +0000
+++ b/VirtualMailManager/__init__.py Thu Jan 13 12:54:53 2011 +0000
@@ -1,15 +1,25 @@
# -*- coding: UTF-8 -*-
# Copyright (c) 2007 - 2010, Pascal Volk
# See COPYING for distribution information.
-# package initialization code
-#
+"""
+ VirtualMailManager
+ ~~~~~~~~~~~~~~~~~~
-import os
-import re
+ VirtualMailManager package initialization code
+"""
+
+import gettext
import locale
-from constants.VERSION import *
-import constants.ERROR as ERR
+from VirtualMailManager.constants import __author__, __date__, __version__
+
+__all__ = [
+ # version information from VERSION
+ '__author__', '__date__', '__version__',
+ # defined stuff
+ 'ENCODING',
+]
+
# Try to set all of the locales according to the current
# environment variables and get the character encoding.
@@ -19,33 +29,4 @@
locale.setlocale(locale.LC_ALL, 'C')
ENCODING = locale.nl_langinfo(locale.CODESET)
-def w_std(*args):
- """Writes each arg of args, encoded in the current ENCODING, to stdout and
- appends a newline."""
- _write = os.sys.stdout.write
- for arg in args:
- _write(arg.encode(ENCODING, 'replace'))
- _write('\n')
-
-def w_err(code, *args):
- """Writes each arg of args, encoded in the current ENCODING, to stderr and
- appends a newline.
- This function additional interrupts the program execution and uses 'code'
- system exit status."""
- _write = os.sys.stderr.write
- for arg in args:
- _write(arg.encode(ENCODING, 'replace'))
- _write('\n')
- os.sys.exit(code)
-
-__all__ = [
- # imported modules
- 'os', 're', 'locale',
- # version information from VERSION
- '__author__', '__date__', '__version__',
- # error codes
- 'ERR',
- # defined stuff
- 'ENCODING', 'w_std', 'w_err'
- ]
-# EOF
+gettext.install('vmm', '/usr/local/share/locale', unicode=1)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/VirtualMailManager/account.py Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,431 @@
+# -*- coding: UTF-8 -*-
+# Copyright (c) 2007 - 2010, Pascal Volk
+# See COPYING for distribution information.
+"""
+ VirtualMailManager.account
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ Virtual Mail Manager's Account class to manage e-mail accounts.
+"""
+
+from VirtualMailManager.domain import Domain
+from VirtualMailManager.emailaddress import EmailAddress
+from VirtualMailManager.transport import Transport
+from VirtualMailManager.common import version_str
+from VirtualMailManager.constants import \
+ ACCOUNT_EXISTS, ACCOUNT_MISSING_PASSWORD, ALIAS_PRESENT, \
+ INVALID_ARGUMENT, INVALID_MAIL_LOCATION, NO_SUCH_ACCOUNT, \
+ NO_SUCH_DOMAIN, UNKNOWN_SERVICE
+from VirtualMailManager.errors import AccountError as AErr
+from VirtualMailManager.maillocation import MailLocation
+from VirtualMailManager.password import pwhash
+
+__all__ = ('SERVICES', 'Account', 'get_account_by_uid')
+
+SERVICES = ('imap', 'pop3', 'smtp', 'sieve')
+
+_ = lambda msg: msg
+cfg_dget = lambda option: None
+
+
+class Account(object):
+ """Class to manage e-mail accounts."""
+ __slots__ = ('_addr', '_dbh', '_domain', '_mail', '_new', '_passwd',
+ '_transport', '_uid')
+
+ def __init__(self, dbh, address):
+ """Creates a new Account instance.
+
+ When an account with the given *address* could be found in the
+ database all relevant data will be loaded.
+
+ Arguments:
+
+ `dbh` : pyPgSQL.PgSQL.Connection
+ A database connection for the database access.
+ `address` : VirtualMailManager.EmailAddress.EmailAddress
+ The e-mail address of the (new) Account.
+ """
+ if not isinstance(address, EmailAddress):
+ raise TypeError("Argument 'address' is not an EmailAddress")
+ self._addr = address
+ self._dbh = dbh
+ self._domain = Domain(self._dbh, self._addr.domainname)
+ if not self._domain.gid:
+ # TP: Hm, what “quotation marks” should be used?
+ # If you are unsure have a look at:
+ # http://en.wikipedia.org/wiki/Quotation_mark,_non-English_usage
+ raise AErr(_(u"The domain '%s' doesn't exist.") %
+ self._addr.domainname, NO_SUCH_DOMAIN)
+ self._uid = 0
+ self._mail = None
+ self._transport = self._domain.transport
+ self._passwd = None
+ self._new = True
+ self._load()
+
+ def __nonzero__(self):
+ """Returns `True` if the Account is known, `False` if it's new."""
+ return not self._new
+
+ def _load(self):
+ """Load 'uid', 'mid' and 'tid' from the database and set _new to
+ `False` - if the user could be found. """
+ dbc = self._dbh.cursor()
+ dbc.execute('SELECT uid, mid, tid FROM users WHERE gid = %s AND '
+ 'local_part=%s', (self._domain.gid, self._addr.localpart))
+ result = dbc.fetchone()
+ dbc.close()
+ if result:
+ self._uid, _mid, _tid = result
+ if _tid != self._transport.tid:
+ self._transport = Transport(self._dbh, tid=_tid)
+ self._mail = MailLocation(self._dbh, mid=_mid)
+ self._new = False
+
+ def _set_uid(self):
+ """Set the unique ID for the new Account."""
+ assert self._uid == 0
+ dbc = self._dbh.cursor()
+ dbc.execute("SELECT nextval('users_uid')")
+ self._uid = dbc.fetchone()[0]
+ dbc.close()
+
+ def _prepare(self, maillocation):
+ """Check and set different attributes - before we store the
+ information in the database.
+ """
+ if maillocation.dovecot_version > cfg_dget('misc.dovecot_version'):
+ raise AErr(_(u"The mailbox format '%(mbfmt)s' requires Dovecot "
+ u">= v%(version)s") % {'mbfmt': maillocation.mbformat,
+ 'version': version_str(maillocation.dovecot_version)},
+ INVALID_MAIL_LOCATION)
+ if not maillocation.postfix and \
+ self._transport.transport.lower() in ('virtual:', 'virtual'):
+ raise AErr(_(u"Invalid transport '%(transport)s' for mailbox "
+ u"format '%(mbfmt)s'") %
+ {'transport': self._transport,
+ 'mbfmt': maillocation.mbformat}, INVALID_MAIL_LOCATION)
+ self._mail = maillocation
+ self._set_uid()
+
+ def _update_services(self, activate, *services):
+ """Activate or deactivate the Account's services.
+
+ Arguments:
+
+ `activate`: bool
+ When `True` the Account's user will be able to login to the
+ services, otherwise the login will fail.
+ `*services`
+ No or one or more of the services: imap, pop3, smtp and sieve
+ """
+ self._chk_state()
+ if services:
+ services = set(services)
+ for service in services:
+ if service not in SERVICES:
+ raise AErr(_(u"Unknown service: '%s'") % service,
+ UNKNOWN_SERVICE)
+ else:
+ services = SERVICES
+ state = ('FALSE', 'TRUE')[activate]
+ sql = 'UPDATE users SET %s WHERE uid = %u' % (
+ (' = %(s)s, '.join(services) + ' = %(s)s') % {'s': state},
+ self._uid)
+ if 'sieve' in services and \
+ cfg_dget('misc.dovecot_version') < 0x10200b02:
+ sql = sql.replace('sieve', 'managesieve')
+ dbc = self._dbh.cursor()
+ dbc.execute(sql)
+ if dbc.rowcount > 0:
+ self._dbh.commit()
+ dbc.close()
+
+ def _count_aliases(self):
+ """Count all alias addresses where the destination address is the
+ address of the Account."""
+ dbc = self._dbh.cursor()
+ dbc.execute('SELECT COUNT(destination) FROM alias WHERE destination '
+ '= %s', (self._addr,))
+ a_count = dbc.fetchone()[0]
+ dbc.close()
+ return a_count
+
+ def _chk_state(self):
+ """Raise an AccountError if the Account is new - not yet saved in the
+ database."""
+ if self._new:
+ raise AErr(_(u"The account '%s' doesn't exist.") % self._addr,
+ NO_SUCH_ACCOUNT)
+
+ @property
+ def address(self):
+ """The Account's EmailAddress instance."""
+ return self._addr
+
+ @property
+ def domain(self):
+ """The Domain to which the Account belongs to."""
+ if self._domain:
+ return self._domain
+ return None
+
+ @property
+ def gid(self):
+ """The Account's group ID."""
+ if self._domain:
+ return self._domain.gid
+ return None
+
+ @property
+ def home(self):
+ """The Account's home directory."""
+ if not self._new:
+ return '%s/%s' % (self._domain.directory, self._uid)
+ return None
+
+ @property
+ def mail_location(self):
+ """The Account's MailLocation."""
+ return self._mail
+
+ @property
+ def uid(self):
+ """The Account's unique ID."""
+ return self._uid
+
+ def set_password(self, password):
+ """Set a password for the new Account.
+
+ If you want to update the password of an existing Account use
+ Account.modify().
+
+ Argument:
+
+ `password` : basestring
+ The password for the new Account.
+ """
+ if not isinstance(password, basestring) or not password:
+ raise AErr(_(u"Could not accept password: '%s'") % password,
+ ACCOUNT_MISSING_PASSWORD)
+ self._passwd = password
+
+ def set_transport(self, transport):
+ """Set the transport for the new Account.
+
+ If you want to update the transport of an existing Account use
+ Account.modify().
+
+ Argument:
+
+ `transport` : basestring
+ The string representation of the transport, e.g.: 'dovecot:'
+ """
+ self._transport = Transport(self._dbh, transport=transport)
+
+ def enable(self, *services):
+ """Enable all or the given service/s for the Account.
+
+ Possible *services* are: 'imap', 'pop3', 'sieve' and 'smtp'.
+ When all services should be enabled, give no service name.
+
+ Arguments:
+
+ `*services` : basestring
+ No or one or more of the services 'imap', 'pop3', 'smtp', and
+ 'sieve'.
+ """
+ self._update_services(True, *services)
+
+ def disable(self, *services):
+ """Disable all or the given service/s for the Account.
+
+ For more information see: Account.enable()."""
+ self._update_services(False, *services)
+
+ def save(self):
+ """Save the new Account in the database."""
+ if not self._new:
+ raise AErr(_(u"The account '%s' already exists.") % self._addr,
+ ACCOUNT_EXISTS)
+ if not self._passwd:
+ raise AErr(_(u"No password set for '%s'.") % self._addr,
+ ACCOUNT_MISSING_PASSWORD)
+ if cfg_dget('misc.dovecot_version') >= 0x10200b02:
+ sieve_col = 'sieve'
+ else:
+ sieve_col = 'managesieve'
+ self._prepare(MailLocation(self._dbh, mbfmt=cfg_dget('mailbox.format'),
+ directory=cfg_dget('mailbox.root')))
+ dbc = self._dbh.cursor()
+ dbc.execute('INSERT INTO users (local_part, passwd, uid, gid, mid, '
+ 'tid, smtp, pop3, imap, %s) VALUES' % (sieve_col,) + \
+ '(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)',
+ (self._addr.localpart,
+ pwhash(self._passwd, user=self._addr), self._uid,
+ self._domain.gid, self._mail.mid, self._transport.tid,
+ cfg_dget('account.smtp'), cfg_dget('account.pop3'),
+ cfg_dget('account.imap'), cfg_dget('account.sieve')))
+ self._dbh.commit()
+ dbc.close()
+ self._new = False
+
+ def modify(self, field, value):
+ """Update the Account's *field* to the new *value*.
+
+ Possible values for *field* are: 'name', 'password' and
+ 'transport'. *value* is the *field*'s new value.
+
+ Arguments:
+
+ `field` : basestring
+ The attribute name: 'name', 'password' or 'transport'
+ `value` : basestring
+ The new value of the attribute.
+ """
+ if field not in ('name', 'password', 'transport'):
+ raise AErr(_(u"Unknown field: '%s'") % field, INVALID_ARGUMENT)
+ self._chk_state()
+ dbc = self._dbh.cursor()
+ if field == 'password':
+ dbc.execute('UPDATE users SET passwd = %s WHERE uid = %s',
+ (pwhash(value, user=self._addr), self._uid))
+ elif field == 'transport':
+ if value != self._transport.transport:
+ self._transport = Transport(self._dbh, transport=value)
+ dbc.execute('UPDATE users SET tid = %s WHERE uid = %s',
+ (self._transport.tid, self._uid))
+ else:
+ dbc.execute('UPDATE users SET name = %s WHERE uid = %s',
+ (value, self._uid))
+ if dbc.rowcount > 0:
+ self._dbh.commit()
+ dbc.close()
+
+ def get_info(self):
+ """Returns a dict with some information about the Account.
+
+ The keys of the dict are: 'address', 'gid', 'home', 'imap'
+ 'mail_location', 'name', 'pop3', 'sieve', 'smtp', transport' and
+ 'uid'.
+ """
+ self._chk_state()
+ if cfg_dget('misc.dovecot_version') >= 0x10200b02:
+ sieve_col = 'sieve'
+ else:
+ sieve_col = 'managesieve'
+ sql = 'SELECT name, smtp, pop3, imap, %s FROM users WHERE uid = %d' % \
+ (sieve_col, self._uid)
+ dbc = self._dbh.cursor()
+ dbc.execute(sql)
+ info = dbc.fetchone()
+ dbc.close()
+ if info:
+ keys = ('name', 'smtp', 'pop3', 'imap', sieve_col)
+ info = dict(zip(keys, info))
+ for service in keys[1:]:
+ if info[service]:
+ # TP: A service (pop3/imap) is enabled/usable for a user
+ info[service] = _('enabled')
+ else:
+ # TP: A service (pop3/imap) isn't enabled/usable for a user
+ info[service] = _('disabled')
+ info['address'] = self._addr
+ info['gid'] = self._domain.gid
+ info['home'] = '%s/%s' % (self._domain.directory, self._uid)
+ info['mail_location'] = self._mail.mail_location
+ info['transport'] = self._transport.transport
+ info['uid'] = self._uid
+ return info
+ # nearly impossible‽
+ raise AErr(_(u"Could not fetch information for account: '%s'") %
+ self._addr, NO_SUCH_ACCOUNT)
+
+ def get_aliases(self):
+ """Return a list with all alias e-mail addresses, whose destination
+ is the address of the Account."""
+ self._chk_state()
+ dbc = self._dbh.cursor()
+ dbc.execute("SELECT address ||'@'|| domainname FROM alias, "
+ "domain_name WHERE destination = %s AND domain_name.gid = "
+ "alias.gid AND domain_name.is_primary ORDER BY address",
+ (str(self._addr),))
+ addresses = dbc.fetchall()
+ dbc.close()
+ aliases = []
+ if addresses:
+ aliases = [alias[0] for alias in addresses]
+ return aliases
+
+ def delete(self, force=False):
+ """Delete the Account from the database.
+
+ Argument:
+
+ `force` : bool
+ if *force* is `True`, all aliases, which points to the Account,
+ will be also deleted. If there are aliases and *force* is
+ `False`, an AccountError will be raised.
+ """
+ if not isinstance(force, bool):
+ raise TypeError('force must be a bool')
+ self._chk_state()
+ dbc = self._dbh.cursor()
+ if force:
+ dbc.execute('DELETE FROM users WHERE uid = %s', (self._uid),)
+ # delete also all aliases where the destination address is the same
+ # as for this account.
+ dbc.execute("DELETE FROM alias WHERE destination = %s",
+ (str(self._addr),))
+ self._dbh.commit()
+ else: # check first for aliases
+ a_count = self._count_aliases()
+ if a_count > 0:
+ dbc.close()
+ raise AErr(_(u"There are %(count)d aliases with the "
+ u"destination address '%(address)s'.") %
+ {'count': a_count, 'address': self._addr},
+ ALIAS_PRESENT)
+ dbc.execute('DELETE FROM users WHERE uid = %s', (self._uid,))
+ self._dbh.commit()
+ dbc.close()
+ self._new = True
+ self._uid = 0
+ self._addr = self._dbh = self._domain = self._passwd = None
+ self._mail = self._transport = None
+
+
+def get_account_by_uid(uid, dbh):
+ """Search an Account by its UID.
+
+ This function returns a dict (keys: 'address', 'gid' and 'uid'), if an
+ Account with the given *uid* exists.
+
+ Argument:
+
+ `uid` : long
+ The Account unique ID.
+ `dbh` : pyPgSQL.PgSQL.Connection
+ a database connection for the database access.
+ """
+ try:
+ uid = long(uid)
+ except ValueError:
+ raise AErr(_(u'UID must be an int/long.'), INVALID_ARGUMENT)
+ if uid < 1:
+ raise AErr(_(u'UID must be greater than 0.'), INVALID_ARGUMENT)
+ dbc = dbh.cursor()
+ dbc.execute("SELECT local_part||'@'|| domain_name.domainname AS address, "
+ "uid, users.gid FROM users LEFT JOIN domain_name ON "
+ "(domain_name.gid = users.gid AND is_primary) WHERE uid = %s",
+ (uid,))
+ info = dbc.fetchone()
+ dbc.close()
+ if not info:
+ raise AErr(_(u"There is no account with the UID '%d'.") % uid,
+ NO_SUCH_ACCOUNT)
+ info = dict(zip(('address', 'uid', 'gid'), info))
+ return info
+
+del _, cfg_dget
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/VirtualMailManager/alias.py Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,164 @@
+# -*- coding: UTF-8 -*-
+# Copyright (c) 2007 - 2010, Pascal Volk
+# See COPYING for distribution information.
+"""
+ VirtualMailManager.alias
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+
+ Virtual Mail Manager's Alias class to manage e-mail aliases.
+"""
+
+from VirtualMailManager.domain import get_gid
+from VirtualMailManager.emailaddress import EmailAddress
+from VirtualMailManager.errors import AliasError as AErr
+from VirtualMailManager.ext.postconf import Postconf
+from VirtualMailManager.pycompat import all
+from VirtualMailManager.constants import \
+ ALIAS_EXCEEDS_EXPANSION_LIMIT, NO_SUCH_ALIAS, NO_SUCH_DOMAIN
+
+
+_ = lambda msg: msg
+cfg_dget = lambda option: None
+
+
+class Alias(object):
+ """Class to manage e-mail aliases."""
+ __slots__ = ('_addr', '_dests', '_gid', '_dbh')
+
+ def __init__(self, dbh, address):
+ assert isinstance(address, EmailAddress)
+ self._addr = address
+ self._dbh = dbh
+ self._gid = get_gid(self._dbh, self._addr.domainname)
+ if not self._gid:
+ raise AErr(_(u"The domain '%s' doesn't exist.") %
+ self._addr.domainname, NO_SUCH_DOMAIN)
+ self._dests = []
+
+ self._load_dests()
+
+ def _load_dests(self):
+ """Loads all known destination addresses into the _dests list."""
+ dbc = self._dbh.cursor()
+ dbc.execute('SELECT destination FROM alias WHERE gid = %s AND '
+ 'address = %s', (self._gid, self._addr.localpart))
+ dests = dbc.fetchall()
+ if dbc.rowcount > 0:
+ self._dests.extend(EmailAddress(dest[0]) for dest in dests)
+ dbc.close()
+
+ def _check_expansion(self, count_new):
+ """Checks the current expansion limit of the alias."""
+ postconf = Postconf(cfg_dget('bin.postconf'))
+ limit = long(postconf.read('virtual_alias_expansion_limit'))
+ dcount = len(self._dests)
+ failed = False
+ if dcount == limit or dcount + count_new > limit:
+ failed = True
+ errmsg = _(
+u"""Can't add %(count_new)i new destination(s) to alias '%(address)s'.
+Currently this alias expands into %(count)i/%(limit)i recipients.
+%(count_new)i additional destination(s) will render this alias unusable.
+Hint: Increase Postfix' virtual_alias_expansion_limit""")
+ elif dcount > limit:
+ failed = True
+ errmsg = _(
+u"""Can't add %(count_new)i new destination(s) to alias '%(address)s'.
+This alias already exceeds its expansion limit (%(count)i/%(limit)i).
+So its unusable, all messages addressed to this alias will be bounced.
+Hint: Delete some destination addresses.""")
+ if failed:
+ raise AErr(errmsg % {'address': self._addr, 'count': dcount,
+ 'limit': limit, 'count_new': count_new},
+ ALIAS_EXCEEDS_EXPANSION_LIMIT)
+
+ def _delete(self, destination=None):
+ """Deletes a destination from the alias, if ``destination`` is
+ not ``None``. If ``destination`` is None, the alias with all
+ its destination addresses will be deleted.
+
+ """
+ dbc = self._dbh.cursor()
+ if not destination:
+ dbc.execute('DELETE FROM alias WHERE gid = %s AND address = %s',
+ (self._gid, self._addr.localpart))
+ else:
+ dbc.execute('DELETE FROM alias WHERE gid = %s AND address = %s '
+ 'AND destination = %s',
+ (self._gid, self._addr.localpart, str(destination)))
+ if dbc.rowcount > 0:
+ self._dbh.commit()
+ dbc.close()
+
+ def __len__(self):
+ """Returns the number of destinations of the alias."""
+ return len(self._dests)
+
+ @property
+ def address(self):
+ """The Alias' EmailAddress instance."""
+ return self._addr
+
+ def add_destinations(self, destinations, warnings=None):
+ """Adds the `EmailAddress`es from *destinations* list to the
+ destinations of the alias.
+
+ Destinations, that are already assigned to the alias, will be
+ removed from *destinations*. When done, this method will return
+ a set with all destinations, that were saved in the database.
+ """
+ destinations = set(destinations)
+ assert destinations and \
+ all(isinstance(dest, EmailAddress) for dest in destinations)
+ if not warnings is None:
+ assert isinstance(warnings, list)
+ if self._addr in destinations:
+ destinations.remove(self._addr)
+ if not warnings is None:
+ warnings.append(self._addr)
+ duplicates = destinations.intersection(set(self._dests))
+ if duplicates:
+ destinations.difference_update(set(self._dests))
+ if not warnings is None:
+ warnings.extend(duplicates)
+ if not destinations:
+ return destinations
+ self._check_expansion(len(destinations))
+ dbc = self._dbh.cursor()
+ dbc.executemany("INSERT INTO alias VALUES (%d, '%s', %%s)" %
+ (self._gid, self._addr.localpart),
+ (str(destination) for destination in destinations))
+ self._dbh.commit()
+ dbc.close()
+ self._dests.extend(destinations)
+ return destinations
+
+ def del_destination(self, destination):
+ """Deletes the specified ``destination`` address from the alias."""
+ assert isinstance(destination, EmailAddress)
+ if not self._dests:
+ raise AErr(_(u"The alias '%s' doesn't exist.") % self._addr,
+ NO_SUCH_ALIAS)
+ if not destination in self._dests:
+ raise AErr(_(u"The address '%(addr)s' isn't a destination of "
+ u"the alias '%(alias)s'.") % {'addr': self._addr,
+ 'alias': destination}, NO_SUCH_ALIAS)
+ self._delete(destination)
+ self._dests.remove(destination)
+
+ def get_destinations(self):
+ """Returns an iterator for all destinations of the alias."""
+ if not self._dests:
+ raise AErr(_(u"The alias '%s' doesn't exist.") % self._addr,
+ NO_SUCH_ALIAS)
+ return iter(self._dests)
+
+ def delete(self):
+ """Deletes the alias with all its destinations."""
+ if not self._dests:
+ raise AErr(_(u"The alias '%s' doesn't exist.") % self._addr,
+ NO_SUCH_ALIAS)
+ self._delete()
+ del self._dests[:]
+
+del _, cfg_dget
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/VirtualMailManager/aliasdomain.py Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,143 @@
+# -*- coding: UTF-8 -*-
+# Copyright (c) 2008 - 2010, Pascal Volk
+# See COPYING for distribution information.
+"""
+ VirtualMailManager.aliasdomain
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ Virtual Mail Manager's AliasDomain class to manage alias domains.
+"""
+
+from VirtualMailManager.domain import Domain, check_domainname
+from VirtualMailManager.constants import \
+ ALIASDOMAIN_EXISTS, ALIASDOMAIN_ISDOMAIN, ALIASDOMAIN_NO_DOMDEST, \
+ NO_SUCH_ALIASDOMAIN, NO_SUCH_DOMAIN
+from VirtualMailManager.errors import AliasDomainError as ADErr
+
+
+_ = lambda msg: msg
+
+
+class AliasDomain(object):
+ """Class to manage e-mail alias domains."""
+ __slots__ = ('_gid', '_name', '_domain', '_dbh')
+
+ def __init__(self, dbh, domainname):
+ """Creates a new AliasDomain instance.
+
+ Arguments:
+
+ `dbh` : pyPgSQL.PgSQL.Connection
+ a database connection for the database access
+ `domainname` : basestring
+ the name of the AliasDomain"""
+ self._dbh = dbh
+ self._name = check_domainname(domainname)
+ self._gid = 0
+ self._domain = None
+ self._load()
+
+ def _load(self):
+ """Loads the AliasDomain's GID from the database and checks if the
+ domain name is marked as primary."""
+ dbc = self._dbh.cursor()
+ dbc.execute('SELECT gid, is_primary FROM domain_name WHERE '
+ 'domainname = %s', (self._name,))
+ result = dbc.fetchone()
+ dbc.close()
+ if result:
+ if result[1]:
+ raise ADErr(_(u"The domain '%s' is a primary domain.") %
+ self._name, ALIASDOMAIN_ISDOMAIN)
+ self._gid = result[0]
+
+ def set_destination(self, dest_domain):
+ """Set the destination of a new AliasDomain or updates the
+ destination of an existing AliasDomain.
+
+ Argument:
+
+ `dest_domain` : VirtualMailManager.Domain.Domain
+ the AliasDomain's destination domain
+ """
+ assert isinstance(dest_domain, Domain)
+ self._domain = dest_domain
+
+ def save(self):
+ """Stores information about the new AliasDomain in the database."""
+ if self._gid > 0:
+ raise ADErr(_(u"The alias domain '%s' already exists.") %
+ self._name, ALIASDOMAIN_EXISTS)
+ if not self._domain:
+ raise ADErr(_(u'No destination domain set for the alias domain.'),
+ ALIASDOMAIN_NO_DOMDEST)
+ if self._domain.gid < 1:
+ raise ADErr(_(u"The target domain '%s' doesn't exist.") %
+ self._domain.name, NO_SUCH_DOMAIN)
+ dbc = self._dbh.cursor()
+ dbc.execute('INSERT INTO domain_name VALUES (%s, %s, FALSE)',
+ (self._name, self._domain.gid))
+ self._dbh.commit()
+ dbc.close()
+ self._gid = self._domain.gid
+
+ def info(self):
+ """Returns a dict (keys: "alias" and "domain") with the names of the
+ AliasDomain and its primary domain."""
+ if self._gid < 1:
+ raise ADErr(_(u"The alias domain '%s' doesn't exist.") %
+ self._name, NO_SUCH_ALIASDOMAIN)
+ dbc = self._dbh.cursor()
+ dbc.execute('SELECT domainname FROM domain_name WHERE gid = %s AND '
+ 'is_primary', (self._gid,))
+ domain = dbc.fetchone()
+ dbc.close()
+ if domain:
+ return {'alias': self._name, 'domain': domain[0]}
+ else: # an almost unlikely case, isn't it?
+ raise ADErr(_(u'There is no primary domain for the alias domain '
+ u"'%s'.") % self._name, NO_SUCH_DOMAIN)
+
+ def switch(self):
+ """Switch the destination of the AliasDomain to the new destination,
+ set with the method `set_destination()`.
+ """
+ if not self._domain:
+ raise ADErr(_(u'No destination domain set for the alias domain.'),
+ ALIASDOMAIN_NO_DOMDEST)
+ if self._domain.gid < 1:
+ raise ADErr(_(u"The target domain '%s' doesn't exist.") %
+ self._domain.name, NO_SUCH_DOMAIN)
+ if self._gid < 1:
+ raise ADErr(_(u"The alias domain '%s' doesn't exist.") %
+ self._name, NO_SUCH_ALIASDOMAIN)
+ if self._gid == self._domain.gid:
+ raise ADErr(_(u"The alias domain '%(alias)s' is already assigned "
+ u"to the domain '%(domain)s'.") %
+ {'alias': self._name, 'domain': self._domain.name},
+ ALIASDOMAIN_EXISTS)
+ dbc = self._dbh.cursor()
+ dbc.execute('UPDATE domain_name SET gid = %s WHERE gid = %s AND '
+ 'domainname = %s AND NOT is_primary', (self._domain.gid,
+ self._gid, self._name))
+ self._dbh.commit()
+ dbc.close()
+ self._gid = self._domain.gid
+
+ def delete(self):
+ """Delete the AliasDomain's record form the database.
+
+ Raises an AliasDomainError if the AliasDomain doesn't exist.
+ """
+ if self._gid < 1:
+ raise ADErr(_(u"The alias domain '%s' doesn't exist.") %
+ self._name, NO_SUCH_ALIASDOMAIN)
+ dbc = self._dbh.cursor()
+ dbc.execute('DELETE FROM domain_name WHERE domainname = %s AND NOT '
+ 'is_primary', (self._name,))
+ if dbc.rowcount > 0:
+ self._dbh.commit()
+ self._gid = 0
+ dbc.close()
+
+del _
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/VirtualMailManager/cli/__init__.py Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,100 @@
+# -*- coding: UTF-8 -*-
+# Copyright (c) 2010, Pascal Volk
+# See COPYING for distribution information.
+"""
+ VirtualMailManager.cli
+ ~~~~~~~~~~~~~~~~~~~~~~
+
+ VirtualMailManager's command line interface.
+"""
+
+import os
+from array import array
+from fcntl import ioctl
+from getpass import getpass
+from termios import TIOCGWINSZ
+
+from VirtualMailManager import ENCODING
+from VirtualMailManager.constants import VMM_TOO_MANY_FAILURES
+from VirtualMailManager.errors import VMMError
+
+
+__all__ = ('prog', 'get_winsize', 'read_pass', 'w_err', 'w_std')
+
+_ = lambda msg: msg
+_std_write = os.sys.stdout.write
+_err_write = os.sys.stderr.write
+prog = os.path.basename(os.sys.argv[0])
+
+
+def w_std(*args):
+ """Writes a line for each arg of *args*, encoded in the current
+ ENCODING, to stdout.
+ """
+ _std_write('\n'.join(a.encode(ENCODING, 'replace') for a in args) + '\n')
+
+
+def w_err(code, *args):
+ """Writes a line for each arg of *args*, encoded in the current
+ ENCODING, to stderr.
+ This function optionally interrupts the program execution if *code*
+ does not equal to 0. *code* will be used as the system exit status.
+ """
+ _err_write('\n'.join(a.encode(ENCODING, 'replace') for a in args) + '\n')
+ if code:
+ os.sys.exit(code)
+
+
+def get_winsize():
+ """Returns a tuple of integers ``(ws_row, ws_col)`` with the height and
+ width of the terminal."""
+ fd = None
+ for dev in (os.sys.stdout, os.sys.stderr, os.sys.stdin):
+ if hasattr(dev, 'fileno') and os.isatty(dev.fileno()):
+ fd = dev.fileno()
+ break
+ if fd is None: # everything seems to be redirected
+ # fall back to environment or assume some common defaults
+ ws_row, ws_col = 24, 80
+ try:
+ ws_col = int(os.environ.get('COLUMNS', 80))
+ ws_row = int(os.environ.get('LINES', 24))
+ except ValueError:
+ pass
+ return ws_row, ws_col
+ #"struct winsize" with the ``unsigned short int``s ws_{row,col,{x,y}pixel}
+ ws = array('H', (0, 0, 0, 0))
+ ioctl(fd, TIOCGWINSZ, ws, True)
+ ws_row, ws_col = ws[:2]
+ return ws_row, ws_col
+
+
+def read_pass():
+ """Interactive 'password chat', returns the password in plain format.
+
+ Throws a VMMError after the third failure.
+ """
+ # TP: Please preserve the trailing space.
+ readp_msg0 = _(u'Enter new password: ').encode(ENCODING, 'replace')
+ # TP: Please preserve the trailing space.
+ readp_msg1 = _(u'Retype new password: ').encode(ENCODING, 'replace')
+ mismatched = True
+ failures = 0
+ while mismatched:
+ if failures > 2:
+ raise VMMError(_(u'Too many failures - try again later.'),
+ VMM_TOO_MANY_FAILURES)
+ clear0 = getpass(prompt=readp_msg0)
+ clear1 = getpass(prompt=readp_msg1)
+ if clear0 != clear1:
+ failures += 1
+ w_err(0, _(u'Sorry, passwords do not match'))
+ continue
+ if not clear0:
+ failures += 1
+ w_err(0, _(u'Sorry, empty passwords are not permitted'))
+ continue
+ mismatched = False
+ return clear0
+
+del _
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/VirtualMailManager/cli/config.py Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,96 @@
+# -*- coding: UTF-8 -*-
+# Copyright (c) 2010, Pascal Volk
+# See COPYING for distribution information.
+"""
+ VirtualMailManager.cli.config
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ Adds some interactive stuff to the Config class.
+"""
+
+from ConfigParser import RawConfigParser
+from shutil import copy2
+
+from VirtualMailManager import ENCODING
+from VirtualMailManager.config import Config, ConfigValueError, LazyConfig
+from VirtualMailManager.errors import ConfigError, VMMError
+from VirtualMailManager.cli import w_err, w_std
+from VirtualMailManager.constants import CONF_ERROR, VMM_TOO_MANY_FAILURES
+
+_ = lambda msg: msg
+
+
+class CliConfig(Config):
+ """Adds the interactive ``configure`` method to the `Config` class
+ and overwrites `LazyConfig.set(), in order to update a single option
+ in the configuration file with a single command line command.
+ """
+
+ def configure(self, sections):
+ """Interactive method for configuring all options of the given
+ iterable ``sections`` object."""
+ input_fmt = _(u'Enter new value for option %(option)s '
+ u'[%(current_value)s]: ')
+ failures = 0
+
+ w_std(_(u'Using configuration file: %s\n') % self._cfg_filename)
+ for section in sections:
+ w_std(_(u"* Configuration section: '%s'") % section)
+ for opt, val in self.items(section):
+ failures = 0
+ while True:
+ newval = raw_input(input_fmt.encode(ENCODING, 'replace') %
+ {'option': opt, 'current_value': val})
+ if newval and newval != val:
+ try:
+ LazyConfig.set(self, '%s.%s' % (section, opt),
+ newval)
+ break
+ except (ValueError, ConfigValueError, VMMError), err:
+ w_err(0, _(u'Warning: %s') % err)
+ failures += 1
+ if failures > 2:
+ raise ConfigError(_(u'Too many failures - try '
+ u'again later.'),
+ VMM_TOO_MANY_FAILURES)
+ else:
+ break
+ print
+ if self._modified:
+ self._save_changes()
+
+ def set(self, option, value):
+ """Set the value of an option.
+
+ If the new `value` has been set, the configuration file will be
+ immediately updated.
+
+ Throws a ``ConfigError`` if `value` couldn't be converted to
+ ``LazyConfigOption.cls`` or ``LazyConfigOption.validate`` fails."""
+ section, option_ = self._get_section_option(option)
+ try:
+ val = self._cfg[section][option_].cls(value)
+ if self._cfg[section][option_].validate:
+ val = self._cfg[section][option_].validate(val)
+ except (ValueError, ConfigValueError), err:
+ raise ConfigError(str(err), CONF_ERROR)
+ # Do not write default values also skip identical values
+ if not self._cfg[section][option_].default is None:
+ old_val = self.dget(option)
+ else:
+ old_val = self.pget(option)
+ if val == old_val:
+ return
+ if not RawConfigParser.has_section(self, section):
+ self.add_section(section)
+ RawConfigParser.set(self, section, option_, val)
+ self._save_changes()
+
+ def _save_changes(self):
+ """Writes changes to the configuration file."""
+ copy2(self._cfg_filename, self._cfg_filename + '.bak')
+ self._cfg_file = open(self._cfg_filename, 'w')
+ self.write(self._cfg_file)
+ self._cfg_file.close()
+
+del _
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/VirtualMailManager/cli/handler.py Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,98 @@
+# -*- coding: UTF-8 -*-
+# Copyright (c) 2010, Pascal Volk
+# See COPYING for distribution information.
+"""
+ VirtualMailManager.cli.handler
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ A derived Handler class with a few changes/additions for cli use.
+"""
+
+import os
+
+from VirtualMailManager.errors import VMMError
+from VirtualMailManager.handler import Handler
+from VirtualMailManager.cli import read_pass
+from VirtualMailManager.cli.config import CliConfig as Cfg
+from VirtualMailManager.constants import ACCOUNT_EXISTS, INVALID_SECTION, \
+ NO_SUCH_ACCOUNT
+from VirtualMailManager.password import randompw
+
+_ = lambda msg: msg
+
+
+class CliHandler(Handler):
+ """This class uses a `CliConfig` for configuration stuff, instead of
+ the non-interactive `Config` class.
+
+ It provides the additional methods cfgSet() and configure().
+
+ Additionally it uses `VirtualMailManager.cli.read_pass()` for for the
+ interactive password dialog.
+ """
+
+ __slots__ = () # nothing additional, also no __dict__/__weakref__
+
+ def __init__(self):
+ """Creates a new CliHandler instance.
+
+ Throws a NotRootError if your uid is greater 0.
+ """
+ # Overwrite the parent CTor partly, we use the CliConfig class
+ # and add some command line checks.
+ skip_some_checks = os.sys.argv[1] in ('cf', 'configure', 'h', 'help',
+ 'v', 'version')
+ super(CliHandler, self).__init__(skip_some_checks)
+
+ self._cfg = Cfg(self._cfg_fname)
+ self._cfg.load()
+
+ def cfg_set(self, option, value):
+ """Set a new value for the given option."""
+ return self._cfg.set(option, value)
+
+ def configure(self, section=None):
+ """Starts the interactive configuration.
+
+ Configures in interactive mode options in the given ``section``.
+ If no section is given (default) all options from all sections
+ will be prompted.
+ """
+ if section is None:
+ self._cfg.configure(self._cfg.sections())
+ elif self._cfg.has_section(section):
+ self._cfg.configure([section])
+ else:
+ raise VMMError(_(u"Invalid section: '%s'") % section,
+ INVALID_SECTION)
+
+ def user_add(self, emailaddress, password=None):
+ """Override the parent user_add() - add the interactive password
+ dialog.
+
+ Returns the generated password, if account.random_password == True.
+ """
+ acc = self._get_account(emailaddress)
+ if acc:
+ raise VMMError(_(u"The account '%s' already exists.") %
+ acc.address, ACCOUNT_EXISTS)
+ rand_pass = self._cfg.dget('account.random_password')
+ if password is None:
+ password = (read_pass, randompw)[rand_pass]()
+ acc.set_password(password)
+ acc.save()
+ self._make_account_dirs(acc)
+ return (None, password)[rand_pass]
+
+ def user_password(self, emailaddress, password=None):
+ """Override the parent user_password() - add the interactive
+ password dialog."""
+ acc = self._get_account(emailaddress)
+ if not acc:
+ raise VMMError(_(u"The account '%s' doesn't exist.") %
+ acc.address, NO_SUCH_ACCOUNT)
+ if not isinstance(password, basestring) or not password:
+ password = read_pass()
+ acc.modify('password', password)
+
+del _
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/VirtualMailManager/cli/main.py Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,77 @@
+# -*- coding: UTF-8 -*-
+# Copyright 2007 - 2010, Pascal Volk
+# See COPYING for distribution information.
+"""
+ VirtualMailManager.cli.main
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ VirtualMailManager's command line interface.
+"""
+
+from ConfigParser import NoOptionError, NoSectionError
+
+from VirtualMailManager import ENCODING, errors
+from VirtualMailManager.config import BadOptionError, ConfigValueError
+from VirtualMailManager.cli import w_err
+from VirtualMailManager.cli.handler import CliHandler
+from VirtualMailManager.constants import DATABASE_ERROR, EX_MISSING_ARGS, \
+ EX_SUCCESS, EX_UNKNOWN_COMMAND, EX_USER_INTERRUPT, INVALID_ARGUMENT
+from VirtualMailManager.cli.subcommands import RunContext, cmd_map, usage
+
+
+_ = lambda msg: msg
+
+
+def _get_handler():
+ """Try to get a CliHandler. Exit the program when an error occurs."""
+ try:
+ handler = CliHandler()
+ except (errors.NotRootError, errors.PermissionError, errors.VMMError,
+ errors.ConfigError), err:
+ w_err(err.code, _(u'Error: %s') % err.msg)
+ else:
+ handler.cfg_install()
+ return handler
+
+
+def run(argv):
+ if len(argv) < 2:
+ usage(EX_MISSING_ARGS, _(u"You must specify a subcommand at least"))
+
+ sub_cmd = argv[1].lower()
+ if sub_cmd in cmd_map:
+ cmd_func = cmd_map[sub_cmd].func
+ else:
+ for cmd in cmd_map.itervalues():
+ if cmd.alias == sub_cmd:
+ cmd_func = cmd.func
+ sub_cmd = cmd.name
+ break
+ else:
+ usage(EX_UNKNOWN_COMMAND, _(u"Unknown subcommand: '%s'") % sub_cmd)
+
+ handler = _get_handler()
+ run_ctx = RunContext(argv, handler, sub_cmd)
+ try:
+ cmd_func(run_ctx)
+ except (EOFError, KeyboardInterrupt):
+ # TP: We have to cry, because root has killed/interrupted vmm
+ # with Ctrl+C or Ctrl+D.
+ w_err(EX_USER_INTERRUPT, '', _(u'Ouch!'), '')
+ except errors.VMMError, err:
+ if err.code != DATABASE_ERROR:
+ w_err(err.code, _(u'Error: %s') % err.msg)
+ w_err(err.code, unicode(err.msg, ENCODING, 'replace'))
+ except (BadOptionError, ConfigValueError), err:
+ w_err(INVALID_ARGUMENT, _(u'Error: %s') % err)
+ except NoSectionError, err:
+ w_err(INVALID_ARGUMENT, _(u"Error: No section '%s'") % err.section)
+ except NoOptionError, err:
+ w_err(INVALID_ARGUMENT,
+ _(u"Error: No option '%(option)s' in section: '%(section)s'") %
+ {'option': err.option, 'section': err.section})
+ if handler.has_warnings():
+ w_err(0, _(u'Warnings:'), *handler.get_warnings())
+ return EX_SUCCESS
+
+del _
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/VirtualMailManager/cli/subcommands.py Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,734 @@
+# -*- coding: UTF-8 -*-
+# Copyright 2007 - 2010, Pascal Volk
+# See COPYING for distribution information.
+"""
+ VirtualMailManager.cli.subcommands
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ VirtualMailManager's cli subcommands.
+"""
+
+import locale
+import os
+
+from textwrap import TextWrapper
+from time import strftime, strptime
+
+from VirtualMailManager import ENCODING
+from VirtualMailManager.account import SERVICES
+from VirtualMailManager.cli import get_winsize, prog, w_err, w_std
+from VirtualMailManager.common import version_str
+from VirtualMailManager.constants import __copyright__, __date__, \
+ __version__, ACCOUNT_EXISTS, ALIAS_EXISTS, ALIASDOMAIN_ISDOMAIN, \
+ DOMAIN_ALIAS_EXISTS, INVALID_ARGUMENT, EX_MISSING_ARGS, RELOCATED_EXISTS
+from VirtualMailManager.errors import VMMError
+
+__all__ = (
+ 'Command', 'RunContext', 'cmd_map', 'usage', 'alias_add', 'alias_delete',
+ 'alias_info', 'aliasdomain_add', 'aliasdomain_delete', 'aliasdomain_info',
+ 'aliasdomain_switch', 'config_get', 'config_set', 'configure',
+ 'domain_add', 'domain_delete', 'domain_info', 'domain_transport',
+ 'get_user', 'help_', 'list_domains', 'relocated_add', 'relocated_delete',
+ 'relocated_info', 'user_add', 'user_delete', 'user_disable', 'user_enable',
+ 'user_info', 'user_name', 'user_password', 'user_transport', 'version',
+)
+
+_ = lambda msg: msg
+txt_wrpr = TextWrapper(width=get_winsize()[1] - 1)
+
+
+class Command(object):
+ """Container class for command information."""
+ __slots__ = ('name', 'alias', 'func', 'args', 'descr')
+
+ def __init__(self, name, alias, func, args, descr):
+ """Create a new Command instance.
+
+ Arguments:
+
+ `name` : str
+ the command name, e.g. ``addalias``
+ `alias` : str
+ the command's short alias, e.g. ``aa``
+ `func` : callable
+ the function to handle the command
+ `args` : str
+ argument placeholders, e.g. ``aliasaddress``
+ `descr` : str
+ short description of the command
+ """
+ self.name = name
+ self.alias = alias
+ self.func = func
+ self.args = args
+ self.descr = descr
+
+ @property
+ def usage(self):
+ """the command's usage info."""
+ return u'%s %s %s' % (prog, self.name, self.args)
+
+
+class RunContext(object):
+ """Contains all information necessary to run a subcommand."""
+ __slots__ = ('argc', 'args', 'cget', 'hdlr', 'scmd')
+ plan_a_b = _(u'Plan A failed ... trying Plan B: %(subcommand)s %(object)s')
+
+ def __init__(self, argv, handler, command):
+ """Create a new RunContext"""
+ self.argc = len(argv)
+ self.args = [unicode(arg, ENCODING) for arg in argv]
+ self.cget = handler.cfg_dget
+ self.hdlr = handler
+ self.scmd = command
+
+
+def alias_add(ctx):
+ """create a new alias e-mail address"""
+ if ctx.argc < 3:
+ usage(EX_MISSING_ARGS, _(u'Missing alias address and destination.'),
+ ctx.scmd)
+ elif ctx.argc < 4:
+ usage(EX_MISSING_ARGS, _(u'Missing destination address.'), ctx.scmd)
+ ctx.hdlr.alias_add(ctx.args[2].lower(), *ctx.args[3:])
+
+
+def alias_delete(ctx):
+ """delete the specified alias e-mail address or one of its destinations"""
+ if ctx.argc < 3:
+ usage(EX_MISSING_ARGS, _(u'Missing alias address.'), ctx.scmd)
+ elif ctx.argc < 4:
+ ctx.hdlr.alias_delete(ctx.args[2].lower())
+ else:
+ ctx.hdlr.alias_delete(ctx.args[2].lower(), ctx.args[3])
+
+
+def alias_info(ctx):
+ """show the destination(s) of the specified alias"""
+ if ctx.argc < 3:
+ usage(EX_MISSING_ARGS, _(u'Missing alias address.'), ctx.scmd)
+ address = ctx.args[2].lower()
+ try:
+ _print_aliase_info(address, ctx.hdlr.alias_info(address))
+ except VMMError, err:
+ if err.code is ACCOUNT_EXISTS:
+ w_err(0, ctx.plan_a_b % {'subcommand': u'userinfo',
+ 'object': address})
+ ctx.args[1] = 'userinfo'
+ user_info(ctx)
+ elif err.code is RELOCATED_EXISTS:
+ w_std(0, ctx.plan_a_b % {'subcommand': u'relocatedinfo',
+ 'object': address})
+ ctx.args[1] = 'relocatedinfo'
+ relocated_info(ctx)
+ else:
+ raise
+
+
+def aliasdomain_add(ctx):
+ """create a new alias for an existing domain"""
+ if ctx.argc < 3:
+ usage(EX_MISSING_ARGS, _(u'Missing alias domain name and destination '
+ u'domain name.'), ctx.scmd)
+ elif ctx.argc < 4:
+ usage(EX_MISSING_ARGS, _(u'Missing destination domain name.'),
+ ctx.scmd)
+ ctx.hdlr.aliasdomain_add(ctx.args[2].lower(), ctx.args[3].lower())
+
+
+def aliasdomain_delete(ctx):
+ """delete the specified alias domain"""
+ if ctx.argc < 3:
+ usage(EX_MISSING_ARGS, _(u'Missing alias domain name.'), ctx.scmd)
+ ctx.hdlr.aliasdomain_delete(ctx.args[2].lower())
+
+
+def aliasdomain_info(ctx):
+ """show the destination of the given alias domain"""
+ if ctx.argc < 3:
+ usage(EX_MISSING_ARGS, _(u'Missing alias domain name.'), ctx.scmd)
+ try:
+ _print_aliasdomain_info(ctx.hdlr.aliasdomain_info(ctx.args[2].lower()))
+ except VMMError, err:
+ if err.code is ALIASDOMAIN_ISDOMAIN:
+ w_err(0, ctx.plan_a_b % {'subcommand': u'domaininfo',
+ 'object': ctx.args[2].lower()})
+ ctx.args[1] = 'domaininfo'
+ domain_info(ctx)
+ else:
+ raise
+
+
+def aliasdomain_switch(ctx):
+ """assign the given alias domain to an other domain"""
+ if ctx.argc < 3:
+ usage(EX_MISSING_ARGS, _(u'Missing alias domain name and destination '
+ u'domain name.'), ctx.scmd)
+ elif ctx.argc < 4:
+ usage(EX_MISSING_ARGS, _(u'Missing destination domain name.'),
+ ctx.scmd)
+ ctx.hdlr.aliasdomain_switch(ctx.args[2].lower(), ctx.args[3].lower())
+
+
+def config_get(ctx):
+ """show the actual value of the configuration option"""
+ if ctx.argc < 3:
+ usage(EX_MISSING_ARGS, _(u"Missing option name."), ctx.scmd)
+ option = ctx.args[2].lower()
+ if option != 'misc.dovecot_version':
+ w_std('%s = %s' % (option, ctx.cget(option)))
+ else:
+ w_std('%s = %s' % (option, version_str(ctx.cget(option))))
+
+
+def config_set(ctx):
+ """set a new value for the configuration option"""
+ if ctx.argc < 3:
+ usage(EX_MISSING_ARGS, _(u'Missing option and new value.'), ctx.scmd)
+ if ctx.argc < 4:
+ usage(EX_MISSING_ARGS, _(u'Missing new configuration value.'),
+ ctx.scmd)
+ ctx.hdlr.cfg_set(ctx.args[2].lower(), ctx.args[3])
+
+
+def configure(ctx):
+ """start interactive configuration modus"""
+ if ctx.argc < 3:
+ ctx.hdlr.configure()
+ else:
+ ctx.hdlr.configure(ctx.args[2].lower())
+
+
+def domain_add(ctx):
+ """create a new domain"""
+ if ctx.argc < 3:
+ usage(EX_MISSING_ARGS, _(u'Missing domain name.'), ctx.scmd)
+ elif ctx.argc < 4:
+ ctx.hdlr.domain_add(ctx.args[2].lower())
+ else:
+ ctx.hdlr.domain_add(ctx.args[2].lower(), ctx.args[3])
+ if not ctx.cget('domain.auto_postmaster'):
+ return
+ ctx.scmd = 'useradd'
+ ctx.args = [prog, ctx.scmd, u'postmaster@' + ctx.args[2].lower()]
+ ctx.argc = 3
+ user_add(ctx)
+
+
+def domain_delete(ctx):
+ """delete the given domain and all its alias domains"""
+ if ctx.argc < 3:
+ usage(EX_MISSING_ARGS, _(u'Missing domain name.'), ctx.scmd)
+ elif ctx.argc < 4:
+ ctx.hdlr.domain_delete(ctx.args[2].lower())
+ elif ctx.args[3].lower() == 'force':
+ ctx.hdlr.domain_delete(ctx.args[2].lower(), True)
+ else:
+ usage(INVALID_ARGUMENT, _(u"Invalid argument: '%s'") % ctx.args[3],
+ ctx.scmd)
+
+
+def domain_info(ctx):
+ """display information about the given domain"""
+ if ctx.argc < 3:
+ usage(EX_MISSING_ARGS, _(u'Missing domain name.'), ctx.scmd)
+ if ctx.argc < 4:
+ details = None
+ else:
+ details = ctx.args[3].lower()
+ if details not in ('accounts', 'aliasdomains', 'aliases', 'full',
+ 'relocated'):
+ usage(INVALID_ARGUMENT, _(u"Invalid argument: '%s'") % details,
+ ctx.scmd)
+ try:
+ info = ctx.hdlr.domain_info(ctx.args[2].lower(), details)
+ except VMMError, err:
+ if err.code is DOMAIN_ALIAS_EXISTS:
+ w_err(0, ctx.plan_a_b % {'subcommand': u'aliasdomaininfo',
+ 'object': ctx.args[2].lower()})
+ ctx.args[1] = 'aliasdomaininfo'
+ aliasdomain_info(ctx)
+ else:
+ raise
+ else:
+ if not details:
+ _print_info(ctx, info, _(u'Domain'))
+ else:
+ _print_info(ctx, info[0], _(u'Domain'))
+ if details == u'accounts':
+ _print_list(info[1], _(u'accounts'))
+ elif details == u'aliasdomains':
+ _print_list(info[1], _(u'alias domains'))
+ elif details == u'aliases':
+ _print_list(info[1], _(u'aliases'))
+ elif details == u'relocated':
+ _print_list(info[1], _(u'relocated users'))
+ else:
+ _print_list(info[1], _(u'alias domains'))
+ _print_list(info[2], _(u'accounts'))
+ _print_list(info[3], _(u'aliases'))
+ _print_list(info[4], _(u'relocated users'))
+
+
+def domain_transport(ctx):
+ """update the transport of the specified domain"""
+ if ctx.argc < 3:
+ usage(EX_MISSING_ARGS, _(u'Missing domain name and new transport.'),
+ ctx.scmd)
+ if ctx.argc < 4:
+ usage(EX_MISSING_ARGS, _(u'Missing new transport.'), ctx.scmd)
+ if ctx.argc < 5:
+ ctx.hdlr.domain_transport(ctx.args[2].lower(), ctx.args[3])
+ else:
+ force = ctx.args[4].lower()
+ if force != 'force':
+ usage(INVALID_ARGUMENT, _(u"Invalid argument: '%s'") % force,
+ ctx.scmd)
+ ctx.hdlr.domain_transport(ctx.args[2].lower(), ctx.args[3], force)
+
+
+def get_user(ctx):
+ """get the address of the user with the given UID"""
+ if ctx.argc < 3:
+ usage(EX_MISSING_ARGS, _(u'Missing userid.'), ctx.scmd)
+ _print_info(ctx, ctx.hdlr.user_by_uid(ctx.args[2]), _(u'Account'))
+
+
+def help_(ctx):
+ """print help messgaes."""
+ if ctx.argc > 2:
+ hlptpc = ctx.args[2].lower()
+ if hlptpc in cmd_map:
+ topic = hlptpc
+ else:
+ for scmd in cmd_map.itervalues():
+ if scmd.alias == hlptpc:
+ topic = scmd.name
+ break
+ else:
+ usage(INVALID_ARGUMENT, _(u"Unknown help topic: '%s'") %
+ ctx.args[2], ctx.scmd)
+ # FIXME
+ w_err(1, "'help %s' not yet implemented." % topic, 'see also: vmm(1)')
+
+ old_ii = txt_wrpr.initial_indent
+ old_si = txt_wrpr.subsequent_indent
+ txt_wrpr.initial_indent = ' '
+ # len(max(_overview.iterkeys(), key=len)) #Py25
+ txt_wrpr.subsequent_indent = 20 * ' '
+ order = cmd_map.keys()
+ order.sort()
+
+ w_std(_(u'List of available subcommands:') + '\n')
+ for key in order:
+ w_std('\n'.join(txt_wrpr.wrap('%-18s %s' % (key, cmd_map[key].descr))))
+
+ txt_wrpr.initial_indent = old_ii
+ txt_wrpr.subsequent_indent = old_si
+ txt_wrpr.initial_indent = ''
+
+
+def list_domains(ctx):
+ """list all domains / search domains by pattern"""
+ matching = ctx.argc > 2
+ if matching:
+ gids, domains = ctx.hdlr.domain_list(ctx.args[2].lower())
+ else:
+ gids, domains = ctx.hdlr.domain_list()
+ _print_domain_list(gids, domains, matching)
+
+
+def relocated_add(ctx):
+ """create a new record for a relocated user"""
+ if ctx.argc < 3:
+ usage(EX_MISSING_ARGS,
+ _(u'Missing relocated address and destination.'), ctx.scmd)
+ elif ctx.argc < 4:
+ usage(EX_MISSING_ARGS, _(u'Missing destination address.'), ctx.scmd)
+ ctx.hdlr.relocated_add(ctx.args[2].lower(), ctx.args[3])
+
+
+def relocated_delete(ctx):
+ """delete the record of the relocated user"""
+ if ctx.argc < 3:
+ usage(EX_MISSING_ARGS, _(u'Missing relocated address.'), ctx.scmd)
+ ctx.hdlr.relocated_delete(ctx.args[2].lower())
+
+
+def relocated_info(ctx):
+ """print information about a relocated user"""
+ if ctx.argc < 3:
+ usage(EX_MISSING_ARGS, _(u'Missing relocated address.'), ctx.scmd)
+ relocated = ctx.args[2].lower()
+ try:
+ _print_relocated_info(addr=relocated,
+ dest=ctx.hdlr.relocated_info(relocated))
+ except VMMError, err:
+ if err.code is ACCOUNT_EXISTS:
+ w_err(0, ctx.plan_a_b % {'subcommand': u'userinfo',
+ 'object': relocated})
+ ctx.args[1] = 'userinfoi'
+ user_info(ctx)
+ elif err.code is ALIAS_EXISTS:
+ w_err(0, ctx.plan_a_b % {'subcommand': u'aliasinfo',
+ 'object': relocated})
+ ctx.args[1] = 'aliasinfo'
+ alias_info(ctx)
+ else:
+ raise
+
+
+def user_add(ctx):
+ """create a new e-mail user with the given address"""
+ if ctx.argc < 3:
+ usage(EX_MISSING_ARGS, _(u'Missing e-mail address.'), ctx.scmd)
+ elif ctx.argc < 4:
+ password = None
+ else:
+ password = ctx.args[3]
+ gen_pass = ctx.hdlr.user_add(ctx.args[2].lower(), password)
+ if gen_pass:
+ w_std(_(u"Generated password: %s") % gen_pass)
+
+
+def user_delete(ctx):
+ """delete the specified user"""
+ if ctx.argc < 3:
+ usage(EX_MISSING_ARGS, _(u'Missing e-mail address.'), ctx.scmd)
+ elif ctx.argc < 4:
+ ctx.hdlr.user_delete(ctx.args[2].lower())
+ elif ctx.args[3].lower() == 'force':
+ ctx.hdlr.user_delete(ctx.args[2].lower(), True)
+ else:
+ usage(INVALID_ARGUMENT, _(u"Invalid argument: '%s'") % ctx.args[3],
+ ctx.scmd)
+
+
+def user_disable(ctx):
+ """deactivate all/the given service(s) for a user"""
+ if ctx.argc < 3:
+ usage(EX_MISSING_ARGS, _(u'Missing e-mail address.'), ctx.scmd)
+ elif ctx.argc < 4:
+ ctx.hdlr.user_disable(ctx.args[2].lower())
+ else:
+ services = [service.lower() for service in ctx.args[3:]]
+ unknown = [service for service in services if service not in SERVICES]
+ if unknown:
+ usage(INVALID_ARGUMENT, _(u"Invalid service arguments: %s") %
+ ' '.join(unknown), ctx.scmd)
+ ctx.hdlr.user_disable(ctx.args[2].lower(), services)
+
+
+def user_enable(ctx):
+ """activate all or the given service(s) for a user"""
+ if ctx.argc < 3:
+ usage(EX_MISSING_ARGS, _(u'Missing e-mail address.'), ctx.scmd)
+ elif ctx.argc < 4:
+ ctx.hdlr.user_enable(ctx.args[2].lower())
+ else:
+ services = [service.lower() for service in ctx.args[3:]]
+ unknown = [service for service in services if service not in SERVICES]
+ if unknown:
+ usage(INVALID_ARGUMENT, _(u"Invalid service arguments: %s") %
+ ' '.join(unknown), ctx.scmd)
+ ctx.hdlr.user_enable(ctx.args[2].lower(), services)
+
+
+def user_info(ctx):
+ """display information about the given address"""
+ if ctx.argc < 3:
+ usage(EX_MISSING_ARGS, _(u'Missing e-mail address.'), ctx.scmd)
+ if ctx.argc < 4:
+ details = None
+ else:
+ details = ctx.args[3].lower()
+ if details not in ('aliases', 'du', 'full'):
+ usage(INVALID_ARGUMENT, _(u"Invalid argument: '%s'") % details,
+ ctx.scmd)
+ try:
+ info = ctx.hdlr.user_info(ctx.args[2].lower(), details)
+ except VMMError, err:
+ if err.code is ALIAS_EXISTS:
+ w_err(0, ctx.plan_a_b % {'subcommand': u'aliasinfo',
+ 'object': ctx.args[2].lower()})
+ ctx.args[1] = 'aliasinfo'
+ alias_info(ctx)
+ elif err.code is RELOCATED_EXISTS:
+ w_err(0, ctx.plan_a_b % {'subcommand': u'relocatedinfo',
+ 'object': ctx.args[2].lower()})
+ ctx.args[1] = 'relocatedinfo'
+ relocated_info(ctx)
+ else:
+ raise
+ else:
+ if details in (None, 'du'):
+ _print_info(ctx, info, _(u'Account'))
+ else:
+ _print_info(ctx, info[0], _(u'Account'))
+ _print_list(info[1], _(u'alias addresses'))
+
+
+def user_name(ctx):
+ """set or update the real name for an address"""
+ if ctx.argc < 3:
+ usage(EX_MISSING_ARGS, _(u"Missing e-mail address and user's name."),
+ ctx.scmd)
+ if ctx.argc < 4:
+ usage(EX_MISSING_ARGS, _(u"Missing user's name."), ctx.scmd)
+ ctx.hdlr.user_name(ctx.args[2].lower(), ctx.args[3])
+
+
+def user_password(ctx):
+ """update the password for the given address"""
+ if ctx.argc < 3:
+ usage(EX_MISSING_ARGS, _(u'Missing e-mail address.'), ctx.scmd)
+ elif ctx.argc < 4:
+ password = None
+ else:
+ password = ctx.args[3]
+ ctx.hdlr.user_password(ctx.args[2].lower(), password)
+
+
+def user_transport(ctx):
+ """update the transport of the given address"""
+ if ctx.argc < 3:
+ usage(EX_MISSING_ARGS, _(u'Missing e-mail address and transport.'),
+ ctx.scmd)
+ if ctx.argc < 4:
+ usage(EX_MISSING_ARGS, _(u'Missing transport.'), ctx.scmd)
+ ctx.hdlr.user_transport(ctx.args[2].lower(), ctx.args[3])
+
+
+def usage(errno, errmsg, subcommand=None):
+ """print usage message for the given command or all commands.
+ When errno > 0, sys,exit(errno) will interrupt the program.
+ """
+ if subcommand and subcommand in cmd_map:
+ w_err(errno, _(u"Error: %s") % errmsg,
+ _(u"usage: ") + cmd_map[subcommand].usage)
+
+ # TP: Please adjust translated words like the original text.
+ # (It's a table header.) Extract from usage text:
+ # usage: vmm subcommand arguments
+ # short long
+ # subcommand arguments
+ #
+ # da domainadd fqdn [transport]
+ # dd domaindelete fqdn [force]
+ u_head = _(u"""usage: %s subcommand arguments
+ short long
+ subcommand arguments\n""") % prog
+ order = cmd_map.keys()
+ order.sort()
+ w_err(0, u_head)
+ for key in order:
+ scmd = cmd_map[key]
+ w_err(0, ' %-5s %-19s %s' % (scmd.alias, scmd.name, scmd.args))
+ w_err(errno, '', _(u"Error: %s") % errmsg)
+
+
+def version(ctx):
+ """Write version and copyright information to stdout."""
+ w_std('%s, %s %s (%s %s)\nPython %s %s %s\n\n%s\n%s %s' % (prog,
+ # TP: The words 'from', 'version' and 'on' are used in
+ # the version information, e.g.:
+ # vmm, version 0.5.2 (from 09/09/09)
+ # Python 2.5.4 on FreeBSD
+ _(u'version'), __version__, _(u'from'),
+ strftime(locale.nl_langinfo(locale.D_FMT),
+ strptime(__date__, '%Y-%m-%d')).decode(ENCODING, 'replace'),
+ os.sys.version.split()[0], _(u'on'), os.uname()[0],
+ __copyright__, prog,
+ _(u'is free software and comes with ABSOLUTELY NO WARRANTY.')))
+
+cmd = Command
+cmd_map = { # {{{
+ # Account commands
+ 'getuser': cmd('getuser', 'gu', get_user, 'uid',
+ _(u'get the address of the user with the given UID')),
+ 'useradd': cmd('useradd', 'ua', user_add, 'address [password]',
+ _(u'create a new e-mail user with the given address')),
+ 'userdelete': cmd('userdelete', 'ud', user_delete, 'address [force]',
+ _(u'delete the specified user')),
+ 'userdisable': cmd('userdisable', 'u0', user_disable,
+ 'address [service ...]',
+ _(u'deactivate all/the given service(s) for a user')),
+ 'userenable': cmd('userenable', 'u1', user_enable, 'address [service ...]',
+ _(u'activate all or the given service(s) for a user')),
+ 'userinfo': cmd('userinfo', 'ui', user_info, 'address [details]',
+ _(u'display information about the given address')),
+ 'username': cmd('username', 'un', user_name, 'address name',
+ _(u'set or update the real name for an address')),
+ 'userpassword': cmd('userpassword', 'up', user_password,
+ 'address [password]',
+ _(u'update the password for the given address')),
+ 'usertransport': cmd('usertransport', 'ut', user_transport,
+ 'address transport',
+ _(u'update the transport of the given address')),
+ # Alias commands
+ 'aliasadd': cmd('aliasadd', 'aa', alias_add, 'address destination ...',
+ _(u'create a new alias e-mail address')),
+ 'aliasdelete': cmd('aliasdelete', 'ad', alias_delete,
+ 'address [destination]',
+ _(u'delete the specified alias e-mail address or one '
+ u'of its destinations')),
+ 'aliasinfo': cmd('aliasinfo', 'ai', alias_info, 'address',
+ _(u'show the destination(s) of the specified alias')),
+ # AliasDomain commands
+ 'aliasdomainadd': cmd('aliasdomainadd', 'ada', aliasdomain_add,
+ 'fqdn destination',
+ _(u'create a new alias for an existing domain')),
+ 'aliasdomaindelete': cmd('aliasdomaindelete', 'add', aliasdomain_delete,
+ 'fqdn', _(u'delete the specified alias domain')),
+ 'aliasdomaininfo': cmd('aliasdomaininfo', 'adi', aliasdomain_info, 'fqdn',
+ _(u'show the destination of the given alias domain')),
+ 'aliasdomainswitch': cmd('aliasdomainswitch', 'ads', aliasdomain_switch,
+ 'fqdn destination',
+ _(u'assign the given alias domain to an other domain')),
+ # Domain commands
+ 'domainadd': cmd('domainadd', 'da', domain_add, 'fqdn [transport]',
+ _(u'create a new domain')),
+ 'domaindelete': cmd('domaindelete', 'dd', domain_delete, 'fqdn [force]',
+ _(u'delete the given domain and all its alias domains')),
+ 'domaininfo': cmd('domaininfo', 'di', domain_info, 'fqdn [details]',
+ _(u'display information about the given domain')),
+ 'domaintransport': cmd('domaintransport', 'dt', domain_transport,
+ 'fqdn transport [force]',
+ _(u'update the transport of the specified domain')),
+ 'listdomains': cmd('listdomains', 'ld', list_domains, '[pattern]',
+ _(u'list all domains / search domains by pattern')),
+ # Relocated commands
+ 'relocatedadd': cmd('relocatedadd', 'ra', relocated_add,
+ 'address newaddress',
+ _(u'create a new record for a relocated user')),
+ 'relocateddelete': cmd('relocateddelete', 'rd', relocated_delete,
+ 'address',
+ _(u'delete the record of the relocated user')),
+ 'relocatedinfo': cmd('relocatedinfo', 'ri', relocated_info, 'address',
+ _(u'print information about a relocated user')),
+ # cli commands
+ 'configget': cmd('configget', 'cg', config_get, 'option',
+ _('show the actual value of the configuration option')),
+ 'configset': cmd('configset', 'cs', config_set, 'option value',
+ _('set a new value for the configuration option')),
+ 'configure': cmd('configure', 'cf', configure, '[section]',
+ _(u'start interactive configuration modus')),
+ 'help': cmd('help', 'h', help_, '[subcommand]',
+ _(u'show a help overview or help for the given subcommand')),
+ 'version': cmd('version', 'v', version, '',
+ _(u'show version and copyright information')),
+} # }}}
+
+
+def _get_order(ctx):
+ """returns a tuple with (key, 1||0) tuples. Used by functions, which
+ get a dict from the handler."""
+ order = ()
+ if ctx.scmd == 'domaininfo':
+ order = ((u'domainname', 0), (u'gid', 1), (u'transport', 0),
+ (u'domaindir', 0), (u'aliasdomains', 0), (u'accounts', 0),
+ (u'aliases', 0), (u'relocated', 0))
+ elif ctx.scmd == 'userinfo':
+ dc12 = ctx.cget('misc.dovecot_version') >= 0x10200b02
+ sieve = (u'managesieve', u'sieve')[dc12]
+ if ctx.argc == 4 and ctx.args[3] != u'aliases' or \
+ ctx.cget('account.disk_usage'):
+ order = ((u'address', 0), (u'name', 0), (u'uid', 1), (u'gid', 1),
+ (u'home', 0), (u'mail_location', 0), (u'disk usage', 0),
+ (u'transport', 0), (u'smtp', 1), (u'pop3', 1),
+ (u'imap', 1), (sieve, 1))
+ else:
+ order = ((u'address', 0), (u'name', 0), (u'uid', 1), (u'gid', 1),
+ (u'home', 0), (u'mail_location', 0), (u'transport', 0),
+ (u'smtp', 1), (u'pop3', 1), (u'imap', 1), (sieve, 1))
+ elif ctx.scmd == 'getuser':
+ order = ((u'uid', 1), (u'gid', 1), (u'address', 0))
+ return order
+
+
+def _print_info(ctx, info, title):
+ """Print info dicts."""
+ # TP: used in e.g. 'Domain information' or 'Account information'
+ msg = u'%s %s' % (title, _(u'information'))
+ w_std(msg, u'-' * len(msg))
+ for key, upper in _get_order(ctx):
+ if upper:
+ w_std(u'\t%s: %s' % (key.upper().ljust(15, u'.'), info[key]))
+ else:
+ w_std(u'\t%s: %s' % (key.title().ljust(15, u'.'), info[key]))
+ print
+
+
+def _print_list(alist, title):
+ """Print a list."""
+ # TP: used in e.g. 'Available alias addresses' or 'Available accounts'
+ msg = u'%s %s' % (_(u'Available'), title)
+ w_std(msg, u'-' * len(msg))
+ if alist:
+ if title != _(u'alias domains'):
+ w_std(*(u'\t%s' % item for item in alist))
+ else:
+ for domain in alist:
+ if not domain.startswith('xn--'):
+ w_std(u'\t%s' % domain)
+ else:
+ w_std(u'\t%s (%s)' % (domain, domain.decode('idna')))
+ print
+ else:
+ w_std(_(u'\tNone'), '')
+
+
+def _print_aliase_info(alias, destinations):
+ """Print the alias address and all its destinations"""
+ title = _(u'Alias information')
+ w_std(title, u'-' * len(title))
+ w_std(_(u'\tMail for %s will be redirected to:') % alias)
+ w_std(*(u'\t * %s' % dest for dest in destinations))
+ print
+
+
+def _print_relocated_info(**kwargs):
+ """Print the old and new addresses of a relocated user."""
+ title = _(u'Relocated information')
+ w_std(title, u'-' * len(title))
+ w_std(_(u"\tUser '%(addr)s' has moved to '%(dest)s'") % kwargs, '')
+
+
+def _format_domain(domain, main=True):
+ """format (prefix/convert) the domain name."""
+ if domain.startswith('xn--'):
+ domain = u'%s (%s)' % (domain, domain.decode('idna'))
+ if main:
+ return u'\t[+] %s' % domain
+ return u'\t[-] %s' % domain
+
+
+def _print_domain_list(dids, domains, matching):
+ """Print a list of (matching) domains/alias domains."""
+ if matching:
+ title = _(u'Matching domains')
+ else:
+ title = _(u'Available domains')
+ w_std(title, '-' * len(title))
+ if domains:
+ for did in dids:
+ if domains[did][0] is not None:
+ w_std(_format_domain(domains[did][0]))
+ if len(domains[did]) > 1:
+ w_std(*(_format_domain(a, False) for a in domains[did][1:]))
+ else:
+ w_std(_('\tNone'))
+ print
+
+
+def _print_aliasdomain_info(info):
+ """Print alias domain information."""
+ title = _(u'Alias domain information')
+ for key in ('alias', 'domain'):
+ if info[key].startswith('xn--'):
+ info[key] = u'%s (%s)' % (info[key], info[key].decode('idna'))
+ w_std(title, '-' * len(title),
+ _('\tThe alias domain %(alias)s belongs to:\n\t * %(domain)s') %
+ info, '')
+
+del _
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/VirtualMailManager/common.py Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,136 @@
+# -*- coding: UTF-8 -*-
+# Copyright (c) 2010, Pascal Volk
+# See COPYING for distribution information.
+"""
+ VirtualMailManager.common
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ Some common functions
+"""
+
+import os
+import re
+import stat
+
+from VirtualMailManager import ENCODING
+from VirtualMailManager.constants import NOT_EXECUTABLE, NO_SUCH_BINARY
+from VirtualMailManager.errors import VMMError
+
+
+VERSION_RE = re.compile(r'^(\d+)\.(\d+)\.(?:(\d+)|(alpha|beta|rc)(\d+))$')
+
+_version_level = dict(alpha=0xA, beta=0xB, rc=0xC)
+_version_cache = {}
+_ = lambda msg: msg
+
+
+def expand_path(path):
+ """Expands paths, starting with ``.`` or ``~``, to an absolute path."""
+ if path.startswith('.'):
+ return os.path.abspath(path)
+ if path.startswith('~'):
+ return os.path.expanduser(path)
+ return path
+
+
+def get_unicode(string):
+ """Converts `string` to `unicode`, if necessary."""
+ if isinstance(string, unicode):
+ return string
+ return unicode(string, ENCODING, 'replace')
+
+
+def lisdir(path):
+ """Checks if `path` is a directory. Doesn't follow symbolic links.
+ Returns bool.
+ """
+ try:
+ lstat = os.lstat(path)
+ except OSError:
+ return False
+ return stat.S_ISDIR(lstat.st_mode)
+
+
+def exec_ok(binary):
+ """Checks if the `binary` exists and if it is executable.
+
+ Throws a `VMMError` if the `binary` isn't a file or is not
+ executable.
+ """
+ binary = expand_path(binary)
+ if not os.path.isfile(binary):
+ raise VMMError(_(u"No such file: '%s'") % get_unicode(binary),
+ NO_SUCH_BINARY)
+ if not os.access(binary, os.X_OK):
+ raise VMMError(_(u"File is not executable: '%s'") %
+ get_unicode(binary), NOT_EXECUTABLE)
+ return binary
+
+
+def version_hex(version_string):
+ """Converts a Dovecot version, e.g.: '1.2.3' or '2.0.beta4', to an int.
+ Raises a `ValueError` if the *version_string* has the wrong™ format.
+
+ version_hex('1.2.3') -> 270548736
+ hex(version_hex('1.2.3')) -> '0x10203f00'
+ """
+ global _version_cache
+ if version_string in _version_cache:
+ return _version_cache[version_string]
+ version = 0
+ version_mo = VERSION_RE.match(version_string)
+ if not version_mo:
+ raise ValueError('Invalid version string: %r' % version_string)
+ major, minor, patch, level, serial = version_mo.groups()
+ major = int(major)
+ minor = int(minor)
+ if patch:
+ patch = int(patch)
+ if serial:
+ serial = int(serial)
+
+ if major > 0xFF or minor > 0xFF or \
+ patch and patch > 0xFF or serial and serial > 0xFF:
+ raise ValueError('Invalid version string: %r' % version_string)
+
+ version += major << 28
+ version += minor << 20
+ if patch:
+ version += patch << 12
+ version += _version_level.get(level, 0xF) << 8
+ if serial:
+ version += serial
+
+ _version_cache[version_string] = version
+ return version
+
+
+def version_str(version):
+ """Converts a Dovecot version previously converted with version_hex back to
+ a string.
+ Raises a `TypeError` if *version* is not an int/long.
+ Raises a `ValueError` if *version* is an incorrect int version.
+ """
+ global _version_cache
+ if version in _version_cache:
+ return _version_cache[version]
+ if not isinstance(version, (int, long)):
+ raise TypeError('Argument is not a int/long: %r', version)
+ major = (version >> 28) & 0xFF
+ minor = (version >> 20) & 0xFF
+ patch = (version >> 12) & 0xFF
+ level = (version >> 8) & 0x0F
+ serial = version & 0xFF
+
+ levels = dict(zip(_version_level.values(), _version_level.keys()))
+ if level == 0xF and not serial:
+ version_string = '%u.%u.%u' % (major, minor, patch)
+ elif level in levels and not patch:
+ version_string = '%u.%u.%s%u' % (major, minor, levels[level], serial)
+ else:
+ raise ValueError('Invalid version: %r' % hex(version))
+
+ _version_cache[version] = version_string
+ return version_string
+
+del _
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/VirtualMailManager/config.py Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,517 @@
+# -*- coding: UTF-8 -*-
+# Copyright (c) 2007 - 2010, Pascal Volk
+# See COPYING for distribution information.
+"""
+ VirtualMailManager.config
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ VMM's configuration module for simplified configuration access.
+"""
+
+from ConfigParser import \
+ Error, MissingSectionHeaderError, NoOptionError, NoSectionError, \
+ ParsingError, RawConfigParser
+from cStringIO import StringIO
+
+from VirtualMailManager.common import VERSION_RE, \
+ exec_ok, expand_path, get_unicode, lisdir, version_hex
+from VirtualMailManager.constants import CONF_ERROR
+from VirtualMailManager.errors import ConfigError, VMMError
+from VirtualMailManager.maillocation import known_format
+from VirtualMailManager.password import verify_scheme as _verify_scheme
+
+DB_MUDULES = ('psycopg2', 'pypgsql')
+DB_SSL_MODES = ('allow', 'disabled', 'prefer', 'require', 'verify-ca',
+ 'verify-full')
+
+_ = lambda msg: msg
+
+
+class BadOptionError(Error):
+ """Raised when a option isn't in the format 'section.option'."""
+ pass
+
+
+class ConfigValueError(Error):
+ """Raised when creating or validating of new values fails."""
+ pass
+
+
+class NoDefaultError(Error):
+ """Raised when the requested option has no default value."""
+
+ def __init__(self, section, option):
+ Error.__init__(self, 'Option %r in section %r has no default value' %
+ (option, section))
+
+
+class LazyConfig(RawConfigParser):
+ """The **lazy** derivate of the `RawConfigParser`.
+
+ There are two additional getters:
+
+ `pget()`
+ The polymorphic getter, which returns a option's value with the
+ appropriate type.
+ `dget()`
+ Like `LazyConfig.pget()`, but returns the option's default, from
+ `LazyConfig._cfg['sectionname']['optionname'].default`, if the
+ option is not configured in a ini-like configuration file.
+
+ `set()` differs from `RawConfigParser`'s `set()` method. `set()`
+ takes the `section` and `option` arguments combined to a single
+ string in the form "section.option".
+ """
+
+ def __init__(self):
+ RawConfigParser.__init__(self)
+ self._modified = False
+ # sample _cfg dict. Create your own in your derived class.
+ self._cfg = {
+ 'sectionname': {
+ 'optionname': LazyConfigOption(int, 1, self.getint),
+ }
+ }
+
+ def bool_new(self, value):
+ """Converts the string `value` into a `bool` and returns it.
+
+ | '1', 'on', 'yes' and 'true' will become `True`
+ | '0', 'off', 'no' and 'false' will become `False`
+
+ Throws a `ConfigValueError` for all other values, except bools.
+ """
+ if isinstance(value, bool):
+ return value
+ if value.lower() in self._boolean_states:
+ return self._boolean_states[value.lower()]
+ else:
+ raise ConfigValueError(_(u"Not a boolean: '%s'") %
+ get_unicode(value))
+
+ def getboolean(self, section, option):
+ """Returns the boolean value of the option, in the given
+ section.
+
+ For a boolean True, the value must be set to '1', 'on', 'yes',
+ 'true' or True. For a boolean False, the value must set to '0',
+ 'off', 'no', 'false' or False.
+ If the option has another value assigned this method will raise
+ a ValueError.
+ """
+ # if the setting was modified it may be still a boolean value lets see
+ tmp = self.get(section, option)
+ if isinstance(tmp, bool):
+ return tmp
+ if not tmp.lower() in self._boolean_states:
+ raise ValueError('Not a boolean: %s' % tmp)
+ return self._boolean_states[tmp.lower()]
+
+ def _get_section_option(self, section_option):
+ """splits ``section_option`` (section.option) in two parts and
+ returns them as list ``[section, option]``, if:
+
+ * it likes the format of ``section_option``
+ * the ``section`` is known
+ * the ``option`` is known
+
+ Else one of the following exceptions will be thrown:
+
+ * `BadOptionError`
+ * `NoSectionError`
+ * `NoOptionError`
+ """
+ sect_opt = section_option.lower().split('.')
+ # TODO: cache it
+ if len(sect_opt) != 2 or not sect_opt[0] or not sect_opt[1]:
+ raise BadOptionError(_(u"Bad format: '%s' - expected: "
+ u"section.option") %
+ get_unicode(section_option))
+ if not sect_opt[0] in self._cfg:
+ raise NoSectionError(sect_opt[0])
+ if not sect_opt[1] in self._cfg[sect_opt[0]]:
+ raise NoOptionError(sect_opt[1], sect_opt[0])
+ return sect_opt
+
+ def items(self, section):
+ """returns an iterable that returns key, value ``tuples`` from
+ the given ``section``.
+ """
+ if section in self._sections: # check if the section was parsed
+ sect = self._sections[section]
+ elif not section in self._cfg:
+ raise NoSectionError(section)
+ else:
+ return ((k, self._cfg[section][k].default) \
+ for k in self._cfg[section].iterkeys())
+ # still here? Get defaults and merge defaults with configured setting
+ defaults = dict((k, self._cfg[section][k].default) \
+ for k in self._cfg[section].iterkeys())
+ defaults.update(sect)
+ if '__name__' in defaults:
+ del defaults['__name__']
+ return defaults.iteritems()
+
+ def dget(self, option):
+ """Returns the value of the `option`.
+
+ If the option could not be found in the configuration file, the
+ configured default value, from ``LazyConfig._cfg`` will be
+ returned.
+
+ Arguments:
+
+ `option` : string
+ the configuration option in the form "section.option"
+
+ Throws a `NoDefaultError`, if no default value was passed to
+ `LazyConfigOption.__init__()` for the `option`.
+ """
+ section, option = self._get_section_option(option)
+ try:
+ return self._cfg[section][option].getter(section, option)
+ except (NoSectionError, NoOptionError):
+ if not self._cfg[section][option].default is None: # may be False
+ return self._cfg[section][option].default
+ else:
+ raise NoDefaultError(section, option)
+
+ def pget(self, option):
+ """Returns the value of the `option`."""
+ section, option = self._get_section_option(option)
+ return self._cfg[section][option].getter(section, option)
+
+ def set(self, option, value):
+ """Set the `value` of the `option`.
+
+ Throws a `ValueError` if `value` couldn't be converted using
+ `LazyConfigOption.cls`.
+ """
+ # pylint: disable=W0221
+ # @pylint: _L A Z Y_
+ section, option = self._get_section_option(option)
+ val = self._cfg[section][option].cls(value)
+ if self._cfg[section][option].validate:
+ val = self._cfg[section][option].validate(val)
+ if not RawConfigParser.has_section(self, section):
+ self.add_section(section)
+ RawConfigParser.set(self, section, option, val)
+ self._modified = True
+
+ def has_section(self, section):
+ """Checks if `section` is a known configuration section."""
+ return section.lower() in self._cfg
+
+ def has_option(self, option):
+ """Checks if the option (section.option) is a known
+ configuration option.
+ """
+ # pylint: disable=W0221
+ # @pylint: _L A Z Y_
+ try:
+ self._get_section_option(option)
+ return True
+ except(BadOptionError, NoSectionError, NoOptionError):
+ return False
+
+ def sections(self):
+ """Returns an iterator object for all configuration sections."""
+ return self._cfg.iterkeys()
+
+
+class LazyConfigOption(object):
+ """A simple container class for configuration settings.
+
+ `LazyConfigOption` instances are required by `LazyConfig` instances,
+ and instances of classes derived from `LazyConfig`, like the
+ `Config` class.
+ """
+ __slots__ = ('__cls', '__default', '__getter', '__validate')
+
+ def __init__(self, cls, default, getter, validate=None):
+ """Creates a new `LazyConfigOption` instance.
+
+ Arguments:
+
+ `cls` : type
+ The class/type of the option's value
+ `default`
+ Default value of the option. Use ``None`` if the option should
+ not have a default value.
+ `getter` : callable
+ A method's name of `RawConfigParser` and derived classes, to
+ get a option's value, e.g. `self.getint`.
+ `validate` : NoneType or a callable
+ None or any method, that takes one argument, in order to
+ check the value, when `LazyConfig.set()` is called.
+ """
+ self.__cls = cls
+ if not default is None: # enforce the type of the default value
+ self.__default = self.__cls(default)
+ else:
+ self.__default = default
+ if not callable(getter):
+ raise TypeError('getter has to be a callable, got a %r' %
+ getter.__class__.__name__)
+ self.__getter = getter
+ if validate and not callable(validate):
+ raise TypeError('validate has to be callable or None, got a %r' %
+ validate.__class__.__name__)
+ self.__validate = validate
+
+ @property
+ def cls(self):
+ """The class of the option's value e.g. `str`, `unicode` or `bool`."""
+ return self.__cls
+
+ @property
+ def default(self):
+ """The option's default value, may be `None`"""
+ return self.__default
+
+ @property
+ def getter(self):
+ """The getter method or function to get the option's value"""
+ return self.__getter
+
+ @property
+ def validate(self):
+ """A method or function to validate the value"""
+ return self.__validate
+
+
+class Config(LazyConfig):
+ """This class is for reading vmm's configuration file."""
+
+ def __init__(self, filename):
+ """Creates a new Config instance
+
+ Arguments:
+
+ `filename` : str
+ path to the configuration file
+ """
+ LazyConfig.__init__(self)
+ self._cfg_filename = filename
+ self._cfg_file = None
+ self._missing = {}
+
+ LCO = LazyConfigOption
+ bool_t = self.bool_new
+ self._cfg = {
+ 'account': {
+ 'delete_directory': LCO(bool_t, False, self.getboolean),
+ 'directory_mode': LCO(int, 448, self.getint),
+ 'disk_usage': LCO(bool_t, False, self.getboolean),
+ 'password_length': LCO(int, 8, self.getint),
+ 'random_password': LCO(bool_t, False, self.getboolean),
+ 'imap': LCO(bool_t, True, self.getboolean),
+ 'pop3': LCO(bool_t, True, self.getboolean),
+ 'sieve': LCO(bool_t, True, self.getboolean),
+ 'smtp': LCO(bool_t, True, self.getboolean),
+ },
+ 'bin': {
+ 'dovecotpw': LCO(str, '/usr/sbin/dovecotpw', self.get,
+ exec_ok),
+ 'du': LCO(str, '/usr/bin/du', self.get, exec_ok),
+ 'postconf': LCO(str, '/usr/sbin/postconf', self.get, exec_ok),
+ },
+ 'database': {
+ 'host': LCO(str, 'localhost', self.get),
+ 'module': LCO(str, 'psycopg2', self.get, check_db_module),
+ 'name': LCO(str, 'mailsys', self.get),
+ 'pass': LCO(str, None, self.get),
+ 'port': LCO(int, 5432, self.getint),
+ 'sslmode': LCO(str, 'prefer', self.get, check_db_ssl_mode),
+ 'user': LCO(str, None, self.get),
+ },
+ 'domain': {
+ 'auto_postmaster': LCO(bool_t, True, self.getboolean),
+ 'delete_directory': LCO(bool_t, False, self.getboolean),
+ 'directory_mode': LCO(int, 504, self.getint),
+ 'force_deletion': LCO(bool_t, False, self.getboolean),
+ },
+ 'mailbox': {
+ 'folders': LCO(str, 'Drafts:Sent:Templates:Trash',
+ self.unicode),
+ 'format': LCO(str, 'maildir', self.get, check_mailbox_format),
+ 'root': LCO(str, 'Maildir', self.unicode),
+ 'subscribe': LCO(bool_t, True, self.getboolean),
+ },
+ 'misc': {
+ 'base_directory': LCO(str, '/srv/mail', self.get, is_dir),
+ 'crypt_blowfish_rounds': LCO(int, 5, self.getint),
+ 'crypt_sha256_rounds': LCO(int, 5000, self.getint),
+ 'crypt_sha512_rounds': LCO(int, 5000, self.getint),
+ 'dovecot_version': LCO(str, None, self.hexversion,
+ check_version_format),
+ 'password_scheme': LCO(str, 'CRAM-MD5', self.get,
+ verify_scheme),
+ 'transport': LCO(str, 'dovecot:', self.get),
+ },
+ }
+
+ def load(self):
+ """Loads the configuration, read only.
+
+ Raises a ConfigError if the configuration syntax is
+ invalid.
+ """
+ try:
+ self._cfg_file = open(self._cfg_filename, 'r')
+ self.readfp(self._cfg_file)
+ except (MissingSectionHeaderError, ParsingError), err:
+ raise ConfigError(str(err), CONF_ERROR)
+ finally:
+ if self._cfg_file and not self._cfg_file.closed:
+ self._cfg_file.close()
+
+ def check(self):
+ """Performs a configuration check.
+
+ Raises a ConfigError if settings w/o a default value are missed.
+ Or some settings have a invalid value.
+ """
+ def iter_dict():
+ for section, options in self._missing.iteritems():
+ errmsg.write(_(u'* Section: %s\n') % section)
+ errmsg.writelines(u' %s\n' % option for option in options)
+ self._missing.clear()
+
+ errmsg = None
+ self._chk_non_default()
+ miss_vers = 'misc' in self._missing and \
+ 'dovecot_version' in self._missing['misc']
+ if self._missing:
+ errmsg = StringIO()
+ errmsg.write(_(u'Check of configuration file %s failed.\n') %
+ self._cfg_filename)
+ errmsg.write(_(u'Missing options, which have no default value.\n'))
+ iter_dict()
+ self._chk_possible_values(miss_vers)
+ if self._missing:
+ if not errmsg:
+ errmsg = StringIO()
+ errmsg.write(_(u'Check of configuration file %s failed.\n') %
+ self._cfg_filename)
+ errmsg.write(_(u'Invalid configuration values.\n'))
+ else:
+ errmsg.write('\n' + _(u'Invalid configuration values.\n'))
+ iter_dict()
+ if errmsg:
+ raise ConfigError(errmsg.getvalue(), CONF_ERROR)
+
+ def hexversion(self, section, option):
+ """Converts the version number (e.g.: 1.2.3) from the *option*'s
+ value to an int."""
+ return version_hex(self.get(section, option))
+
+ def unicode(self, section, option):
+ """Returns the value of the `option` from `section`, converted
+ to Unicode."""
+ return get_unicode(self.get(section, option))
+
+ def _chk_non_default(self):
+ """Checks all section's options for settings w/o a default
+ value. Missing items will be stored in _missing.
+ """
+ for section in self._cfg.iterkeys():
+ missing = []
+ for option, value in self._cfg[section].iteritems():
+ if (value.default is None and
+ not RawConfigParser.has_option(self, section, option)):
+ missing.append(option)
+ if missing:
+ self._missing[section] = missing
+
+ def _chk_possible_values(self, miss_vers):
+ """Check settings for which the possible values are known."""
+ if not miss_vers:
+ value = self.get('misc', 'dovecot_version')
+ if not VERSION_RE.match(value):
+ self._missing['misc'] = ['version: ' +\
+ _(u"Not a valid Dovecot version: '%s'") % value]
+ # section database
+ db_err = []
+ value = self.dget('database.module').lower()
+ if value not in DB_MUDULES:
+ db_err.append('module: ' + \
+ _(u"Unsupported database module: '%s'") % value)
+ if value == 'psycopg2':
+ value = self.dget('database.sslmode')
+ if value not in DB_SSL_MODES:
+ db_err.append('sslmode: ' + \
+ _(u"Unknown pgsql SSL mode: '%s'") % value)
+ if db_err:
+ self._missing['database'] = db_err
+ # section mailbox
+ value = self.dget('mailbox.format')
+ if not known_format(value):
+ self._missing['mailbox'] = ['format: ' +\
+ _(u"Unsupported mailbox format: '%s'") % value]
+
+
+def is_dir(path):
+ """Check if the expanded path is a directory. When the expanded path
+ is a directory the expanded path will be returned. Otherwise a
+ ConfigValueError will be raised.
+ """
+ path = expand_path(path)
+ if lisdir(path):
+ return path
+ raise ConfigValueError(_(u"No such directory: %s") % get_unicode(path))
+
+
+def check_db_module(module):
+ """Check if the *module* is a supported pgsql module."""
+ if module.lower() in DB_MUDULES:
+ return module
+ raise ConfigValueError(_(u"Unsupported database module: '%s'") %
+ get_unicode(module))
+
+
+def check_db_ssl_mode(ssl_mode):
+ """Check if the *ssl_mode* is one of the SSL modes, known by pgsql."""
+ if ssl_mode in DB_SSL_MODES:
+ return ssl_mode
+ raise ConfigValueError(_(u"Unknown pgsql SSL mode: '%s'") %
+ get_unicode(ssl_mode))
+
+
+def check_mailbox_format(format):
+ """
+ Check if the mailbox format *format* is supported. When the *format*
+ is supported it will be returned, otherwise a `ConfigValueError` will
+ be raised.
+ """
+ format = format.lower()
+ if known_format(format):
+ return format
+ raise ConfigValueError(_(u"Unsupported mailbox format: '%s'") %
+ get_unicode(format))
+
+
+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.
+ """
+ if not VERSION_RE.match(version_string):
+ raise ConfigValueError(_(u"Not a valid Dovecot version: '%s'") %
+ get_unicode(version_string))
+ return version_string
+
+
+def verify_scheme(scheme):
+ """Checks if the password scheme *scheme* can be accepted and returns
+ the verified scheme.
+ """
+ try:
+ scheme, encoding = _verify_scheme(scheme)
+ except VMMError, err: # 'cast' it
+ raise ConfigValueError(err.msg)
+ if not encoding:
+ return scheme
+ return '%s.%s' % (scheme, encoding)
+
+del _
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/VirtualMailManager/constants.py Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,92 @@
+# -*- coding: UTF-8 -*-
+# Copyright (c) 2007 - 2010, Pascal Volk
+# See COPYING for distribution information.
+"""
+ VirtualMailManager.constants
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ VirtualMailManager's constants:
+ * version information
+ * upper and lower limits MIN_* / MAX_*
+ * exit codes
+ * error codes
+"""
+# version information
+
+__all__ = ['__author__', '__date__', '__version__']
+AUTHOR = 'Pascal Volk <neverseen@users.sourceforge.net>'
+RELDATE = '2009-09-09'
+VERSION = '0.5.2'
+__author__ = AUTHOR
+__copyright__ = 'Copyright (c) 2007-2010 %s' % __author__
+__date__ = RELDATE
+__version__ = VERSION
+
+
+# limits
+
+MIN_GID = 70000
+MIN_UID = 70000
+
+
+# exit codes
+
+EX_SUCCESS = 0
+EX_MISSING_ARGS = 1
+EX_UNKNOWN_COMMAND = 2
+EX_USER_INTERRUPT = 3
+
+
+# error codes
+
+ACCOUNT_AND_ALIAS_PRESENT = 20
+ACCOUNT_EXISTS = 21
+ACCOUNT_MISSING_PASSWORD = 69
+ACCOUNT_PRESENT = 22
+ALIASDOMAIN_EXISTS = 23
+ALIASDOMAIN_ISDOMAIN = 24
+ALIASDOMAIN_NO_DOMDEST = 25
+ALIAS_ADDR_DEST_IDENTICAL = 26
+ALIAS_EXCEEDS_EXPANSION_LIMIT = 27
+ALIAS_EXISTS = 28
+ALIAS_MISSING_DEST = 29
+ALIAS_PRESENT = 30
+CONF_ERROR = 31
+CONF_NOFILE = 32
+CONF_NOPERM = 33
+CONF_WRONGPERM = 34
+DATABASE_ERROR = 35
+DOMAINDIR_GROUP_MISMATCH = 36
+DOMAIN_ALIAS_EXISTS = 37
+DOMAIN_EXISTS = 38
+DOMAIN_INVALID = 39
+DOMAIN_NO_NAME = 40
+DOMAIN_TOO_LONG = 41
+FOUND_DOTS_IN_PATH = 42
+INVALID_ADDRESS = 43
+INVALID_ARGUMENT = 44
+INVALID_MAIL_LOCATION = 70
+INVALID_OPTION = 45
+INVALID_SECTION = 46
+LOCALPART_INVALID = 47
+LOCALPART_TOO_LONG = 48
+MAILDIR_PERM_MISMATCH = 49
+MAILLOCATION_INIT = 50
+NOT_EXECUTABLE = 51
+NO_SUCH_ACCOUNT = 52
+NO_SUCH_ALIAS = 53
+NO_SUCH_ALIASDOMAIN = 54
+NO_SUCH_BINARY = 55
+NO_SUCH_DIRECTORY = 56
+NO_SUCH_DOMAIN = 57
+NO_SUCH_RELOCATED = 58
+RELOCATED_ADDR_DEST_IDENTICAL = 59
+RELOCATED_EXISTS = 60
+RELOCATED_MISSING_DEST = 61
+TRANSPORT_INIT = 62
+UNKNOWN_MAILLOCATION_ID = 63
+UNKNOWN_MAILLOCATION_NAME = 64
+UNKNOWN_SERVICE = 65
+UNKNOWN_TRANSPORT_ID = 66
+VMM_ERROR = 67
+VMM_TOO_MANY_FAILURES = 68
--- a/VirtualMailManager/constants/ERROR.py Thu Jan 13 12:48:30 2011 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-# -*- coding: UTF-8 -*-
-# Copyright (c) 2007 - 2010, Pascal Volk
-# See COPYING for distribution information.
-
-ACCOUNT_AND_ALIAS_PRESENT = 20
-ACCOUNT_EXISTS = 21
-ACCOUNT_PRESENT = 22
-ALIASDOMAIN_EXISTS = 23
-ALIASDOMAIN_ISDOMAIN = 24
-ALIASDOMAIN_NO_DOMDEST = 25
-ALIAS_ADDR_DEST_IDENTICAL = 26
-ALIAS_EXCEEDS_EXPANSION_LIMIT = 27
-ALIAS_EXISTS = 28
-ALIAS_MISSING_DEST = 29
-ALIAS_PRESENT = 30
-CONF_ERROR = 31
-CONF_NOFILE = 32
-CONF_NOPERM = 33
-CONF_WRONGPERM = 34
-DATABASE_ERROR = 35
-DOMAINDIR_GROUP_MISMATCH = 36
-DOMAIN_ALIAS_EXISTS = 37
-DOMAIN_EXISTS = 38
-DOMAIN_INVALID = 39
-DOMAIN_NO_NAME = 40
-DOMAIN_TOO_LONG = 41
-FOUND_DOTS_IN_PATH = 42
-INVALID_ADDRESS = 43
-INVALID_AGUMENT = 44
-INVALID_OPTION = 45
-INVALID_SECTION = 46
-LOCALPART_INVALID = 47
-LOCALPART_TOO_LONG = 48
-MAILDIR_PERM_MISMATCH = 49
-MAILLOCATION_INIT = 50
-NOT_EXECUTABLE = 51
-NO_SUCH_ACCOUNT = 52
-NO_SUCH_ALIAS = 53
-NO_SUCH_ALIASDOMAIN = 54
-NO_SUCH_BINARY = 55
-NO_SUCH_DIRECTORY = 56
-NO_SUCH_DOMAIN = 57
-NO_SUCH_RELOCATED = 58
-RELOCATED_ADDR_DEST_IDENTICAL = 59
-RELOCATED_EXISTS = 60
-RELOCATED_MISSING_DEST = 61
-TRANSPORT_INIT = 62
-UNKNOWN_MAILLOCATION_ID = 63
-UNKNOWN_SERVICE = 64
-UNKNOWN_TRANSPORT_ID = 65
-VMM_ERROR = 66
-VMM_TOO_MANY_FAILURES = 67
--- a/VirtualMailManager/constants/EXIT.py Thu Jan 13 12:48:30 2011 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-# -*- coding: UTF-8 -*-
-# Copyright (c) 2007 - 2010, Pascal Volk
-# See COPYING for distribution information.
-
-MISSING_ARGS = 1
-UNKNOWN_COMMAND = 2
-USER_INTERRUPT = 3
--- a/VirtualMailManager/constants/VERSION.py Thu Jan 13 12:48:30 2011 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-# -*- coding: UTF-8 -*-
-# Copyright (c) 2007 - 2010, Pascal Volk
-# See COPYING for distribution information.
-
-AUTHOR = 'Pascal Volk <neverseen@users.sourceforge.net>'
-RELDATE = '2009-09-09'
-VERSION = '0.5.2'
-__author__ = AUTHOR
-__date__ = RELDATE
-__version__ = VERSION
-__all__ = ['__author__', '__date__', '__version__']
--- a/VirtualMailManager/constants/__init__.py Thu Jan 13 12:48:30 2011 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-# -*- coding: UTF-8 -*-
-# Copyright (c) 2007 - 2010, Pascal Volk
-# See COPYING for distribution information.
-# package placeholder
-#
-# EOF
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/VirtualMailManager/domain.py Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,394 @@
+# -*- coding: UTF-8 -*-
+# Copyright (c) 2007 - 2010, Pascal Volk
+# See COPYING for distribution information.
+"""
+ VirtualMailManager.domain
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ Virtual Mail Manager's Domain class to manage e-mail domains.
+"""
+
+import os
+import re
+from random import choice
+
+from VirtualMailManager.constants import \
+ ACCOUNT_AND_ALIAS_PRESENT, DOMAIN_ALIAS_EXISTS, DOMAIN_EXISTS, \
+ DOMAIN_INVALID, DOMAIN_TOO_LONG, NO_SUCH_DOMAIN
+from VirtualMailManager.errors import DomainError as DomErr
+from VirtualMailManager.pycompat import any
+from VirtualMailManager.transport import Transport
+
+
+MAILDIR_CHARS = '0123456789abcdefghijklmnopqrstuvwxyz'
+RE_DOMAIN = re.compile(r"^(?:[a-z0-9-]{1,63}\.){1,}[a-z]{2,6}$")
+_ = lambda msg: msg
+
+
+class Domain(object):
+ """Class to manage e-mail domains."""
+ __slots__ = ('_directory', '_gid', '_name', '_transport', '_dbh', '_new')
+
+ def __init__(self, dbh, domainname):
+ """Creates a new Domain instance.
+
+ Loads all relevant data from the database, if the domain could be
+ found. To create a new domain call the methods set_directory() and
+ set_transport() before save().
+
+ A DomainError will be thrown when the *domainname* is the name of
+ an alias domain.
+
+ Arguments:
+
+ `dbh` : pyPgSQL.PgSQL.Connection
+ a database connection for the database access
+ `domainname` : basestring
+ The name of the domain
+ """
+ self._name = check_domainname(domainname)
+ self._dbh = dbh
+ self._gid = 0
+ self._transport = None
+ self._directory = None
+ self._new = True
+ self._load()
+
+ def _load(self):
+ """Load information from the database and checks if the domain name
+ is the primary one.
+
+ Raises a DomainError if Domain._name isn't the primary name of the
+ domain.
+ """
+ dbc = self._dbh.cursor()
+ dbc.execute('SELECT dd.gid, tid, domaindir, is_primary FROM '
+ 'domain_data dd, domain_name dn WHERE domainname = %s AND '
+ 'dn.gid = dd.gid', (self._name,))
+ result = dbc.fetchone()
+ dbc.close()
+ if result:
+ if not result[3]:
+ raise DomErr(_(u"The domain '%s' is an alias domain.") %
+ self._name, DOMAIN_ALIAS_EXISTS)
+ self._gid, self._directory = result[0], result[2]
+ self._transport = Transport(self._dbh, tid=result[1])
+ self._new = False
+
+ def _set_gid(self):
+ """Sets the ID of the domain - if not set yet."""
+ assert self._gid == 0
+ dbc = self._dbh.cursor()
+ dbc.execute("SELECT nextval('domain_gid')")
+ self._gid = dbc.fetchone()[0]
+ dbc.close()
+
+ def _check_for_addresses(self):
+ """Checks dependencies for deletion. Raises a DomainError if there
+ are accounts, aliases and/or relocated users.
+ """
+ dbc = self._dbh.cursor()
+ dbc.execute('SELECT count(gid) FROM users WHERE gid = %(gid)u '
+ 'UNION SELECT count(gid) FROM alias WHERE gid = %(gid)u '
+ 'UNION SELECT count(gid) FROM relocated WHERE gid = '
+ '%(gid)u' % {'gid': self._gid})
+ result = dbc.fetchall()
+ dbc.close()
+ result = [count[0] for count in result]
+ if any(result):
+ keys = ('account_count', 'alias_count', 'relocated_count')
+ raise DomErr(_(u'There are %(account_count)u accounts, '
+ u'%(alias_count)u aliases and %(relocated_count)u '
+ u'relocated users.') % dict(zip(keys, result)),
+ ACCOUNT_AND_ALIAS_PRESENT)
+
+ def _chk_state(self):
+ """Throws a DomainError if the Domain is new - not saved in the
+ database."""
+ if self._new:
+ raise DomErr(_(u"The domain '%s' doesn't exist.") % self._name,
+ NO_SUCH_DOMAIN)
+
+ @property
+ def gid(self):
+ """The GID of the Domain."""
+ return self._gid
+
+ @property
+ def name(self):
+ """The Domain's name."""
+ return self._name
+
+ @property
+ def directory(self):
+ """The Domain's directory."""
+ return self._directory
+
+ def set_directory(self, basedir):
+ """Set the path value of the Domain's directory, inside *basedir*.
+
+ Argument:
+
+ `basedir` : basestring
+ The base directory of all domains
+ """
+ if not self._new:
+ raise DomErr(_(u"The domain '%s' already exists.") % self._name,
+ DOMAIN_EXISTS)
+ assert self._directory is None
+ self._set_gid()
+ self._directory = os.path.join(basedir, choice(MAILDIR_CHARS),
+ str(self._gid))
+
+ @property
+ def transport(self):
+ """The Domain's transport."""
+ return self._transport
+
+ def set_transport(self, transport):
+ """Set the transport for the new Domain.
+
+ Argument:
+
+ `transport` : VirtualMailManager.Transport
+ The transport of the new Domain
+ """
+ if not self._new:
+ raise DomErr(_(u"The domain '%s' already exists.") % self._name,
+ DOMAIN_EXISTS)
+ assert isinstance(transport, Transport)
+ self._transport = transport
+
+ def save(self):
+ """Stores the new domain in the database."""
+ if not self._new:
+ raise DomErr(_(u"The domain '%s' already exists.") % self._name,
+ DOMAIN_EXISTS)
+ assert self._directory is not None and self._transport is not None
+ dbc = self._dbh.cursor()
+ dbc.execute("INSERT INTO domain_data VALUES (%s, %s, %s)", (self._gid,
+ self._transport.tid, self._directory))
+ dbc.execute("INSERT INTO domain_name VALUES (%s, %s, %s)", (self._name,
+ self._gid, True))
+ self._dbh.commit()
+ dbc.close()
+ self._new = False
+
+ def delete(self, force=False):
+ """Deletes the domain.
+
+ Arguments:
+
+ `force` : bool
+ force the deletion of all available accounts, aliases and
+ relocated users. When *force* is `False` and there are accounts,
+ aliases and/or relocated users a DomainError will be raised.
+ Default `False`
+ """
+ if not isinstance(force, bool):
+ raise TypeError('force must be a bool')
+ self._chk_state()
+ if not force:
+ self._check_for_addresses()
+ dbc = self._dbh.cursor()
+ for tbl in ('alias', 'users', 'relocated', 'domain_name',
+ 'domain_data'):
+ dbc.execute("DELETE FROM %s WHERE gid = %u" % (tbl, self._gid))
+ self._dbh.commit()
+ dbc.close()
+ self._gid = 0
+ self._directory = self._transport = None
+ self._new = True
+
+ def update_transport(self, transport, force=False):
+ """Sets a new transport for the Domain.
+
+ If *force* is `True` the new *transport* will be assigned to all
+ existing accounts. Otherwise the *transport* will be only used for
+ accounts created from now on.
+
+ Arguments:
+
+ `transport` : VirtualMailManager.Transport
+ the new transport
+ `force` : bool
+ enforce new transport setting for all accounts, default `False`
+ """
+ self._chk_state()
+ assert isinstance(transport, Transport)
+ if transport == self._transport:
+ return
+ dbc = self._dbh.cursor()
+ dbc.execute("UPDATE domain_data SET tid = %s WHERE gid = %s",
+ (transport.tid, self._gid))
+ if dbc.rowcount > 0:
+ self._dbh.commit()
+ if force:
+ dbc.execute("UPDATE users SET tid = %s WHERE gid = %s",
+ (transport.tid, self._gid))
+ if dbc.rowcount > 0:
+ self._dbh.commit()
+ dbc.close()
+ self._transport = transport
+
+ def get_info(self):
+ """Returns a dictionary with information about the domain."""
+ self._chk_state()
+ dbc = self._dbh.cursor()
+ dbc.execute('SELECT gid, domainname, transport, domaindir, '
+ 'aliasdomains, accounts, aliases, relocated FROM '
+ 'vmm_domain_info WHERE gid = %s', (self._gid,))
+ info = dbc.fetchone()
+ dbc.close()
+ keys = ('gid', 'domainname', 'transport', 'domaindir', 'aliasdomains',
+ 'accounts', 'aliases', 'relocated')
+ return dict(zip(keys, info))
+
+ def get_accounts(self):
+ """Returns a list with all accounts of the domain."""
+ self._chk_state()
+ dbc = self._dbh.cursor()
+ dbc.execute('SELECT local_part from users where gid = %s ORDER BY '
+ 'local_part', (self._gid,))
+ users = dbc.fetchall()
+ dbc.close()
+ accounts = []
+ if users:
+ addr = u'@'.join
+ _dom = self._name
+ accounts = [addr((account[0], _dom)) for account in users]
+ return accounts
+
+ def get_aliases(self):
+ """Returns a list with all aliases e-mail addresses of the domain."""
+ self._chk_state()
+ dbc = self._dbh.cursor()
+ dbc.execute('SELECT DISTINCT address FROM alias WHERE gid = %s ORDER '
+ 'BY address', (self._gid,))
+ addresses = dbc.fetchall()
+ dbc.close()
+ aliases = []
+ if addresses:
+ addr = u'@'.join
+ _dom = self._name
+ aliases = [addr((alias[0], _dom)) for alias in addresses]
+ return aliases
+
+ def get_relocated(self):
+ """Returns a list with all addresses of relocated users."""
+ self._chk_state()
+ dbc = self._dbh.cursor()
+ dbc.execute('SELECT address FROM relocated WHERE gid = %s ORDER BY '
+ 'address', (self._gid,))
+ addresses = dbc.fetchall()
+ dbc.close()
+ relocated = []
+ if addresses:
+ addr = u'@'.join
+ _dom = self._name
+ relocated = [addr((address[0], _dom)) for address in addresses]
+ return relocated
+
+ def get_aliase_names(self):
+ """Returns a list with all alias domain names of the domain."""
+ self._chk_state()
+ dbc = self._dbh.cursor()
+ dbc.execute('SELECT domainname FROM domain_name WHERE gid = %s AND '
+ 'NOT is_primary ORDER BY domainname', (self._gid,))
+ anames = dbc.fetchall()
+ dbc.close()
+ aliasdomains = []
+ if anames:
+ aliasdomains = [aname[0] for aname in anames]
+ return aliasdomains
+
+
+def check_domainname(domainname):
+ """Returns the validated domain name `domainname`.
+
+ Throws an `DomainError`, if the domain name is too long or doesn't
+ look like a valid domain name (label.label.label).
+
+ """
+ if not RE_DOMAIN.match(domainname):
+ domainname = domainname.encode('idna')
+ if len(domainname) > 255:
+ raise DomErr(_(u'The domain name is too long'), DOMAIN_TOO_LONG)
+ if not RE_DOMAIN.match(domainname):
+ raise DomErr(_(u"The domain name '%s' is invalid") % domainname,
+ DOMAIN_INVALID)
+ return domainname
+
+
+def get_gid(dbh, domainname):
+ """Returns the group id of the domain *domainname*.
+
+ If the domain couldn't be found in the database 0 will be returned.
+ """
+ domainname = check_domainname(domainname)
+ dbc = dbh.cursor()
+ dbc.execute('SELECT gid FROM domain_name WHERE domainname = %s',
+ (domainname,))
+ gid = dbc.fetchone()
+ dbc.close()
+ if gid:
+ return gid[0]
+ return 0
+
+
+def search(dbh, pattern=None, like=False):
+ """'Search' for domains by *pattern* in the database.
+
+ *pattern* may be a domain name or a partial domain name - starting
+ and/or ending with a '%' sign. When the *pattern* starts or ends with
+ a '%' sign *like* has to be `True` to perform a wildcard search.
+ To retrieve all available domains use the arguments' default values.
+
+ This function returns a tuple with a list and a dict: (order, domains).
+ The order list contains the domains' gid, alphabetical sorted by the
+ primary domain name. The domains dict's keys are the gids of the
+ domains. The value of item is a list. The first list element contains
+ the primary domain name or `None`. The elements [1:] contains the
+ names of alias domains.
+
+ Arguments:
+
+ `pattern` : basestring
+ a (partial) domain name (starting and/or ending with a "%" sign)
+ `like` : bool
+ should be `True` when *pattern* starts/ends with a "%" sign
+ """
+ if pattern and not like:
+ pattern = check_domainname(pattern)
+ sql = 'SELECT gid, domainname, is_primary FROM domain_name'
+ if pattern:
+ if like:
+ sql += " WHERE domainname LIKE '%s'" % pattern
+ else:
+ sql += " WHERE domainname = '%s'" % pattern
+ sql += ' ORDER BY is_primary DESC, domainname'
+ dbc = dbh.cursor()
+ dbc.execute(sql)
+ result = dbc.fetchall()
+ dbc.close()
+
+ gids = [domain[0] for domain in result if domain[2]]
+ domains = {}
+ for gid, domain, is_primary in result:
+ if is_primary:
+ if not gid in domains:
+ domains[gid] = [domain]
+ else:
+ domains[gid].insert(0, domain)
+ else:
+ if gid in gids:
+ if gid in domains:
+ domains[gid].append(domain)
+ else:
+ domains[gid] = [domain]
+ else:
+ gids.append(gid)
+ domains[gid] = [None, domain]
+ return gids, domains
+
+del _
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/VirtualMailManager/emailaddress.py Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,103 @@
+# -*- coding: UTF-8 -*-
+# Copyright (c) 2008 - 2010, Pascal Volk
+# See COPYING for distribution information.
+"""
+ VirtualMailManager.emailaddress
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ Virtual Mail Manager's EmailAddress class to handle e-mail addresses.
+"""
+import re
+
+from VirtualMailManager.domain import check_domainname
+from VirtualMailManager.constants import \
+ DOMAIN_NO_NAME, INVALID_ADDRESS, LOCALPART_INVALID, LOCALPART_TOO_LONG
+from VirtualMailManager.errors import EmailAddressError as EAErr
+
+
+RE_LOCALPART = re.compile(r"[^\w!#$%&'\*\+-\.\/=?^_`{\|}~]")
+_ = lambda msg: msg
+
+
+class EmailAddress(object):
+ """Simple class for validated e-mail addresses."""
+ __slots__ = ('_localpart', '_domainname')
+
+ def __init__(self, address):
+ """Creates a new instance from the string/unicode ``address``."""
+ assert isinstance(address, basestring)
+ self._localpart = None
+ self._domainname = None
+ self._chk_address(address)
+
+ @property
+ def localpart(self):
+ """The local-part of the address *local-part@domain*"""
+ return self._localpart
+
+ @property
+ def domainname(self):
+ """The domain part of the address *local-part@domain*"""
+ return self._domainname
+
+ def __eq__(self, other):
+ if isinstance(other, self.__class__):
+ return self._localpart == other._localpart and \
+ self._domainname == other._domainname
+ return NotImplemented
+
+ def __ne__(self, other):
+ if isinstance(other, self.__class__):
+ return self._localpart != other._localpart or \
+ self._domainname != other._domainname
+ return NotImplemented
+
+ def __hash__(self):
+ return hash((self._localpart.lower(), self._domainname.lower()))
+
+ def __repr__(self):
+ return "EmailAddress('%s@%s')" % (self._localpart, self._domainname)
+
+ def __str__(self):
+ return '%s@%s' % (self._localpart, self._domainname)
+
+ def _chk_address(self, address):
+ """Checks if the string ``address`` could be used for an e-mail
+ address. If so, it will assign the corresponding values to the
+ attributes `_localpart` and `_domainname`."""
+ parts = address.split('@')
+ p_len = len(parts)
+ if p_len < 2:
+ raise EAErr(_(u"Missing the '@' sign in address '%s'") % address,
+ INVALID_ADDRESS)
+ elif p_len > 2:
+ raise EAErr(_(u"Too many '@' signs in address '%s'") % address,
+ INVALID_ADDRESS)
+ if not parts[0]:
+ raise EAErr(_(u"Missing local-part in address '%s'") % address,
+ LOCALPART_INVALID)
+ if not parts[1]:
+ raise EAErr(_(u"Missing domain name in address '%s'") % address,
+ DOMAIN_NO_NAME)
+ self._localpart = check_localpart(parts[0])
+ self._domainname = check_domainname(parts[1])
+
+
+def check_localpart(localpart):
+ """Returns the validated local-part `localpart`.
+
+ Throws a `EmailAddressError` if the local-part is too long or contains
+ invalid characters.
+ """
+ if len(localpart) > 64:
+ raise EAErr(_(u"The local-part '%s' is too long") % localpart,
+ LOCALPART_TOO_LONG)
+ invalid_chars = set(RE_LOCALPART.findall(localpart))
+ if invalid_chars:
+ i_chars = u''.join((u'"%s" ' % c for c in invalid_chars))
+ raise EAErr(_(u"The local-part '%(l_part)s' contains invalid "
+ u"characters: %(i_chars)s") % {'l_part': localpart,
+ 'i_chars': i_chars}, LOCALPART_INVALID)
+ return localpart
+
+del _
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/VirtualMailManager/errors.py Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,76 @@
+# -*- coding: UTF-8 -*-
+# Copyright (c) 2007 - 2010, Pascal Volk
+# See COPYING for distribution information.
+"""
+ VirtualMailManager.errors
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ VMM's Exception classes
+"""
+
+
+class VMMError(Exception):
+ """Exception base class for VirtualMailManager exceptions"""
+
+ def __init__(self, msg, code):
+ Exception.__init__(self, msg)
+ self.msg = msg
+ self.code = int(code)
+
+ def __repr__(self):
+ return '%s(%r, %r)' % (self.__class__.__name__, self.msg, self.code)
+
+
+class ConfigError(VMMError):
+ """Exception class for configuration exceptions"""
+ pass
+
+
+class PermissionError(VMMError):
+ """Exception class for permissions exceptions"""
+ pass
+
+
+class NotRootError(VMMError):
+ """Exception class for non-root exceptions"""
+ pass
+
+
+class DomainError(VMMError):
+ """Exception class for Domain exceptions"""
+ pass
+
+
+class AliasDomainError(VMMError):
+ """Exception class for AliasDomain exceptions"""
+ pass
+
+
+class AccountError(VMMError):
+ """Exception class for Account exceptions"""
+ pass
+
+
+class AliasError(VMMError):
+ """Exception class for Alias exceptions"""
+ pass
+
+
+class EmailAddressError(VMMError):
+ """Exception class for EmailAddress exceptions"""
+ pass
+
+
+class MailLocationError(VMMError):
+ """Exception class for MailLocation exceptions"""
+ pass
+
+
+class RelocatedError(VMMError):
+ """Exception class for Relocated exceptions"""
+ pass
+
+
+class TransportError(VMMError):
+ """Exception class for Transport exceptions"""
+ pass
--- a/VirtualMailManager/ext/Postconf.py Thu Jan 13 12:48:30 2011 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,83 +0,0 @@
-# -*- coding: UTF-8 -*-
-# Copyright (c) 2008 - 2010, Pascal Volk
-# See COPYING for distribution information.
-
-"""A small - r/o - wrapper class for Postfix' postconf."""
-
-from subprocess import Popen, PIPE
-
-from __main__ import re, ERR
-from VirtualMailManager.Exceptions import VMMException
-
-RE_PC_PARAMS = """^\w+$"""
-RE_PC_VARIABLES = r"""\$\b\w+\b"""
-
-class Postconf(object):
- __slots__ = ('__bin', '__val', '__varFinder')
- def __init__(self, postconf_bin):
- """Creates a new Postconf instance.
-
- Keyword arguments:
- postconf_bin -- absolute path to the Postfix postconf binary (str)
- """
- self.__bin = postconf_bin
- self.__val = ''
- self.__varFinder = re.compile(RE_PC_VARIABLES)
-
- def read(self, parameter, expand_vars=True):
- """Returns the parameters value.
-
- If expand_vars is True (default), all variables in the value will be
- expanded:
- e.g. mydestination -> mail.example.com, localhost.example.com, localhost
- Otherwise the value may contain one or more variables.
- e.g. mydestination -> $myhostname, localhost.$mydomain, localhost
-
- Keyword arguments:
- parameter -- the name of a Postfix configuration parameter (str)
- expand_vars -- default True (bool)
- """
- if not re.match(RE_PC_PARAMS, parameter):
- raise VMMException(_(u'The value “%s” doesn\'t look like a valid\
- postfix configuration parameter name.') % parameter, ERR.VMM_ERROR)
- self.__val = self.__read(parameter)
- if expand_vars:
- self.__expandVars()
- return self.__val
-
- def __expandVars(self):
- while True:
- pvars = set(self.__varFinder.findall(self.__val))
- pvars_len = len(pvars)
- if pvars_len < 1:
- break
- if pvars_len > 1:
- self.__expandMultiVars(self.__readMulti(pvars))
- continue
- pvars = pvars.pop()
- self.__val = self.__val.replace(pvars, self.__read(pvars[1:]))
-
- def __expandMultiVars(self, old_new):
- for old, new in old_new.items():
- self.__val = self.__val.replace('$'+old, new)
-
- def __read(self, parameter):
- out, err = Popen([self.__bin, '-h', parameter], stdout=PIPE,
- stderr=PIPE).communicate()
- if len(err):
- raise VMMException(err.strip(), ERR.VMM_ERROR)
- return out.strip()
-
- def __readMulti(self, parameters):
- cmd = [self.__bin]
- for parameter in parameters:
- cmd.append(parameter[1:])
- out, err = Popen(cmd, stdout=PIPE, stderr=PIPE).communicate()
- if len(err):
- raise VMMException(err.strip(), ERR.VMM_ERROR)
- par_val = {}
- for line in out.splitlines():
- par, val = line.split(' = ')
- par_val[par] = val
- return par_val
-
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/VirtualMailManager/ext/postconf.py Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,127 @@
+# -*- coding: UTF-8 -*-
+# Copyright (c) 2008 - 2010, Pascal Volk
+# See COPYING for distribution information.
+"""
+ VirtualMailManager.ext.postconf
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ Wrapper class for Postfix's postconf.
+ Postconf instances can be used to read actual values of configuration
+ parameters or edit the value of a configuration parameter.
+
+ postconf.read(parameter) -> value
+ postconf.edit(parameter, value)
+"""
+
+import re
+from subprocess import Popen, PIPE
+
+from VirtualMailManager.errors import VMMError
+from VirtualMailManager.constants import VMM_ERROR
+
+_ = lambda msg: msg
+
+
+class Postconf(object):
+ """Wrapper class for Postfix's postconf."""
+ __slots__ = ('_bin', '_val')
+ _parameter_re = re.compile(r'^\w+$')
+ _variables_re = re.compile(r'\$\b\w+\b')
+
+ def __init__(self, postconf_bin):
+ """Creates a new Postconf instance.
+
+ Argument:
+
+ `postconf_bin` : str
+ absolute path to the Postfix postconf binary.
+ """
+ self._bin = postconf_bin
+ self._val = ''
+
+ def edit(self, parameter, value):
+ """Set the `parameter`'s value to `value`.
+
+ Arguments:
+
+ `parameter` : str
+ the name of a Postfix configuration parameter
+ `value` : str
+ the parameter's new value.
+ """
+ self._check_parameter(parameter)
+ stdout, stderr = Popen((self._bin, '-e', parameter + '=' + str(value)),
+ stderr=PIPE).communicate()
+ if stderr:
+ raise VMMError(stderr.strip(), VMM_ERROR)
+
+ def read(self, parameter, expand_vars=True):
+ """Returns the parameters value.
+
+ If expand_vars is True (default), all variables in the value will be
+ expanded:
+ e.g. mydestination: mail.example.com, localhost.example.com, localhost
+ Otherwise the value may contain one or more variables.
+ e.g. mydestination: $myhostname, localhost.$mydomain, localhost
+
+ Arguments:
+
+ `parameter` : str
+ the name of a Postfix configuration parameter.
+ `expand_vars` : bool
+ indicates if variables should be expanded or not, default True
+ """
+ self._check_parameter(parameter)
+ self._val = self._read(parameter)
+ if expand_vars:
+ self._expand_vars()
+ return self._val
+
+ def _check_parameter(self, parameter):
+ """Check that the `parameter` looks like a configuration parameter.
+ If not, a VMMError will be raised."""
+ if not self.__class__._parameter_re.match(parameter):
+ raise VMMError(_(u"The value '%s' doesn't look like a valid "
+ u"postfix configuration parameter name.") %
+ parameter, VMM_ERROR)
+
+ def _expand_vars(self):
+ """Expand the $variables in self._val to their values."""
+ while True:
+ pvars = set(self.__class__._variables_re.findall(self._val))
+ if not pvars:
+ break
+ if len(pvars) > 1:
+ self._expand_multi_vars(self._read_multi(pvars))
+ continue
+ pvars = pvars.pop()
+ self._val = self._val.replace(pvars, self._read(pvars[1:]))
+
+ def _expand_multi_vars(self, old_new):
+ """Replace all $vars in self._val with their values."""
+ for old, new in old_new.iteritems():
+ self._val = self._val.replace('$' + old, new)
+
+ def _read(self, parameter):
+ """Ask postconf for the value of a single configuration parameter."""
+ stdout, stderr = Popen([self._bin, '-h', parameter], stdout=PIPE,
+ stderr=PIPE).communicate()
+ if stderr:
+ raise VMMError(stderr.strip(), VMM_ERROR)
+ return stdout.strip()
+
+ def _read_multi(self, parameters):
+ """Ask postconf for multiple configuration parameters. Returns a dict
+ parameter: value items."""
+ cmd = [self._bin]
+ cmd.extend(parameter[1:] for parameter in parameters)
+ stdout, stderr = Popen(cmd, stdout=PIPE, stderr=PIPE).communicate()
+ if stderr:
+ raise VMMError(stderr.strip(), VMM_ERROR)
+ par_val = {}
+ for line in stdout.splitlines():
+ par, val = line.split(' = ')
+ par_val[par] = val
+ return par_val
+
+del _
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/VirtualMailManager/handler.py Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,727 @@
+# -*- coding: UTF-8 -*-
+# Copyright (c) 2007 - 2010, Pascal Volk
+# See COPYING for distribution information.
+"""
+ VirtualMailManager.handler
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ A wrapper class. It wraps round all other classes and does some
+ dependencies checks.
+
+ Additionally it communicates with the PostgreSQL database, creates
+ or deletes directories of domains or users.
+"""
+
+import os
+import re
+
+from shutil import rmtree
+from subprocess import Popen, PIPE
+
+from VirtualMailManager.account import Account
+from VirtualMailManager.alias import Alias
+from VirtualMailManager.aliasdomain import AliasDomain
+from VirtualMailManager.common import exec_ok, lisdir
+from VirtualMailManager.config import Config as Cfg
+from VirtualMailManager.constants import MIN_GID, MIN_UID, \
+ ACCOUNT_EXISTS, ALIAS_EXISTS, CONF_NOFILE, CONF_NOPERM, CONF_WRONGPERM, \
+ DATABASE_ERROR, DOMAINDIR_GROUP_MISMATCH, DOMAIN_INVALID, \
+ FOUND_DOTS_IN_PATH, INVALID_ARGUMENT, MAILDIR_PERM_MISMATCH, \
+ NOT_EXECUTABLE, NO_SUCH_ACCOUNT, NO_SUCH_ALIAS, NO_SUCH_BINARY, \
+ NO_SUCH_DIRECTORY, NO_SUCH_RELOCATED, RELOCATED_EXISTS, VMM_ERROR
+from VirtualMailManager.domain import Domain, get_gid
+from VirtualMailManager.emailaddress import EmailAddress
+from VirtualMailManager.errors import \
+ DomainError, NotRootError, PermissionError, VMMError
+from VirtualMailManager.mailbox import new as new_mailbox
+from VirtualMailManager.pycompat import all, any
+from VirtualMailManager.relocated import Relocated
+from VirtualMailManager.transport import Transport
+
+
+_ = lambda msg: msg
+_db_mod = None
+
+CFG_FILE = 'vmm.cfg'
+CFG_PATH = '/root:/usr/local/etc:/etc'
+RE_DOMAIN_SEARCH = """^[a-z0-9-\.]+$"""
+TYPE_ACCOUNT = 0x1
+TYPE_ALIAS = 0x2
+TYPE_RELOCATED = 0x4
+OTHER_TYPES = {
+ TYPE_ACCOUNT: (_(u'an account'), ACCOUNT_EXISTS),
+ TYPE_ALIAS: (_(u'an alias'), ALIAS_EXISTS),
+ TYPE_RELOCATED: (_(u'a relocated user'), RELOCATED_EXISTS),
+}
+
+
+class Handler(object):
+ """Wrapper class to simplify the access on all the stuff from
+ VirtualMailManager"""
+ __slots__ = ('_cfg', '_cfg_fname', '_db_connect', '_dbh', '_warnings')
+
+ def __init__(self, skip_some_checks=False):
+ """Creates a new Handler instance.
+
+ ``skip_some_checks`` : bool
+ When a derived class knows how to handle all checks this
+ argument may be ``True``. By default it is ``False`` and
+ all checks will be performed.
+
+ Throws a NotRootError if your uid is greater 0.
+ """
+ self._cfg_fname = ''
+ self._warnings = []
+ self._cfg = None
+ self._dbh = None
+ self._db_connect = None
+
+ if os.geteuid():
+ raise NotRootError(_(u"You are not root.\n\tGood bye!\n"),
+ CONF_NOPERM)
+ if self._check_cfg_file():
+ self._cfg = Cfg(self._cfg_fname)
+ self._cfg.load()
+ if not skip_some_checks:
+ self._cfg.check()
+ self._chkenv()
+ self._set_db_connect()
+
+ def _find_cfg_file(self):
+ """Search the CFG_FILE in CFG_PATH.
+ Raise a VMMError when no vmm.cfg could be found.
+ """
+ for path in CFG_PATH.split(':'):
+ tmp = os.path.join(path, CFG_FILE)
+ if os.path.isfile(tmp):
+ self._cfg_fname = tmp
+ break
+ if not self._cfg_fname:
+ raise VMMError(_(u"Could not find '%(cfg_file)s' in: "
+ u"'%(cfg_path)s'") % {'cfg_file': CFG_FILE,
+ 'cfg_path': CFG_PATH}, CONF_NOFILE)
+
+ def _check_cfg_file(self):
+ """Checks the configuration file, returns bool"""
+ self._find_cfg_file()
+ fstat = os.stat(self._cfg_fname)
+ fmode = int(oct(fstat.st_mode & 0777))
+ if fmode % 100 and fstat.st_uid != fstat.st_gid or \
+ fmode % 10 and fstat.st_uid == fstat.st_gid:
+ raise PermissionError(_(u"wrong permissions for '%(file)s': "
+ u"%(perms)s\n`chmod 0600 %(file)s` would "
+ u"be great.") % {'file': self._cfg_fname,
+ 'perms': fmode}, CONF_WRONGPERM)
+ else:
+ return True
+
+ def _chkenv(self):
+ """Make sure our base_directory is a directory and that all
+ required executables exists and are executable.
+ If not, a VMMError will be raised"""
+ dir_created = False
+ basedir = self._cfg.dget('misc.base_directory')
+ if not os.path.exists(basedir):
+ old_umask = os.umask(0006)
+ os.makedirs(basedir, 0771)
+ os.chown(basedir, 0, 0)
+ os.umask(old_umask)
+ dir_created = True
+ if not dir_created and not lisdir(basedir):
+ raise VMMError(_(u"'%(path)s' is not a directory.\n(%(cfg_file)s: "
+ u"section 'misc', option 'base_directory')") %
+ {'path': basedir, 'cfg_file': self._cfg_fname},
+ NO_SUCH_DIRECTORY)
+ for opt, val in self._cfg.items('bin'):
+ try:
+ exec_ok(val)
+ except VMMError, err:
+ if err.code in (NO_SUCH_BINARY, NOT_EXECUTABLE):
+ raise VMMError(err.msg + _(u"\n(%(cfg_file)s: section "
+ u"'bin', option '%(option)s')") %
+ {'cfg_file': self._cfg_fname,
+ 'option': opt}, err.code)
+ else:
+ raise
+
+ def _set_db_connect(self):
+ """check which module to use and set self._db_connect"""
+ global _db_mod
+ if self._cfg.dget('database.module').lower() == 'psycopg2':
+ try:
+ _db_mod = __import__('psycopg2')
+ except ImportError:
+ raise VMMError(_(u"Unable to import database module '%s'") %
+ 'psycopg2', VMM_ERROR)
+ self._db_connect = self._psycopg2_connect
+ else:
+ try:
+ tmp = __import__('pyPgSQL', globals(), locals(), ['PgSQL'])
+ except ImportError:
+ raise VMMError(_(u"Unable to import database module '%s'") %
+ 'pyPgSQL', VMM_ERROR)
+ _db_mod = tmp.PgSQL
+ self._db_connect = self._pypgsql_connect
+
+ def _pypgsql_connect(self):
+ """Creates a pyPgSQL.PgSQL.connection instance."""
+ if self._dbh is None or (isinstance(self._dbh, _db_mod.Connection) and
+ not self._dbh._isOpen):
+ try:
+ self._dbh = _db_mod.connect(
+ database=self._cfg.dget('database.name'),
+ user=self._cfg.pget('database.user'),
+ host=self._cfg.dget('database.host'),
+ port=self._cfg.dget('database.port'),
+ password=self._cfg.pget('database.pass'),
+ client_encoding='utf8', unicode_results=True)
+ dbc = self._dbh.cursor()
+ dbc.execute("SET NAMES 'UTF8'")
+ dbc.close()
+ except _db_mod.libpq.DatabaseError, err:
+ raise VMMError(str(err), DATABASE_ERROR)
+
+ def _psycopg2_connect(self):
+ """Return a new psycopg2 connection object."""
+ if self._dbh is None or \
+ (isinstance(self._dbh, _db_mod.extensions.connection) and
+ self._dbh.closed):
+ try:
+ self._dbh = _db_mod.connect(
+ host=self._cfg.dget('database.host'),
+ sslmode=self._cfg.dget('database.sslmode'),
+ port=self._cfg.dget('database.port'),
+ database=self._cfg.dget('database.name'),
+ user=self._cfg.pget('database.user'),
+ password=self._cfg.pget('database.pass'))
+ self._dbh.set_client_encoding('utf8')
+ _db_mod.extensions.register_type(_db_mod.extensions.UNICODE)
+ dbc = self._dbh.cursor()
+ dbc.execute("SET NAMES 'UTF8'")
+ dbc.close()
+ except _db_mod.DatabaseError, err:
+ raise VMMError(str(err), DATABASE_ERROR)
+
+ def _chk_other_address_types(self, address, exclude):
+ """Checks if the EmailAddress *address* is known as `TYPE_ACCOUNT`,
+ `TYPE_ALIAS` or `TYPE_RELOCATED`, but not as the `TYPE_*` specified
+ by *exclude*. If the *address* is known as one of the `TYPE_*`s
+ the according `TYPE_*` constant will be returned. Otherwise 0 will
+ be returned."""
+ assert exclude in (TYPE_ACCOUNT, TYPE_ALIAS, TYPE_RELOCATED) and \
+ isinstance(address, EmailAddress)
+ if exclude is not TYPE_ACCOUNT:
+ account = Account(self._dbh, address)
+ if account:
+ return TYPE_ACCOUNT
+ if exclude is not TYPE_ALIAS:
+ alias = Alias(self._dbh, address)
+ if alias:
+ return TYPE_ALIAS
+ if exclude is not TYPE_RELOCATED:
+ relocated = Relocated(self._dbh, address)
+ if relocated:
+ return TYPE_RELOCATED
+ return 0
+
+ def _is_other_address(self, address, exclude):
+ """Checks if *address* is known for an Account (TYPE_ACCOUNT),
+ Alias (TYPE_ALIAS) or Relocated (TYPE_RELOCATED), except for
+ *exclude*. Returns `False` if the address is not known for other
+ types.
+
+ Raises a `VMMError` if the address is known.
+ """
+ other = self._chk_other_address_types(address, exclude)
+ if not other:
+ return False
+ # TP: %(a_type)s will be one of: 'an account', 'an alias' or
+ # 'a relocated user'
+ msg = _(u"There is already %(a_type)s with the address '%(address)s'.")
+ raise VMMError(msg % {'a_type': OTHER_TYPES[other][0],
+ 'address': address}, OTHER_TYPES[other][1])
+
+ def _get_account(self, address):
+ """Return an Account instances for the given address (str)."""
+ address = EmailAddress(address)
+ self._db_connect()
+ return Account(self._dbh, address)
+
+ def _get_alias(self, address):
+ """Return an Alias instances for the given address (str)."""
+ address = EmailAddress(address)
+ self._db_connect()
+ return Alias(self._dbh, address)
+
+ def _get_relocated(self, address):
+ """Return a Relocated instances for the given address (str)."""
+ address = EmailAddress(address)
+ self._db_connect()
+ return Relocated(self._dbh, address)
+
+ def _get_domain(self, domainname):
+ """Return a Domain instances for the given domain name (str)."""
+ self._db_connect()
+ return Domain(self._dbh, domainname)
+
+ def _get_disk_usage(self, directory):
+ """Estimate file space usage for the given directory.
+
+ Arguments:
+
+ `directory` : basestring
+ The directory to summarize recursively disk usage for
+ """
+ if lisdir(directory):
+ return Popen([self._cfg.dget('bin.du'), "-hs", directory],
+ stdout=PIPE).communicate()[0].split('\t')[0]
+ else:
+ self._warnings.append(_('No such directory: %s') % directory)
+ return 0
+
+ def _make_domain_dir(self, domain):
+ """Create a directory for the `domain` and its accounts."""
+ cwd = os.getcwd()
+ hashdir, domdir = domain.directory.split(os.path.sep)[-2:]
+ dir_created = False
+ os.chdir(self._cfg.dget('misc.base_directory'))
+ if not os.path.exists(hashdir):
+ os.mkdir(hashdir, 0711)
+ os.chown(hashdir, 0, 0)
+ dir_created = True
+ if not dir_created and not lisdir(hashdir):
+ raise VMMError(_(u"'%s' is not a directory.") % hashdir,
+ NO_SUCH_DIRECTORY)
+ os.mkdir(os.path.join(hashdir, domdir),
+ self._cfg.dget('domain.directory_mode'))
+ os.chown(domain.directory, 0, domain.gid)
+ os.chdir(cwd)
+
+ def _make_home(self, account):
+ """Create a home directory for the new Account *account*."""
+ domdir = account.domain.directory
+ if not lisdir(domdir):
+ self._make_domain_dir(account.domain)
+ os.umask(0007)
+ uid = account.uid
+ os.chdir(domdir)
+ os.mkdir('%s' % uid, self._cfg.dget('account.directory_mode'))
+ os.chown('%s' % uid, uid, account.gid)
+
+ def _make_account_dirs(self, account):
+ """Create all necessary directories for the account."""
+ oldpwd = os.getcwd()
+ self._make_home(account)
+ mailbox = new_mailbox(account)
+ mailbox.create()
+ folders = self._cfg.dget('mailbox.folders').split(':')
+ if any(folders):
+ bad = mailbox.add_boxes(folders,
+ self._cfg.dget('mailbox.subscribe'))
+ if bad:
+ self._warnings.append(_(u"Skipped mailbox folders:") +
+ '\n\t- ' + '\n\t- '.join(bad))
+ os.chdir(oldpwd)
+
+ def _delete_home(self, domdir, uid, gid):
+ """Delete a user's home directory.
+
+ Arguments:
+
+ `domdir` : basestring
+ The directory of the domain the user belongs to
+ (commonly AccountObj.domain.directory)
+ `uid` : int/long
+ The user's UID (commonly AccountObj.uid)
+ `gid` : int/long
+ The user's GID (commonly AccountObj.gid)
+ """
+ assert all(isinstance(xid, (long, int)) for xid in (uid, gid)) and \
+ isinstance(domdir, basestring)
+ if uid < MIN_UID or gid < MIN_GID:
+ raise VMMError(_(u"UID '%(uid)u' and/or GID '%(gid)u' are less "
+ u"than %(min_uid)u/%(min_gid)u.") % {'uid': uid,
+ 'gid': gid, 'min_gid': MIN_GID, 'min_uid': MIN_UID},
+ MAILDIR_PERM_MISMATCH)
+ if domdir.count('..'):
+ raise VMMError(_(u'Found ".." in domain directory path: %s') %
+ domdir, FOUND_DOTS_IN_PATH)
+ if not lisdir(domdir):
+ raise VMMError(_(u"No such directory: %s") % domdir,
+ NO_SUCH_DIRECTORY)
+ os.chdir(domdir)
+ userdir = '%s' % uid
+ if not lisdir(userdir):
+ self._warnings.append(_(u"No such directory: %s") %
+ os.path.join(domdir, userdir))
+ return
+ mdstat = os.lstat(userdir)
+ if (mdstat.st_uid, mdstat.st_gid) != (uid, gid):
+ raise VMMError(_(u'Detected owner/group mismatch in home '
+ u'directory.'), MAILDIR_PERM_MISMATCH)
+ rmtree(userdir, ignore_errors=True)
+
+ def _delete_domain_dir(self, domdir, gid):
+ """Delete a domain's directory.
+
+ Arguments:
+
+ `domdir` : basestring
+ The domain's directory (commonly DomainObj.directory)
+ `gid` : int/long
+ The domain's GID (commonly DomainObj.gid)
+ """
+ assert isinstance(domdir, basestring) and isinstance(gid, (long, int))
+ if gid < MIN_GID:
+ raise VMMError(_(u"GID '%(gid)u' is less than '%(min_gid)u'.") %
+ {'gid': gid, 'min_gid': MIN_GID},
+ DOMAINDIR_GROUP_MISMATCH)
+ if domdir.count('..'):
+ raise VMMError(_(u'Found ".." in domain directory path: %s') %
+ domdir, FOUND_DOTS_IN_PATH)
+ if not lisdir(domdir):
+ self._warnings.append(_('No such directory: %s') % domdir)
+ return
+ dirst = os.lstat(domdir)
+ if dirst.st_gid != gid:
+ raise VMMError(_(u'Detected group mismatch in domain directory: '
+ u'%s') % domdir, DOMAINDIR_GROUP_MISMATCH)
+ rmtree(domdir, ignore_errors=True)
+
+ def has_warnings(self):
+ """Checks if warnings are present, returns bool."""
+ return bool(len(self._warnings))
+
+ def get_warnings(self):
+ """Returns a list with all available warnings and resets all
+ warnings.
+ """
+ ret_val = self._warnings[:]
+ del self._warnings[:]
+ return ret_val
+
+ def cfg_dget(self, option):
+ """Get the configured value of the *option* (section.option).
+ When the option was not configured its default value will be
+ returned."""
+ return self._cfg.dget(option)
+
+ def cfg_pget(self, option):
+ """Get the configured value of the *option* (section.option)."""
+ return self._cfg.pget(option)
+
+ def cfg_install(self):
+ """Installs the cfg_dget method as ``cfg_dget`` into the built-in
+ namespace."""
+ import __builtin__
+ assert 'cfg_dget' not in __builtin__.__dict__
+ __builtin__.__dict__['cfg_dget'] = self._cfg.dget
+
+ def domain_add(self, domainname, transport=None):
+ """Wrapper around Domain.set_transport() and Domain.save()"""
+ dom = self._get_domain(domainname)
+ if transport is None:
+ dom.set_transport(Transport(self._dbh,
+ transport=self._cfg.dget('misc.transport')))
+ else:
+ dom.set_transport(Transport(self._dbh, transport=transport))
+ dom.set_directory(self._cfg.dget('misc.base_directory'))
+ dom.save()
+ self._make_domain_dir(dom)
+
+ def domain_transport(self, domainname, transport, force=None):
+ """Wrapper around Domain.update_transport()"""
+ if force is not None and force != 'force':
+ raise DomainError(_(u"Invalid argument: '%s'") % force,
+ INVALID_ARGUMENT)
+ dom = self._get_domain(domainname)
+ trsp = Transport(self._dbh, transport=transport)
+ if force is None:
+ dom.update_transport(trsp)
+ else:
+ dom.update_transport(trsp, force=True)
+
+ def domain_delete(self, domainname, force=False):
+ """Wrapper around Domain.delete()"""
+ if not isinstance(force, bool):
+ raise TypeError('force must be a bool')
+ dom = self._get_domain(domainname)
+ gid = dom.gid
+ domdir = dom.directory
+ if self._cfg.dget('domain.force_deletion') or force:
+ dom.delete(True)
+ else:
+ dom.delete(False)
+ if self._cfg.dget('domain.delete_directory'):
+ self._delete_domain_dir(domdir, gid)
+
+ def domain_info(self, domainname, details=None):
+ """Wrapper around Domain.get_info(), Domain.get_accounts(),
+ Domain.get_aliase_names(), Domain.get_aliases() and
+ Domain.get_relocated."""
+ if details not in [None, 'accounts', 'aliasdomains', 'aliases', 'full',
+ 'relocated']:
+ raise VMMError(_(u"Invalid argument: '%s'") % details,
+ INVALID_ARGUMENT)
+ dom = self._get_domain(domainname)
+ dominfo = dom.get_info()
+ if dominfo['domainname'].startswith('xn--'):
+ dominfo['domainname'] += ' (%s)' % \
+ dominfo['domainname'].decode('idna')
+ if details is None:
+ return dominfo
+ elif details == 'accounts':
+ return (dominfo, dom.get_accounts())
+ elif details == 'aliasdomains':
+ return (dominfo, dom.get_aliase_names())
+ elif details == 'aliases':
+ return (dominfo, dom.get_aliases())
+ elif details == 'relocated':
+ return(dominfo, dom.get_relocated())
+ else:
+ return (dominfo, dom.get_aliase_names(), dom.get_accounts(),
+ dom.get_aliases(), dom.get_relocated())
+
+ def aliasdomain_add(self, aliasname, domainname):
+ """Adds an alias domain to the domain.
+
+ Arguments:
+
+ `aliasname` : basestring
+ The name of the alias domain
+ `domainname` : basestring
+ The name of the target domain
+ """
+ dom = self._get_domain(domainname)
+ alias_dom = AliasDomain(self._dbh, aliasname)
+ alias_dom.set_destination(dom)
+ alias_dom.save()
+
+ def aliasdomain_info(self, aliasname):
+ """Returns a dict (keys: "alias" and "domain") with the names of
+ the alias domain and its primary domain."""
+ self._db_connect()
+ alias_dom = AliasDomain(self._dbh, aliasname)
+ return alias_dom.info()
+
+ def aliasdomain_switch(self, aliasname, domainname):
+ """Modifies the target domain of an existing alias domain.
+
+ Arguments:
+
+ `aliasname` : basestring
+ The name of the alias domain
+ `domainname` : basestring
+ The name of the new target domain
+ """
+ dom = self._get_domain(domainname)
+ alias_dom = AliasDomain(self._dbh, aliasname)
+ alias_dom.set_destination(dom)
+ alias_dom.switch()
+
+ def aliasdomain_delete(self, aliasname):
+ """Deletes the given alias domain.
+
+ Argument:
+
+ `aliasname` : basestring
+ The name of the alias domain
+ """
+ self._db_connect()
+ alias_dom = AliasDomain(self._dbh, aliasname)
+ alias_dom.delete()
+
+ def domain_list(self, pattern=None):
+ """Wrapper around function search() from module Domain."""
+ from VirtualMailManager.domain import search
+ like = False
+ if pattern and (pattern.startswith('%') or pattern.endswith('%')):
+ like = True
+ if not re.match(RE_DOMAIN_SEARCH, pattern.strip('%')):
+ raise VMMError(_(u"The pattern '%s' contains invalid "
+ u"characters.") % pattern, DOMAIN_INVALID)
+ self._db_connect()
+ return search(self._dbh, pattern=pattern, like=like)
+
+ def user_add(self, emailaddress, password):
+ """Wrapper around Account.set_password() and Account.save()."""
+ acc = self._get_account(emailaddress)
+ if acc:
+ raise VMMError(_(u"The account '%s' already exists.") %
+ acc.address, ACCOUNT_EXISTS)
+ acc.set_password(password)
+ acc.save()
+ self._make_account_dirs(acc)
+
+ def alias_add(self, aliasaddress, *targetaddresses):
+ """Creates a new `Alias` entry for the given *aliasaddress* with
+ the given *targetaddresses*."""
+ alias = self._get_alias(aliasaddress)
+ destinations = [EmailAddress(address) for address in targetaddresses]
+ warnings = []
+ destinations = alias.add_destinations(destinations, warnings)
+ if warnings:
+ self._warnings.append(_('Ignored destination addresses:'))
+ self._warnings.extend((' * %s' % w for w in warnings))
+ for destination in destinations:
+ if get_gid(self._dbh, destination.domainname) and \
+ not self._chk_other_address_types(destination, TYPE_RELOCATED):
+ self._warnings.append(_(u"The destination account/alias '%s' "
+ u"doesn't exist.") % destination)
+
+ def user_delete(self, emailaddress, force=False):
+ """Wrapper around Account.delete(...)"""
+ if not isinstance(force, bool):
+ raise TypeError('force must be a bool')
+ acc = self._get_account(emailaddress)
+ if not acc:
+ raise VMMError(_(u"The account '%s' doesn't exist.") %
+ acc.address, NO_SUCH_ACCOUNT)
+ uid = acc.uid
+ gid = acc.gid
+ dom_dir = acc.domain.directory
+ acc_dir = acc.home
+ acc.delete(force)
+ if self._cfg.dget('account.delete_directory'):
+ try:
+ self._delete_home(dom_dir, uid, gid)
+ except VMMError, err:
+ if err.code in (FOUND_DOTS_IN_PATH, MAILDIR_PERM_MISMATCH,
+ NO_SUCH_DIRECTORY):
+ warning = _(u"""\
+The account has been successfully deleted from the database.
+ But an error occurred while deleting the following directory:
+ '%(directory)s'
+ Reason: %(reason)s""") % {'directory': acc_dir, 'reason': err.msg}
+ self._warnings.append(warning)
+ else:
+ raise
+
+ def alias_info(self, aliasaddress):
+ """Returns an iterator object for all destinations (`EmailAddress`
+ instances) for the `Alias` with the given *aliasaddress*."""
+ alias = self._get_alias(aliasaddress)
+ if alias:
+ return alias.get_destinations()
+ if not self._is_other_address(alias.address, TYPE_ALIAS):
+ raise VMMError(_(u"The alias '%s' doesn't exist.") %
+ alias.address, NO_SUCH_ALIAS)
+
+ def alias_delete(self, aliasaddress, targetaddress=None):
+ """Deletes the `Alias` *aliasaddress* with all its destinations from
+ the database. If *targetaddress* is not ``None``, only this
+ destination will be removed from the alias."""
+ alias = self._get_alias(aliasaddress)
+ if targetaddress is None:
+ alias.delete()
+ else:
+ alias.del_destination(EmailAddress(targetaddress))
+
+ def user_info(self, emailaddress, details=None):
+ """Wrapper around Account.get_info(...)"""
+ if details not in (None, 'du', 'aliases', 'full'):
+ raise VMMError(_(u"Invalid argument: '%s'") % details,
+ INVALID_ARGUMENT)
+ acc = self._get_account(emailaddress)
+ if not acc:
+ if not self._is_other_address(acc.address, TYPE_ACCOUNT):
+ raise VMMError(_(u"The account '%s' doesn't exist.") %
+ acc.address, NO_SUCH_ACCOUNT)
+ info = acc.get_info()
+ if self._cfg.dget('account.disk_usage') or details in ('du', 'full'):
+ path = os.path.join(acc.home, acc.mail_location.directory)
+ info['disk usage'] = self._get_disk_usage(path)
+ if details in (None, 'du'):
+ return info
+ if details in ('aliases', 'full'):
+ return (info, acc.get_aliases())
+ return info
+
+ def user_by_uid(self, uid):
+ """Search for an Account by its *uid*.
+ Returns a dict (address, uid and gid) if a user could be found."""
+ from VirtualMailManager.account import get_account_by_uid
+ self._db_connect()
+ return get_account_by_uid(uid, self._dbh)
+
+ def user_password(self, emailaddress, password):
+ """Wrapper for Account.modify('password' ...)."""
+ if not isinstance(password, basestring) or not password:
+ raise VMMError(_(u"Could not accept password: '%s'") % password,
+ INVALID_ARGUMENT)
+ acc = self._get_account(emailaddress)
+ if not acc:
+ raise VMMError(_(u"The account '%s' doesn't exist.") %
+ acc.address, NO_SUCH_ACCOUNT)
+ acc.modify('password', password)
+
+ def user_name(self, emailaddress, name):
+ """Wrapper for Account.modify('name', ...)."""
+ if not isinstance(name, basestring) or not name:
+ raise VMMError(_(u"Could not accept name: '%s'") % name,
+ INVALID_ARGUMENT)
+ acc = self._get_account(emailaddress)
+ if not acc:
+ raise VMMError(_(u"The account '%s' doesn't exist.") %
+ acc.address, NO_SUCH_ACCOUNT)
+ acc.modify('name', name)
+
+ def user_transport(self, emailaddress, transport):
+ """Wrapper for Account.modify('transport', ...)."""
+ if not isinstance(transport, basestring) or not transport:
+ raise VMMError(_(u"Could not accept transport: '%s'") % transport,
+ INVALID_ARGUMENT)
+ acc = self._get_account(emailaddress)
+ if not acc:
+ raise VMMError(_(u"The account '%s' doesn't exist.") %
+ acc.address, NO_SUCH_ACCOUNT)
+ acc.modify('transport', transport)
+
+ def user_disable(self, emailaddress, services=None):
+ """Wrapper for Account.disable(*services)"""
+ if services is None:
+ services = []
+ else:
+ assert isinstance(services, list)
+ acc = self._get_account(emailaddress)
+ if not acc:
+ raise VMMError(_(u"The account '%s' doesn't exist.") % acc.address,
+ NO_SUCH_ACCOUNT)
+ acc.disable(*services)
+
+ def user_enable(self, emailaddress, services=None):
+ """Wrapper for Account.enable(*services)"""
+ if services is None:
+ services = []
+ else:
+ assert isinstance(services, list)
+ acc = self._get_account(emailaddress)
+ if not acc:
+ raise VMMError(_(u"The account '%s' doesn't exist.") % acc.address,
+ NO_SUCH_ACCOUNT)
+ acc.enable(*services)
+
+ def relocated_add(self, emailaddress, targetaddress):
+ """Creates a new `Relocated` entry in the database. If there is
+ already a relocated user with the given *emailaddress*, only the
+ *targetaddress* for the relocated user will be updated."""
+ relocated = self._get_relocated(emailaddress)
+ relocated.set_destination(EmailAddress(targetaddress))
+
+ def relocated_info(self, emailaddress):
+ """Returns the target address of the relocated user with the given
+ *emailaddress*."""
+ relocated = self._get_relocated(emailaddress)
+ if relocated:
+ return relocated.get_info()
+ if not self._is_other_address(relocated.address, TYPE_RELOCATED):
+ raise VMMError(_(u"The relocated user '%s' doesn't exist.") %
+ relocated.address, NO_SUCH_RELOCATED)
+
+ def relocated_delete(self, emailaddress):
+ """Deletes the relocated user with the given *emailaddress* from
+ the database."""
+ relocated = self._get_relocated(emailaddress)
+ relocated.delete()
+
+del _
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/VirtualMailManager/mailbox.py Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,287 @@
+# -*- coding: UTF-8 -*-
+# Copyright (c) 2010, Pascal Volk
+# See COPYING for distribution information.
+"""
+ VirtualMailManager.mailbox
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ VirtualMailManager's mailbox classes for the Maildir, single dbox
+ (sdbox) and multi dbox (mdbox) mailbox formats.
+"""
+
+import os
+import re
+from binascii import a2b_base64, b2a_base64
+from subprocess import Popen, PIPE
+
+from VirtualMailManager.account import Account
+from VirtualMailManager.common import lisdir
+from VirtualMailManager.errors import VMMError
+from VirtualMailManager.constants import VMM_ERROR
+
+
+__all__ = ('new', 'Maildir', 'SingleDbox', 'MultiDbox',
+ 'utf8_to_mutf7', 'mutf7_to_utf8')
+
+cfg_dget = lambda option: None
+
+
+def _mbase64_encode(inp, dest):
+ if inp:
+ mb64 = b2a_base64(''.join(inp).encode('utf-16be'))
+ dest.append('&%s-' % mb64.rstrip('\n=').replace('/', ','))
+ del inp[:]
+
+
+def _mbase64_to_unicode(mb64):
+ return unicode(a2b_base64(mb64.replace(',', '/') + '==='), 'utf-16be')
+
+
+def utf8_to_mutf7(src):
+ """
+ Converts the international mailbox name `src` into a modified
+ version version of the UTF-7 encoding.
+ """
+ ret = []
+ tmp = []
+ for c in src:
+ ordc = ord(c)
+ if 0x20 <= ordc <= 0x25 or 0x27 <= ordc <= 0x7E:
+ _mbase64_encode(tmp, ret)
+ ret.append(c)
+ elif ordc == 0x26:
+ _mbase64_encode(tmp, ret)
+ ret.append('&-')
+ else:
+ tmp.append(c)
+ _mbase64_encode(tmp, ret)
+ return ''.join(ret)
+
+
+def mutf7_to_utf8(src):
+ """
+ Converts the mailbox name `src` from modified UTF-7 encoding to UTF-8.
+ """
+ ret = []
+ tmp = []
+ for c in src:
+ if c == '&' and not tmp:
+ tmp.append(c)
+ elif c == '-' and tmp:
+ if len(tmp) is 1:
+ ret.append('&')
+ else:
+ ret.append(_mbase64_to_unicode(''.join(tmp[1:])))
+ tmp = []
+ elif tmp:
+ tmp.append(c)
+ else:
+ ret.append(c)
+ if tmp:
+ ret.append(_mbase64_to_unicode(''.join(tmp[1:])))
+ return ''.join(ret)
+
+
+class Mailbox(object):
+ """Base class of all mailbox classes."""
+ __slots__ = ('_boxes', '_root', '_sep', '_user')
+ FILE_MODE = 0600
+ _ctrl_chr_re = re.compile('[\x00-\x1F\x7F-\x9F]')
+ _box_name_re = re.compile('^[\x20-\x25\x27-\x7E]+$')
+
+ def __init__(self, account):
+ """
+ Creates a new mailbox instance.
+ Use one of the `Maildir`, `SingleDbox` or `MultiDbox` classes.
+ """
+ assert isinstance(account, Account) and lisdir(account.home)
+ self._user = account
+ self._boxes = []
+ self._root = self._user.mail_location.directory
+ self._sep = '/'
+ os.chdir(self._user.home)
+
+ def _add_boxes(self, mailboxes, subscribe):
+ raise NotImplementedError
+
+ def _validate_box_name(self, name, good, bad):
+ """
+ Validates the mailboxes name `name`. When the name is valid, it
+ will be added to the `good` set. Invalid mailbox names will be
+ appended to the `bad` list.
+ """
+ name = name.strip()
+ if not name:
+ return
+ if self.__class__._ctrl_chr_re.search(name): # no control chars
+ bad.append(name)
+ return
+ if name[0] in (self._sep, '~'):
+ bad.append(name)
+ return
+ if self._sep == '/':
+ if '//' in name or '/./' in name or '/../' in name or \
+ name.startswith('../'):
+ bad.append(name)
+ return
+ if '/' in name or '..' in name:
+ bad.append(name)
+ return
+ if not self.__class__._box_name_re.match(name):
+ tmp = utf8_to_mutf7(name)
+ if name == mutf7_to_utf8(tmp):
+ if self._user.mail_location.mbformat == 'maildir':
+ good.add(tmp)
+ else:
+ good.add(name)
+ return
+ else:
+ bad.append(name)
+ return
+ good.add(name)
+
+ def add_boxes(self, mailboxes, subscribe):
+ """
+ Create all mailboxes from the `mailboxes` list in the user's
+ mail directory. When `subscribe` is ``True`` all created mailboxes
+ will be listed in the subscriptions file.
+ Returns a list of invalid mailbox names, if any.
+ """
+ assert isinstance(mailboxes, list) and isinstance(subscribe, bool)
+ good = set()
+ bad = []
+ for box in mailboxes:
+ self._validate_box_name(box, good, bad)
+ self._add_boxes(good, subscribe)
+ return bad
+
+ def create(self):
+ """Create the INBOX in the user's mail directory."""
+ raise NotImplementedError
+
+
+class Maildir(Mailbox):
+ """Class for Maildir++ mailboxes."""
+
+ __slots__ = ('_subdirs')
+
+ def __init__(self, account):
+ """
+ Create a new Maildir++ instance.
+ Call the instance's create() method, in order to create the INBOX.
+ For additional mailboxes use the add_boxes() method.
+ """
+ super(self.__class__, self).__init__(account)
+ self._sep = '.'
+ self._subdirs = ('cur', 'new', 'tmp')
+
+ def _create_maildirfolder_file(self, path):
+ """Mark the Maildir++ folder as Maildir folder."""
+ maildirfolder_file = os.path.join(self._sep + path, 'maildirfolder')
+ os.close(os.open(maildirfolder_file, os.O_CREAT | os.O_WRONLY,
+ self.__class__.FILE_MODE))
+ os.chown(maildirfolder_file, self._user.uid, self._user.gid)
+
+ def _make_maildir(self, path):
+ """
+ Create Maildir++ folders with the cur, new and tmp subdirectories.
+ """
+ mode = cfg_dget('account.directory_mode')
+ uid = self._user.uid
+ gid = self._user.gid
+ os.mkdir(path, mode)
+ os.chown(path, uid, gid)
+ for subdir in self._subdirs:
+ dir_ = os.path.join(path, subdir)
+ os.mkdir(dir_, mode)
+ os.chown(dir_, uid, gid)
+
+ def _subscribe_boxes(self):
+ """Writes all created mailboxes to the subscriptions file."""
+ if not self._boxes:
+ return
+ subscriptions = open('subscriptions', 'w')
+ subscriptions.write('\n'.join(self._boxes))
+ subscriptions.write('\n')
+ subscriptions.flush()
+ subscriptions.close()
+ os.chown('subscriptions', self._user.uid, self._user.gid)
+ os.chmod('subscriptions', self.__class__.FILE_MODE)
+ del self._boxes[:]
+
+ def _add_boxes(self, mailboxes, subscribe):
+ for mailbox in mailboxes:
+ self._make_maildir(self._sep + mailbox)
+ self._create_maildirfolder_file(mailbox)
+ self._boxes.append(mailbox)
+ if subscribe:
+ self._subscribe_boxes()
+
+ def create(self):
+ """Creates a Maildir++ INBOX."""
+ self._make_maildir(self._root)
+ os.chdir(self._root)
+
+
+class SingleDbox(Mailbox):
+ """
+ Class for (single) dbox mailboxes.
+ See http://wiki.dovecot.org/MailboxFormat/dbox for details.
+ """
+
+ __slots__ = ()
+
+ def __init__(self, account):
+ """
+ Create a new dbox instance.
+ Call the instance's create() method, in order to create the INBOX.
+ For additional mailboxes use the add_boxes() method.
+ """
+ assert cfg_dget('misc.dovecot_version') >= \
+ account.mail_location.dovecot_version
+ super(SingleDbox, self).__init__(account)
+
+ def _doveadm_create(self, mailboxes, subscribe):
+ """Wrap around Dovecot's doveadm"""
+ cmd_args = [cfg_dget('bin.dovecotpw'), 'mailbox', 'create', '-u',
+ str(self._user.address)]
+ if subscribe:
+ cmd_args.append('-s')
+ cmd_args.extend(mailboxes)
+ process = Popen(cmd_args, stdout=PIPE, stderr=PIPE)
+ stdout, stderr = process.communicate()
+ if process.returncode:
+ raise VMMError(stderr.strip(), VMM_ERROR)
+
+ def create(self):
+ """Create a dbox INBOX"""
+ os.mkdir(self._root, cfg_dget('account.directory_mode'))
+ os.chown(self._root, self._user.uid, self._user.gid)
+ self._doveadm_create(('INBOX',), False)
+ os.chdir(self._root)
+
+ def _add_boxes(self, mailboxes, subscribe):
+ self._doveadm_create(mailboxes, subscribe)
+
+
+class MultiDbox(SingleDbox):
+ """
+ Class for multi dbox mailboxes.
+ See http://wiki.dovecot.org/MailboxFormat/dbox#Multi-dbox for details.
+ """
+
+ __slots__ = ()
+
+
+def new(account):
+ """Create a new Mailbox instance for the given Account."""
+ mbfmt = account.mail_location.mbformat
+ if mbfmt == 'maildir':
+ return Maildir(account)
+ elif mbfmt == 'mdbox':
+ return MultiDbox(account)
+ elif mbfmt == 'sdbox':
+ return SingleDbox(account)
+ raise ValueError('unsupported mailbox format: %r' % mbfmt)
+
+del cfg_dget
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/VirtualMailManager/maillocation.py Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,163 @@
+# -*- coding: UTF-8 -*-
+# Copyright (c) 2008 - 2010, Pascal Volk
+# See COPYING for distribution information.
+"""
+ VirtualMailManager.maillocation
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ Virtual Mail Manager's maillocation module to handle Dovecot's
+ mail_location setting for accounts.
+
+"""
+
+from VirtualMailManager.constants import \
+ MAILLOCATION_INIT, UNKNOWN_MAILLOCATION_ID
+from VirtualMailManager.errors import MailLocationError as MLErr
+from VirtualMailManager.pycompat import all
+
+
+__all__ = ('MailLocation', 'known_format')
+
+_ = lambda msg: msg
+_format_info = {
+ 'maildir': dict(dovecot_version=0x10000f00, postfix=True),
+ 'mdbox': dict(dovecot_version=0x20000b05, postfix=False),
+ 'sdbox': dict(dovecot_version=0x20000c03, postfix=False),
+}
+
+
+class MailLocation(object):
+ """Class to handle mail_location relevant information."""
+ __slots__ = ('_directory', '_mbfmt', '_mid', '_dbh')
+ _kwargs = ('mid', 'mbfmt', 'directory')
+
+ def __init__(self, dbh, **kwargs):
+ """Creates a new MailLocation instance.
+
+ Either the mid keyword or the mbfmt and directory keywords must be
+ specified.
+
+ Arguments:
+
+ `dbh` : pyPgSQL.PgSQL.Connection
+ A database connection for the database access.
+
+ Keyword arguments:
+
+ `mid` : int
+ the id of a mail_location
+ `mbfmt` : str
+ the mailbox format of the mail_location. One out of: ``maildir``,
+ ``sdbox`` and ``mdbox``.
+ `directory` : str
+ name of the mailbox root directory.
+ """
+ self._dbh = dbh
+ self._directory = None
+ self._mbfmt = None
+ self._mid = 0
+
+ for key in kwargs.iterkeys():
+ if key not in self.__class__._kwargs:
+ raise ValueError('unrecognized keyword: %r' % key)
+ mid = kwargs.get('mid')
+ if mid:
+ assert isinstance(mid, (int, long))
+ self._load_by_mid(mid)
+ else:
+ args = kwargs.get('mbfmt'), kwargs.get('directory')
+ assert all(isinstance(arg, basestring) for arg in args)
+ if args[0].lower() not in _format_info:
+ raise MLErr(_(u"Unsupported mailbox format: '%s'") % args[0],
+ MAILLOCATION_INIT)
+ directory = args[1].strip()
+ if not directory:
+ raise MLErr(_(u"Empty directory name"), MAILLOCATION_INIT)
+ if len(directory) > 20:
+ raise MLErr(_(u"Directory name is too long: '%s'") % directory,
+ MAILLOCATION_INIT)
+ self._load_by_names(args[0].lower(), directory)
+
+ def __str__(self):
+ return u'%s:~/%s' % (self._mbfmt, self._directory)
+
+ @property
+ def directory(self):
+ """The mail_location's directory name."""
+ return self._directory
+
+ @property
+ def dovecot_version(self):
+ """The required Dovecot version for this mailbox format."""
+ return _format_info[self._mbfmt]['dovecot_version']
+
+ @property
+ def postfix(self):
+ """`True` if Postfix supports this mailbox format, else `False`."""
+ return _format_info[self._mbfmt]['postfix']
+
+ @property
+ def mbformat(self):
+ """The mail_location's mailbox format."""
+ return self._mbfmt
+
+ @property
+ def mail_location(self):
+ """The mail_location, e.g. ``maildir:~/Maildir``"""
+ return self.__str__()
+
+ @property
+ def mid(self):
+ """The mail_location's unique ID."""
+ return self._mid
+
+ def _load_by_mid(self, mid):
+ """Load mail_location relevant information by *mid*"""
+ dbc = self._dbh.cursor()
+ dbc.execute('SELECT format, directory FROM mailboxformat, '
+ 'maillocation WHERE mid = %u AND '
+ 'maillocation.fid = mailboxformat.fid' % mid)
+ result = dbc.fetchone()
+ dbc.close()
+ if not result:
+ raise MLErr(_(u'Unknown mail_location id: %u') % mid,
+ UNKNOWN_MAILLOCATION_ID)
+ self._mid = mid
+ self._mbfmt, self._directory = result
+
+ def _load_by_names(self, mbfmt, directory):
+ """Try to load mail_location relevant information by *mbfmt* and
+ *directory* name. If it fails goto _save()."""
+ dbc = self._dbh.cursor()
+ dbc.execute("SELECT mid FROM maillocation WHERE fid = (SELECT fid "
+ "FROM mailboxformat WHERE format = %s) AND directory = %s",
+ (mbfmt, directory))
+ result = dbc.fetchone()
+ dbc.close()
+ if not result:
+ self._save(mbfmt, directory)
+ else:
+ self._mid = result[0]
+ self._mbfmt = mbfmt
+ self._directory = directory
+
+ def _save(self, mbfmt, directory):
+ """Save a new mail_location in the database."""
+ dbc = self._dbh.cursor()
+ dbc.execute("SELECT nextval('maillocation_id')")
+ mid = dbc.fetchone()[0]
+ dbc.execute("INSERT INTO maillocation (fid, mid, directory) VALUES ("
+ "(SELECT fid FROM mailboxformat WHERE format = %s), %s, "
+ "%s)", (mbfmt, mid, directory))
+ self._dbh.commit()
+ dbc.close()
+ self._mid = mid
+ self._mbfmt = mbfmt
+ self._directory = directory
+
+
+def known_format(mbfmt):
+ """Checks if the mailbox format *mbfmt* is known, returns bool."""
+ return mbfmt.lower() in _format_info
+
+del _
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/VirtualMailManager/password.py Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,441 @@
+# -*- coding: UTF-8 -*-
+# Copyright (c) 2010, Pascal Volk
+# See COPYING for distribution information.
+"""
+ VirtualMailManager.password
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ VirtualMailManager's password module to generate password hashes from
+ passwords or random passwords. This module provides following
+ functions:
+
+ hashed_password = pwhash(password[, scheme][, user])
+ random_password = randompw()
+ scheme, encoding = verify_scheme(scheme)
+"""
+
+from crypt import crypt
+from random import SystemRandom
+from subprocess import Popen, PIPE
+
+try:
+ import hashlib
+except ImportError:
+ from VirtualMailManager.pycompat import hashlib
+
+from VirtualMailManager import ENCODING
+from VirtualMailManager.emailaddress import EmailAddress
+from VirtualMailManager.common import get_unicode, version_str
+from VirtualMailManager.constants import VMM_ERROR
+from VirtualMailManager.errors import VMMError
+
+COMPAT = hasattr(hashlib, 'compat')
+SALTCHARS = './0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
+PASSWDCHARS = '._-+#*23456789abcdefghikmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'
+DEFAULT_B64 = (None, 'B64', 'BASE64')
+DEFAULT_HEX = (None, 'HEX')
+CRYPT_ID_MD5 = 1
+CRYPT_ID_BLF = '2a'
+CRYPT_ID_SHA256 = 5
+CRYPT_ID_SHA512 = 6
+CRYPT_SALT_LEN = 2
+CRYPT_BLF_ROUNDS_MIN = 4
+CRYPT_BLF_ROUNDS_MAX = 31
+CRYPT_BLF_SALT_LEN = 22
+CRYPT_MD5_SALT_LEN = 8
+CRYPT_SHA2_ROUNDS_DEFAULT = 5000
+CRYPT_SHA2_ROUNDS_MIN = 1000
+CRYPT_SHA2_ROUNDS_MAX = 999999999
+CRYPT_SHA2_SALT_LEN = 16
+SALTED_ALGO_SALT_LEN = 4
+
+
+_ = lambda msg: msg
+cfg_dget = lambda option: None
+_sys_rand = SystemRandom()
+_choice = _sys_rand.choice
+_get_salt = lambda s_len: ''.join(_choice(SALTCHARS) for x in xrange(s_len))
+
+
+def _dovecotpw(password, scheme, encoding):
+ """Communicates with dovecotpw (Dovecot 2.0: `doveadm pw`) and returns
+ the hashed password: {scheme[.encoding]}hash
+ """
+ if encoding:
+ scheme = '.'.join((scheme, encoding))
+ cmd_args = [cfg_dget('bin.dovecotpw'), '-s', scheme, '-p',
+ get_unicode(password)]
+ if cfg_dget('misc.dovecot_version') >= 0x20000a01:
+ cmd_args.insert(1, 'pw')
+ process = Popen(cmd_args, stdout=PIPE, stderr=PIPE)
+ stdout, stderr = process.communicate()
+ if process.returncode:
+ raise VMMError(stderr.strip(), VMM_ERROR)
+ hashed = stdout.strip()
+ if not hashed.startswith('{%s}' % scheme):
+ raise VMMError('Unexpected result from %s: %s' %
+ (cfg_dget('bin.dovecotpw'), hashed), VMM_ERROR)
+ return hashed
+
+
+def _md4_new():
+ """Returns an new MD4-hash object if supported by the hashlib or
+ provided by PyCrypto - other `None`.
+ """
+ try:
+ return hashlib.new('md4')
+ except ValueError, err:
+ if str(err) == 'unsupported hash type':
+ if not COMPAT:
+ try:
+ from Crypto.Hash import MD4
+ return MD4.new()
+ except ImportError:
+ return None
+ else:
+ raise
+
+
+def _sha256_new(data=''):
+ """Returns a new sha256 object from the hashlib.
+
+ Returns `None` if the PyCrypto in pycompat.hashlib is too old."""
+ if not COMPAT:
+ return hashlib.sha256(data)
+ try:
+ return hashlib.new('sha256', data)
+ except ValueError, err:
+ if str(err) == 'unsupported hash type':
+ return None
+ else:
+ raise
+
+
+def _format_digest(digest, scheme, encoding):
+ """Formats the arguments to a string: {scheme[.encoding]}digest."""
+ if not encoding:
+ return '{%s}%s' % (scheme, digest)
+ return '{%s.%s}%s' % (scheme, encoding, digest)
+
+
+def _clear_hash(password, scheme, encoding):
+ """Generates a (encoded) CLEARTEXT/PLAIN 'hash'."""
+ if encoding:
+ if encoding == 'HEX':
+ password = password.encode('hex')
+ else:
+ password = password.encode('base64').replace('\n', '')
+ return _format_digest(password, scheme, encoding)
+ return get_unicode('{%s}%s' % (scheme, password))
+
+
+def _get_crypt_blowfish_salt():
+ """Generates a salt for Blowfish crypt."""
+ rounds = cfg_dget('misc.crypt_blowfish_rounds')
+ if rounds < CRYPT_BLF_ROUNDS_MIN:
+ rounds = CRYPT_BLF_ROUNDS_MIN
+ elif rounds > CRYPT_BLF_ROUNDS_MAX:
+ rounds = CRYPT_BLF_ROUNDS_MAX
+ return '$%s$%02d$%s' % (CRYPT_ID_BLF, rounds,
+ _get_salt(CRYPT_BLF_SALT_LEN))
+
+
+def _get_crypt_sha2_salt(crypt_id):
+ """Generates a salt for crypt using the SHA-256 or SHA-512 encryption
+ method.
+ *crypt_id* must be either `5` (SHA-256) or `6` (SHA-512).
+ """
+ assert crypt_id in (CRYPT_ID_SHA256, CRYPT_ID_SHA512), 'invalid crypt ' \
+ 'id: %r' % crypt_id
+ if crypt_id is CRYPT_ID_SHA512:
+ rounds = cfg_dget('misc.crypt_sha512_rounds')
+ else:
+ rounds = cfg_dget('misc.crypt_sha256_rounds')
+ if rounds < CRYPT_SHA2_ROUNDS_MIN:
+ rounds = CRYPT_SHA2_ROUNDS_MIN
+ elif rounds > CRYPT_SHA2_ROUNDS_MAX:
+ rounds = CRYPT_SHA2_ROUNDS_MAX
+ if rounds == CRYPT_SHA2_ROUNDS_DEFAULT:
+ return '$%d$%s' % (crypt_id, _get_salt(CRYPT_SHA2_SALT_LEN))
+ return '$%d$rounds=%d$%s' % (crypt_id, rounds,
+ _get_salt(CRYPT_SHA2_SALT_LEN))
+
+
+def _crypt_hash(password, scheme, encoding):
+ """Generates (encoded) CRYPT/MD5/{BLF,MD5,SHA{256,512}}-CRYPT hashes."""
+ if scheme == 'CRYPT':
+ salt = _get_salt(CRYPT_SALT_LEN)
+ elif scheme == 'BLF-CRYPT':
+ salt = _get_crypt_blowfish_salt()
+ elif scheme in ('MD5-CRYPT', 'MD5'):
+ salt = '$%d$%s' % (CRYPT_ID_MD5, _get_salt(CRYPT_MD5_SALT_LEN))
+ elif scheme == 'SHA256-CRYPT':
+ salt = _get_crypt_sha2_salt(CRYPT_ID_SHA256)
+ else:
+ salt = _get_crypt_sha2_salt(CRYPT_ID_SHA512)
+ encrypted = crypt(password, salt)
+ if encoding:
+ if encoding == 'HEX':
+ encrypted = encrypted.encode('hex')
+ else:
+ encrypted = encrypted.encode('base64').replace('\n', '')
+ if scheme in ('BLF-CRYPT', 'SHA256-CRYPT', 'SHA512-CRYPT') and \
+ cfg_dget('misc.dovecot_version') < 0x20000b06:
+ scheme = 'CRYPT'
+ return _format_digest(encrypted, scheme, encoding)
+
+
+def _md4_hash(password, scheme, encoding):
+ """Generates encoded PLAIN-MD4 hashes."""
+ md4 = _md4_new()
+ if md4:
+ md4.update(password)
+ if encoding in DEFAULT_HEX:
+ digest = md4.hexdigest()
+ else:
+ digest = md4.digest().encode('base64').rstrip()
+ return _format_digest(digest, scheme, encoding)
+ return _dovecotpw(password, scheme, encoding)
+
+
+def _md5_hash(password, scheme, encoding, user=None):
+ """Generates DIGEST-MD5 aka PLAIN-MD5 and LDAP-MD5 hashes."""
+ md5 = hashlib.md5()
+ if scheme == 'DIGEST-MD5':
+ # Prior to Dovecot v1.1.12/v1.2.beta2 there was a problem with a
+ # empty auth_realms setting in dovecot.conf and user@domain.tld
+ # usernames. So we have to generate different hashes for different
+ # versions. See also:
+ # http://dovecot.org/list/dovecot-news/2009-March/000103.html
+ # http://hg.dovecot.org/dovecot-1.1/rev/2b0043ba89ae
+ if cfg_dget('misc.dovecot_version') >= 0x1010cf00:
+ md5.update('%s:%s:' % (user.localpart, user.domainname))
+ else:
+ md5.update('%s::' % user)
+ md5.update(password)
+ if (scheme in ('PLAIN-MD5', 'DIGEST-MD5') and encoding in DEFAULT_HEX) or \
+ (scheme == 'LDAP-MD5' and encoding == 'HEX'):
+ digest = md5.hexdigest()
+ else:
+ digest = md5.digest().encode('base64').rstrip()
+ return _format_digest(digest, scheme, encoding)
+
+
+def _ntlm_hash(password, scheme, encoding):
+ """Generates NTLM hashes."""
+ md4 = _md4_new()
+ if md4:
+ password = ''.join('%s\x00' % c for c in password)
+ md4.update(password)
+ if encoding in DEFAULT_HEX:
+ digest = md4.hexdigest()
+ else:
+ digest = md4.digest().encode('base64').rstrip()
+ return _format_digest(digest, scheme, encoding)
+ return _dovecotpw(password, scheme, encoding)
+
+
+def _sha1_hash(password, scheme, encoding):
+ """Generates SHA1 aka SHA hashes."""
+ sha1 = hashlib.sha1(password)
+ if encoding in DEFAULT_B64:
+ digest = sha1.digest().encode('base64').rstrip()
+ else:
+ digest = sha1.hexdigest()
+ return _format_digest(digest, scheme, encoding)
+
+
+def _sha256_hash(password, scheme, encoding):
+ """Generates SHA256 hashes."""
+ sha256 = _sha256_new(password)
+ if sha256:
+ if encoding in DEFAULT_B64:
+ digest = sha256.digest().encode('base64').rstrip()
+ else:
+ digest = sha256.hexdigest()
+ return _format_digest(digest, scheme, encoding)
+ return _dovecotpw(password, scheme, encoding)
+
+
+def _sha512_hash(password, scheme, encoding):
+ """Generates SHA512 hashes."""
+ if not COMPAT:
+ sha512 = hashlib.sha512(password)
+ if encoding in DEFAULT_B64:
+ digest = sha512.digest().encode('base64').replace('\n', '')
+ else:
+ digest = sha512.hexdigest()
+ return _format_digest(digest, scheme, encoding)
+ return _dovecotpw(password, scheme, encoding)
+
+
+def _smd5_hash(password, scheme, encoding):
+ """Generates SMD5 (salted PLAIN-MD5) hashes."""
+ md5 = hashlib.md5(password)
+ salt = _get_salt(SALTED_ALGO_SALT_LEN)
+ md5.update(salt)
+ if encoding in DEFAULT_B64:
+ digest = (md5.digest() + salt).encode('base64').rstrip()
+ else:
+ digest = md5.hexdigest() + salt.encode('hex')
+ return _format_digest(digest, scheme, encoding)
+
+
+def _ssha1_hash(password, scheme, encoding):
+ """Generates SSHA (salted SHA/SHA1) hashes."""
+ sha1 = hashlib.sha1(password)
+ salt = _get_salt(SALTED_ALGO_SALT_LEN)
+ sha1.update(salt)
+ if encoding in DEFAULT_B64:
+ digest = (sha1.digest() + salt).encode('base64').rstrip()
+ else:
+ digest = sha1.hexdigest() + salt.encode('hex')
+ return _format_digest(digest, scheme, encoding)
+
+
+def _ssha256_hash(password, scheme, encoding):
+ """Generates SSHA256 (salted SHA256) hashes."""
+ sha256 = _sha256_new(password)
+ if sha256:
+ salt = _get_salt(SALTED_ALGO_SALT_LEN)
+ sha256.update(salt)
+ if encoding in DEFAULT_B64:
+ digest = (sha256.digest() + salt).encode('base64').rstrip()
+ else:
+ digest = sha256.hexdigest() + salt.encode('hex')
+ return _format_digest(digest, scheme, encoding)
+ return _dovecotpw(password, scheme, encoding)
+
+
+def _ssha512_hash(password, scheme, encoding):
+ """Generates SSHA512 (salted SHA512) hashes."""
+ if not COMPAT:
+ salt = _get_salt(SALTED_ALGO_SALT_LEN)
+ sha512 = hashlib.sha512(password + salt)
+ if encoding in DEFAULT_B64:
+ digest = (sha512.digest() + salt).encode('base64').replace('\n',
+ '')
+ else:
+ digest = sha512.hexdigest() + salt.encode('hex')
+ return _format_digest(digest, scheme, encoding)
+ return _dovecotpw(password, scheme, encoding)
+
+_scheme_info = {
+ 'CLEARTEXT': (_clear_hash, 0x10000f00),
+ 'CRAM-MD5': (_dovecotpw, 0x10000f00),
+ 'CRYPT': (_crypt_hash, 0x10000f00),
+ 'DIGEST-MD5': (_md5_hash, 0x10000f00),
+ 'HMAC-MD5': (_dovecotpw, 0x10000f00),
+ 'LANMAN': (_dovecotpw, 0x10000f00),
+ 'LDAP-MD5': (_md5_hash, 0x10000f00),
+ 'MD5': (_crypt_hash, 0x10000f00),
+ 'MD5-CRYPT': (_crypt_hash, 0x10000f00),
+ 'NTLM': (_ntlm_hash, 0x10000f00),
+ 'OTP': (_dovecotpw, 0x10100a01),
+ 'PLAIN': (_clear_hash, 0x10000f00),
+ 'PLAIN-MD4': (_md4_hash, 0x10000f00),
+ 'PLAIN-MD5': (_md5_hash, 0x10000f00),
+ 'RPA': (_dovecotpw, 0x10000f00),
+ 'SHA': (_sha1_hash, 0x10000f00),
+ 'SHA1': (_sha1_hash, 0x10000f00),
+ 'SHA256': (_sha256_hash, 0x10100a01),
+ 'SHA512': (_sha512_hash, 0x20000b03),
+ 'SKEY': (_dovecotpw, 0x10100a01),
+ 'SMD5': (_smd5_hash, 0x10000f00),
+ 'SSHA': (_ssha1_hash, 0x10000f00),
+ 'SSHA256': (_ssha256_hash, 0x10200a04),
+ 'SSHA512': (_ssha512_hash, 0x20000b03),
+}
+
+
+def verify_scheme(scheme):
+ """Checks if the password scheme *scheme* is known and supported by the
+ configured `misc.dovecot_version`.
+
+ The *scheme* maybe a password scheme's name (e.g.: 'PLAIN') or a scheme
+ name with a encoding suffix (e.g. 'PLAIN.BASE64'). If the scheme is
+ known and supported by the used Dovecot version,
+ a tuple ``(scheme, encoding)`` will be returned.
+ The `encoding` in the tuple may be `None`.
+
+ Raises a `VMMError` if the password scheme:
+ * is unknown
+ * depends on a newer Dovecot version
+ * has a unknown encoding suffix
+ """
+ assert isinstance(scheme, basestring), 'Not a str/unicode: %r' % scheme
+ scheme_encoding = scheme.upper().split('.')
+ scheme = scheme_encoding[0]
+ if scheme not in _scheme_info:
+ raise VMMError(_(u"Unsupported password scheme: '%s'") % scheme,
+ VMM_ERROR)
+ if cfg_dget('misc.dovecot_version') < _scheme_info[scheme][1]:
+ raise VMMError(_(u"The password scheme '%(scheme)s' requires Dovecot "
+ u">= v%(version)s") % {'scheme': scheme,
+ 'version': version_str(_scheme_info[scheme][1])},
+ VMM_ERROR)
+ if len(scheme_encoding) > 1:
+ if cfg_dget('misc.dovecot_version') < 0x10100a01:
+ raise VMMError(_(u'Encoding suffixes for password schemes require '
+ u'Dovecot >= v1.1.alpha1'), VMM_ERROR)
+ if scheme_encoding[1] not in ('B64', 'BASE64', 'HEX'):
+ raise VMMError(_(u"Unsupported password encoding: '%s'") %
+ scheme_encoding[1], VMM_ERROR)
+ encoding = scheme_encoding[1]
+ else:
+ encoding = None
+ return scheme, encoding
+
+
+def pwhash(password, scheme=None, user=None):
+ """Generates a password hash from the plain text *password* string.
+
+ If no *scheme* is given the password scheme from the configuration will
+ be used for the hash generation. When 'DIGEST-MD5' is used as scheme,
+ also an EmailAddress instance must be given as *user* argument.
+ """
+ if not isinstance(password, basestring):
+ raise TypeError('Password is not a string: %r' % password)
+ if isinstance(password, unicode):
+ password = password.encode(ENCODING)
+ password = password.strip()
+ if not password:
+ raise ValueError("Couldn't accept empty password.")
+ if scheme is None:
+ scheme = cfg_dget('misc.password_scheme')
+ scheme, encoding = verify_scheme(scheme)
+ if scheme == 'DIGEST-MD5':
+ assert isinstance(user, EmailAddress)
+ return _md5_hash(password, scheme, encoding, user)
+ return _scheme_info[scheme][0](password, scheme, encoding)
+
+
+def randompw():
+ """Generates a plain text random password.
+
+ The length of the password can be configured in the ``vmm.cfg``
+ (account.password_length).
+ """
+ pw_len = cfg_dget('account.password_length')
+ if pw_len < 8:
+ pw_len = 8
+ return ''.join(_sys_rand.sample(PASSWDCHARS, pw_len))
+
+
+def _test_crypt_algorithms():
+ """Check for Blowfish/SHA-256/SHA-512 support in crypt.crypt()."""
+ _blowfish = '$2a$04$0123456789abcdefABCDE.N.drYX5yIAL1LkTaaZotW3yI0hQhZru'
+ _sha256 = '$5$rounds=1000$0123456789abcdef$K/DksR0DT01hGc8g/kt9McEgrbFMKi\
+9qrb1jehe7hn4'
+ _sha512 = '$6$rounds=1000$0123456789abcdef$ZIAd5WqfyLkpvsVCVUU1GrvqaZTqvh\
+JoouxdSqJO71l9Ld3tVrfOatEjarhghvEYADkq//LpDnTeO90tcbtHR1'
+
+ if crypt('08/15!test~4711', '$2a$04$0123456789abcdefABCDEF$') == _blowfish:
+ _scheme_info['BLF-CRYPT'] = (_crypt_hash, 0x10000f00)
+ if crypt('08/15!test~4711', '$5$rounds=1000$0123456789abcdef$') == _sha256:
+ _scheme_info['SHA256-CRYPT'] = (_crypt_hash, 0x10000f00)
+ if crypt('08/15!test~4711', '$6$rounds=1000$0123456789abcdef$') == _sha512:
+ _scheme_info['SHA512-CRYPT'] = (_crypt_hash, 0x10000f00)
+
+_test_crypt_algorithms()
+del _, cfg_dget, _test_crypt_algorithms
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/VirtualMailManager/pycompat/__init__.py Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,38 @@
+# -*- coding: UTF-8 -*-
+# Copyright (c) 2010, Pascal Volk
+# See COPYING for distribution information.
+
+"""
+ VirtualMailManager.pycompat
+
+ VirtualMailManager's compatibility stuff for Python 2.4
+"""
+
+# http://docs.python.org/library/functions.html#all
+try:
+ all = all
+except NameError:
+ def all(iterable):
+ """Return True if all elements of the *iterable* are true
+ (or if the iterable is empty).
+
+ """
+ for element in iterable:
+ if not element:
+ return False
+ return True
+
+
+# http://docs.python.org/library/functions.html#any
+try:
+ any = any
+except NameError:
+ def any(iterable):
+ """Return True if any element of the *iterable* is true. If the
+ iterable is empty, return False.
+
+ """
+ for element in iterable:
+ if element:
+ return True
+ return False
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/VirtualMailManager/pycompat/hashlib.py Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,58 @@
+# -*- coding: UTF-8 -*-
+# Copyright (c) 2010, Pascal Volk
+# See COPYING for distribution information.
+
+"""
+ VirtualMailManager.pycompat.hashlib
+
+ VirtualMailManager's minimal hashlib emulation for Python 2.4
+
+ hashlib.md5(...), hashlib.sha1(...), hashlib.new('md5', ...) and
+ hashlib.new('sha1', ...) will work always.
+
+ When the PyCrypto module <http://www.pycrypto.org/> could be found in
+ sys.path hashlib.new('md4', ...) will also work.
+
+ With PyCrypto >= 2.1.0alpha1 hashlib.new('sha256', ...) and
+ hashlib.sha256(...) becomes functional.
+"""
+
+
+import md5 as _md5
+import sha as _sha1
+
+try:
+ import Crypto
+except ImportError:
+ _md4 = None
+ SHA256 = None
+else:
+ from Crypto.Hash import MD4 as _md4
+ if hasattr(Crypto, 'version_info'): # <- Available since v2.1.0alpha1
+ from Crypto.Hash import SHA256 # SHA256 works since v2.1.0alpha1
+ sha256 = SHA256.new
+ else:
+ SHA256 = None
+ del Crypto
+
+
+compat = 0x01
+md5 = _md5.new
+sha1 = _sha1.new
+
+
+def new(name, string=''):
+ """Return a new hashing object using the named algorithm, optionally
+ initialized with the provided string.
+ """
+ if name in ('md5', 'MD5'):
+ return _md5.new(string)
+ if name in ('sha1', 'SHA1'):
+ return _sha1.new(string)
+ if not _md4:
+ raise ValueError('unsupported hash type')
+ if name in ('md4', 'MD4'):
+ return _md4.new(string)
+ if name in ('sha256', 'SHA256') and SHA256:
+ return SHA256.new(string)
+ raise ValueError('unsupported hash type')
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/VirtualMailManager/relocated.py Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,114 @@
+# -*- coding: UTF-8 -*-
+# Copyright (c) 2008 - 2010, Pascal Volk
+# See COPYING for distribution information.
+"""
+ VirtualMailManager.relocated
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ Virtual Mail Manager's Relocated class to handle relocated users.
+"""
+
+from VirtualMailManager.domain import get_gid
+from VirtualMailManager.emailaddress import EmailAddress
+from VirtualMailManager.errors import RelocatedError as RErr
+from VirtualMailManager.constants import NO_SUCH_DOMAIN, \
+ NO_SUCH_RELOCATED, RELOCATED_ADDR_DEST_IDENTICAL, RELOCATED_EXISTS
+
+
+_ = lambda msg: msg
+
+
+class Relocated(object):
+ """Class to handle e-mail addresses of relocated users."""
+ __slots__ = ('_addr', '_dest', '_gid', '_dbh')
+
+ def __init__(self, dbh, address):
+ """Creates a new *Relocated* instance. The ``address`` is the
+ old e-mail address of the user.
+
+ Use `setDestination()` to set/update the new address, where the
+ user has moved to.
+
+ """
+ assert isinstance(address, EmailAddress)
+ self._addr = address
+ self._dbh = dbh
+ self._gid = get_gid(self._dbh, self._addr.domainname)
+ if not self._gid:
+ raise RErr(_(u"The domain '%s' doesn't exist.") %
+ self._addr.domainname, NO_SUCH_DOMAIN)
+ self._dest = None
+
+ self._load()
+
+ def __nonzero__(self):
+ """Returns `True` if the Relocated is known, `False` if it's new."""
+ return self._dest is not None
+
+ def _load(self):
+ """Loads the destination address from the database into the
+ `_dest` attribute.
+
+ """
+ dbc = self._dbh.cursor()
+ dbc.execute('SELECT destination FROM relocated WHERE gid = %s AND '
+ 'address = %s', (self._gid, self._addr.localpart))
+ destination = dbc.fetchone()
+ dbc.close()
+ if destination:
+ self._dest = EmailAddress(destination[0])
+
+ @property
+ def address(self):
+ """The Relocated's EmailAddress instance."""
+ return self._addr
+
+ def set_destination(self, destination):
+ """Sets/updates the new address of the relocated user."""
+ update = False
+ assert isinstance(destination, EmailAddress)
+ if self._addr == destination:
+ raise RErr(_(u'Address and destination are identical.'),
+ RELOCATED_ADDR_DEST_IDENTICAL)
+ if self._dest:
+ if self._dest == destination:
+ raise RErr(_(u"The relocated user '%s' already exists.") %
+ self._addr, RELOCATED_EXISTS)
+ else:
+ self._dest = destination
+ update = True
+ else:
+ self._dest = destination
+
+ dbc = self._dbh.cursor()
+ if not update:
+ dbc.execute('INSERT INTO relocated VALUES (%s, %s, %s)',
+ (self._gid, self._addr.localpart, str(self._dest)))
+ else:
+ dbc.execute('UPDATE relocated SET destination = %s WHERE gid = %s '
+ 'AND address = %s',
+ (str(self._dest), self._gid, self._addr.localpart))
+ self._dbh.commit()
+ dbc.close()
+
+ def get_info(self):
+ """Returns the address to which mails should be sent."""
+ if not self._dest:
+ raise RErr(_(u"The relocated user '%s' doesn't exist.") %
+ self._addr, NO_SUCH_RELOCATED)
+ return self._dest
+
+ def delete(self):
+ """Deletes the relocated entry from the database."""
+ if not self._dest:
+ raise RErr(_(u"The relocated user '%s' doesn't exist.") %
+ self._addr, NO_SUCH_RELOCATED)
+ dbc = self._dbh.cursor()
+ dbc.execute('DELETE FROM relocated WHERE gid = %s AND address = %s',
+ (self._gid, self._addr.localpart))
+ if dbc.rowcount > 0:
+ self._dbh.commit()
+ dbc.close()
+ self._dest = None
+
+del _
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/VirtualMailManager/transport.py Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,104 @@
+# -*- coding: UTF-8 -*-
+# Copyright (c) 2008 - 2010, Pascal Volk
+# See COPYING for distribution information.
+"""
+ VirtualMailManager.transport
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ Virtual Mail Manager's Transport class to manage the transport for
+ domains and accounts.
+"""
+
+from VirtualMailManager.constants import UNKNOWN_TRANSPORT_ID
+from VirtualMailManager.errors import TransportError
+from VirtualMailManager.pycompat import any
+
+_ = lambda msg: msg
+
+
+class Transport(object):
+ """A wrapper class that provides access to the transport table"""
+ __slots__ = ('_tid', '_transport', '_dbh')
+
+ def __init__(self, dbh, tid=None, transport=None):
+ """Creates a new Transport instance.
+
+ Either tid or transport must be specified. When both arguments
+ are given, tid will be used.
+
+ Keyword arguments:
+ dbh -- a pyPgSQL.PgSQL.connection
+ tid -- the id of a transport (int/long)
+ transport -- the value of the transport (str)
+
+ """
+ self._dbh = dbh
+ assert any((tid, transport))
+ if tid:
+ assert not isinstance(tid, bool) and isinstance(tid, (int, long))
+ self._tid = tid
+ self._load_by_id()
+ else:
+ assert isinstance(transport, basestring)
+ self._transport = transport
+ self._load_by_name()
+
+ @property
+ def tid(self):
+ """The transport's unique ID."""
+ return self._tid
+
+ @property
+ def transport(self):
+ """The transport's value, ex: 'dovecot:'"""
+ return self._transport
+
+ def __eq__(self, other):
+ if isinstance(other, self.__class__):
+ return self._tid == other._tid
+ return NotImplemented
+
+ def __ne__(self, other):
+ if isinstance(other, self.__class__):
+ return self._tid != other._tid
+ return NotImplemented
+
+ def __str__(self):
+ return self._transport
+
+ def _load_by_id(self):
+ """load a transport by its id from the database"""
+ dbc = self._dbh.cursor()
+ dbc.execute('SELECT transport FROM transport WHERE tid = %s',
+ (self._tid,))
+ result = dbc.fetchone()
+ dbc.close()
+ if result:
+ self._transport = result[0]
+ else:
+ raise TransportError(_(u'Unknown transport id specified.'),
+ UNKNOWN_TRANSPORT_ID)
+
+ def _load_by_name(self):
+ """Load a transport by its transport name from the database."""
+ dbc = self._dbh.cursor()
+ dbc.execute('SELECT tid FROM transport WHERE transport = %s',
+ (self._transport,))
+ result = dbc.fetchone()
+ dbc.close()
+ if result:
+ self._tid = result[0]
+ else:
+ self._save()
+
+ def _save(self):
+ """Save the new transport in the database."""
+ dbc = self._dbh.cursor()
+ dbc.execute("SELECT nextval('transport_id')")
+ self._tid = dbc.fetchone()[0]
+ dbc.execute('INSERT INTO transport VALUES (%s, %s)', (self._tid,
+ self._transport))
+ self._dbh.commit()
+ dbc.close()
+
+del _
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/Makefile Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,89 @@
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS =
+SPHINXBUILD = sphinx-build
+PAPER =
+BUILDDIR = build
+
+# Internal variables.
+PAPEROPT_a4 = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
+
+.PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest
+
+help:
+ @echo "Please use \`make <target>' where <target> is one of"
+ @echo " html to make standalone HTML files"
+ @echo " dirhtml to make HTML files named index.html in directories"
+ @echo " pickle to make pickle files"
+ @echo " json to make JSON files"
+ @echo " htmlhelp to make HTML files and a HTML help project"
+ @echo " qthelp to make HTML files and a qthelp project"
+ @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+ @echo " changes to make an overview of all changed/added/deprecated items"
+ @echo " linkcheck to check all external links for integrity"
+ @echo " doctest to run all doctests embedded in the documentation (if enabled)"
+
+clean:
+ -rm -rf $(BUILDDIR)/*
+
+html:
+ $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
+ @echo
+ @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
+
+dirhtml:
+ $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
+ @echo
+ @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+
+pickle:
+ $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
+ @echo
+ @echo "Build finished; now you can process the pickle files."
+
+json:
+ $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
+ @echo
+ @echo "Build finished; now you can process the JSON files."
+
+htmlhelp:
+ $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
+ @echo
+ @echo "Build finished; now you can run HTML Help Workshop with the" \
+ ".hhp project file in $(BUILDDIR)/htmlhelp."
+
+qthelp:
+ $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
+ @echo
+ @echo "Build finished; now you can run "qcollectiongenerator" with the" \
+ ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
+ @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/vmm.qhcp"
+ @echo "To view the help file:"
+ @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/vmm.qhc"
+
+latex:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo
+ @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
+ @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
+ "run these through (pdf)latex."
+
+changes:
+ $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
+ @echo
+ @echo "The overview file is in $(BUILDDIR)/changes."
+
+linkcheck:
+ $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
+ @echo
+ @echo "Link check complete; look for any errors in the above output " \
+ "or in $(BUILDDIR)/linkcheck/output.txt."
+
+doctest:
+ $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
+ @echo "Testing of doctests in the sources finished, look at the " \
+ "results in $(BUILDDIR)/doctest/output.txt."
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/source/conf.py Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,201 @@
+# -*- coding: utf-8 -*-
+#
+# vmm documentation build configuration file, created by
+# sphinx-quickstart on Sun Feb 14 00:08:08 2010.
+#
+# This file is execfile()d with the current directory set to its containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import sys, os
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+#sys.path.append(os.path.abspath('.'))
+
+# -- General configuration -----------------------------------------------------
+
+# Add any Sphinx extension module names here, as strings. They can be extensions
+# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
+extensions = ['sphinx.ext.intersphinx', 'sphinx.ext.todo']
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['.templates']
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The encoding of source files.
+#source_encoding = 'utf-8'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = u'vmm'
+copyright = u'2010, Pascal Volk'
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = '0.6'
+# The full version, including alpha/beta/rc tags.
+release = '0.6.x'
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#today_fmt = '%B %d, %Y'
+
+# List of documents that shouldn't be included in the build.
+#unused_docs = []
+
+# List of directories, relative to source directory, that shouldn't be searched
+# for source files.
+exclude_trees = []
+
+# The reST default role (used for this markup: `text`) to use for all documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# A list of ignored prefixes for module index sorting.
+#modindex_common_prefix = []
+
+
+# -- Options for HTML output ---------------------------------------------------
+
+# The theme to use for HTML and HTML Help pages. Major themes that come with
+# Sphinx are currently 'default' and 'sphinxdoc'.
+html_theme = 'default'
+#html_theme = 'sphinxdoc'
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further. For a list of options available for each theme, see the
+# documentation.
+#html_theme_options = {}
+
+# Add any paths that contain custom themes here, relative to this directory.
+#html_theme_path = []
+
+# The name for this set of Sphinx documents. If None, it defaults to
+# "<project> v<release> documentation".
+#html_title = None
+
+# A shorter title for the navigation bar. Default is the same as html_title.
+#html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+#html_logo = None
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+#html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = ['.static']
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+#html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+#html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = {}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+#html_additional_pages = {}
+
+# If false, no module index is generated.
+#html_use_modindex = True
+
+# If false, no index is generated.
+#html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+#html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+#html_show_sourcelink = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it. The value of this option must be the
+# base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = ''
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'vmmdoc'
+
+
+# -- Options for LaTeX output --------------------------------------------------
+
+# The paper size ('letter' or 'a4').
+#latex_paper_size = 'letter'
+
+# The font size ('10pt', '11pt' or '12pt').
+#latex_font_size = '10pt'
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title, author, documentclass [howto/manual]).
+latex_documents = [
+ ('index', 'vmm.tex', u'vmm Documentation',
+ u'Pascal Volk', 'manual'),
+]
+
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+#latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+#latex_use_parts = False
+
+# Additional stuff for the LaTeX preamble.
+#latex_preamble = ''
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+#latex_use_modindex = True
+
+
+# Example configuration for intersphinx: refer to the Python standard library.
+intersphinx_mapping = {'http://docs.python.org/': None}
+
+todo_include_todos = True
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/source/index.rst Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,29 @@
+======================
+VirtualMailManager API
+======================
+
+:Author: Pascal Volk <neverseen@users.sourceforge.net>
+:Date: |today|
+:Release: |version|
+
+Contents:
+
+.. toctree::
+ :maxdepth: 1
+ :numbered:
+
+ vmm.rst
+ vmm_config.rst
+ vmm_emailaddress.rst
+ vmm_alias.rst
+ vmm_relocated.rst
+ vmm_errors.rst
+ vmm_constants_error.rst
+
+Indices and tables
+==================
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/source/vmm.rst Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,132 @@
+:mod:`VirtualMailManager` --- Initialization code and some functions
+=====================================================================
+
+.. module:: VirtualMailManager
+ :synopsis: Initialization code and some functions
+
+.. moduleauthor:: Pascal Volk <neverseen@users.sourceforge.net>
+
+.. toctree::
+ :maxdepth: 2
+
+When the VirtualMailManager module, or one of its sub modules, is imported,
+the following actions will be performed:
+
+ - :func:`locale.setlocale` (with :const:`locale.LC_ALL`) is called, to set
+ :const:`ENCODING`
+ - :func:`gettext.install` is called, to have 18N support.
+
+Constants and data
+------------------
+
+.. data:: ENCODING
+
+ The systems current character encoding, e.g. ``'UTF-8'`` or
+ ``'ANSI_X3.4-1968'`` (aka ASCII).
+
+
+Functions
+---------
+
+.. function:: ace2idna(domainname)
+
+ Converts the idn domain name *domainname* into punycode.
+
+ :param domainname: the domain-ace representation (``xn--…``)
+ :type domainname: str
+ :rtype: unicode
+
+.. function:: check_domainname(domainname)
+
+ Returns the validated domain name *domainname*.
+
+ It also converts the name of the domain from IDN to ASCII, if necessary.
+
+ :param domainname: the name of the domain
+ :type domainname: :obj:`basestring`
+ :rtype: str
+ :raise VirtualMailManager.errors.VMMError: if the domain name is
+ too long or doesn't look like a valid domain name (label.label.label).
+
+.. function:: check_localpart(localpart)
+
+ Returns the validated local-part *localpart* of an e-mail address.
+
+ :param localpart: The local-part of an e-mail address.
+ :type localpart: str
+ :rtype: str
+ :raise VirtualMailManager.errors.VMMError: if the local-part is too
+ long or contains invalid characters.
+
+.. function:: exec_ok(binary)
+
+ Checks if the *binary* exists and if it is executable.
+
+ :param binary: path to the binary
+ :type binary: str
+ :rtype: str
+ :raise VirtualMailManager.errors.VMMError: if *binary* isn't a file
+ or is not executable.
+
+.. function:: expand_path(path)
+
+ Expands paths, starting with ``.`` or ``~``, to an absolute path.
+
+ :param path: Path to a file or directory
+ :type path: str
+ :rtype: str
+
+.. function:: get_unicode(string)
+
+ Converts `string` to `unicode`, if necessary.
+
+ :param string: The string taht should be converted
+ :type string: str
+ :rtype: unicode
+
+.. function:: idn2ascii(domainname)
+
+ Converts the idn domain name *domainname* into punycode.
+
+ :param domainname: the unicode representation of the domain name
+ :type domainname: unicode
+ :rtype: str
+
+.. function:: is_dir(path)
+
+ Checks if *path* is a directory.
+
+ :param path: Path to a directory
+ :type path: str
+ :rtype: str
+ :raise VirtualMailManager.errors.VMMError: if *path* is not a directory.
+
+
+Examples
+--------
+
+ >>> from VirtualMailManager import *
+ >>> ace2idna('xn--pypal-4ve.tld')
+ u'p\u0430ypal.tld'
+ >>> idn2ascii(u'öko.de')
+ 'xn--ko-eka.de'
+ >>> check_domainname(u'pаypal.tld')
+ 'xn--pypal-4ve.tld'
+ >>> check_localpart('john.doe')
+ 'john.doe'
+ >>> exec_ok('usr/bin/vim')
+ Traceback (most recent call last):
+ File "<stdin>", line 1, in <module>
+ File "./VirtualMailManager/__init__.py", line 93, in exec_ok
+ NO_SUCH_BINARY)
+ VirtualMailManager.errors.VMMError: 'usr/bin/vim' is not a file
+ >>> exec_ok('/usr/bin/vim')
+ '/usr/bin/vim'
+ >>> expand_path('.')
+ '/home/user/hg/vmm'
+ >>> get_unicode('hello world')
+ u'hello world'
+ >>> is_dir('~/hg')
+ '/home/user/hg'
+ >>>
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/source/vmm_alias.rst Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,87 @@
+:mod:`VirtualMailManager.Alias` --- Handling of alias e-mail addresses
+======================================================================
+
+.. module:: VirtualMailManager.Alias
+ :synopsis: Handling of alias e-mail addresses
+
+.. moduleauthor:: Pascal Volk <neverseen@users.sourceforge.net>
+
+.. toctree::
+ :maxdepth: 2
+
+
+This module provides the :class:`Alias` class. The data are read from/stored
+in the ``alias`` table. This table is used by Postfix to rewrite recipient
+addresses.
+
+
+Alias
+---------
+.. class:: Alias(dbh, address)
+
+ Creates a new *Alias* instance. Alias instances provides the :func:`__len__`
+ method. So the existence of an alias in the database can be tested with a
+ simple if condition.
+
+ :param dbh: a database connection
+ :type dbh: :class:`pyPgSQL.PgSQL.Connection`
+ :param address: the alias e-mail address.
+ :type address: :class:`VirtualMailManager.EmailAddress.EmailAddress`
+
+ .. method:: add_destinations(destinations, expansion_limit [, warnings=None])
+
+ Adds the *destinations* to the destinations of the alias. This method
+ returns a ``set`` of all addresses which successfully were stored into the
+ database.
+
+ If one of the e-mail addresses in *destinations* is the same as the alias
+ address, it will be silently discarded. Destination addresses, that are
+ already assigned to the alias, will be also ignored.
+
+ When the optional *warnings* list is given, all ignored addresses will be
+ appended to it.
+
+ :param destinations: The destination addresses of the alias
+ :type destinations: :obj:`list` of
+ :class:`VirtualMailManager.EmailAddress.EmailAddress` instances
+ :param expansion_limit: The maximal number of destinations (see also:
+ `virtual_alias_expansion_limit
+ <http://www.postfix.org/postconf.5.html#virtual_alias_expansion_limit>`_)
+ :type expansion_limit: :obj:`int`
+ :param warnings: A optional list, to record all ignored addresses
+ :type warnings: :obj:`list`
+ :rtype: :obj:`set`
+ :raise VirtualMailManager.errors.AliasError: if the additional
+ *destinations* will exceed the *expansion_limit* or if the alias
+ already exceeds its *expansion_limit*.
+
+ .. seealso:: :mod:`VirtualMailManager.ext.postconf` -- to read actual
+ values of Postfix configuration parameters.
+
+
+ .. method:: del_destination(destination)
+
+ Deletes the given *destination* address from the alias.
+
+ :param destination: a destination address of the alias
+ :type destination: :class:`VirtualMailManager.EmailAddress.EmailAddress`
+ :rtype: :obj:`None`
+ :raise VirtualMailManager.errors.AliasError: if the destination wasn't
+ assigned to the alias or the alias doesn't exist.
+
+
+ .. method:: delete()
+
+ Deletes the alias with all its destinations.
+
+ :rtype: :obj:`None`
+ :raise VirtualMailManager.errors.AliasError: if the alias doesn't exist.
+
+
+ .. method:: get_destinations()
+
+ Returns an iterator for all destinations (``EmailAddress`` instances) of
+ the alias.
+
+ :rtype: :obj:`listiterator`
+ :raise VirtualMailManager.errors.AliasError: if the alias doesn't exist.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/source/vmm_config.rst Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,275 @@
+:mod:`VirtualMailManager.Config` --- Simplified configuration access
+======================================================================
+
+.. module:: VirtualMailManager.Config
+ :synopsis: Simplified configuration access
+
+.. moduleauthor:: Pascal Volk <neverseen@users.sourceforge.net>
+
+.. toctree::
+ :maxdepth: 2
+
+
+This module provides a few classes for simplified configuration handling
+and the validation of the setting's *type* and *value*.
+
+:class:`LazyConfig` is derived from Python's
+:class:`ConfigParser.RawConfigParser`. It doesn't use ``RawConfigParser``'s
+``DEFAULT`` section. All settings and their defaults, if supposed, are
+handled by :class:`LazyConfigOption` objects in the :attr:`LazyConfig._cfg`
+*dict*.
+
+``LazyConfig``'s setters and getters for options are taking a single string
+for the *section* and *option* argument, e.g. ``config.pget('database.user')``
+instead of ``config.get('database', 'user')``.
+
+
+
+LazyConfig
+----------
+.. class:: LazyConfig
+
+ Bases: :class:`ConfigParser.RawConfigParser`
+
+ .. versionadded:: 0.6.0
+
+ .. attribute:: _cfg
+
+ a multi dimensional :class:`dict`, containing *sections* and *options*,
+ represented by :class:`LazyConfigOption` objects.
+
+ For example::
+
+ from VirtualMailManager.Config import LazyConfig, LazyConfigOption
+
+ class FooConfig(LazyConfig):
+ def __init__(self, ...):
+ LazyConfig.__init__(self)
+ ...
+ LCO = LazyConfigOption
+ self._cfg = {
+ 'database': {# section database:
+ 'host': LCO(str, '::1', self.get), # options of the
+ 'name': LCO(str, 'dbx', self.get), # database section.
+ 'pass': LCO(str, None, self.get), # No defaults for the
+ 'user': LCO(str, None, self.get), # user and pass options
+ }
+ }
+
+ ...
+
+
+ .. method:: bool_new(value)
+
+ Converts the string *value* into a `bool` and returns it.
+
+ | ``'1'``, ``'on'``, ``'yes'`` and ``'true'`` will become :const:`True`
+ | ``'0'``, ``'off'``, ``'no'`` and ``'false'`` will become :const:`False`
+
+ :param value: one of the above mentioned strings
+ :type value: :obj:`basestring`
+ :rtype: bool
+ :raise ConfigValueError: for all other values, except ``bool``\ s
+
+ .. method:: dget(option)
+
+ Like :meth:`pget`, but returns the *option*'s default value, from
+ :attr:`_cfg` (defined by :attr:`LazyConfigOption.default`) if the *option*
+ is not configured in a ini-like configuration file.
+
+ :param option: the section.option combination
+ :type option: :obj:`basestring`
+ :raise NoDefaultError: if the *option* couldn't be found in the
+ configuration file and no default value was passed to
+ :class:`LazyConfigOption`'s constructor for the requested *option*.
+
+ .. method:: getboolean(section, option)
+
+ Returns the boolean value of the *option*, in the given *section*.
+
+ For a boolean :const:`True`, the value must be set to ``'1'``, ``'on'``,
+ ``'yes'``, ``'true'`` or :const:`True`. For a boolean :const:`False`, the
+ value must set to ``'0'``, ``'off'``, ``'no'``, ``'false'`` or
+ :const:`False`.
+
+ :param section: The section's name
+ :type section: :obj:`basestring`
+ :param option: The option's name
+ :type option: :obj:`basestring`
+ :rtype: bool
+ :raise ValueError: if the option has an other value than the values
+ mentioned above.
+
+ .. method:: has_option(option)
+
+ Checks if the *option* (section\ **.**\ option) is a known configuration
+ option.
+
+ :param option: The option's name
+ :type option: :obj:`basestring`
+ :rtype: bool
+
+ .. method:: has_section(section)
+
+ Checks if *section* is a known configuration section.
+
+ :param section: The section's name
+ :type section: :obj:`basestring`
+ :rtype: bool
+
+ .. method:: items(section)
+
+ Returns an iterator for ``key, value`` :obj:`tuple`\ s for each option in
+ the given *section*.
+
+ :param section: The section's name
+ :type section: :obj:`basestring`
+ :raise NoSectionError: if the given *section* is not known.
+
+ .. method:: pget(option)
+
+ Polymorphic getter which returns the *option*'s value (by calling
+ :attr:`LazyConfigOption.getter`) with the appropriate type, defined by
+ :attr:`LazyConfigOption.cls`.
+
+ :param option: the section.option combination
+ :type option: :obj:`basestring`
+
+ .. method:: sections()
+
+ Returns an iterator object for all configuration sections from the
+ :attr:`_cfg` dictionary.
+
+ :rtype: :obj:`dictionary-keyiterator`
+
+ .. method:: set(option, value)
+
+ Like :meth:`ConfigParser.RawConfigParser.set`, but converts the *option*'s
+ new *value* (by calling :attr:`LazyConfigOption.cls`) to the appropriate
+ type/class. When the ``LazyConfigOption``'s optional parameter *validate*
+ was not :const:`None`, the new *value* will be also validated.
+
+ :param option: the section.option combination
+ :type option: :obj:`basestring`
+ :param value: the new value to be set
+ :type value: :obj:`basestring`
+ :rtype: :const:`None`
+ :raise ConfigValueError: if a boolean value shout be set (:meth:`bool_new`)
+ and it fails
+ :raise ValueError: if an other setter (:attr:`LazyConfigOption.cls`) or
+ validator (:attr:`LazyConfigOption.validate`) fails.
+ :raise VirtualMailManager.errors.VMMError: if
+ :attr:`LazyConfigOption.validate` is set to
+ :func:`VirtualMailManager.exec_ok` or :func:`VirtualMailManager.is_dir`.
+
+
+LazyConfigOption
+----------------
+LazyConfigOption instances are required by :class:`LazyConfig` instances, and
+instances of classes derived from `LazyConfig`, like the :class:`Config`
+class.
+
+.. class:: LazyConfigOption (cls, default, getter[, validate=None])
+
+ .. versionadded:: 0.6.0
+
+ The constructor's parameters are:
+
+ ``cls`` : :obj:`type`
+ The class/type of the option's value.
+ ``default`` : :obj:`str` or the one defined by ``cls``
+ Default value of the option. Use :const:`None` if the option shouldn't
+ have a default value.
+ ``getter``: :obj:`callable`
+ A method's name of :class:`ConfigParser.RawConfigParser` and derived
+ classes, to get a option's value, e.g. `self.getint`.
+ ``validate`` : :obj:`callable` or :const:`None`
+ :const:`None` or any function, which takes one argument and returns the
+ validated argument with the appropriate type (for example:
+ :meth:`LazyConfig.bool_new`). The function should raise a
+ :exc:`ConfigValueError` if the validation fails. This function checks the
+ new value when :meth:`LazyConfig.set()` is called.
+
+ Each LazyConfigOption object has the following read-only attributes:
+
+ .. attribute:: cls
+
+ The class of the option's value e.g. `str`, `unicode` or `bool`. Used as
+ setter method when :meth:`LazyConfig.set` (or the ``set()`` method of a
+ derived class) is called.
+
+ .. attribute:: default
+
+ The option's default value, may be ``None``
+
+ .. attribute:: getter
+
+ A method's name of :class:`ConfigParser.RawConfigParser` and derived
+ classes, to get a option's value, e.g. ``self.getint``.
+
+ .. attribute:: validate
+
+ A method or function to validate the option's new value.
+
+
+Config
+------
+The final configuration class of the virtual mail manager.
+
+.. class:: Config (filename)
+
+ Bases: :class:`LazyConfig`
+
+ :param filename: absolute path to the configuration file.
+ :type filename: :obj:`basestring`
+
+ .. attribute:: _cfg
+
+ The configuration ``dict``, containing all configuration sections and
+ options, as described in :attr:`LazyConfig._cfg`.
+
+ .. method:: check()
+
+ Checks all section's options for settings w/o a default value.
+
+ :raise VirtualMailManager.errors.ConfigError: if the check fails
+
+ .. method:: load()
+
+ Loads the configuration read-only.
+
+ :raise VirtualMailManager.errors.ConfigError: if the
+ configuration syntax is invalid
+
+ .. method:: unicode(section, option)
+
+ Returns the value of the *option* from *section*, converted to Unicode.
+ This method is intended for the :attr:`LazyConfigOption.getter`.
+
+ :param section: The name of the configuration section
+ :type section: :obj:`basestring`
+ :param option: The name of the configuration option
+ :type option: :obj:`basestring`
+ :rtype: :obj:`unicode`
+
+
+Exceptions
+----------
+
+.. exception:: BadOptionError(msg)
+
+ Bases: :exc:`ConfigParser.Error`
+
+ Raised when a option isn't in the format 'section.option'.
+
+.. exception:: ConfigValueError(msg)
+
+ Bases: :exc:`ConfigParser.Error`
+
+ Raised when creating or validating of new values fails.
+
+.. exception:: NoDefaultError(section, option)
+
+ Bases: :exc:`ConfigParser.Error`
+
+ Raised when the requested option has no default value.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/source/vmm_constants_error.rst Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,227 @@
+:mod:`VirtualMailManager.constants.ERROR` --- Error codes
+=========================================================
+
+.. module:: VirtualMailManager.constants.ERROR
+ :synopsis: VirtualMailManager's error codes
+
+.. moduleauthor:: Pascal Volk <neverseen@users.sourceforge.net>
+
+.. toctree::
+ :maxdepth: 2
+
+Error codes, used by all :mod:`VirtualMailManager.errors`.
+
+.. data:: ACCOUNT_AND_ALIAS_PRESENT
+
+ Can't delete the Domain - there are accounts and aliases assigned
+
+.. data:: ACCOUNT_EXISTS
+
+ The Account exists already
+
+.. data:: ACCOUNT_PRESENT
+
+ Can't delete the Domain - there are accounts
+
+.. data:: ALIASDOMAIN_EXISTS
+
+ Can't save/switch the destination of the AliasDomain - old and new destination
+ are the same.
+
+.. data:: ALIASDOMAIN_ISDOMAIN
+
+ Can't create AliasDomain - there is already a Domain with the given name
+
+ .. todo:: Move the related check to the Handler class
+
+.. data:: ALIASDOMAIN_NO_DOMDEST
+
+ Can't save/switch the destination of an AliasDomain if the destination was
+ omitted
+
+.. data:: ALIAS_ADDR_DEST_IDENTICAL
+
+ The alias address and its destination are the same
+
+ obsolete?
+
+.. data:: ALIAS_EXCEEDS_EXPANSION_LIMIT
+
+ The Alias has reached or exceeds its expansion limit
+
+.. data:: ALIAS_EXISTS
+
+ Alias with the given destination exists already
+
+ obsolete?
+
+.. data:: ALIAS_MISSING_DEST
+
+ obsolete?
+
+.. data:: ALIAS_PRESENT
+
+ Can't delete Domain or Account - there are aliases assigned
+
+.. data:: CONF_ERROR
+
+ Syntax error in the configuration file or missing settings w/o a default value
+
+.. data:: CONF_NOFILE
+
+ The configuration file couldn't be found
+
+.. data:: CONF_NOPERM
+
+ The user's permissions are insufficient
+
+.. data:: CONF_WRONGPERM
+
+ Configuration file has the wrong access mode
+
+.. data:: DATABASE_ERROR
+
+ A database error occurred
+
+.. data:: DOMAINDIR_GROUP_MISMATCH
+
+ Domain directory is owned by the wrong group
+
+.. data:: DOMAIN_ALIAS_EXISTS
+
+ Can't create Domain - there is already an AliasDomain with the same name
+
+ .. todo:: Move the related check to the Handler class
+
+.. data:: DOMAIN_EXISTS
+
+ The Domain is already available in the database
+
+.. data:: DOMAIN_INVALID
+
+ The domain name is invalid
+
+.. data:: DOMAIN_NO_NAME
+
+ Missing the domain name
+
+.. data:: DOMAIN_TOO_LONG
+
+ The length of domain is > 255
+
+.. data:: FOUND_DOTS_IN_PATH
+
+ Can't delete directory with ``.`` or ``..`` in path
+
+ .. todo:: check if we can solve this issue with expand_path()
+
+.. data:: INVALID_ADDRESS
+
+ The specified value doesn't look like a e-mail address
+
+.. data:: INVALID_AGUMENT
+
+ The given argument is invalid
+
+.. data:: INVALID_OPTION
+
+ The given option is invalid
+
+.. data:: INVALID_SECTION
+
+ The section is not a known configuration section
+
+.. data:: LOCALPART_INVALID
+
+ The local-part of an e-mail address was omitted or is invalid
+
+.. data:: LOCALPART_TOO_LONG
+
+ The local-part (w/o a extension) is too long (> 64)
+
+.. data:: MAILDIR_PERM_MISMATCH
+
+ The Maildir is owned by the wrong user/group
+
+.. data:: MAILLOCATION_INIT
+
+ Can't create a new MailLocation instance
+
+ obsolete?
+
+.. data:: NOT_EXECUTABLE
+
+ The binary is not executable
+
+.. data:: NO_SUCH_ACCOUNT
+
+ No Account with the given e-mail address
+
+.. data:: NO_SUCH_ALIAS
+
+ No Alias with the given e-mail address
+
+.. data:: NO_SUCH_ALIASDOMAIN
+
+ The given domain is not an AliasDomain
+
+.. data:: NO_SUCH_BINARY
+
+ Can't find the file at the specified location
+
+.. data:: NO_SUCH_DIRECTORY
+
+ There is no directory with the given path
+
+.. data:: NO_SUCH_DOMAIN
+
+ No Domain with the given name
+
+.. data:: NO_SUCH_RELOCATED
+
+ There is no Relocated user with the given e-mail address
+
+.. data:: RELOCATED_ADDR_DEST_IDENTICAL
+
+ The e-mail address of the Relocated user an its destination are the same
+
+.. data:: RELOCATED_EXISTS
+
+ Can't create Account or Alias, there is already a Relocated user with the
+ given e-mail address
+
+.. data:: RELOCATED_MISSING_DEST
+
+ obsolete?
+
+.. data:: TRANSPORT_INIT
+
+ Can't initialize a new Transport instance
+
+ obsolete?
+
+.. data:: UNKNOWN_MAILLOCATION_ID
+
+ There is no MailLocation entry with the given ID
+
+ obsolete?
+
+.. data:: UNKNOWN_SERVICE
+
+ The specified service is unknown
+
+.. data:: UNKNOWN_TRANSPORT_ID
+
+ There is no Transport entry with the given ID
+
+.. data:: UNKNOWN_MAILLOCATION_NAME
+
+ The given mail_location directory couldn't be accepted
+
+.. data:: VMM_ERROR
+
+ Internal error
+
+.. data:: VMM_TOO_MANY_FAILURES
+
+ Too many errors in interactive mode
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/source/vmm_emailaddress.rst Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,61 @@
+:mod:`VirtualMailManager.EmailAddress` --- Handling of e-mail addresses
+=======================================================================
+
+.. module:: VirtualMailManager.EmailAddress
+ :synopsis: Handling of e-mail addresses
+
+.. moduleauthor:: Pascal Volk <neverseen@users.sourceforge.net>
+
+.. toctree::
+ :maxdepth: 2
+
+
+This module provides the :class:`EmailAddress` class to handle validated e-mail
+addresses.
+
+
+EmailAddress
+------------
+
+.. class:: EmailAddress(address)
+
+ Creates a new EmailAddress instance.
+
+ :param address: string representation of an e-mail addresses
+ :type address: :obj:`basestring`
+ :raise VirtualMailManager.errors.EmailAddressError: if the
+ *address* is syntactically wrong.
+ :raise VirtualMailManager.errors.VMMError: if the validation of the
+ local-part or domain name fails.
+
+ An EmailAddress instance has the both read-only attributes:
+
+ .. attribute:: localpart
+
+ The local-part of the address *local-part@domain*
+
+
+ .. attribute:: domainname
+
+ The domain part of the address *local-part@domain*
+
+
+Examples
+--------
+
+ >>> from VirtualMailManager.EmailAddress import EmailAddress
+ >>> john = EmailAddress('john.doe@example.com')
+ >>> john.localpart
+ 'john.doe'
+ >>> john.domainname
+ 'example.com'
+ >>> jane = EmailAddress('jane.doe@example.com')
+ >>> jane != john
+ True
+ >>> EmailAddress('info@xn--pypal-4ve.tld') == EmailAddress(u'info@pаypal.tld')
+ True
+ >>> jane
+ EmailAddress('jane.doe@example.com')
+ >>> print john
+ john.doe@example.com
+ >>>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/source/vmm_errors.rst Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,122 @@
+:mod:`VirtualMailManager.errors` --- Exception classes
+======================================================
+
+.. module:: VirtualMailManager.errors
+ :synopsis: Exception classes
+
+.. moduleauthor:: Pascal Volk <neverseen@users.sourceforge.net>
+
+.. toctree::
+ :maxdepth: 2
+
+Exceptions, used by VirtualMailManager's classes.
+
+
+Exceptions
+----------
+
+.. exception:: VMMError(msg, code)
+
+ Bases: :exc:`exceptions.Exception`
+
+ :param msg: the error message
+ :type msg: :obj:`basestring`
+ :param code: the error code (one of :mod:`VirtualMailManager.constants.ERROR`)
+ :type code: :obj:`int`
+
+ Base class for all other Exceptions in the VirtualMailManager package.
+
+ The *msg* and *code* are accessible via the both attributes:
+
+ .. attribute:: msg
+
+ The error message of the exception.
+
+
+ .. attribute:: code
+
+ The numerical error code of the exception.
+
+
+.. exception:: ConfigError(msg, code)
+
+ Bases: :exc:`VirtualMailManager.errors.VMMError`
+
+ Exception class for configuration (:mod:`VirtualMailManager.Config`)
+ exceptions.
+
+
+.. exception:: PermissionError(msg, code)
+
+ Bases: :exc:`VirtualMailManager.errors.VMMError`
+
+ Exception class for file permission exceptions.
+
+
+.. exception:: NotRootError(msg, code)
+
+ Bases: :exc:`VirtualMailManager.errors.VMMError`
+
+ Exception class for non-root exceptions.
+
+
+.. exception:: DomainError(msg, code)
+
+ Bases: :exc:`VirtualMailManager.errors.VMMError`
+
+ Exception class for Domain (:mod:`VirtualMailManager.Domain`) exceptions.
+
+
+.. exception:: AliasDomainError(msg, code)
+
+ Bases: :exc:`VirtualMailManager.errors.VMMError`
+
+ Exception class for AliasDomain (:mod:`VirtualMailManager.AliasDomain`)
+ exceptions.
+
+
+.. exception:: AccountError(msg, code)
+
+ Bases: :exc:`VirtualMailManager.errors.VMMError`
+
+ Exception class for Account (:mod:`VirtualMailManager.Account`) exceptions.
+
+
+.. exception:: AliasError(msg, code)
+
+ Bases: :exc:`VirtualMailManager.errors.VMMError`
+
+ Exception class for Alias (:mod:`VirtualMailManager.Alias`) exceptions.
+
+
+.. exception:: EmailAddressError(msg, code)
+
+ Bases: :exc:`VirtualMailManager.errors.VMMError`
+
+ Exception class for EmailAddress (:mod:`VirtualMailManager.EmailAddress`)
+ exceptions.
+
+
+.. exception:: MailLocationError(msg, code)
+
+ Bases: :exc:`VirtualMailManager.errors.VMMError`
+
+ Exception class for MailLocation (:mod:`VirtualMailManager.MailLocation`)
+ exceptions.
+
+
+.. exception:: RelocatedError(msg, code)
+
+ Bases: :exc:`VirtualMailManager.errors.VMMError`
+
+ Exception class for Relocated (:mod:`VirtualMailManager.Relocated`)
+ exceptions.
+
+
+.. exception:: TransportError(msg, code)
+
+ Bases: :exc:`VirtualMailManager.errors.VMMError`
+
+ Exception class for Transport (:mod:`VirtualMailManager.Transport`)
+ exceptions.
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/source/vmm_relocated.rst Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,60 @@
+:mod:`VirtualMailManager.Relocated` --- Handling of relocated users
+===================================================================
+
+.. module:: VirtualMailManager.Relocated
+ :synopsis: Handling of relocated users
+
+.. moduleauthor:: Pascal Volk <neverseen@users.sourceforge.net>
+
+.. toctree::
+ :maxdepth: 2
+
+
+This module provides the :class:`Relocated` class. The data are read
+from/stored in the ``relocated`` table. An optional lookup table, used
+by Postfix for the "``user has moved to new_location``" reject/bounce message.
+
+
+Relocated
+---------
+.. class:: Relocated(dbh, address)
+
+ Creates a new *Relocated* instance. If the relocated user with the given
+ *address* is already stored in the database use :meth:`get_info` to get the
+ destination address of the relocated user. To set or update the destination
+ of the relocated user use :meth:`set_destination`. Use :meth:`delete` in
+ order to delete the relocated user from the database.
+
+ :param dbh: a database connection
+ :type dbh: :class:`pyPgSQL.PgSQL.Connection`
+ :param address: the e-mail address of the relocated user.
+ :type address: :class:`VirtualMailManager.EmailAddress.EmailAddress`
+
+
+ .. method:: delete()
+
+ :rtype: :obj:`None`
+ :raise VirtualMailManager.errors.RelocatedError: if the relocated user
+ doesn't exist.
+
+ Deletes the relocated user from the database.
+
+
+ .. method:: get_info()
+
+ :rtype: :class:`VirtualMailManager.EmailAddress.EmailAddress`
+ :raise VirtualMailManager.errors.RelocatedError: if the relocated user
+ doesn't exist.
+
+ Returns the destination e-mail address of the relocated user.
+
+
+ .. method:: set_destination(destination)
+
+ :param destination: the new address where the relocated user has moved to
+ :type destination: :class:`VirtualMailManager.EmailAddress.EmailAddress`
+ :rtype: :obj:`None`
+ :raise VirtualMailManager.errors.RelocatedError: if the *destination*
+ address is already saved or is the same as the relocated user's address.
+
+ Sets or updates the *destination* address of the relocated user.
--- a/install.sh Thu Jan 13 12:48:30 2011 +0000
+++ b/install.sh Thu Jan 13 12:54:53 2011 +0000
@@ -26,7 +26,7 @@
exit 1
fi
-python setup.py -q install --prefix ${PREFIX}
+python setup.py -q install --force --prefix ${PREFIX}
python setup.py clean --all >/dev/null
install -b -m 0600 ${INSTALL_OPTS} vmm.cfg ${PREFIX}/etc/
@@ -50,7 +50,7 @@
[ -d ${MANDIR}/man5 ] || mkdir -m 0755 -p ${MANDIR}/man5
install -m 0644 ${INSTALL_OPTS} man5/vmm.cfg.5 ${MANDIR}/man5
-for l in $(find . -maxdepth 1 -mindepth 1 -type d \! -name man\? \! -name .svn)
+for l in $(find . -maxdepth 1 -mindepth 1 -type d \! -name man\?)
do
for s in man1 man5; do
[ -d ${MANDIR}/${l}/${s} ] || mkdir -m 0755 -p ${MANDIR}/${l}/${s}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/man/de/man1/vmm.1.rst Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,504 @@
+=====
+ vmm
+=====
+
+-----------------------------------------------------------------------------
+Kommandozeilenprogramm zur Verwaltung von E-Mail-Domains, -Konten und -Aliase
+-----------------------------------------------------------------------------
+
+:Author: Pascal Volk <neverseen@users.sourceforge.net>
+:Date: |today|
+:Version: vmm-0.6.0
+:Manual group: vmm Manual
+:Manual section: 1
+
+.. contents::
+ :backlinks: top
+ :class: htmlout
+
+SYNOPSIS
+========
+vmm *Unterbefehl* *Objekt* [ *Argumente* ]
+
+
+BESCHREIBUNG
+============
+**vmm** (a virtual mail manager) ist ein Kommandozeilenprogramm für
+Administratoren/Postmaster zur Verwaltung von (Alias-) Domains, Konten und
+Alias-Adressen. Es wurde entwickelt für Dovecot und Postfix mit einem
+PostgreSQL-Backend.
+
+
+UNTERBEFEHLE
+============
+Von jedem Unterbefehl gibt es jeweils eine lange und kurze Variante. Die
+Kurzform ist in Klammern geschrieben. Bei beiden Formen ist die
+Groß-/Kleinschreibung zu berücksichtigen.
+
+
+ALLGEMEINE UNTERBEFEHLE
+-----------------------
+.. _configget:
+
+``configget (cg) Option``
+ Dieser Unterbefehl wird verwendet, um den aktuellen Wert der übergebenen
+ *Option* anzuzeigen. Die *Option* wird in der Form *Sektion*\ **.**\ *Option*
+ angegeben. Zum Beispiel: **misc.transport**.
+
+.. _configset:
+
+``configset (cs) Option Wert``
+ Verwenden Sie diesen Unterbefehl, um einer einzelnen Konfigurations-*Option*
+ einen neuen *Wert* zuzuweisen. Die *Option* wird dabei in der Form
+ *Sektion*\ **.**\ *Option* angegeben. *Wert* ist der neue Wert der *Option*.
+
+ Beispiel::
+
+ vmm configget misc.transport
+ misc.transport = dovecot:
+ vmm configset misc.transport lmtp:unix:private/dovecot-lmtp
+ vmm cg misc.transport
+ misc.transport = lmtp:unix:private/dovecot-lmtp
+
+.. _configure:
+
+``configure (cf) [ Sektion ]``
+ Startet den interaktiven Konfiguration-Modus für alle Sektionen der
+ Konfiguration.
+
+ Dabei wird der aktuell konfigurierte Wert einer jeden Option in eckigen
+ Klammern ausgegeben. Sollte kein Wert konfiguriert sein, wird der
+ Vorgabewert der jeweiligen Option in in eckigen Klammern angezeigt. Um den
+ angezeigten Wert unverändert zu übernehmen, ist dieser mit der
+ Eingabe-Taste zu bestätigen.
+
+ Wurde das optionale Argument *Sektion* angegeben, werden nur die Optionen
+ der angegebenen Sektion angezeigt und können geändert werden. Folgende
+ Sektionen sind vorhanden:
+
+ | - **account**
+ | - **bin**
+ | - **database**
+ | - **domain**
+ | - **maildir**
+ | - **misc**
+
+ Beispiel::
+
+ vmm configure domain
+ Verwende Konfigurationsdatei: /usr/local/etc/vmm.cfg
+
+ * Konfigurations Sektion: „domain“
+ Neuer Wert für Option directory_mode [504]:
+ Neuer Wert für Option delete_directory [False]: 1
+ Neuer Wert für Option auto_postmaster [True]:
+ Neuer Wert für Option force_deletion [False]: on
+
+.. _getuser:
+
+``getuser (gu) userid``
+ Wenn nur eine UserID vorhanden ist, zum Beispiel aus der Prozessliste,
+ kann mit dem Unterbefehl **getuser** die E-Mail-Adresse des Users
+ ermittelt werden.
+
+ Beispiel::
+
+ vmm getuser 70004
+ Account Informationen
+ ---------------------
+ UID............: 70004
+ GID............: 70000
+ Address........: c.user@example.com
+
+.. _listdomains:
+
+``listdomains (ld) [ Muster ]``
+ Dieser Unterbefehl listet alle verfügbaren Domains auf. Allen Domains wird
+ ein Präfix vorangestellt. Entweder ein '[+]', falls es sich um eine
+ primäre Domain handelt, oder ein '[-]', falls es sich um eine Alias-Domain
+ handelt. Die Ausgabe kann reduziert werden, indem ein optionales *Muster*
+ angegeben wird.
+
+ Um eine Wildcard-Suche durchzuführen kann das **%**-Zeichen am Anfang
+ und/oder Ende des *Musters* verwendet werden.
+
+ Beispiel::
+
+ vmm listdomains %example%
+ Übereinstimmende Domains
+ ------------------------
+ [+] example.com
+ [-] e.g.example.com
+ [-] example.name
+ [+] example.net
+ [+] example.org
+
+.. _help:
+
+``help (h)``
+ Dieser Unterbefehl gibt alle verfügbaren Kommandos auf der Standardausgabe
+ (stdout) aus. Danach beendet sich **vmm**.
+
+.. _version:
+
+``version (v)``
+ Gibt Versionsinformationen zu **vmm** aus.
+
+DOMAIN UNTERBEFEHLE
+-------------------
+.. _domainadd:
+
+``domainadd (da) Domain [ Transport ]``
+ Fügt eine neue *Domain* in die Datenbank ein und erstellt das
+ Domain-Verzeichnis.
+
+ Ist das optionale Argument *Transport* angegeben, wird der
+ Vorgabe-Transport (|misc.transport|_) aus |vmm.cfg(5)|_ für diese *Domain*
+ ignoriert und der angegebene *Transport* verwendet. Der angegebene
+ *Transport* ist gleichzeitig der Vorgabe-Transport für alle neuen Konten,
+ die unter dieser Domain eingerichtet werden.
+
+ Wenn der Wert der Konfigurations-Option |domain.auto_postmaster|_ **true**
+ ist, wird **vmm** auch ein Konto für **postmaster@**\ *Domain* erstellen.
+
+ Beispiele::
+
+ vmm domainadd support.example.com smtp:mx1.example.com
+ vmm domainadd sales.example.com
+
+.. _domaininfo:
+
+``domaininfo (di) Domain [ Details ]``
+ Dieser Unterbefehl zeigt Information zur angegeben *Domain* an.
+
+ Um detaillierte Informationen über die *Domain* zu erhalten, kann das
+ optionale Argument *Details* angegeben werden. Ein möglicher Wert für
+ *Details* kann eines der folgenden fünf Schlüsselwörter sein:
+
+ ``accounts``
+ um alle existierenden Konten aufzulisten
+ ``aliasdomains``
+ um alle zugeordneten Alias-Domains aufzulisten
+ ``aliases``
+ um alle verfügbaren Alias-Adressen aufzulisten
+ ``relocated``
+ um alle Adressen der relocated Users aufzulisten
+ ``full``
+ um alle oben genannten Informationen aufzulisten
+
+ Beispiel::
+
+ vmm domaininfo sales.example.com
+ Domain Informationen
+ --------------------
+ Domainname.....: sales.example.com
+ GID............: 70002
+ Transport......: dovecot:
+ Domaindir......: /home/mail/5/70002
+ Aliasdomains...: 0
+ Accounts.......: 0
+ Aliases........: 0
+ Relocated......: 0
+
+.. _domaintransport:
+
+``domaintransport (dt) Domain Transport [ force ]``
+ Ein neuer *Transport* für die angegebene *Domain* kann mit diesem
+ Unterbefehl festgelegt werden.
+
+ Wurde das optionale Schlüsselwort **force** angegeben, so werden alle
+ bisherigen Transport-Einstellungen, der in dieser Domain vorhandenen
+ Konten, mit dem neuen *Transport* überschrieben.
+
+ Andernfalls gilt der neue *Transport* nur für Konten, die zukünftig
+ erstellt werden.
+
+ Beispiel::
+
+ vmm domaintransport support.example.com dovecot:
+
+.. _domaindelete:
+
+``domaindelete (dd) Domain [ force ]``
+ Mit diesem Unterbefehl wird die angegebene *Domain* gelöscht.
+
+ Sollten der *Domain* Konten, Aliase und/oder relocated User zugeordnet
+ sein, wird **vmm** die Ausführung des Befehls mit einer entsprechenden
+ Fehlermeldung beenden.
+
+ Sollten Sie sich Ihres Vorhabens sicher sein, so kann optional das
+ Schlüsselwort **force** angegeben werden.
+
+ Sollten Sie wirklich immer wissen was Sie tun, so editieren Sie Ihre
+ *vmm.cfg* und setzen den Wert der Option |domain.force_deletion|_ auf
+ true. Dann werden Sie beim Löschen von Domains nicht mehr wegen vorhanden
+ Konten, Aliase und/oder relocated User gewarnt.
+
+
+ALIAS-DOMAIN UNTERBEFEHLE
+-------------------------
+.. _aliasdomainadd:
+
+``aliasdomainadd (ada) Aliasdomain Zieldomain``
+ Mit diesem Unterbefehl wird der *Zieldomain* die Alias-Domain
+ *Aliasdomain* zugewiesen.
+
+ Beispiel::
+
+ vmm aliasdomainadd example.name example.com
+
+.. _aliasdomaininfo:
+
+``aliasdomaininfo (adi) Aliasdomain``
+ Dieser Unterbefehl informiert darüber, welcher Domain die Alias-Domain
+ *Aliasdomain* zugeordnet ist.
+
+ Beispiel::
+
+ vmm aliasdomaininfo example.name
+ Alias-Domain Informationen
+ --------------------------
+ Die Alias-Domain example.name gehört zu:
+ * example.com
+
+.. _aliasdomainswitch:
+
+``aliasdomainswitch (ads) Aliasdomain Zieldomain``
+ Wenn das Ziel der vorhandenen *Aliasdomain* auf eine andere *Zieldomain*
+ geändert werden soll, ist dieser Unterbefehl zu verwenden.
+
+ Beispiel::
+
+ vmm aliasdomainswitch example.name example.org
+
+.. _aliasdomaindelete:
+
+``aliasdomaindelete (add) Aliasdomain``
+ Wenn die Alias-Domain mit dem Namen *Aliasdomain* gelöscht werden soll,
+ ist dieser Unterbefehl zu verwenden.
+
+ Beispiel::
+
+ vmm aliasdomaindelete e.g.example.com
+
+
+KONTO UNTERBEFEHLE
+------------------
+.. _useradd:
+
+``useradd (ua) Adresse [ Passwort ]``
+ Mit diesem Unterbefehl wird ein neues Konto für die angegebene *Adresse*
+ angelegt.
+
+ Wurde kein *Passwort* angegeben wird **vmm** dieses im interaktiven Modus
+ erfragen. Falls kein *Passwort* angegeben wurde und
+ |account.random_password|_ den Wert **true** hat, wird **vmm** ein
+ zufälliges Passwort generieren und auf stdout ausgeben, nachdem das Konto
+ angelegt wurde.
+
+ Beispiele::
+
+ vmm ua d.user@example.com 'A 5ecR3t P4s5\\/\\/0rd'
+ vmm ua e.user@example.com
+ Neues Passwort eingeben:
+ Neues Passwort wiederholen:
+
+.. _userinfo:
+
+``userinfo (ui) Adresse [ Details ]``
+ Dieser Unterbefehl zeigt einige Informationen über das Konto mit der
+ angegebenen *Adresse* an.
+
+ Wurde das optionale Argument *Details* angegeben, werden weitere
+ Informationen ausgegeben. Mögliche Werte für *Details* sind:
+
+ ``aliases``
+ um alle Alias-Adressen, mit dem Ziel *Adresse*, aufzulisten
+ ``du``
+ um zusätzlich die Festplattenbelegung des Maildirs eines Kontos
+ anzuzeigen. Soll die Festplattenbelegung jedes Mal mit der **userinfo**
+ ermittelt werden, ist in der *vmm.cfg* der Wert der Option
+ |account.disk_usage|_ auf true zu setzen.
+ ``full``
+ um alle oben genannten Informationen anzuzeigen
+
+.. _username:
+
+``username (un) Adresse 'Bürgerlicher Name'``
+ Der Bürgerliche Name des Konto-Inhabers mit der angegebenen *Adresse* kann
+ mit diesem Unterbefehl gesetzt/aktualisiert werden.
+
+ Beispiel::
+
+ vmm un d.user@example.com 'John Doe'
+
+.. _userpassword:
+
+``userpassword (up) Adresse [ Passwort ]``
+ Das *Passwort* eines Kontos kann mit diesem Unterbefehl aktualisiert
+ werden.
+
+ Wurde kein *Passwort* angegeben wird **vmm** dieses im interaktiven Modus
+ erfragen.
+
+ Beispiel::
+
+ vmm up d.user@example.com 'A |\\/|0r3 5ecur3 P4s5\\/\\/0rd?'
+
+.. _usertransport:
+
+``usertransport (ut) Adresse Transport``
+ Mit diesem Unterbefehl kann ein abweichender *Transport* für das Konto mit
+ der angegebenen *Adresse* bestimmt werden.
+
+ Beispiel::
+
+ vmm ut d.user@example.com smtp:pc105.it.example.com
+
+.. _userdisable:
+
+``userdisable (u0) Adresse [ Service ... ]``
+ Soll ein Anwender keinen Zugriff auf bestimmte oder alle Service haben, kann
+ der Zugriff mit diesem Unterbefehl beschränkt werden.
+
+ Wurde kein *Service* angegeben, werden alle Services (**smtp**, **pop3**,
+ **imap**, und **sieve**) für das Konto mit der angegebenen *Adresse*
+ deaktiviert.
+
+ Andernfalls wird nur der Zugriff auf den/die angegebenen *Service*/s
+ gesperrt.
+
+ Beispiele::
+
+ vmm u0 b.user@example.com imap pop3
+ vmm userdisable c.user@example.com
+
+.. _userenable:
+
+``userenable (u1) Adresse [ Service ... ]``
+ Um den Zugriff auf bestimmte oder alle gesperrten Service zu gewähren,
+ wird dieser Unterbefehl verwendet.
+
+ Wurde kein *Service* angegeben, werden alle Services (**smtp**, **pop3**,
+ **imap**, und **sieve**) für das Konto mit der angegebenen *Adresse*
+ aktiviert.
+
+ Andernfalls wird nur der Zugriff auf den/die angegebenen *Service*/s
+ aktiviert.
+
+.. _userdelete:
+
+``userdelete (ud) Adresse [ force ]``
+ Verwenden Sie diesen Unterbefehl um, das Konto mit der angegebenen
+ *Adresse* zu löschen.
+
+ Sollte es einen oder mehrere Aliase geben, deren Zieladresse mit der
+ *Adresse* des zu löschenden Kontos identisch ist, wird **vmm** die
+ Ausführung des Befehls mit einer entsprechenden Fehlermeldung beenden. Um
+ dieses zu umgehen, kann das optionale Schlüsselwort **force**
+ angegebenen werden.
+
+
+ALIAS UNTERBEFEHLE
+------------------
+.. _aliasadd:
+
+``aliasadd (aa) Alias Ziel``
+ Mit diesem Unterbefehl werden neue Aliase erstellt.
+
+ Beispiele::
+
+ vmm aliasadd john.doe@example.com d.user@example.com
+ vmm aa support@example.com d.user@example.com
+ vmm aa support@example.com e.user@example.com
+
+.. _aliasinfo:
+
+``aliasinfo (ai) Alias``
+ Informationen zu einem Alias können mit diesem Unterbefehl ausgegeben
+ werden.
+
+ Beispiel::
+
+ vmm aliasinfo support@example.com
+ Alias Informationen
+ -------------------
+ E-Mails für support@example.com werden weitergeleitet an:
+ * d.user@example.com
+ * e.user@example.com
+
+.. _aliasdelete:
+
+``aliasdelete (ad) Alias [ Ziel ]``
+ Verwenden Sie diesen Unterbefehl um den angegebenen *Alias* zu löschen.
+
+ Wurde die optionale Zieladresse *Ziel* angegeben, so wird nur diese
+ Zieladresse vom angegebenen *Alias* entfernt.
+
+ Beispiel::
+
+ vmm ad support@example.com d.user@example.com
+
+
+RELOCATED UNTERBEFEHLE
+----------------------
+.. _relocatedadd:
+
+``relocatedadd (ra) alte_adresse neue_adresse``
+ Um einen neuen relocated User anzulegen kann dieser Unterbefehl verwendet
+ werden.
+
+ Dabei ist *alte_adresse* die ehemalige Adresse des Benutzers, zum Beispiel
+ b.user@example.com, und *neue_adresse* die neue Adresse, unter der
+ Benutzer erreichbar ist.
+
+ Beispiel::
+
+ vmm relocatedadd b.user@example.com b-user@company.tld
+
+.. _relocatedinfo:
+
+``relocatedinfo (ri) alte_adresse``
+ Dieser Unterbefehl zeigt die neue Adresse des relocated Users mit
+ *alte_adresse*.
+
+ Beispiel::
+
+ vmm relocatedinfo b.user@example.com
+ Relocated Informationen
+ -----------------------
+ Der Benutzer „b.user@example.com“ ist erreichbar unter „b-user@company.tld“
+
+.. _relocateddelete:
+
+``relocateddelete (rd) alte_adresse``
+ Mit diesem Unterbefehl kann der relocated User mit *alte_adresse*
+ gelöscht werden.
+
+ Beispiel::
+
+ vmm relocateddelete b.user@example.com
+
+
+DATEIEN
+=======
+*/root/vmm.cfg*
+ | Wird verwendet, falls vorhanden.
+*/usr/local/etc/vmm.cfg*
+ | Wird verwendet, sollte obige Datei nicht gefunden werden.
+*/etc/vmm.cfg*
+ | Wird verwendet, falls obengenannte Dateien nicht existieren.
+
+
+SIEHE AUCH
+==========
+|vmm.cfg(5)|_
+
+
+COPYING
+=======
+vmm und die dazugehörigen Manualseiten wurden von Pascal Volk geschrieben
+und sind unter den Bedingungen der BSD Lizenz lizenziert.
+
+.. include:: ../../substitute_links.rst
+.. include:: ../../substitute_links_1.rst
--- a/man/de/man5/vmm.cfg.5 Thu Jan 13 12:48:30 2011 +0000
+++ b/man/de/man5/vmm.cfg.5 Thu Jan 13 12:54:53 2011 +0000
@@ -1,273 +1,458 @@
-.TH vmm.cfg 5 "17 Aug 2009" "Pascal Volk"
+.\" Man page generated from reStructeredText.
+.
+.TH VMM.CFG 5 "2010-01-18" "vmm-0.6.0" "vmm Manual"
.SH NAME
vmm.cfg \- Konfigurationsdatei für vmm
+.
+.nr rst2man-indent-level 0
+.
+.de1 rstReportMargin
+\\$1 \\n[an-margin]
+level \\n[rst2man-indent-level]
+level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
+-
+\\n[rst2man-indent0]
+\\n[rst2man-indent1]
+\\n[rst2man-indent2]
+..
+.de1 INDENT
+.\" .rstReportMargin pre:
+. RS \\$1
+. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
+. nr rst2man-indent-level +1
+.\" .rstReportMargin post:
+..
+.de UNINDENT
+. RE
+.\" indent \\n[an-margin]
+.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.nr rst2man-indent-level -1
+.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
+..
.SH SYNOPSIS
+.sp
vmm.cfg
.SH BESCHREIBUNG
-\fBvmm\fR(1) liest Konfigurationsparameter aus der Datei \fIvmm.cfg\fP.
-.br
+.sp
+\fBvmm\fP(1) liest seine Konfigurationsparameter aus der Datei \fIvmm.cfg\fP.
+.sp
Die Konfigurationsdatei ist in mehrere Abschnitte unterteilt. Jeder Abschnitt
-wird mit dem, in eckigen Klammern '[' und ']' eingefassten, Namen des Abschnitts
-eingeleitet (z. B. \fB[database]\fP), gefolgt von \'Option = Wert\' Einträgen
-(Z. B. \fBhost = 127.0.0.1\fP).
-.br
-Leerräume um das Gleichheitszeichen '=' und am Ende eine Wertes werden
+wird mit dem, in eckigen Klammern \(aq\fB[\fP\(aq und \(aq\fB]\fP\(aq eingefassten, Namen des
+Abschnitts eingeleitet, gefolgt von \(aq\fIOption\fP = \fIWert\fP\(aq Einträgen:
+.sp
+.nf
+.ft C
+[database]
+host = 127.0.0.1
+.ft P
+.fi
+.sp
+Leerräume um das Gleichheitszeichen \(aq=\(aq und am Ende eines Wertes werden
ignoriert.
-.PP
-Leerzeilen und Zeilen, die mit einer '#' oder einem ';' anfangen, werden
+.sp
+Leerzeilen und Zeilen, die mit einer \(aq#\(aq oder einem \(aq;\(aq anfangen, werden
ignoriert.
-.PP
+.sp
Jeder Wert ist von einem der folgenden Datentypen:
-.IP \(bu
-.I Boolean
-um zu bestimmen, ob etwas eingeschaltet/aktiviert (true) oder
+.INDENT 0.0
+.IP \(bu 2
+.
+\fIBoolean\fP um zu bestimmen, ob etwas eingeschaltet/aktiviert (true) oder
ausgeschaltet/deaktiviert (false) ist.
-.br
-Mögliche Werte für \fBtrue\fP sind: \fB1\fP, \fByes\fP, \fBtrue\fP und \fBon\fP.
-.br
-Mögliche Werte für \fBfalse\fP sind: \fB0\fP, \fBno\fP, \fBfalse\fP und
-\fBoff\fP.
-.IP \(bu
-.I Int
-eine Integer-Zahl, geschrieben ohne eine gebrochene oder dezimale Komponente.
-.br
-Beispielsweise sind \fB1\fP, \fB50\fP oder \fB321\fP Integer-Zahlen.
-.IP \(bu
-.I String
-eine Folge von Buchstaben und Zahlen.
-.br
-Zum Beispiel: '\fBWort\fP', '\fBHallo Welt\fP', oder '\fB/usr/bin/strings\fP'
+.nf
+Mögliche Werte für \fItrue\fP sind: \fB1\fP, \fByes\fP, \fBtrue\fP und \fBon\fP.
+Mögliche Werte für \fIfalse\fP sind: \fB0\fP, \fBno\fP, \fBfalse\fP und \fBoff\fP.
+.fi
+.sp
+.IP \(bu 2
+.
+\fIInt\fP eine Integer\-Zahl, geschrieben ohne eine gebrochene oder dezimale
+Komponente.
+.nf
+Beispielsweise \fB1\fP, \fB50\fP oder \fB321\fP sind Integer\-Zahlen.
+.fi
+.sp
+.IP \(bu 2
+.
+\fIString\fP eine Folge von Buchstaben und Zahlen.
+.nf
+Zum Beispiel: \(aq\fBWort\fP\(aq, \(aq\fBHallo Welt\fP\(aq oder \(aq\fB/usr/bin/strings\fP\(aq
+.fi
+.sp
+.UNINDENT
.SS SUCHREIHENFOLGE
-Standardmäßig sucht vmm die \fIvmm.cfg\fP in folgenden Verzeichnissen, in dieser
-Reihenfolge:
-.RS
-.PD 0
+.sp
+Standardmäßig sucht \fBvmm\fP(1) die \fIvmm.cfg\fP in folgenden Verzeichnissen,
+in der angegebenen Reihenfolge:
+.INDENT 0.0
+.INDENT 3.5
+.nf
+\fI/root\fP
+\fI/usr/local/etc\fP
+\fI/etc\fP
+.fi
+.sp
+.UNINDENT
+.UNINDENT
+.sp
+Die zuerst gefundene Datei wird verwendet.
+.SH ABSCHNITTE
+.sp
+Im Folgenden werden die Abschnitte der \fIvmm.cfg\fP und deren Optionen
+beschrieben.
+.SS ACCOUNT
+.sp
+Die Optionen des Abschnitts \fBaccount\fP legen Konto\-spezifische
+Einstellungen fest.
+.INDENT 0.0
.TP
-.I
-/root
-.TP
-.I
-/usr/local/etc
+.B \fCdelete_directory\fP
+\fIBoolean\fP
+.sp
+Bestimmt das Verhalten von \fBvmm\fP(1) beim Löschen eines Kontos.
+Wenn der Wert dieser Option \fItrue\fP ist, wird das Home\-Verzeichnis des
+zu löschenden Anwenders rekursiv gelöscht.
.TP
-.I
-/etc
-.PD
-.RE
-.PP
-Die zuerst gefundene Datei wird verwendet.
-.\" -----
-.SH DATABASE ABSCHNITT
-Der \fBdatabase\fP-Abschnitt wird verwendet, um die für den Datenbankzugriff
-benötigten Optionen festzulegen.
-.TP
-\fBhost\fP (\fIString\fP)
-Der Hostname oder die IP-Adresse des Datenbank-Servers.
-.TP
-\fBuser\fP (\fIString\fP)
-Der Name des Datenbank-Benutzers.
-.TP
-\fBpass\fP (\fIString\fP)
-Das Passwort des Datenbank-Benutzers
+.B \fCdirectory_mode\fP
+\fIInt\fP
+.sp
+Zugriffsbits des Home\-Verzeichnisses, sowie aller enthaltenen
+Verzeichnisse, in Dezimal\-Schreibweise (Basis 10).
+.nf
+Beispiel: \(aqdrwx\-\-\-\-\-\-\(aq \-> oktal 0700 \-> dezimal 448
+.fi
+.sp
.TP
-\fBname\fP (\fIString\fP)
-Name der zu verwendenden Datenbank.
+.B \fCdisk_usage\fP
+\fIBoolean\fP
+.sp
+Legt fest, ob die Festplattenbelegung des Maildirs eines Benutzers jedes
+Mal mit \fBdu\fP(1) ermittelt und mit den Konto\-Informationen ausgegeben
+werden soll.
+.sp
+Bei umfangreichen Maildirs kann das langsam sein. Falls Sie Quotas
+aktiviert haben, wird der \fBvmm\fP\-Unterbefehl \fBuserinfo\fP ebenfalls
+die aktuelle Quota\-Nutzung des Kontos mit ausgegeben. Sie können auch
+eines der optionalen Argumente \fBdu\fP oder \fBfull\fP an \fBuserinfo\fP
+übergeben, um sich die aktuelle Festplattenbelegung anzeigen zu lassen.
+.TP
+.B \fCimap\fP
+\fIBoolean\fP
+.sp
+Bestimmt, ob sich neu angelegte Benutzer per IMAP anmelden können sollen.
.TP
-\fBBeispiel\fP:
-[database]
-.br
-host = localhost
-.br
-user = vmm
-.br
-pass = T~_:L4OYyl]TU?)
-.br
-name = mailsys
-.\" -----
-.SH MAILDIR ABSCHNITT
-Im \fBmaildir\fP-Abschnitt werden die für die Maildirs erforderlichen Optionen
-festgelegt.
+.B \fCpassword_length\fP
+\fIInt\fP
+.sp
+Diese Option legt die Anzahl der Zeichen für automatisch erzeugte
+Passwörter fest. Alle Werte kleiner als 8 werden auf 8 erhöht.
+.TP
+.B \fCpop3\fP
+.sp
+Bestimmt, ob sich neu angelegte Benutzer per POP3 anmelden können sollen.
.TP
-\fBname\fP (\fIString\fP)
-Standard-Name des Maildir-Verzeichnisses im Verzeichnis des jeweiligen
-Anwenders.
+.B \fCrandom_password\fP
+\fIBoolean\fP
+.sp
+Mit dieser Option wird bestimmt , ob \fBvmm\fP(1) ein zufälliges Passwort
+generieren soll, wenn kein Passwort an den \fBuseradd\fP Unterbefehl
+übergeben wurde. Ist der Wert dieser Option \fIfalse\fP, wird \fBvmm\fP Sie
+auffordern, ein Passwort für den neun Account einzugeben.
+.sp
+Sie können die Länge für automatisch generierte Passwörter mit der
+Option \fBpassword_length\fP konfigurieren.
.TP
-\fBfolders\fP (\fIString\fP)
-Eine durch Doppelpunkten getrennte Liste mit Verzeichnisnamen, die innerhalb des
-Maildirs erstellt werden sollen.
-.br
-Sollen innerhalb des Maildirs keine Verzeichnisse angelegt werden, ist dieser
-Optionen ein einzelner Doppelpunkt (':') als Wert zuzuweisen.
-.TP
-\fBmode\fP (\fIInt\fP)
-Zugriffsbits des Maildirs in Dezimal-Schreibweise (Basis 10).
-.br
-Beispiel: \'drwx------' -> oktal 0700 -> dezimal 448
+.B \fCsieve\fP
+\fIBoolean\fP
+.sp
+Bestimmt, ob sich neu angelegte Benutzer per ManageSieve anmelden
+können sollen.
.TP
-\fBdiskusage\fP (\fIBoolean\fP)
-Legt fest, ob die Festplattenbelegung des Maildirs jedes Mal, wenn
-Konto-Informationen ausgegeben werden, ermittelt und mit ausgegeben werden
-sollen.
-.TP
-\fBdelete\fP (\fIBoolean\fP)
-Bestimmt, ob das Maildir rekursiv gelöscht werden soll, wenn ein Konto gelöscht
-wird.
+.B \fCsmtp\fP
+\fIBoolean\fP
+.sp
+Bestimmt, ob sich neu angelegte Benutzer per SMTP (SMTP AUTH) anmelden
+können sollen.
+.UNINDENT
+.sp
+Beispiel:
+.sp
+.nf
+.ft C
+[account]
+delete_directory = false
+directory_mode = 448
+disk_usage = false
+random_password = true
+password_length = 10
+smtp = true
+pop3 = true
+imap = true
+sieve = true
+.ft P
+.fi
+.SS BIN
+.sp
+Im \fBbin\fP\-Abschnitt werden Pfade zu Binaries angegeben, die von
+\fBvmm\fP(1) benötigt werden.
+.INDENT 0.0
.TP
-\fBBeispiel\fP:
-[maildir]
-.br
-name = Maildir
-.br
-folders = Drafts:Sent:Templates:Trash:INBOX.News
-.br
-mode = 448
-.br
-diskusage = false
-.br
-delete = false
-.\" -----
-.SH SERVICES ABSCHNITT
-Im \fBservices\fP-Abschnitt werden die Standard-Beschränkungen für alle Konten
-festgelegt.
+.B \fCdovecotpw\fP
+\fIString\fP
+.sp
+Der absolute Pfad zum dovecotpw Binary. Dieses Binary wird zur
+Hash\-Erzeugung verwendet, wenn \fBmisc.password_scheme\fP einen der
+nachfolgenden Werte hat: \(aqSMD5\(aq, \(aqSSHA\(aq, \(aqCRAM\-MD5\(aq, \(aqHMAC\-MD5\(aq,
+\(aqLANMAN\(aq, \(aqNTLM\(aq oder \(aqRPA\(aq.
+.TP
+.B \fCdu\fP
+\fIString\fP
+.sp
+Der absolute Pfad zu \fBdu\fP(1). Dieses Binary wird verwendet, wenn
+die Festplattenbelegung eines Kontos ermittelt wird.
.TP
-\fBsmtp\fP (\fIBoolean\fP)
-Legt fest, ob sich ein Anwender standardmäßig per SMTP einloggen kann.
-.TP
-\fBpop3\fP (\fIBoolean\fP)
-Legt fest, ob sich ein Anwender standardmäßig per POP3 einloggen kann.
-.TP
-\fBimap\fP (\fIBoolean\fP)
-Legt fest, ob sich ein Anwender standardmäßig per IMAP einloggen kann.
+.B \fCpostconf\fP
+\fIString\fP
+.sp
+Der absolute Pfad zu Postfix\(aq \fBpostconf\fP(1). Dieses Binary wird
+verwendet, wenn \fBvmm\fP(1) diverse Postfix\-Einstellungen prüft, zum
+Beispiel das \fIvirtual_alias_expansion_limit\fP.
+.UNINDENT
+.sp
+Beispiel:
+.sp
+.nf
+.ft C
+[bin]
+dovecotpw = /usr/sbin/dovecotpw
+du = /usr/bin/du
+postconf = /usr/sbin/postconf
+.ft P
+.fi
+.SS CONFIG
+.sp
+Beim \fBconfig\fP\-Abschnitt handelt es sich um einen internen
+Steuerungs\-Abschnitt.
+.INDENT 0.0
.TP
-\fBsieve\fP (\fIBoolean\fP)
-Legt fest, ob sich ein Anwender standardmäßig per MANAGESIEVE einloggen kann.
+.B \fCdone\fP
+\fIBoolean\fP
+.sp
+Diese Option hat den Wert \fIfalse\fP, wenn \fBvmm\fP(1) zum ersten Mal
+installiert wurde. Wenn Sie die Datei \fIvmm.cfg\fP von Hand editieren,
+weisen Sie dieser Option abschließend den Wert \fItrue\fP zu. Wird die
+Konfiguration über das Kommando \fBvmm configure\fP angepasst, wird der
+Wert dieser Option automatisch auf \fItrue\fP gesetzt.
+.sp
+Ist der Wert dieser Option \fIfalse\fP, so startet \fBvmm\fP(1) beim
+nächsten Aufruf im interaktiven Konfigurations\-Modus.
+.UNINDENT
+.sp
+Beispiel:
+.sp
+.nf
+.ft C
+[config]
+done = true
+.ft P
+.fi
+.SS DATABASE
+.sp
+Der \fBdatabase\fP\-Abschnitt wird verwendet, um die für den Datenbankzugriff
+benötigten Optionen festzulegen.
+.INDENT 0.0
.TP
-\fBBeispiel\fP:
-[services]
-.br
-smtp = true
-.br
-pop3 = true
-.br
-imap = false
-.br
-sieve = false
-.\" -----
-.SH DOMDIR ABSCHNITT
-Im \fBdomdir\fP-Abschnitt werden die Optionen der Domain-Verzeichnisse bestimmt.
+.B \fChost\fP
+\fIString\fP
+.sp
+Der Hostname oder die IP\-Adresse des Datenbank\-Servers.
.TP
-\fBbase\fP (\fIString\fP)
-Alle Domain-Verzeichnisse werden unterhalb dieses Basis-Verzeichnisses angelegt.
+.B \fCname\fP
+\fIString\fP
+.sp
+Der Name der zu verwendenden Datenbank.
.TP
-\fBmode\fP (\fIInt\fP)
-Zugriffsbits des Domain-Verzeichnisses in Dezimal-Schreibweise (Basis 10).
-.br
-Beispiel: 'drwxrwx---' -> oktal 0770 -> dezimal 504
+.B \fCpass\fP
+\fIString\fP
+.sp
+Das Passwort des Datenbank\-Benutzers.
.TP
-\fBdelete\fP (\fIBoolean\fP)
-Bestimmt, ob beim Löschen einer Domain das Verzeichnis einer Domain, inklusive
-aller Anwender-Verzeichnisse, rekursiv gelöscht werden soll.
+.B \fCuser\fP
+\fIString\fP
+.sp
+Der Name des Datenbank\-Benutzers.
+.UNINDENT
+.sp
+Beispiel:
+.sp
+.nf
+.ft C
+[database]
+host = localhost
+user = vmm
+pass = PY_SRJ}L/0p\-oOk
+name = mailsys
+.ft P
+.fi
+.SS DOMAIN
+.sp
+Im \fBdomain\fP\-Abschnitt werden Domain\-spezifische Informationen konfiguriert.
+.INDENT 0.0
+.TP
+.B \fCauto_postmaster\fP
+\fIBoolean\fP
+.sp
+Ist der Wert dieser Option \fItrue\fP, wird \fBvmm\fP(1) beim Anlegen einer
+Domain automatisch einen postmaster\-Account erstellen.
.TP
-\fBBeispiel\fP:
-[domdir]
-.br
-base = /srv/mail
-.br
-mode = 504
-.br
-delete = false
-.\" -----
-.SH BIN ABSCHNITT
-Der \fBbin\fP-Abschnitt wird verwendet, um Pfade zu Binaries, die von \fBvmm\fP
-benötigt werden, anzugeben.
+.B \fCdelete_directory\fP
+\fIBoolean\fP
+.sp
+Bestimmt, ob beim Löschen einer Domain das Verzeichnis einer Domain,
+inklusive aller Anwender\-Verzeichnisse, rekursiv gelöscht werden soll.
+.TP
+.B \fCdirectory_mode\fP
+\fIInt\fP
+.sp
+Zugriffsbits des Domain\-Verzeichnisses in Dezimal\-Schreibweise (Basis
+10).
+.nf
+Beispiel: \(aqdrwxrwx\-\-\-\(aq \-> oktal 0770 \-> dezimal 504
+.fi
+.sp
.TP
-\fBdovecotpw\fP (\fIString\fP)
-Der absolute Pfad zum dovecotpw-Binary. Dieses wird verwendet, wenn als
-Passwort-Schema eines der folgenden verwendet wird: 'SMD5', 'SSHA', 'CRAM-MD5',
-\'HMAC-MD5', 'LANMAN', 'NTLM' oder 'RPA'.
-.TP
-\fBdu\fP (\fIString\fP)
-Der absolute Pfad zu \fBdu\fR(1). Dieses Binary wird verwendet, wenn die
-Festplattenbelegung eines Kontos ermittelt wird.
-.TP
-\fBpostconf\fP (\fIString\fP)
-Der absolute Pfad zu Postfix' \fBpostconf\fR(1).
-.br
-Dieses Binary wird verwendet, wenn \fBvmm\fR(1) diverse Postfix-Einstellungen
-prüft, zum Beispiel virtual_alias_expansion_limit.
+.B \fCforce_deletion\fP
+\fIBoolean\fP
+.sp
+Erzwingt das Löschen von Konten und Aliase beim Löschen einer Domain.
+.UNINDENT
+.sp
+Beispiel:
+.sp
+.nf
+.ft C
+[domain]
+auto_postmaster = true
+delete_directory = false
+directory_mode = 504
+force_deletion = false
+.ft P
+.fi
+.SS MAILDIR
+.sp
+Im \fBmaildir\fP\-Abschnitt werden die für die Maildirs erforderlichen Optionen
+festgelegt.
+.INDENT 0.0
.TP
-\fBBeispiel\fP:
-[bin]
-.br
-dovecotpw = /usr/sbin/dovecotpw
-.br
-du = /usr/bin/du
-.br
-postconf = /usr/sbin/postconf
-.\" -----
-.SH MISC ABSCHNITT
-Im \fBmisc\fP-Abschnitt werden verschiedene Einstellungen festgelegt.
+.B \fCfolders\fP
+\fIString\fP
+.sp
+Eine durch Doppelpunkten getrennte Liste mit Verzeichnisnamen, die
+innerhalb des Maildirs erstellt werden sollen. Sollen innerhalb des
+Maildirs keine Verzeichnisse angelegt werden, ist dieser Optionen ein
+einzelner Doppelpunkt (\(aq\fB:\fP\(aq) als Wert zuzuweisen.
+.sp
+Sollen Verzeichnisse mit Unterverzeichnissen angelegt werden, ist ein
+einzelner Punkt (\(aq\fB.\fP\(aq) als Separator zu verwenden.
.TP
-\fBpasswdscheme\fP (\fIString\fP)
-Das zu verwendende Passwort-Schema (siehe auch: dovecotpw -l)
+.B \fCname\fP
+\fIString\fP
+.sp
+Der Standard\-Name des Maildir\-Verzeichnisses im Verzeichnis des
+jeweiligen Anwenders.
+.UNINDENT
+.sp
+Beispiel:
+.sp
+.nf
+.ft C
+[maildir]
+folders = Drafts:Sent:Templates:Trash:Lists.Dovecot:Lists.Postfix
+name = Maildir
+.ft P
+.fi
+.SS MISC
+.sp
+Im \fBmisc\fP\-Abschnitt werden verschiedene Einstellungen festgelegt.
+.INDENT 0.0
.TP
-\fBgid_mail\fP (\fIInt\fP)
-Die numerische Gruppen-ID der Gruppe mail, bzw. der Gruppe aus
-mail_privileged_group der Datei dovecot.conf.
+.B \fCbase_directory\fP
+\fIString\fP
+.sp
+Alle Domain\-Verzeichnisse werden innerhalb dieses Basis\-Verzeichnisses
+angelegt.
.TP
-\fBforcedel\fP (\fIBoolean\fP)
-Legt fest, ob beim Löschen einer Domain alle vorhanden Konten und/oder Aliase,
-ohne Nachfrage, gelöscht werden sollen.
+.B \fCpassword_scheme\fP
+\fIString\fP
+.sp
+Das zu verwendende Passwort\-Schema (siehe auch: \fBdovecotpw \-l\fP).
+.TP
+.B \fCgid_mail\fP
+\fIInt\fP
+.sp
+Die numerische Gruppen\-ID der Gruppe mail, bzw. der Gruppe aus
+\fImail_privileged_group\fP der Datei \fIdovecot.conf\fP.
.TP
-\fBtransport\fP (\fIString\fP)
-Der Standard-Transport aller Domains und Konten.
+.B \fCtransport\fP
+\fIString\fP
+.sp
+Der Standard\-Transport aller Domains und Konten. Siehe auch:
+\fBtransport\fP(5)
.TP
-\fBdovecotvers\fP (\fIInt\fP)
-Die verketteten Major- und Minor-Teile der eingesetzten Dovecot-Version
-(siehe: dovecot --version).
-.br
-Diese Option beeinflusst diverse Datenbankzugriffe. Da es zwischen Dovecot
-v1.1.x und v1.2.x einige Änderungen gab. Zum Beispiel \fB11\fP, falls
-\fBdovecot --version\fP den Wert \fB1.1\fP.18 ausgibt.
-.TP
-\fBBeispiel\fP:
+.B \fCdovecot_version\fP
+\fIInt\fP
+.sp
+Die verketteten Major\- und Minor\-Teile der eingesetzten Dovecot\-Version
+(siehe: \fBdovecot \-\-version\fP).
+.sp
+Wenn das Kommando \fBdovecot \-\-version\fP zum Beispiel \fI1.1.18\fP ausgibt,
+ist dieser Option der Wert \fB11\fP zuzuweisen.
+.UNINDENT
+.sp
+Beispiel:
+.sp
+.nf
+.ft C
[misc]
-.br
-passwdscheme = CRAM-MD5
-.br
+base_directory = /srv/mail
+password_scheme = CRAM\-MD5
gid_mail = 8
-.br
-forcedel = false
-.br
transport = dovecot:
-.br
-dovecotvers = 11
-.\" -----
-.SH CONFIG ABSCHNITT
-Beim \fBconfig\fP-Abschnitt handelt es sich um einen internen
-Steuerungs-Abschnitt.
+dovecot_version = 11
+.ft P
+.fi
+.SH DATEIEN
+.INDENT 0.0
+.TP
+.B \fI/root/vmm.cfg\fP
+.nf
+Wird verwendet, falls vorhanden.
+.fi
+.sp
.TP
-\fBdone\fP (\fIBoolean\fP)
-Diese Option hat den den Wert \fIfalse\fP, wenn vmm zum ersten Mal installiert
-wurde. Wenn die Datei \fIvmm.cfg\fP von Hand editiert wird, weisen Sie dieser
-Option abschließend den Wert \fItrue\fP zu.
-.br
-Wird die Konfiguration über das Kommando \fBvmm configure\fP angepasst, wird der
-Wert dieser Option automatisch auf \fItrue\fP gesetzt.
-.br
-Sollte diese Option den Wert \fIfalse\fP zugewiesen haben, so startet \fBvmm\fP
-beim nächsten Aufruf im interaktiven Konfigurations-Modus.
+.B \fI/usr/local/etc/vmm.cfg\fP
+.nf
+Wird verwendet, sollte obige Datei nicht gefunden werden.
+.fi
+.sp
.TP
-\fBBeispiel\fP:
-[config]
-.br
-done = true
-.\" -----
-.SH DATEIEN
-vmm.cfg
+.B \fI/etc/vmm.cfg\fP
+.nf
+Wird verwendet, falls obengenannte Dateien nicht existieren.
+.fi
+.sp
+.UNINDENT
.SH SIEHE AUCH
-vmm(1), Programm für die Kommandozeile, um E-Mail-Domains, -Konten und -Aliase
+.sp
+vmm(1), Programm für die Kommandozeile, um E\-Mail\-Domains, \-Konten und \-Aliase
zu verwalten.
-.SH AUTOR
-\fBvmm\fP und die dazugehörigen Manualseiten wurden von Pascal Volk
-<\fIneverseen@users.sourceforge.net\fP> geschrieben und sind unter den
-Bedingungen der BSD Lizenz lizenziert.
+.SH COPYING
+.sp
+vmm und die dazugehörigen Manualseiten wurden von Pascal Volk geschrieben
+und sind unter den Bedingungen der BSD Lizenz lizenziert.
+.SH AUTHOR
+Pascal Volk <neverseen@users.sourceforge.net>
+.\" Generated by docutils manpage writer.
+.\"
+.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/man/de/man5/vmm.cfg.5.rst Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,461 @@
+=========
+ vmm.cfg
+=========
+
+---------------------------
+Konfigurationsdatei für vmm
+---------------------------
+
+:Author: Pascal Volk <neverseen@users.sourceforge.net>
+:Date: |today|
+:Version: vmm-0.6.0
+:Manual group: vmm Manual
+:Manual section: 5
+
+.. contents::
+ :backlinks: top
+ :class: htmlout
+
+SYNOPSIS
+========
+vmm.cfg
+
+
+BESCHREIBUNG
+============
+|vmm(1)|_ liest seine Konfigurationsparameter aus der Datei *vmm.cfg*.
+
+Die Konfigurationsdatei ist in mehrere Sektionen unterteilt. Jede Sektion
+wird mit dem in eckigen Klammern '**[**' und '**]**' eingefassten Namen der
+Sektion eingeleitet, gefolgt von '*Option* = *Wert*' Einträgen.
+
+Leerräume um das Gleichheitszeichen '=' und am Ende eines Wertes werden
+ignoriert.
+
+Leerzeilen und Zeilen, die mit einer '#' oder einem ';' anfangen, werden
+ignoriert.
+
+Jeder Wert ist von einem der folgenden Datentypen:
+
+* *Boolean* um zu bestimmen, ob etwas eingeschaltet/aktiviert (true) oder
+ ausgeschaltet/deaktiviert (false) ist.
+
+ | Mögliche Werte für *true* sind: **1**, **yes**, **true** und **on**.
+ | Mögliche Werte für *false* sind: **0**, **no**, **false** und **off**.
+
+* *Int* eine Integer-Zahl, geschrieben ohne eine gebrochene oder dezimale
+ Komponente.
+
+ | Beispielsweise **1**, **50** oder **321** sind Integer-Zahlen.
+
+* *String* eine Folge von Buchstaben und Zahlen.
+
+ | Zum Beispiel: '**Wort**', '**Hallo Welt**' oder '**/usr/bin/strings**'
+
+Die meisten Optionen haben einen Vorgabewert. Dieser ist nach dem Namen der
+Option in Klammern angegebenen. Um den Vorgabewert einer Option zu
+verwenden, wird die entsprechende Zeile entweder mit **#** oder **;**
+auskommentiert oder die Zeile wird einfach aus der *vmm.cfg* entfernt.
+
+Eine minimale *vmm.cfg* könnte so aussehen::
+
+ [database]
+ user = ich
+ pass = xxxxxxxx
+
+ [misc]
+ dovecot_version = 1.2.11
+
+
+SUCHREIHENFOLGE
+---------------
+Standardmäßig sucht |vmm(1)|_ die *vmm.cfg* in folgenden Verzeichnissen,
+in der angegebenen Reihenfolge:
+
+ | */root*
+ | */usr/local/etc*
+ | */etc*
+
+Die zuerst gefundene Datei wird verwendet.
+
+
+SEKTIONEN
+=========
+Im Folgenden werden die Sektionen der *vmm.cfg* und deren Optionen
+beschrieben.
+
+
+ACCOUNT
+-------
+Die Optionen der Sektion **account** legen Konto-spezifische Einstellungen
+fest.
+
+.. _account.delete_directory:
+
+``delete_directory (Vorgabe: false)`` : *Boolean*
+ Bestimmt das Verhalten von |vmm(1)|_ beim Löschen eines Kontos
+ (|userdelete|_). Wenn der Wert dieser Option *true* ist, wird das
+ Home-Verzeichnis des zu löschenden Anwenders rekursiv gelöscht.
+
+.. _account.directory_mode:
+
+``directory_mode (Vorgabe: 448)`` : *Int*
+ Zugriffsbits des Home-Verzeichnisses, sowie aller enthaltenen
+ Verzeichnisse, in Dezimal-Schreibweise (Basis 10).
+
+ | Beispiel: 'drwx------' -> oktal 0700 -> dezimal 448
+
+.. _account.disk_usage:
+
+``disk_usage (Vorgabe: false)`` : *Boolean*
+ Legt fest, ob die Festplattenbelegung des Maildirs eines Benutzers jedes
+ Mal mit **du**\(1) ermittelt und mit den Konto-Informationen ausgegeben
+ werden soll.
+
+ Bei umfangreichen Maildirs kann das langsam sein. Falls Sie Quotas
+ aktiviert haben, wird der **vmm**-Unterbefehl |userinfo|_ ebenfalls die
+ aktuelle Quota-Nutzung des Kontos mit ausgegeben. Sie können auch eines
+ der optionalen Argumente **du** oder **full** an |userinfo|_ übergeben,
+ um sich die aktuelle Festplattenbelegung anzeigen zu lassen.
+
+.. _account.imap:
+
+``imap (Vorgabe: true)`` : *Boolean*
+ Bestimmt, ob sich neu angelegte Benutzer per IMAP anmelden können sollen.
+
+.. _account.password_length:
+
+``password_length (Vorgabe: 8)`` : *Int*
+ Diese Option legt die Anzahl der Zeichen für automatisch erzeugte
+ Passwörter fest. Alle Werte kleiner als 8 werden auf 8 erhöht.
+
+.. _account.pop3:
+
+``pop3 (Vorgabe: true)`` : *Boolean*
+ Bestimmt, ob sich neu angelegte Benutzer per POP3 anmelden können sollen.
+
+.. _account.random_password:
+
+``random_password (Vorgabe: false)`` : *Boolean*
+ Mit dieser Option wird bestimmt , ob **vmm** ein zufälliges Passwort
+ generieren soll, wenn kein Passwort an den Unterbefehl |useradd|_
+ übergeben wurde. Ist der Wert dieser Option *false*, wird **vmm** Sie
+ auffordern, ein Passwort für den neun Account einzugeben.
+
+ Sie können die Länge für automatisch generierte Passwörter mit der Option
+ |account.password_length|_ konfigurieren.
+
+.. _account.sieve:
+
+``sieve (Vorgabe: true)`` : *Boolean*
+ Bestimmt, ob sich neu angelegte Benutzer per ManageSieve anmelden können
+ sollen.
+
+.. _account.smtp:
+
+``smtp (Vorgabe: true)`` : *Boolean*
+ Bestimmt, ob sich neu angelegte Benutzer per SMTP (SMTP AUTH) anmelden
+ können sollen.
+
+Beispiel::
+
+ [account]
+ delete_directory = false
+ directory_mode = 448
+ disk_usage = false
+ random_password = true
+ password_length = 10
+ smtp = true
+ pop3 = true
+ imap = true
+ sieve = true
+
+
+BIN
+---
+In der **bin**-Sektion werden die Pfade zu den von |vmm(1)|_ benötigten
+Binaries angegeben.
+
+.. _bin.dovecotpw:
+
+``dovecotpw (Vorgabe: /usr/sbin/dovecotpw)`` : *String*
+ Der absolute Pfad zum dovecotpw Binary. Geben Sie den absoluten Pfad zum
+ **doveadm**\(1) Binary an, falls Sie Dovecot v2.0 verwenden. Dieses Binary
+ wird zur Hash-Erzeugung verwendet, wenn |misc.password_scheme|_ einen der
+ nachfolgenden Werte hat: 'CRAM-MD5', 'HMAC-MD5', 'LANMAN', 'OTP' 'RPA'
+ oder 'SKEY'. Dieses Binary wird auch benötigt, wenn Ihre
+ Python-Installation einen der folgenden Hash-Algorithmen nicht
+ unterstützt:
+
+ * md4 (hashlib + OpenSSL oder PyCrypto) verwendet für die
+ Passwort-Schemen: 'PLAIN-MD4' und 'NTLM'
+ * sha256 (hashlib oder PyCrypto >= 2.1.0alpha1) verwendet für die
+ Passwort-Schemen: 'SHA256' und 'SSHA256'
+ * sha512 (hashlib) verwendet für die Passwort-Schemen: 'SHA512' und
+ 'SSHA512'
+
+.. _bin.du:
+
+``du (Vorgabe: /usr/bin/du)`` : *String*
+ Der absolute Pfad zu **du**\(1). Dieses Binary wird verwendet, wenn die
+ Festplattenbelegung eines Kontos ermittelt wird.
+
+.. _bin.postconf:
+
+``postconf (Vorgabe: /usr/sbin/postconf)`` : *String*
+ Der absolute Pfad zu Postfix' |postconf(1)|_. Dieses Binary wird
+ verwendet, wenn |vmm(1)|_ diverse Postfix-Einstellungen prüft, zum
+ Beispiel das |virtual_alias_expansion_limit|_.
+
+Beispiel::
+
+ [bin]
+ dovecotpw = /usr/sbin/dovecotpw
+ du = /usr/bin/du
+ postconf = /usr/sbin/postconf
+
+
+DATABASE
+--------
+Die **database**-Sektion wird verwendet, um die für den Datenbankzugriff
+benötigten Optionen festzulegen.
+
+.. _database.host:
+
+``host (Vorgabe: localhost)`` : *String*
+ Der Hostname oder die IP-Adresse des Datenbankservers.
+
+.. _database.module:
+
+``module (Vorgabe: psycopg2)`` : *String*
+ Das für den Datenbankzugriff zu verwendende Python PostgreSQL Adapter
+ Module. Unterstützte Module sind **psycopg2** und **pyPgSQL**.
+
+.. _database.name:
+
+``name (Vorgabe: mailsys)`` : *String*
+ Der Name der zu verwendenden Datenbank.
+
+.. _database.pass:
+
+``pass (Vorgabe: Nichts)`` : *String*
+ Das Passwort des Datenbank-Benutzers.
+
+.. _database.port:
+
+``port (Vorgabe: 5432)`` : *Int*
+ Der TCP-Port, auf dem der Datenbankserver Verbindungen annimmt.
+
+.. _database.sslmode:
+
+``sslmode (Vorgabe: prefer)`` : *String*
+ Bestimmt, ob und mit welcher Priorität eine SSL-Verbindung mit dem
+ Datenbankserver ausgehandelt wird. Mögliche Werte sind: **disabled**,
+ **allow**, **prefer**, **require**, **verify-ca**, and **verify-full**.
+ Die Modi **verify-ca** und **verify-full** stehen seit PostgreSQL 8.4 zur
+ Verfügung.
+
+ Diese Option wird ignoriert, wenn das *modul* pyPgSQL verwendet wird.
+
+.. _database.user:
+
+``user (Vorgabe: Nichts)`` : *String*
+ Der Name des Datenbank-Benutzers.
+
+Beispiel::
+
+ [database]
+ host = dbsrv8.example.net
+ port 5433
+ sslmode = require
+ user = vmm
+ pass = PY_SRJ}L/0p-oOk
+ name = mailsys
+
+
+DOMAIN
+------
+In der **domain**-Sektion werden Domain-spezifische Informationen
+konfiguriert.
+
+.. _domain.auto_postmaster:
+
+``auto_postmaster (Vorgabe: true)`` : *Boolean*
+ Ist der Wert dieser Option *true*, wird |vmm(1)|_ beim Anlegen einer
+ Domain (|domainadd|_) automatisch einen postmaster-Account erstellen.
+
+.. _domain.delete_directory:
+
+``delete_directory (Vorgabe: false)`` : *Boolean*
+ Bestimmt, ob beim Löschen einer Domain (|domaindelete|_) das Verzeichnis
+ der zu löschenden Domain, inklusive aller Anwender-Verzeichnisse, rekursiv
+ gelöscht werden soll.
+
+.. _domain.directory_mode:
+
+``directory_mode (Vorgabe: 504)`` : *Int*
+ Zugriffsbits des Domain-Verzeichnisses in Dezimal-Schreibweise (Basis 10).
+
+ | Beispiel: 'drwxrwx---' -> oktal 0770 -> dezimal 504
+
+.. _domain.force_deletion:
+
+``force_deletion (Vorgabe: false)`` : *Boolean*
+ Erzwingt das Löschen aller zugeordneten Konten und Aliase beim Löschen
+ einer Domain (|domaindelete|_).
+
+Beispiel::
+
+ [domain]
+ auto_postmaster = true
+ delete_directory = false
+ directory_mode = 504
+ force_deletion = false
+
+
+MAILBOX
+-------
+In der **mailbox**-Sektion werden die für die Erstellung von Mailboxen
+erforderlichen Optionen festgelegt. Die INBOX wird in jedem Fall erstellt.
+
+.. _mailbox.folders:
+
+``folders (Vorgabe: Drafts:Sent:Templates:Trash)`` : *String*
+ Eine durch Doppelpunkten getrennte Liste mit Mailboxnamen die
+ erstellt werden sollen. Sollen keine zusätzlichen Mailboxen angelegt werden,
+ ist dieser Optionen ein einzelner Doppelpunkt ('**:**') als Wert zuzuweisen.
+
+ Sollen Verzeichnisse mit Unterverzeichnissen angelegt werden, ist ein
+ einzelner Punkt ('**.**') als Separator zu verwenden.
+
+ Sollen Mailboxen mit internationalisierten Namen erstellt werden (zum
+ Beispiel: 'Wysłane' oder 'Gelöschte Objekte'), ist der Name UTF-8 kodiert
+ anzugeben. |vmm(1)|_ wird die internationalisierten Mailboxnamen in eine
+ modifizierten Variante des UTF-7-Zeichensatzes (siehe auch: :RFC:`3501`,
+ Sektion 5.1.3) konvertieren.
+
+.. _mailbox.format:
+
+``format (Vorgabe: maildir)`` : *String*
+ Das zu verwendende Format der Mailbox der Benutzer. Abhängig von der
+ verwendeten Dovecot-Version, stehen bis zu drei Formate zur Verfügung:
+
+ ``maildir``
+ seit Dovecot v1.0.0
+ ``mdbox``
+ seit Dovecot v2.0.beta5
+ ``sdbox``
+ seit Dovecot v2.0.rc3
+
+.. _mailbox.root:
+
+``root (Vorgabe: Maildir)`` : *String*
+ Name des Mailbox-Wurzelverzeichnisses im Home-Verzeichnis des jeweiligen
+ Benutzers. Übliche Namen, je nach verwendetem |mailbox.format|_, sind:
+ **Maildir**, **mdbox** oder **sdbox**.
+
+.. _mailbox.subscribe:
+
+``subscribe (Vorgabe: true)`` : *Boolean*
+ Wenn dieser Option der Wert **true** zugewiesen wurde, werden die, gemäß
+ |mailbox.folders|_, erstellen Mailboxen in der subscriptions-Datei des
+ Benutzers gelistet. Sollen die erstellen Mailboxen nicht nicht in der
+ subscriptions-Datei gelistet werden, weisen Sie dieser Option den Wert
+ **false** zu.
+
+Beispiel::
+
+ [mailbox]
+ folders = Drafts:Sent:Templates:Trash:Lists.Dovecot:Lists.Postfix
+ format = maildir
+ root = Maildir
+ subscribe = false
+
+
+MISC
+----
+In der **misc**-Sektion werden verschiedene Einstellungen festgelegt.
+
+.. _misc.base_directory:
+
+``base_directory (Vorgabe: /srv/mail)`` : *String*
+ Alle Domain-Verzeichnisse werden innerhalb dieses Basis-Verzeichnisses
+ angelegt.
+
+.. _misc.crypt_blowfish_rounds:
+
+``crypt_blowfish_rounds (Vorgabe: 5)`` : *Int*
+ Anzahl der Verschlüsselungsdurchgänge für das *password_scheme*
+ **BLF-CRYPT**.
+
+ Der Wert muss im Bereich von **4** - **31** liegen.
+
+.. _misc.crypt_sha256_rounds:
+
+``crypt_sha256_rounds (Vorgabe: 5000)`` : *Int*
+ Anzahl der Verschlüsselungdurchgänge für das *password_scheme*
+ **SHA256-CRYPT**.
+
+ Der Wert muss im Bereich von **1000** - **999999999** liegen.
+
+.. _misc.crypt_sha512_rounds:
+
+``crypt_sha512_rounds (Vorgabe: 5000)`` : *Int*
+ Anzahl der Verschlüsselungsdurchgänge für das *password_scheme*
+ **SHA256-CRYPT**.
+
+ Der Wert muss im Bereich von **1000** - **999999999** liegen.
+
+.. _misc.password_scheme:
+
+``password_scheme (Vorgabe: CRAM-MD5)`` : *String*
+ Das zu verwendende Passwort-Schema. Um eine Liste aller verfügbaren
+ Passwort-Schemata zu erhalten, für Sie das Kommando **dovecotpw -l**
+ (Dovecot v1.x) oder **doveadm pw -l** (Dovecot v2.0) aus.
+
+.. _misc.transport:
+
+``transport (Vorgabe: dovecot:)`` : *String*
+ Der Standard-Transport aller Domains und Konten. Siehe auch:
+ |transport(5)|_
+
+.. _misc.dovecot_version:
+
+``dovecot_version (Vorgabe: Nichts)`` : *String*
+ Die eingesetzten Dovecot-Version. (siehe: **dovecot --version**).
+
+ Wenn das Kommando **dovecot --version** zum Beispiel
+ *2.0.beta4 (8818db00d347)* ausgibt, ist dieser Option der Wert
+ **2.0.beta4** zuzuweisen.
+
+Beispiel::
+
+ [misc]
+ base_directory = /srv/mail
+ crypt_sha512_rounds = 10000
+ password_scheme = SHA512-CRYPT
+ transport = dovecot:
+ dovecot_version = 2.0.beta4
+
+
+DATEIEN
+=======
+*/root/vmm.cfg*
+ | Wird verwendet, falls vorhanden.
+*/usr/local/etc/vmm.cfg*
+ | Wird verwendet, sollte obige Datei nicht gefunden werden.
+*/etc/vmm.cfg*
+ | Wird verwendet, falls obengenannte Dateien nicht existieren.
+
+SIEHE AUCH
+==========
+|vmm(1)|_
+
+
+COPYING
+=======
+vmm und die dazugehörigen Manualseiten wurden von Pascal Volk geschrieben
+und sind unter den Bedingungen der BSD Lizenz lizenziert.
+
+.. include:: ../../substitute_links.rst
+.. include:: ../../substitute_links_5.rst
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/man/man1/vmm.1.rst Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,470 @@
+=====
+ vmm
+=====
+
+----------------------------------------------------------
+command line tool to manage email domains/accounts/aliases
+----------------------------------------------------------
+
+:Author: Pascal Volk <neverseen@users.sourceforge.net>
+:Date: |today|
+:Version: vmm-0.6.0
+:Manual group: vmm Manual
+:Manual section: 1
+
+.. contents::
+ :backlinks: top
+ :class: htmlout
+
+SYNOPSIS
+========
+**vmm** *subcommand* *object* [ *arguments* ]
+
+
+DESCRIPTION
+===========
+**vmm** (a virtual mail manager) is a command line tool for
+administrators/postmasters to manage (alias) domains, accounts and alias
+addresses. It's designed for Dovecot and Postfix with a PostgreSQL backend.
+
+
+SUBCOMMANDS
+===========
+Each subcommand has both a long and a short form. The short form is shown
+enclosed in parentheses. Both forms are case sensitive.
+
+
+GENERAL SUBCOMMANDS
+-------------------
+.. _configget:
+
+``configget (cg) option``
+ This subcommand is used to display the actual value of the given
+ configuration *option*. The option has to be written as
+ *section*\ **.**\ *option*, e.g. **misc.transport**.
+
+.. _configset:
+
+``configset (cs) option value``
+ Use this subcommand to set/update a single configuration option. *option*
+ is the configuration option, written as *section*\ **.**\ *option*. *value*
+ is the *option*'s new value.
+
+ Example::
+
+ vmm configget misc.transport
+ misc.transport = dovecot:
+ vmm configset misc.transport lmtp:unix:private/dovecot-lmtp
+ vmm cg misc.transport
+ misc.transport = lmtp:unix:private/dovecot-lmtp
+
+.. _configure:
+
+``configure (cf) [ section ]``
+ Starts the interactive configuration for all configuration sections.
+
+ In this process the currently set value of each option will be shown in
+ square brackets. If no value is configured, the default value of each
+ option will be displayed in square brackets. Pres the enter key, to accept
+ the displayed value.
+
+ If the optional argument *section* is given, only the configuration
+ options from the given section will be displayed and will be
+ configurable. The following sections are available:
+
+ | - **account**
+ | - **bin**
+ | - **database**
+ | - **domain**
+ | - **maildir**
+ | - **misc**
+
+ Example::
+
+ vmm configure domain
+ Using configuration file: /usr/local/etc/vmm.cfg
+
+ * Configuration section: “domain”
+ Enter new value for option directory_mode [504]:
+ Enter new value for option delete_directory [True]: no
+ Enter new value for option auto_postmaster [True]:
+ Enter new value for option force_deletion [True]: off
+
+.. _getuser:
+
+``getuser (gu) userid``
+ If only the *userid* is available, for example from process list, the
+ subcommand **getuser** will show the user's address.
+
+ Example::
+
+ vmm getuser 70004
+ Account information
+ -------------------
+ UID............: 70004
+ GID............: 70000
+ Address........: c.user@example.com
+
+.. _listdomains:
+
+``listdomains (ld) [ pattern ]``
+ This subcommand lists all available domains. All domain names will be
+ prefixed either with '[+]', if the domain is a primary domain, or with
+ '[-]', if it is an alias domain name. The output can be limited with an
+ optional *pattern*.
+
+ To perform a wild card search, the **%** character can be used at the
+ start and/or the end of the *pattern*.
+
+ Example::
+
+ vmm listdomains %example%
+ Matching domains
+ ----------------
+ [+] example.com
+ [-] e.g.example.com
+ [-] example.name
+ [+] example.net
+ [+] example.org
+
+.. _help:
+
+``help (h)``
+ Prints all available subcommands to stdout. After this **vmm** exits.
+
+.. _version:
+
+``version (v)``
+ Prints the version information from **vmm**.
+
+
+DOMAIN SUBCOMMANDS
+------------------
+.. _domainadd:
+
+``domainadd (da) domain [ transport ]``
+ Adds the new *domain* into the database and creates the domain directory.
+
+ If the optional argument *transport* is given, it will overwrite the
+ default transport (|misc.transport|_) from |vmm.cfg(5)|_. The specified
+ *transport* will be the default transport for all new accounts in this
+ domain.
+
+ When |domain.auto_postmaster|_ is set to **true**, **vmm** will also create
+ an account for **postmaster@**\ *domain*.
+
+ Examples::
+
+ vmm domainadd support.example.com smtp:mx1.example.com
+ vmm domainadd sales.example.com
+
+.. _domaininfo:
+
+``domaininfo (di) domain [ details ]``
+ This subcommand shows some information about the given *domain*.
+
+ For a more detailed information about the *domain* the optional argument
+ *details* can be specified. A possible *details* value may be one of the
+ following five keywords:
+
+ ``accounts``
+ to list all existing accounts
+ ``aliasdomains``
+ to list all assigned alias domains
+ ``aliases``
+ to list all available aliases addresses
+ ``relocated``
+ to list all relocated users
+ ``full``
+ to list all information mentioned above
+
+ Example::
+
+ vmm domaininfo sales.example.com
+ Domain information
+ ------------------
+ Domainname.....: sales.example.com
+ GID............: 70002
+ Transport......: dovecot:
+ Domaindir......: /home/mail/5/70002
+ Aliasdomains...: 0
+ Accounts.......: 0
+ Aliases........: 0
+ Relocated......: 0
+
+.. _domaintransport:
+
+``domaintransport (dt) domain transport [ force ]``
+ A new *transport* for the indicated *domain* can be set with this
+ subcommand.
+
+ If the additional keyword **force** is given all account specific
+ transport settings will be overwritten. Otherwise this setting will affect
+ only new created accounts.
+
+ Example::
+
+ vmm domaintransport support.example.com dovecot:
+
+.. _domaindelete:
+
+``domaindelete (dd) domain [ force ]``
+ This subcommand deletes the specified *domain*.
+
+ If there are accounts, aliases and/or relocated users assigned to the given
+ domain, **vmm** will abort the requested operation and show an error
+ message. If you know, what you are doing, you can specify the keyword
+ **force**.
+
+ If you really always know what you are doing, edit your *vmm.cfg* and set
+ the option |domain.force_deletion|_ to true.
+
+
+ALIAS DOMAIN SUBCOMMANDS
+------------------------
+.. _aliasdomainadd:
+
+``aliasdomainadd (ada) aliasdomain targetdomain``
+ This subcommand adds the new *aliasdomain* to the *targetdomain* that
+ should be aliased.
+
+ Example::
+
+ vmm aliasdomainadd example.name example.com
+
+.. _aliasdomaininfo:
+
+``aliasdomaininfo (adi) aliasdomain``
+ This subcommand shows to which domain the *aliasdomain* is assigned to.
+
+ Example::
+
+ vmm aliasdomaininfo example.name
+ Alias domain information
+ ------------------------
+ The alias domain example.name belongs to:
+ * example.com
+
+.. _aliasdomainswitch:
+
+``aliasdomainswitch (ads) aliasdomain targetdomain``
+ If the target of the existing *aliasdomain* should be switched to another
+ *targetdomain* use this subcommand.
+
+ Example::
+
+ vmm aliasdomainswitch example.name example.org
+
+.. _aliasdomaindelete:
+
+``aliasdomaindelete (add) aliasdomain``
+ Use this subcommand if the alias domain *aliasdomain* should be removed.
+
+ Example::
+
+ vmm aliasdomaindelete e.g.example.com
+
+
+ACCOUNT SUBCOMMANDS
+-------------------
+.. _useradd:
+
+``useradd (ua) address [ password ]``
+ Use this subcommand to create a new email account for the given *address*.
+
+ If the *password* is not provided, **vmm** will prompt for it
+ interactively. When no *password* is provided and |account.random_password|_
+ is set to **true**, **vmm** will generate a random password and print it to
+ stdout after the account has been created.
+
+ Examples::
+
+ vmm ua d.user@example.com 'A 5ecR3t P4s5\\/\\/0rd'
+ vmm ua e.user@example.com
+ Enter new password:
+ Retype new password:
+
+.. _userinfo:
+
+``userinfo (ui) address [ details ]``
+ This subcommand displays some information about the account specified by
+ *address*.
+
+ If the optional argument *details* is given some more information will be
+ displayed. Possible values for *details* are:
+
+ ``aliases``
+ to list all alias addresses with the destination *address*
+ ``du``
+ to display the disk usage of a user's Maildir. In order to summarize the
+ disk usage each time the this subcommand is executed automatically, set
+ |account.disk_usage|_ in the *vmm.cfg* to true.
+ ``full``
+ to list all information mentioned above
+
+.. _username:
+
+``username (un) address "User's Name"``
+ The user's real name can be set/updated with this subcommand.
+
+ Example::
+
+ vmm un d.user@example.com 'John Doe'
+
+.. _userpassword:
+
+``userpassword (up) address [ password ]``
+ The *password* from an account can be updated with this subcommand.
+
+ If the *password* is not provided, **vmm** will prompt for it
+ interactively.
+
+ Example::
+
+ vmm up d.user@example.com 'A |\\/|0r3 5ecur3 P4s5\\/\\/0rd?'
+
+.. _usertransport:
+
+``usertransport (ut) address transport``
+ A different *transport* for an account can be specified with this
+ subcommand.
+
+ Example::
+
+ vmm ut d.user@example.com smtp:pc105.it.example.com
+
+.. _userdisable:
+
+``userdisable (u0) address [ service ... ]``
+ If a user shouldn't have access to one or more services you can restrict
+ the access with this subcommand.
+
+ If no *service* was given all services (**smtp**, **pop3**, **imap**, and
+ **sieve**) will be disabled for the account with the specified *address*.
+ Otherwise only the specified *service*/s will be restricted.
+
+ Examples::
+
+ vmm u0 b.user@example.com imap pop3
+ vmm userdisable c.user@example.com
+
+.. _userenable:
+
+``userenable (u1) address [ service ... ]``
+ To allow access to one or more restricted services use this subcommand.
+
+ If no *service* was given all services (**smtp**, **pop3**, **imap**, and
+ **sieve**) will be enabled for the account with the specified *address*.
+ Otherwise only the specified *service*/s will be enabled.
+
+.. _userdelete:
+
+``userdelete (ud) address [ force ]``
+ Use this subcommand to delete the account with the given *address*.
+
+ If there are one or more aliases with an identical destination *address*,
+ **vmm** will abort the requested operation and show an error message. To
+ prevent this, specify the optional keyword **force**.
+
+
+ALIAS SUBCOMMANDS
+-----------------
+.. _aliasadd:
+
+``aliasadd (aa) alias target``
+ This subcommand is used to create a new alias.
+
+ Examples::
+
+ vmm aliasadd john.doe@example.com d.user@example.com
+ vmm aa support@example.com d.user@example.com
+ vmm aa support@example.com e.user@example.com
+
+.. _aliasinfo:
+
+``aliasinfo (ai) alias``
+ Information about an alias can be displayed with this subcommand.
+
+ Example::
+
+ vmm aliasinfo support@example.com
+ Alias information
+ -----------------
+ Mail for support@example.com will be redirected to:
+ * d.user@example.com
+ * e.user@example.com
+
+.. _aliasdelete:
+
+``aliasdelete (ad) alias [ target ]``
+ Use this subcommand to delete the *alias*.
+
+ If the optional destination address *target* is given, only this
+ destination will be removed from the *alias*.
+
+ Example::
+
+ vmm ad support@example.com d.user@example.com
+
+
+RELOCATED SUBCOMMANDS
+---------------------
+.. _relocatedadd:
+
+``relocatedadd (ra) old_address new_address``
+ A new relocated user can be created with this subcommand.
+
+ *old_address* is the users ex-email address, for example
+ b.user@example.com, and *new_address* points to the new email address
+ where the user can be reached.
+
+ Example::
+
+ vmm relocatedadd b.user@example.com b-user@company.tld
+
+.. _relocatedinfo:
+
+``relocatedinfo (ri) old_address``
+ This subcommand shows the new address of the relocated user with the
+ *old_address*.
+
+ Example::
+
+ vmm relocatedinfo b.user@example.com
+ Relocated information
+ ---------------------
+ User “b.user@example.com” has moved to “b-user@company.tld”
+
+.. _relocateddelete:
+
+``relocateddelete (rd) old_address``
+ Use this subcommand in order to delete the relocated user with the
+ *old_address*.
+
+ Example::
+
+ vmm relocateddelete b.user@example.com
+
+
+FILES
+=====
+*/root/vmm.cfg*
+ | will be used when found.
+*/usr/local/etc/vmm.cfg*
+ | will be used when the above file doesn't exist.
+*/etc/vmm.cfg*
+ | will be used when none of the both above mentioned files exists.
+
+
+SEE ALSO
+========
+|vmm.cfg(5)|_
+
+
+COPYING
+=======
+vmm and its manual pages were written by Pascal Volk and are licensed under
+the terms of the BSD License.
+
+.. include:: ../substitute_links.rst
+.. include:: ../substitute_links_1.rst
--- a/man/man5/vmm.cfg.5 Thu Jan 13 12:48:30 2011 +0000
+++ b/man/man5/vmm.cfg.5 Thu Jan 13 12:54:53 2011 +0000
@@ -1,256 +1,444 @@
-.TH vmm.cfg 5 "17 Aug 2009" "Pascal Volk"
+.\" Man page generated from reStructeredText.
+.
+.TH VMM.CFG 5 "2010-01-18" "vmm-0.6.0" "vmm Manual"
.SH NAME
vmm.cfg \- configuration file for vmm
+.
+.nr rst2man-indent-level 0
+.
+.de1 rstReportMargin
+\\$1 \\n[an-margin]
+level \\n[rst2man-indent-level]
+level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
+-
+\\n[rst2man-indent0]
+\\n[rst2man-indent1]
+\\n[rst2man-indent2]
+..
+.de1 INDENT
+.\" .rstReportMargin pre:
+. RS \\$1
+. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
+. nr rst2man-indent-level +1
+.\" .rstReportMargin post:
+..
+.de UNINDENT
+. RE
+.\" indent \\n[an-margin]
+.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.nr rst2man-indent-level -1
+.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
+..
.SH SYNOPSIS
+.sp
vmm.cfg
.SH DESCRIPTION
-\fBvmm\fR(1) reads configuration data from \fIvmm.cfg\fP.
-.br
-The configuration file is split in multiple sections. A section starts 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
+.sp
+\fBvmm\fP(1) reads its configuration data from \fIvmm.cfg\fP.
+.sp
+The configuration file is split into multiple sections. A section starts with
+the section name, enclosed in square brackets \(aq\fB[\fP\(aq and \(aq\fB]\fP\(aq, followed
+by \(aq\fIoption\fP = \fIvalue\fP\(aq pairs:
+.sp
+.nf
+.ft C
+[database]
+host = 127.0.0.1
+.ft P
+.fi
+.sp
+Whitespace around the \(aq=\(aq and at the end of a value is ignored.
+.sp
+Empty lines and lines starting with \(aq#\(aq or \(aq;\(aq will be ignored.
+.sp
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).
-.br
-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
-an 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'
+.INDENT 0.0
+.IP \(bu 2
+.
+\fIBoolean\fP to indicate if something is enabled/activated (true) or
+disabled/deactivated (false).
+.nf
+Accepted values for \fItrue\fP are: \fB1\fP, \fByes\fP, \fBtrue\fP and \fBon\fP.
+Accepted values for \fIfalse\fP are: \fB0\fP, \fBno\fP, \fBfalse\fP and \fBoff\fP.
+.fi
+.sp
+.IP \(bu 2
+.
+\fIInt\fP an integer number, written without a fractional or decimal component.
+.nf
+For example \fB1\fP, \fB50\fP or \fB321\fP are integers.
+.fi
+.sp
+.IP \(bu 2
+.
+\fIString\fP a sequence of characters and numbers.
+.nf
+For example \(aq\fBword\fP\(aq, \(aq\fBhello world\fP\(aq or \(aq\fB/usr/bin/strings\fP\(aq
+.fi
+.sp
+.UNINDENT
.SS SEARCH ORDER
-By default vmm looks for \fIvmm.cfg\fP in the following directories in the
+.sp
+By default \fBvmm\fP(1) looks for \fIvmm.cfg\fP in the following directories in the
order listed:
-.RS
-.PD 0
+.INDENT 0.0
+.INDENT 3.5
+.nf
+\fI/root\fP
+\fI/usr/local/etc\fP
+\fI/etc\fP
+.fi
+.sp
+.UNINDENT
+.UNINDENT
+.sp
+The first configuration file found will be used.
+.SH SECTIONS
+.sp
+This section describes all sections and their options of the \fIvmm.cfg\fP.
+.SS ACCOUNT
+.sp
+The options in the section \fBaccount\fP are used to specify user account
+related settings.
+.INDENT 0.0
+.TP
+.B \fCdelete_directory\fP
+\fIBoolean\fP
+.sp
+Determines the behavior of \fBvmm\fP(1) when an account is deleted. If
+this option is set to \fItrue\fP the user\(aqs home directory will be deleted
+recursively.
+.TP
+.B \fCdirectory_mode\fP
+\fIInt\fP
+.sp
+Access mode for a user\(aqs home directory and all directories inside.
+The value has to be specified in decimal (base 10) notation.
+.nf
+For example: \(aqdrwx\-\-\-\-\-\-\(aq \-> octal 0700 \-> decimal 448
+.fi
+.sp
.TP
-.I
-/root
+.B \fCdisk_usage\fP
+\fIBoolean\fP
+.sp
+Determines whether the disk usage of a user\(aqs Maildir always should be
+summarized, using \fBdu\fP(1), and displayed with account information.
+.sp
+This could be slow on large Maildirs. When you have enabled quotas,
+\fBvmm\fP\(aqs \fBuserinfo\fP subcomammand will also display the current quota
+usage of the account. You may also use \fBuserinfo\fP\(aqs optional argument
+\fBdu\fP or \fBfull\fP, in order to display the current disk usage of an
+account.
+.TP
+.B \fCimap\fP
+\fIBoolean\fP
+.sp
+Determines whether a newly created user can log in via IMAP.
+.TP
+.B \fCpassword_length\fP
+\fIInt\fP
+.sp
+Determines how many characters and/or numbers should be used for random
+generated passwords. Any value less than 8 will be increased to 8.
+.TP
+.B \fCpop3\fP
+\fIBoolean\fP
+.sp
+Determines whether a newly created user can log in via POP3.
+.TP
+.B \fCrandom_password\fP
+\fIBoolean\fP
+.sp
+Determines whether \fBvmm\fP should generate a random password when no
+password was given for the \fBuseradd\fP subcommand. If this option is
+set to \fIfalse\fP \fBvmm\fP will prompt you to enter a password for the new
+account.
+.sp
+You can specify the password length of generated passwords with the
+\fBpassword_length\fP option.
+.TP
+.B \fCsieve\fP
+\fIBoolean\fP
+.sp
+Determines whether a newly created user can log in via ManageSieve.
.TP
-.I
-/usr/local/etc
+.B \fCsmtp\fP
+\fIBoolean\fP
+.sp
+Determines whether a newly created user can log in via SMTP (SMTP AUTH).
+.UNINDENT
+.sp
+Example:
+.sp
+.nf
+.ft C
+[account]
+delete_directory = false
+directory_mode = 448
+disk_usage = false
+random_password = true
+password_length = 10
+smtp = true
+pop3 = true
+imap = true
+sieve = true
+.ft P
+.fi
+.SS BIN
+.sp
+The \fBbin\fP section is used to specify some paths to some binaries required
+by \fBvmm\fP(1).
+.INDENT 0.0
+.TP
+.B \fCdovecotpw\fP
+\fIString\fP
+.sp
+The absolute path to the dovecotpw binary. This binary is used to
+generate a password hash, if \fBmisc.password_scheme\fP is set to one of
+\(aqSMD5\(aq, \(aqSSHA\(aq, \(aqCRAM\-MD5\(aq, \(aqHMAC\-MD5\(aq, \(aqLANMAN\(aq, \(aqNTLM\(aq or \(aqRPA\(aq.
+.TP
+.B \fCdu\fP
+\fIString\fP
+.sp
+The absolute path to \fBdu\fP(1). This binary is used to summarize the
+disk usage of a user\(aqs Maildir.
.TP
-.I
-/etc
-.PD
-.RE
-.PP
-The first match it finds will be used.
-.\" -----
-.SH DATABASE SECTION
+.B \fCpostconf\fP
+\fIString\fP
+.sp
+The absolute path to Postfix\(aq \fBpostconf\fP(1). This binary is required
+when \fBvmm\fP(1) has to check for some Postfix settings, e.g.
+\fIvirtual_alias_expansion_limit\fP.
+.UNINDENT
+.sp
+Example:
+.sp
+.nf
+.ft C
+[bin]
+dovecotpw = /usr/sbin/dovecotpw
+du = /usr/bin/du
+postconf = /usr/sbin/postconf
+.ft P
+.fi
+.SS CONFIG
+.sp
+The \fBconfig\fP section is an internal used control section.
+.INDENT 0.0
+.TP
+.B \fCdone\fP
+\fIBoolean\fP
+.sp
+This option is set to \fIfalse\fP when \fBvmm\fP(1) 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 \fBvmm\fP(1) with the command \fBvmm
+configure\fP.
+.sp
+If this option is set to \fIfalse\fP, \fBvmm\fP(1) will start in the
+interactive configurations mode.
+.UNINDENT
+.sp
+Example:
+.sp
+.nf
+.ft C
+[config]
+done = true
+.ft P
+.fi
+.SS DATABASE
+.sp
The \fBdatabase\fP section is used to specify some options required to
connect to the database.
+.INDENT 0.0
.TP
-\fBhost\fP (\fIString\fP)
+.B \fChost\fP
+\fIString\fP
+.sp
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)
+.B \fCname\fP
+\fIString\fP
+.sp
Name of the database.
.TP
-\fBExample\fP:
+.B \fCpass\fP
+\fIString\fP
+.sp
+Database password.
+.TP
+.B \fCuser\fP
+\fIString\fP
+.sp
+Name of the database user.
+.UNINDENT
+.sp
+Example:
+.sp
+.nf
+.ft C
[database]
-.br
host = localhost
-.br
user = vmm
-.br
-pass = T~_:L4OYyl]TU?)
-.br
+pass = PY_SRJ}L/0p\-oOk
name = mailsys
-.\" -----
-.SH MAILDIR SECTION
-The \fBmaildir\fP section is used to specify some options for the Maildirs.
+.ft P
+.fi
+.SS DOMAIN
+.sp
+The \fBdomain\fP section specifies some domain related settings.
+.INDENT 0.0
.TP
-\fBname\fP (\fIString\fP)
-Default name of the maildir folder in users home directory.
+.B \fCauto_postmaster\fP
+\fIBoolean\fP
+.sp
+Determines if \fBvmm\fP(1) should create also a postmaster account when a
+new domain is created.
+.TP
+.B \fCdelete_directory\fP
+\fIBoolean\fP
+.sp
+Specifies whether the domain directory and all user directories inside
+should be deleted when a domain is deleted.
.TP
-\fBfolders\fP (\fIString\fP)
-A colon separated list of folder names, that should be created.
-.br
-If no folders should be created inside the Maildir, set the value of this option
-to a single colon (':').
-.TP
-\fBmode\fP (\fIInt\fP)
-Access mode for the maildir in decimal (base 10) notation. For example:
-\'drwx------' -> octal 0700 -> decimal 448
+.B \fCdirectory_mode\fP
+\fIInt\fP
+.sp
+Access mode for the domain directory in decimal (base 10) notation.
+.nf
+For example: \(aqdrwxrwx\-\-\-\(aq \-> octal 0770 \-> decimal 504
+.fi
+.sp
.TP
-\fBdiskusage\fP (\fIBoolean\fP)
-Decides if the disk usage of users maildir always should be summarized and
-displayed with account information.
+.B \fCforce_deletion\fP
+\fIBoolean\fP
+.sp
+Force deletion of accounts and aliases when a domain is deleted.
+.UNINDENT
+.sp
+Example:
+.sp
+.nf
+.ft C
+[domain]
+auto_postmaster = true
+delete_directory = false
+directory_mode = 504
+force_deletion = false
+.ft P
+.fi
+.SS MAILDIR
+.sp
+The \fBmaildir\fP section is used to specify some default options for new
+created Maildirs and folders inside.
+.INDENT 0.0
.TP
-\fBdelete\fP (\fIBoolean\fP)
-Decides if the maildir should be deleted recursive when the account is deleted.
+.B \fCfolders\fP
+\fIString\fP
+.sp
+A colon separated list of folder names, that should be created. If no
+folders should be created inside the Maildir, set the value of this
+option to a single colon (\(aq\fB:\fP\(aq).
+.sp
+If you want to create folders containing one or more subfolders, separate
+them with a single dot (\(aq\fB.\fP\(aq).
.TP
-\fBExample\fP:
+.B \fCname\fP
+\fIString\fP
+.sp
+Default name of the Maildir folder in users home directories.
+.UNINDENT
+.sp
+Example:
+.sp
+.nf
+.ft C
[maildir]
-.br
+folders = Drafts:Sent:Templates:Trash:Lists.Dovecot:Lists.Postfix
name = Maildir
-.br
-folders = Drafts:Sent:Templates:Trash:INBOX.News
-.br
-mode = 448
-.br
-diskusage = false
-.br
-delete = false
-.\" -----
-.SH SERVICES SECTION
-The \fBservices\fP section is used to specify the default restrictions for
-all accounts.
-.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.
+.ft P
+.fi
+.SS MISC
+.sp
+The \fBmisc\fP section is used to define miscellaneous settings.
+.INDENT 0.0
.TP
-\fBimap\fP (\fIBoolean\fP)
-Decides if users can login via imap by default.
-.TP
-\fBsieve\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
-sieve = false
-.\" -----
-.SH DOMDIR SECTION
-The \fBdomdir\fP section is used to specify options for the directories of the
-domains.
-.TP
-\fBbase\fP (\fIString\fP)
+.B \fCbase_directory\fP
+\fIString\fP
+.sp
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 = /srv/mail
-.br
-mode = 504
-.br
-delete = false
-.\" -----
-.SH BIN SECTION
-The \fBbin\fP section is used to specify some paths to some binaries required
-by \fBvmm\fP.
+.B \fCpassword_scheme\fP
+\fIString\fP
+.sp
+Password scheme to use (see also: \fBdovecotpw \-l\fP).
.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
-\fBpostconf\fP (\fIString\fP)
-The absolute path to Postfix' \fBpostconf\fR(1).
-.br
-This binary is required if \fBvmm\fR(1) has to check for some Postfix settings,
-e.g. virtual_alias_expansion_limit.
+.B \fCgid_mail\fP
+\fIInt\fP
+.sp
+Numeric group ID of group mail (\fImail_privileged_group\fP from
+\fIdovecot.conf\fP)
.TP
-\fBExample\fP:
-[bin]
-.br
-dovecotpw = /usr/sbin/dovecotpw
-.br
-du = /usr/bin/du
-.br
-postconf = /usr/sbin/postconf
-.\" -----
-.SH MISC SECTION
-The \fBmisc\fP section is used to define miscellaneous settings.
-.TP
-\fBpasswdscheme\fP (\fIString\fP)
-Password scheme to use (see also: dovecotpw -l)
+.B \fCtransport\fP
+\fIString\fP
+.sp
+Default transport for domains and accounts. For details see
+\fBtransport\fP(5).
.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
-\fBdovecotvers\fP (\fIInt\fP)
-The concatenated major and minor version number of the currently used Dovecot
-version. (see: dovecot --version).
-.br
-This option affects various database operations. There are some differences
-between Dovecot v1.1.x and v1.2.x. For example, when the command \fBdovecot
---version\fP shows \fB1.1\fP.18, set the value of this option to \fB11\fP.
-.TP
-\fBExample\fP:
+.B \fCdovecot_version\fP
+\fIInt\fP
+.sp
+The concatenated major and minor version number of the currently used
+Dovecot version. (see: \fBdovecot \-\-version\fP).
+.sp
+When, for example, the command \fBdovecot \-\-version\fP prints \fI1.1.18\fP, set
+the value of this option to \fB11\fP.
+.UNINDENT
+.sp
+Example:
+.sp
+.nf
+.ft C
[misc]
-.br
-passwdscheme = CRAM-MD5
-.br
+base_directory = /srv/mail
+password_scheme = CRAM\-MD5
gid_mail = 8
-.br
-forcedel = false
-.br
transport = dovecot:
-.br
-dovecotvers = 11
-.\" -----
-.SH CONFIG SECTION
-The \fBconfig\fP section is a internal used control section.
+dovecot_version = 11
+.ft P
+.fi
+.SH FILES
+.INDENT 0.0
+.TP
+.B \fI/root/vmm.cfg\fP
+.nf
+will be used when found.
+.fi
+.sp
+.TP
+.B \fI/usr/local/etc/vmm.cfg\fP
+.nf
+will be used when the above file doesn\(aqt exist.
+.fi
+.sp
.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
-.\" -----
-.SH FILES
-vmm.cfg
+.B \fI/etc/vmm.cfg\fP
+.nf
+will be used when none of the both above mentioned files exists.
+.fi
+.sp
+.UNINDENT
.SH SEE ALSO
+.sp
vmm(1), command line tool to manage email domains/accounts/aliases
+.SH COPYING
+.sp
+vmm and its manual pages were written by Pascal Volk and are licensed under
+the terms of the BSD License.
.SH AUTHOR
-\fBvmm\fP and its man pages were written by Pascal Volk
-<\fIneverseen@users.sourceforge.net\fP> and are licensed under the terms of the
-BSD License.
+Pascal Volk <neverseen@users.sourceforge.net>
+.\" Generated by docutils manpage writer.
+.\"
+.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/man/man5/vmm.cfg.5.rst Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,443 @@
+=========
+ vmm.cfg
+=========
+
+--------------------------
+configuration file for vmm
+--------------------------
+
+:Author: Pascal Volk <neverseen@users.sourceforge.net>
+:Date: |today|
+:Version: vmm-0.6.0
+:Manual group: vmm Manual
+:Manual section: 5
+
+.. contents::
+ :backlinks: top
+ :class: htmlout
+
+SYNOPSIS
+========
+vmm.cfg
+
+
+DESCRIPTION
+===========
+|vmm(1)|_ reads its configuration data from *vmm.cfg*.
+
+The configuration file is split into multiple sections. A section starts with
+the section name, enclosed in square brackets '**[**' and '**]**', followed
+by '*option* = *value*' pairs.
+
+Whitespace around the '=' and at the end of a value is ignored.
+
+Empty lines and lines starting with '#' or ';' will be ignored.
+
+Each value uses one of the following data types:
+
+* *Boolean* to indicate if something is enabled/activated (true) or
+ disabled/deactivated (false).
+
+ | Accepted values for *true* are: **1**, **yes**, **true** and **on**.
+ | Accepted values for *false* are: **0**, **no**, **false** and **off**.
+
+* *Int* an integer number, written without a fractional or decimal component.
+
+ | For example **1**, **50** or **321** are integers.
+
+* *String* a sequence of characters and numbers.
+
+ | For example '**word**', '**hello world**' or '**/usr/bin/strings**'
+
+Most options have a default value, shown in parentheses after the option's
+name. In order to use a option's default setting, comment out the line,
+either with a **#** or **;** or simply remove the setting from *vmm.cfg*.
+
+A minimal *vmm.cfg* would be::
+
+ [database]
+ user = me
+ pass = xxxxxxxx
+
+ [misc]
+ dovecot_version = 1.2.11
+
+
+SEARCH ORDER
+-------------
+By default |vmm(1)|_ looks for *vmm.cfg* in the following directories in the
+order listed:
+
+ | */root*
+ | */usr/local/etc*
+ | */etc*
+
+The first configuration file found will be used.
+
+
+SECTIONS
+========
+This section describes all sections and their options of the *vmm.cfg*.
+
+
+ACCOUNT
+-------
+The options in the section **account** are used to specify user account
+related settings.
+
+.. _account.delete_directory:
+
+``delete_directory (default: false)`` : *Boolean*
+ Determines the behavior of |vmm(1)|_ when an account is deleted
+ (|userdelete|_). If this option is set to *true* the user's home directory
+ will be deleted recursively.
+
+.. _account.directory_mode:
+
+``directory_mode (default: 448)`` : *Int*
+ Access mode for a user's home directory and all directories inside. The
+ value has to be specified in decimal (base 10) notation.
+
+ | For example: 'drwx------' -> octal 0700 -> decimal 448
+
+.. _account.disk_usage:
+
+``disk_usage (default: false)`` : *Boolean*
+ Determines whether the disk usage of a user's Maildir always should be
+ summarized, using **du**\(1), and displayed with account information.
+
+ This could be slow on large Maildirs. When you have enabled quotas,
+ **vmm**'s |userinfo|_ subcomammand will also display the current quota
+ usage of the account. You may also use |userinfo|_'s optional argument
+ **du** or **full**, in order to display the current disk usage of an
+ account's Maildir.
+
+.. _account.imap:
+
+``imap (default: true)`` : *Boolean*
+ Determines whether a newly created user can log in via IMAP.
+
+.. _account.password_length:
+
+``password_length (default: 8)`` : *Int*
+ Determines how many characters and/or numbers should be used for randomly
+ generated passwords. Any value less than 8 will be increased to 8.
+
+.. _account.pop3:
+
+``pop3 (default: true)`` : *Boolean*
+ Determines whether a newly created user can log in via POP3.
+
+.. _account.random_password:
+
+``random_password (default: false)`` : *Boolean*
+ Determines whether **vmm** should generate a random password when no
+ password was given for the |useradd|_ subcommand. If this option is set to
+ *false* **vmm** will prompt you to enter a password for the new account.
+
+ You can specify the password length of generated passwords with the
+ |account.password_length|_ option.
+
+.. _account.sieve:
+
+``sieve (default: true)`` : *Boolean*
+ Determines whether a newly created user can log in via ManageSieve.
+
+.. _account.smtp:
+
+``smtp (default: true)`` : *Boolean*
+ Determines whether a newly created user can log in via SMTP (SMTP AUTH).
+
+Example::
+
+ [account]
+ delete_directory = false
+ directory_mode = 448
+ disk_usage = false
+ random_password = true
+ password_length = 10
+ smtp = true
+ pop3 = true
+ imap = true
+ sieve = true
+
+
+BIN
+---
+The **bin** section is used to specify some paths to some binaries required
+by |vmm(1)|_.
+
+.. _bin.dovecotpw:
+
+``dovecotpw (default: /usr/sbin/dovecotpw)`` : *String*
+ The absolute path to the dovecotpw binary. Use the absolute path to the
+ **doveadm**\(1) binary, if you are using Dovecot v2.0. This binary is used
+ to generate a password hash, if |misc.password_scheme|_ is set to one of
+ 'CRAM-MD5', 'HMAC-MD5', 'LANMAN', 'OTP', 'RPA' or 'SKEY'. This binary will
+ be also required if your Python installation doesn't support the:
+
+ * md4 hash algorithm (hashlib + OpenSSL or PyCrypto) used for the password
+ schemes: 'PLAIN-MD4' and 'NTLM'
+ * sha256 hash algorithm (hashlib or PyCrypto >= 2.1.0alpha1) used for the
+ password schemes: 'SHA256' and 'SSHA256'
+ * sha512 hash algorithm (hashlib) used for the password schemes 'SHA512'
+ and 'SSHA512'
+
+.. _bin.du:
+
+``du (default: /usr/bin/du)`` : *String*
+ The absolute path to **du**\(1). This binary is used to summarize the disk
+ usage of a user's Maildir.
+
+.. _bin.postconf:
+
+``postconf (default: /usr/sbin/postconf)`` : *String*
+ The absolute path to Postfix' |postconf(1)|_. This binary is required when
+ |vmm(1)|_ has to check for some Postfix settings, e.g.
+ |virtual_alias_expansion_limit|_.
+
+Example::
+
+ [bin]
+ dovecotpw = /usr/sbin/dovecotpw
+ du = /usr/bin/du
+ postconf = /usr/sbin/postconf
+
+
+DATABASE
+--------
+The **database** section is used to specify some options required to
+connect to the database.
+
+.. _database.host:
+
+``host (default: localhost)`` : *String*
+ Hostname or IP address of the database server.
+
+.. _database.module:
+
+``module (default: psycopg2)`` : *String*
+ The Python PostgreSQL database adapter module to be used. Supported modules
+ are **psycopg2** and **pyPgSQL**.
+
+.. _database.name:
+
+``name (default: mailsys)`` : *String*
+ Name of the database.
+
+.. _database.pass:
+
+``pass (default: None)`` : *String*
+ Database password.
+
+.. _database.port:
+
+``port (default: 5432)`` : *Int*
+ The TCP port, on which the database server is listening for connections.
+
+.. _database.sslmode:
+
+``sslmode (default: prefer)`` : *String*
+ Determines whether and with what priority an SSL connection will be
+ negotiated with the database server. Possible values are: **disabled**,
+ **allow**, **prefer**, **require**, **verify-ca**, and **verify-full**.
+ The modes **verify-ca** and **verify-full** are available since PostgreSQL
+ 8.4.
+
+ This setting will be ignored when the pyPgSQL *module* is used.
+
+.. _database.user:
+
+``user (default: None)`` : *String*
+ Name of the database user.
+
+Example::
+
+ [database]
+ host = dbsrv8.example.net
+ port 5433
+ sslmode = require
+ user = vmm
+ pass = PY_SRJ}L/0p-oOk
+ name = mailsys
+
+
+DOMAIN
+------
+The **domain** section specifies some domain related settings.
+
+.. _domain.auto_postmaster:
+
+``auto_postmaster (default: true)`` : *Boolean*
+ Determines if |vmm(1)|_ should create also a postmaster account when a new
+ domain is created (|domainadd|_).
+
+.. _domain.delete_directory:
+
+``delete_directory (default: false)`` : *Boolean*
+ Specifies whether the domain directory and all user directories inside
+ should be deleted when a domain is deleted (|domaindelete|_).
+
+.. _domain.directory_mode:
+
+``directory_mode (default: 504)`` : *Int*
+ Access mode for the domain directory in decimal (base 10) notation.
+
+ | For example: 'drwxrwx---' -> octal 0770 -> decimal 504
+
+.. _domain.force_deletion:
+
+``force_deletion (default: false)`` : *Boolean*
+ Force deletion of accounts and aliases when a domain is deleted
+ (|domaindelete|_).
+
+Example::
+
+ [domain]
+ auto_postmaster = true
+ delete_directory = false
+ directory_mode = 504
+ force_deletion = false
+
+
+MAILBOX
+-------
+The **mailbox** section is used to specify some options for new created
+mailboxes in the users home directories. The INBOX will be created always.
+
+.. _mailbox.folders:
+
+``folders (default: Drafts:Sent:Templates:Trash)`` : *String*
+ A colon separated list of mailboxes that should be created. If no
+ additionally mailboxes should be created, set the value of this option to a
+ single colon ('**:**').
+
+ If you want to create folders containing one or more subfolders, separate
+ them with a single dot ('**.**').
+
+ If you want to use internationalized mailbox names (e.g. 'Wysłane' or
+ 'Gelöschte Objekte'), write their names UTF-8 encoded. |vmm(1)|_ will convert
+ internationalized mailbox names to a modified version of the UTF-7 encoding
+ (see also: :RFC:`3501`, section 5.1.3).
+
+.. _mailbox.format:
+
+``format (default: maildir)`` : *String*
+ The mailbox format to be used for a user's mailbox. Depending on the used
+ Dovecot version there are up to three supported formats:
+
+ ``maildir``
+ since Dovecot v1.0.0
+ ``mdbox``
+ since Dovecot v2.0.beta5
+ ``sdbox``
+ since Dovecot v2.0.rc3
+
+.. _mailbox.root:
+
+``root (default: Maildir)`` : *String*
+ Name of the mailbox root directory in a user's home directory. Commonly used
+ names, depending on the used |mailbox.format|_, are **Maildir**, **mdbox**
+ or **sdbox**.
+
+.. _mailbox.subscribe:
+
+``subscribe (default: true)`` : *Boolean*
+ When this option is set to **true**, the mailboxes from the
+ |mailbox.folders|_ option will be listed in the user's subscriptions file.
+ If you don't want to subscribe the created mailboxes, set this option to
+ **false**.
+
+Example::
+
+ [mailbox]
+ folders = Drafts:Sent:Templates:Trash:Lists.Dovecot:Lists.Postfix
+ format = maildir
+ root = Maildir
+ subscribe = false
+
+
+MISC
+----
+The **misc** section is used to define miscellaneous settings.
+
+.. _misc.base_directory:
+
+``base_directory (default: /srv/mail)`` : *String*
+ All domain directories will be created inside this directory.
+
+.. _misc.crypt_blowfish_rounds:
+
+``crypt_blowfish_rounds (default: 5)`` : *Int*
+ Number of encryption rounds for the *password_scheme* **BLF-CRYPT**.
+
+ The value must be in range **4** - **31**.
+
+.. _misc.crypt_sha256_rounds:
+
+``crypt_sha256_rounds (default: 5000)`` : *Int*
+ Number of encryption rounds for the *password_scheme* **SHA256-CRYPT**.
+
+ The value must be in range **1000** - **999999999**.
+
+.. _misc.crypt_sha512_rounds:
+
+``crypt_sha512_rounds (default: 5000)`` : *Int*
+ Number of encryption rounds for the *password_scheme* **SHA512-CRYPT**.
+
+ The value must be in range **1000** - **999999999**.
+
+.. _misc.password_scheme:
+
+``password_scheme (default: CRAM-MD5)`` : *String*
+ Password scheme to use. To get a list of all available password schemes
+ execute the command **dovecotpw -l** (Dovecot v1.x) or **doveadm pw -l**
+ (Dovecot v2.0).
+
+.. _misc.transport:
+
+``transport (default: dovecot:)`` : *String*
+ Default transport for domains and accounts. For details see
+ |transport(5)|_.
+
+.. _misc.dovecot_version:
+
+``dovecot_version (default: None)`` : *String*
+ The version number of the currently used Dovecot version.
+ (see: **dovecot --version**).
+
+ When, for example, the command **dovecot --version** prints
+ *2.0.beta4 (8818db00d347)*, set the value of this option to **2.0.beta4**.
+
+Example::
+
+ [misc]
+ base_directory = /srv/mail
+ crypt_sha512_rounds = 10000
+ password_scheme = SHA512-CRYPT
+ transport = dovecot:
+ dovecot_version = 2.0.beta4
+
+
+FILES
+=====
+*/root/vmm.cfg*
+ | will be used when found.
+*/usr/local/etc/vmm.cfg*
+ | will be used when the above file doesn't exist.
+*/etc/vmm.cfg*
+ | will be used when none of the both above mentioned files exists.
+
+
+SEE ALSO
+========
+|vmm(1)|_
+
+
+COPYING
+=======
+vmm and its manual pages were written by Pascal Volk and are licensed under
+the terms of the BSD License.
+
+.. include:: ../substitute_links.rst
+.. include:: ../substitute_links_5.rst
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/man/substitute_links.rst Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,20 @@
+.. set references to other manpages and set links in the html output
+
+.. |vmm(1)| replace:: **vmm**\(1)
+.. _vmm(1): vmm.1
+
+.. |vmm.cfg(5)| replace:: **vmm.cfg**\(5)
+.. _vmm.cfg(5): vmm.cfg.5
+
+
+.. non vmm
+
+.. |postconf(1)| replace:: **postconf**\(1)
+.. _postconf(1): http://www.postfix.org/postconf.1.html
+
+.. |transport(5)| replace:: **transport**\(5)
+.. _transport(5): http://www.postfix.org/transport.5.html
+
+.. |today| date::
+.. #EOF
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/man/substitute_links_1.rst Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,16 @@
+.. Substitutions in section 1
+
+.. |account.disk_usage| replace:: `account.disk_usage`
+.. _account.disk_usage: vmm.cfg.5#account-disk-usage
+.. |account.random_password| replace:: `account.random_password`
+.. _account.random_password: vmm.cfg.5#account-random-password
+
+.. |domain.auto_postmaster| replace:: `domain.auto_postmaster`
+.. _domain.auto_postmaster: vmm.cfg.5#domain-auto-postmaster
+.. |domain.force_deletion| replace:: `domain.force_deletion`
+.. _domain.force_deletion: vmm.cfg.5#domain-force-deletion
+
+.. |misc.transport| replace:: `misc.transport`
+.. _misc.transport: vmm.cfg.5#misc-transport
+
+.. #EOF
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/man/substitute_links_5.rst Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,33 @@
+.. Substitutions in section 5
+
+.. |account.password_length| replace:: **password_length**
+.. |mailbox.folders| replace:: **folders**
+.. |mailbox.format| replace:: **format**
+.. |misc.crypt_sha256_rounds| replace:: **crypt_sha256_rounds**
+.. |misc.crypt_sha512_rounds| replace:: **crypt_sha512_rounds**
+.. |misc.password_scheme| replace:: **misc.password_scheme**
+
+.. |vmm configure| replace:: **vmm configure**
+.. _`vmm configure`: vmm.1#configure
+
+.. |domainadd| replace:: **domainadd**
+.. _domainadd: vmm.1#domainadd
+
+.. |domaindelete| replace:: **domaindelete**
+.. _domaindelete: vmm.1#domaindelete
+
+.. |useradd| replace:: **useradd**
+.. _useradd: vmm.1#useradd
+
+.. |userdelete| replace:: **userdelete**
+.. _userdelete: vmm.1#userdelete
+
+.. |userinfo| replace:: **userinfo**
+.. _userinfo: vmm.1#userinfo
+
+.. non vmm
+.. |virtual_alias_expansion_limit| replace:: `virtual_alias_expansion_limit`
+.. _virtual_alias_expansion_limit:
+ http://www.postfix.org/postconf.5.html#virtual_alias_expansion_limit
+
+.. #EOF
--- a/pgsql/create_optional_types_and_functions-dovecot-1.2.x.pgsql Thu Jan 13 12:48:30 2011 +0000
+++ b/pgsql/create_optional_types_and_functions-dovecot-1.2.x.pgsql Thu Jan 13 12:54:53 2011 +0000
@@ -88,7 +88,7 @@
address varchar(320) := localpart || '@' || the_domain;
BEGIN
FOR rec IN
- SELECT address, domaindir||'/'||users.uid||'/'||maillocation||'/'
+ SELECT address, domaindir||'/'||users.uid||'/'||directory||'/'
FROM domain_data, users, maillocation
WHERE domain_data.gid = did
AND users.gid = did
@@ -108,7 +108,6 @@
-- ---
-- Data type for functions: postfix_relocated_map(varchar, varchar)
-- postfix_virtual_alias_map(varchar, varchar)
---
-- ---
CREATE TYPE recipient_destination AS (
recipient varchar(320),
@@ -296,7 +295,9 @@
-- Returns: dovecotuser records
--
-- Required access privileges for your dovecot database user:
--- GRANT SELECT ON users,domain_data,domain_name,maillocation TO dovecot;
+-- GRANT SELECT
+-- ON users, domain_data, domain_name, maillocation, mailboxformat
+-- TO dovecot;
--
-- For more details see http://wiki.dovecot.org/UserDatabase
-- ---
@@ -309,12 +310,13 @@
did bigint := (SELECT gid FROM domain_name WHERE domainname=the_domain);
BEGIN
FOR record IN
- SELECT userid, uid, did, domaindir ||'/'|| uid AS home,
- '~/'|| maillocation AS mail
- FROM users, domain_data, maillocation
+ SELECT userid, uid, did, domaindir || '/' || uid AS home,
+ format || ':~/' || directory AS mail
+ FROM users, domain_data, mailboxformat, maillocation
WHERE users.gid = did
AND users.local_part = localpart
AND maillocation.mid = users.mid
+ AND mailboxformat.fid = maillocation.fid
AND domain_data.gid = did
LOOP
RETURN NEXT record;
@@ -332,7 +334,7 @@
-- ---
CREATE TYPE dovecotpassword AS (
userid varchar(320),
- password varchar(74),
+ password varchar(270),
smtp boolean,
pop3 boolean,
imap boolean,
--- a/pgsql/create_optional_types_and_functions.pgsql Thu Jan 13 12:48:30 2011 +0000
+++ b/pgsql/create_optional_types_and_functions.pgsql Thu Jan 13 12:54:53 2011 +0000
@@ -88,7 +88,7 @@
address varchar(320) := localpart || '@' || the_domain;
BEGIN
FOR rec IN
- SELECT address, domaindir||'/'||users.uid||'/'||maillocation||'/'
+ SELECT address, domaindir||'/'||users.uid||'/'||directory||'/'
FROM domain_data, users, maillocation
WHERE domain_data.gid = did
AND users.gid = did
@@ -108,7 +108,6 @@
-- ---
-- Data type for functions: postfix_relocated_map(varchar, varchar)
-- postfix_virtual_alias_map(varchar, varchar)
---
-- ---
CREATE TYPE recipient_destination AS (
recipient varchar(320),
@@ -296,7 +295,9 @@
-- Returns: dovecotuser records
--
-- Required access privileges for your dovecot database user:
--- GRANT SELECT ON users,domain_data,domain_name,maillocation TO dovecot;
+-- GRANT SELECT
+-- ON users, domain_data, domain_name, maillocation, mailboxformat
+-- TO dovecot;
--
-- For more details see http://wiki.dovecot.org/UserDatabase
-- ---
@@ -309,12 +310,13 @@
did bigint := (SELECT gid FROM domain_name WHERE domainname=the_domain);
BEGIN
FOR record IN
- SELECT userid, uid, did, domaindir ||'/'|| uid AS home,
- '~/'|| maillocation AS mail
- FROM users, domain_data, maillocation
+ SELECT userid, uid, did, domaindir || '/' || uid AS home,
+ format || ':~/' || directory AS mail
+ FROM users, domain_data, mailboxformat, maillocation
WHERE users.gid = did
AND users.local_part = localpart
AND maillocation.mid = users.mid
+ AND mailboxformat.fid = maillocation.fid
AND domain_data.gid = did
LOOP
RETURN NEXT record;
@@ -332,7 +334,7 @@
-- ---
CREATE TYPE dovecotpassword AS (
userid varchar(320),
- password varchar(74),
+ password varchar(270),
smtp boolean,
pop3 boolean,
imap boolean,
--- a/pgsql/create_tables-dovecot-1.2.x.pgsql Thu Jan 13 12:48:30 2011 +0000
+++ b/pgsql/create_tables-dovecot-1.2.x.pgsql Thu Jan 13 12:54:53 2011 +0000
@@ -4,6 +4,8 @@
CREATE SEQUENCE transport_id;
+CREATE SEQUENCE mailboxformat_id;
+
CREATE SEQUENCE maillocation_id;
CREATE SEQUENCE domain_gid
@@ -30,18 +32,32 @@
-- Insert default transport
INSERT INTO transport(transport) VALUES ('dovecot:');
-CREATE TABLE maillocation(
- mid bigint NOT NULL DEFAULT nextval('maillocation_id'),
- maillocation varchar(20) NOT NULL,
+CREATE TABLE mailboxformat (
+ fid bigint NOT NULL DEFAULT nextval('mailboxformat_id'),
+ format varchar(20) NOT NULL,
+ CONSTRAINT pkey_mailboxformat PRIMARY KEY (fid),
+ CONSTRAINT ukey_mailboxformat UNIQUE (format)
+);
+-- Insert supported mailbox formats
+INSERT INTO mailboxformat(format) VALUES ('maildir');
+INSERT INTO mailboxformat(format) VALUES ('mdbox');
+INSERT INTO mailboxformat(format) VALUES ('sdbox');
+
+CREATE TABLE maillocation (
+ mid bigint NOT NULL DEFAULT nextval('maillocation_id'),
+ fid bigint NOT NULL DEFAULT 1,
+ directory varchar(20) NOT NULL,
+ extra varchar(1024),
CONSTRAINT pkey_maillocation PRIMARY KEY (mid),
- CONSTRAINT ukey_maillocation UNIQUE (maillocation)
+ CONSTRAINT fkey_maillocation_fid_mailboxformat FOREIGN KEY (fid)
+ REFERENCES mailboxformat (fid);
);
-- Insert default Maildir-folder name
-INSERT INTO maillocation(maillocation) VALUES ('Maildir');
+INSERT INTO maillocation(directory) VALUES ('Maildir');
CREATE TABLE domain_data (
gid bigint NOT NULL DEFAULT nextval('domain_gid'),
- tid bigint NOT NULL DEFAULT 1, -- defualt transport
+ tid bigint NOT NULL DEFAULT 1, -- default transport
domaindir varchar(40) NOT NULL, --/srv/mail/$RAND/4294967294
CONSTRAINT pkey_domain_data PRIMARY KEY (gid),
CONSTRAINT fkey_domain_data_tid_transport FOREIGN KEY (tid)
@@ -59,7 +75,7 @@
CREATE TABLE users (
local_part varchar(64) NOT NULL,-- only localpart w/o '@'
- passwd varchar(74) NOT NULL,-- {CRAM-MD5}+64hex numbers
+ passwd varchar(270) NOT NULL,
name varchar(128) NULL,
uid bigint NOT NULL DEFAULT nextval('users_uid'),
gid bigint NOT NULL,
@@ -106,11 +122,12 @@
CREATE OR REPLACE VIEW dovecot_user AS
SELECT local_part || '@' || domain_name.domainname AS userid,
uid, gid, domain_data.domaindir || '/' || uid AS home,
- '~/' || maillocation.maillocation AS mail
+ mailboxformat.format || ':~/' || maillocation.directory AS mail
FROM users
LEFT JOIN domain_data USING (gid)
LEFT JOIN domain_name USING (gid)
- LEFT JOIN maillocation USING (mid);
+ LEFT JOIN maillocation USING (mid)
+ LEFT JOIN mailboxformat USING (fid);
CREATE OR REPLACE VIEW postfix_gid AS
SELECT gid, domainname
@@ -123,7 +140,7 @@
CREATE OR REPLACE VIEW postfix_maildir AS
SELECT local_part || '@' || domain_name.domainname AS address,
- domain_data.domaindir||'/'||uid||'/'||maillocation.maillocation||'/'
+ domain_data.domaindir||'/'||uid||'/'||maillocation.directory||'/'
AS maildir
FROM users
LEFT JOIN domain_data USING (gid)
--- a/pgsql/create_tables.pgsql Thu Jan 13 12:48:30 2011 +0000
+++ b/pgsql/create_tables.pgsql Thu Jan 13 12:54:53 2011 +0000
@@ -4,6 +4,8 @@
CREATE SEQUENCE transport_id;
+CREATE SEQUENCE mailboxformat_id;
+
CREATE SEQUENCE maillocation_id;
CREATE SEQUENCE domain_gid
@@ -30,18 +32,32 @@
-- Insert default transport
INSERT INTO transport(transport) VALUES ('dovecot:');
-CREATE TABLE maillocation(
- mid bigint NOT NULL DEFAULT nextval('maillocation_id'),
- maillocation varchar(20) NOT NULL,
+CREATE TABLE mailboxformat (
+ fid bigint NOT NULL DEFAULT nextval('mailboxformat_id'),
+ format varchar(20) NOT NULL,
+ CONSTRAINT pkey_mailboxformat PRIMARY KEY (fid),
+ CONSTRAINT ukey_mailboxformat UNIQUE (format)
+);
+-- Insert supported mailbox formats
+INSERT INTO mailboxformat(format) VALUES ('maildir');
+INSERT INTO mailboxformat(format) VALUES ('mdbox');
+INSERT INTO mailboxformat(format) VALUES ('sdbox');
+
+CREATE TABLE maillocation (
+ mid bigint NOT NULL DEFAULT nextval('maillocation_id'),
+ fid bigint NOT NULL DEFAULT 1,
+ directory varchar(20) NOT NULL,
+ extra varchar(1024),
CONSTRAINT pkey_maillocation PRIMARY KEY (mid),
- CONSTRAINT ukey_maillocation UNIQUE (maillocation)
+ CONSTRAINT fkey_maillocation_fid_mailboxformat FOREIGN KEY (fid)
+ REFERENCES mailboxformat (fid);
);
-- Insert default Maildir-folder name
-INSERT INTO maillocation(maillocation) VALUES ('Maildir');
+INSERT INTO maillocation(directory) VALUES ('Maildir');
CREATE TABLE domain_data (
gid bigint NOT NULL DEFAULT nextval('domain_gid'),
- tid bigint NOT NULL DEFAULT 1, -- defualt transport
+ tid bigint NOT NULL DEFAULT 1, -- default transport
domaindir varchar(40) NOT NULL, --/srv/mail/$RAND/4294967294
CONSTRAINT pkey_domain_data PRIMARY KEY (gid),
CONSTRAINT fkey_domain_data_tid_transport FOREIGN KEY (tid)
@@ -59,7 +75,7 @@
CREATE TABLE users (
local_part varchar(64) NOT NULL,-- only localpart w/o '@'
- passwd varchar(74) NOT NULL,-- {CRAM-MD5}+64hex numbers
+ passwd varchar(270) NOT NULL,
name varchar(128) NULL,
uid bigint NOT NULL DEFAULT nextval('users_uid'),
gid bigint NOT NULL,
@@ -106,11 +122,12 @@
CREATE OR REPLACE VIEW dovecot_user AS
SELECT local_part || '@' || domain_name.domainname AS userid,
uid, gid, domain_data.domaindir || '/' || uid AS home,
- '~/' || maillocation.maillocation AS mail
+ mailboxformat.format || ':~/' || maillocation.directory AS mail
FROM users
LEFT JOIN domain_data USING (gid)
LEFT JOIN domain_name USING (gid)
- LEFT JOIN maillocation USING (mid);
+ LEFT JOIN maillocation USING (mid)
+ LEFT JOIN mailboxformat USING (fid);
CREATE OR REPLACE VIEW postfix_gid AS
SELECT gid, domainname
@@ -123,7 +140,7 @@
CREATE OR REPLACE VIEW postfix_maildir AS
SELECT local_part || '@' || domain_name.domainname AS address,
- domain_data.domaindir||'/'||uid||'/'||maillocation.maillocation||'/'
+ domain_data.domaindir||'/'||uid||'/'||maillocation.directory||'/'
AS maildir
FROM users
LEFT JOIN domain_data USING (gid)
--- a/pgsql/update_tables_0.4.x-0.5.pgsql Thu Jan 13 12:48:30 2011 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,156 +0,0 @@
-SET client_encoding = 'UTF8';
-SET client_min_messages = warning;
-
-ALTER SEQUENCE domains_gid RENAME TO domain_gid;
-
-
-CREATE TABLE domain_data (
- gid bigint NOT NULL DEFAULT nextval('domain_gid'),
- tid bigint NOT NULL DEFAULT 1,
- domaindir varchar(40) NOT NULL,
- CONSTRAINT pkey_domain_data PRIMARY KEY (gid),
- CONSTRAINT fkey_domain_data_tid_transport FOREIGN KEY (tid)
- REFERENCES transport (tid)
-);
-
-CREATE TABLE domain_name (
- domainname varchar(255) NOT NULL,
- gid bigint NOT NULL,
- is_primary boolean NOT NULL,
- CONSTRAINT pkey_domain_name PRIMARY KEY (domainname),
- CONSTRAINT fkey_domain_name_gid_domain_data FOREIGN KEY (gid)
- REFERENCES domain_data (gid)
-);
-
-INSERT INTO domain_data (gid, tid, domaindir)
- SELECT gid, tid, domaindir
- FROM domains;
-
-INSERT INTO domain_name (domainname, gid, is_primary)
- SELECT domainname, gid, TRUE
- FROM domains;
-
-
-ALTER TABLE users DROP CONSTRAINT pkye_users;
-ALTER TABLE users ADD CONSTRAINT pkey_users PRIMARY KEY (local_part, gid);
-ALTER TABLE users DROP CONSTRAINT fkey_users_gid_domains;
-ALTER TABLE users ADD CONSTRAINT fkey_users_gid_domain_data FOREIGN KEY (gid)
- REFERENCES domain_data (gid);
-
-ALTER TABLE alias DROP CONSTRAINT fkey_alias_gid_domains;
-ALTER TABLE alias DROP CONSTRAINT pkey_alias;
-ALTER TABLE alias ADD CONSTRAINT fkey_alias_gid_domain_data FOREIGN KEY (gid)
- REFERENCES domain_data (gid);
-
-ALTER TABLE relocated DROP CONSTRAINT fkey_relocated_gid_domains;
-ALTER TABLE relocated ADD CONSTRAINT fkey_relocated_gid_domain_data
- FOREIGN KEY (gid) REFERENCES domain_data (gid);
-
-
-CREATE OR REPLACE VIEW dovecot_password AS
- SELECT local_part || '@' || domain_name.domainname AS "user",
- passwd AS "password", smtp, pop3, imap, managesieve
- FROM users
- LEFT JOIN domain_name USING (gid);
-
-CREATE OR REPLACE VIEW dovecot_user AS
- SELECT local_part || '@' || domain_name.domainname AS userid,
- uid, gid, domain_data.domaindir || '/' || uid AS home,
- '~/' || maillocation.maillocation AS mail
- FROM users
- LEFT JOIN domain_data USING (gid)
- LEFT JOIN domain_name USING (gid)
- LEFT JOIN maillocation USING (mid);
-
-CREATE OR REPLACE VIEW postfix_gid AS
- SELECT gid, domainname
- FROM domain_name;
-
-CREATE OR REPLACE VIEW postfix_uid AS
- SELECT local_part || '@' || domain_name.domainname AS address, uid
- FROM users
- LEFT JOIN domain_name USING (gid);
-
-CREATE OR REPLACE VIEW postfix_maildir AS
- SELECT local_part || '@' || domain_name.domainname AS address,
- domain_data.domaindir||'/'||uid||'/'||maillocation.maillocation||'/'
- AS maildir
- FROM users
- LEFT JOIN domain_data USING (gid)
- LEFT JOIN domain_name USING (gid)
- LEFT JOIN maillocation USING (mid);
-
-CREATE OR REPLACE VIEW postfix_relocated AS
- SELECT address || '@' || domain_name.domainname AS address, destination
- FROM relocated
- LEFT JOIN domain_name USING (gid);
-
-DROP VIEW postfix_alias;
-DROP VIEW vmm_domain_info;
-DROP VIEW vmm_alias_count;
-
-ALTER TABLE alias ALTER address TYPE varchar(64);
-ALTER TABLE alias ADD CONSTRAINT pkey_alias
- PRIMARY KEY (gid, address, destination);
-
-CREATE OR REPLACE VIEW postfix_alias AS
- SELECT address || '@' || domain_name.domainname AS address, destination, gid
- FROM alias
- LEFT JOIN domain_name USING (gid);
-
-CREATE OR REPLACE VIEW postfix_transport AS
- SELECT local_part || '@' || domain_name.domainname AS address,
- transport.transport
- FROM users
- LEFT JOIN transport USING (tid)
- LEFT JOIN domain_name USING (gid);
-
-CREATE OR REPLACE VIEW vmm_domain_info AS
- SELECT gid, domainname, transport, domaindir,
- count(uid) AS accounts,
- (SELECT count(DISTINCT address)
- FROM alias
- WHERE alias.gid = domain_data.gid) AS aliases,
- (SELECT count(gid)
- FROM relocated
- WHERE relocated.gid = domain_data.gid) AS relocated,
- (SELECT count(gid)
- FROM domain_name
- WHERE domain_name.gid = domain_data.gid
- AND NOT domain_name.is_primary) AS aliasdomains
- FROM domain_data
- LEFT JOIN domain_name USING (gid)
- LEFT JOIN transport USING (tid)
- LEFT JOIN users USING (gid)
- WHERE domain_name.is_primary
- GROUP BY gid, domainname, transport, domaindir;
-
-
-DROP TABLE domains;
-
-
-CREATE LANGUAGE plpgsql;
-
-CREATE OR REPLACE FUNCTION domain_primary_trigger() RETURNS TRIGGER AS $$
-DECLARE
- primary_count bigint;
-BEGIN
- SELECT INTO primary_count count(gid) + NEW.is_primary::integer
- FROM domain_name
- WHERE domain_name.gid = NEW.gid
- AND is_primary;
-
- IF (primary_count > 1) THEN
- RAISE EXCEPTION 'There can only be one domain marked as primary.';
- END IF;
-
- RETURN NEW;
-END;
-$$ LANGUAGE plpgsql STABLE;
-
-DROP TRIGGER IF EXISTS primary_count ON domain_name;
-CREATE TRIGGER primary_count_ins BEFORE INSERT ON domain_name
- FOR EACH ROW EXECUTE PROCEDURE domain_primary_trigger();
-
-CREATE TRIGGER primary_count_upd AFTER UPDATE ON domain_name
- FOR EACH ROW EXECUTE PROCEDURE domain_primary_trigger();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pgsql/update_tables_0.5.x-0.6-dovecot-1.2.x.pgsql Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,64 @@
+SET client_encoding = 'UTF8';
+SET client_min_messages = warning;
+
+
+-- ---
+-- Make room for sha512-crypt.hex hashed passwords
+-- ---
+DROP VIEW dovecot_password;
+
+ALTER TABLE users ALTER COLUMN passwd TYPE varchar(270);
+
+CREATE VIEW dovecot_password AS
+ SELECT local_part || '@' || domain_name.domainname AS "user",
+ passwd AS "password", smtp, pop3, imap, sieve
+ FROM users
+ LEFT JOIN domain_name USING (gid);
+
+-- ---
+-- Make room for different mailbox formats.
+-- ---
+DROP VIEW dovecot_user;
+DROP VIEW postfix_maildir;
+
+CREATE SEQUENCE mailboxformat_id;
+
+CREATE TABLE mailboxformat (
+ fid bigint NOT NULL DEFAULT nextval('mailboxformat_id'),
+ format varchar(20) NOT NULL,
+ CONSTRAINT pkey_mailboxformat PRIMARY KEY (fid),
+ CONSTRAINT ukey_mailboxformat UNIQUE (format)
+);
+-- Insert supported mailbox formats
+INSERT INTO mailboxformat(format) VALUES ('maildir');
+INSERT INTO mailboxformat(format) VALUES ('mdbox');
+INSERT INTO mailboxformat(format) VALUES ('sdbox');
+
+-- Adjust maillocation table
+ALTER TABLE maillocation DROP CONSTRAINT ukey_maillocation;
+ALTER TABLE maillocation RENAME COLUMN maillocation TO directory;
+ALTER TABLE maillocation
+ ADD COLUMN fid bigint NOT NULL DEFAULT 1,
+ ADD COLUMN extra varchar(1024);
+ALTER TABLE maillocation ADD CONSTRAINT fkey_maillocation_fid_mailboxformat
+ FOREIGN KEY (fid) REFERENCES mailboxformat (fid);
+
+
+CREATE VIEW dovecot_user AS
+ SELECT local_part || '@' || domain_name.domainname AS userid,
+ uid, gid, domain_data.domaindir || '/' || uid AS home,
+ mailboxformat.format || ':~/' || maillocation.directory AS mail
+ FROM users
+ LEFT JOIN domain_data USING (gid)
+ LEFT JOIN domain_name USING (gid)
+ LEFT JOIN maillocation USING (mid)
+ LEFT JOIN mailboxformat USING (fid);
+
+CREATE VIEW postfix_maildir AS
+ SELECT local_part || '@' || domain_name.domainname AS address,
+ domain_data.domaindir||'/'||uid||'/'||maillocation.directory||'/'
+ AS maildir
+ FROM users
+ LEFT JOIN domain_data USING (gid)
+ LEFT JOIN domain_name USING (gid)
+ LEFT JOIN maillocation USING (mid);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pgsql/update_tables_0.5.x-0.6.pgsql Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,64 @@
+SET client_encoding = 'UTF8';
+SET client_min_messages = warning;
+
+
+-- ---
+-- Make room for sha512-crypt.hex hashed passwords
+-- ---
+DROP VIEW dovecot_password;
+
+ALTER TABLE users ALTER COLUMN passwd TYPE varchar(270);
+
+CREATE VIEW dovecot_password AS
+ SELECT local_part || '@' || domain_name.domainname AS "user",
+ passwd AS "password", smtp, pop3, imap, managesieve
+ FROM users
+ LEFT JOIN domain_name USING (gid);
+
+-- ---
+-- Make room for different mailbox formats.
+-- ---
+DROP VIEW dovecot_user;
+DROP VIEW postfix_maildir;
+
+CREATE SEQUENCE mailboxformat_id;
+
+CREATE TABLE mailboxformat (
+ fid bigint NOT NULL DEFAULT nextval('mailboxformat_id'),
+ format varchar(20) NOT NULL,
+ CONSTRAINT pkey_mailboxformat PRIMARY KEY (fid),
+ CONSTRAINT ukey_mailboxformat UNIQUE (format)
+);
+-- Insert supported mailbox formats
+INSERT INTO mailboxformat(format) VALUES ('maildir');
+INSERT INTO mailboxformat(format) VALUES ('mdbox');
+INSERT INTO mailboxformat(format) VALUES ('sdbox');
+
+-- Adjust maillocation table
+ALTER TABLE maillocation DROP CONSTRAINT ukey_maillocation;
+ALTER TABLE maillocation RENAME COLUMN maillocation TO directory;
+ALTER TABLE maillocation
+ ADD COLUMN fid bigint NOT NULL DEFAULT 1,
+ ADD COLUMN extra varchar(1024);
+ALTER TABLE maillocation ADD CONSTRAINT fkey_maillocation_fid_mailboxformat
+ FOREIGN KEY (fid) REFERENCES mailboxformat (fid);
+
+
+CREATE VIEW dovecot_user AS
+ SELECT local_part || '@' || domain_name.domainname AS userid,
+ uid, gid, domain_data.domaindir || '/' || uid AS home,
+ mailboxformat.format || ':~/' || maillocation.directory AS mail
+ FROM users
+ LEFT JOIN domain_data USING (gid)
+ LEFT JOIN domain_name USING (gid)
+ LEFT JOIN maillocation USING (mid)
+ LEFT JOIN mailboxformat USING (fid);
+
+CREATE VIEW postfix_maildir AS
+ SELECT local_part || '@' || domain_name.domainname AS address,
+ domain_data.domaindir||'/'||uid||'/'||maillocation.directory||'/'
+ AS maildir
+ FROM users
+ LEFT JOIN domain_data USING (gid)
+ LEFT JOIN domain_name USING (gid)
+ LEFT JOIN maillocation USING (mid);
--- a/pgsql/update_tables_0.5.x_for_dovecot-1.2.x.pgsql Thu Jan 13 12:48:30 2011 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
--- ---
--- with Dovecot v1.2.x the service managesieve was renamed to sieve
--- ---
-ALTER TABLE users RENAME managesieve TO sieve;
-
-DROP VIEW dovecot_password;
-CREATE OR REPLACE VIEW dovecot_password AS
- SELECT local_part || '@' || domain_name.domainname AS "user",
- passwd AS "password", smtp, pop3, imap, sieve
- FROM users
- LEFT JOIN domain_name USING (gid);
-
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pgsql/update_types_and_functions_0.5.x-0.6-dovecot-1.2.x.pgsql Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,123 @@
+SET client_encoding = 'UTF8';
+SET client_min_messages = warning;
+
+
+-- ---
+-- Parameters (from recipients address (MAIL TO) [localpart@the_domain]):
+-- varchar localpart
+-- varchar the_domain
+-- Returns: address_maildir records
+--
+-- Required access privileges for your postfix database user:
+-- GRANT SELECT ON domain_data,domain_name,maillocation,users TO postfix;
+--
+-- For more details see postconf(5) section virtual_mailbox_maps
+-- ---
+CREATE OR REPLACE FUNCTION postfix_virtual_mailbox_map(
+ IN localpart varchar, IN the_domain varchar) RETURNS SETOF address_maildir
+AS $$
+ DECLARE
+ rec address_maildir;
+ did bigint := (SELECT gid FROM domain_name WHERE domainname=the_domain);
+ address varchar(320) := localpart || '@' || the_domain;
+ BEGIN
+ FOR rec IN
+ SELECT address, domaindir||'/'||users.uid||'/'||directory||'/'
+ FROM domain_data, users, maillocation
+ WHERE domain_data.gid = did
+ AND users.gid = did
+ AND users.local_part = localpart
+ AND maillocation.mid = users.mid
+ LOOP
+ RETURN NEXT rec;
+ END LOOP;
+ RETURN;
+ END;
+$$ LANGUAGE plpgsql STABLE
+RETURNS NULL ON NULL INPUT
+EXTERNAL SECURITY INVOKER;
+
+
+DROP TYPE dovecotpassword CASCADE;
+-- ---
+-- Data type for function dovecotpassword(varchar, varchar)
+-- ---
+CREATE TYPE dovecotpassword AS (
+ userid varchar(320),
+ password varchar(270),
+ smtp boolean,
+ pop3 boolean,
+ imap boolean,
+ sieve boolean
+);
+-- ---
+-- Parameters (from login name [localpart@the_domain]):
+-- varchar localpart
+-- varchar the_domain
+-- Returns: dovecotpassword records
+--
+-- Required access privileges for your dovecot database user:
+-- GRANT SELECT ON users, domain_name TO dovecot;
+--
+-- For more details see http://wiki.dovecot.org/AuthDatabase/SQL
+-- ---
+CREATE OR REPLACE FUNCTION dovecotpassword(
+ IN localpart varchar, IN the_domain varchar) RETURNS SETOF dovecotpassword
+AS $$
+ DECLARE
+ record dovecotpassword;
+ userid varchar(320) := localpart || '@' || the_domain;
+ BEGIN
+ FOR record IN
+ SELECT userid, passwd, smtp, pop3, imap, sieve
+ FROM users
+ WHERE gid = (SELECT gid
+ FROM domain_name
+ WHERE domainname = the_domain)
+ AND local_part = localpart
+ LOOP
+ RETURN NEXT record;
+ END LOOP;
+ RETURN;
+ END;
+$$ LANGUAGE plpgsql STABLE
+RETURNS NULL ON NULL INPUT
+EXTERNAL SECURITY INVOKER;
+-- ---
+-- Parameters (from login name [localpart@the_domain]):
+-- varchar localpart
+-- varchar the_domain
+-- Returns: dovecotuser records
+--
+-- Required access privileges for your dovecot database user:
+-- GRANT SELECT
+-- ON users, domain_data, domain_name, maillocation, mailboxformat
+-- TO dovecot;
+--
+-- For more details see http://wiki.dovecot.org/UserDatabase
+-- ---
+CREATE OR REPLACE FUNCTION dovecotuser(
+ IN localpart varchar, IN the_domain varchar) RETURNS SETOF dovecotuser
+AS $$
+ DECLARE
+ record dovecotuser;
+ userid varchar(320) := localpart || '@' || the_domain;
+ did bigint := (SELECT gid FROM domain_name WHERE domainname=the_domain);
+ BEGIN
+ FOR record IN
+ SELECT userid, uid, did, domaindir || '/' || uid AS home,
+ format || ':~/' || directory AS mail
+ FROM users, domain_data, mailboxformat, maillocation
+ WHERE users.gid = did
+ AND users.local_part = localpart
+ AND maillocation.mid = users.mid
+ AND mailboxformat.fid = maillocation.fid
+ AND domain_data.gid = did
+ LOOP
+ RETURN NEXT record;
+ END LOOP;
+ RETURN;
+ END;
+$$ LANGUAGE plpgsql STABLE
+RETURNS NULL ON NULL INPUT
+EXTERNAL SECURITY INVOKER;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pgsql/update_types_and_functions_0.5.x-0.6.pgsql Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,123 @@
+SET client_encoding = 'UTF8';
+SET client_min_messages = warning;
+
+
+-- ---
+-- Parameters (from recipients address (MAIL TO) [localpart@the_domain]):
+-- varchar localpart
+-- varchar the_domain
+-- Returns: address_maildir records
+--
+-- Required access privileges for your postfix database user:
+-- GRANT SELECT ON domain_data,domain_name,maillocation,users TO postfix;
+--
+-- For more details see postconf(5) section virtual_mailbox_maps
+-- ---
+CREATE OR REPLACE FUNCTION postfix_virtual_mailbox_map(
+ IN localpart varchar, IN the_domain varchar) RETURNS SETOF address_maildir
+AS $$
+ DECLARE
+ rec address_maildir;
+ did bigint := (SELECT gid FROM domain_name WHERE domainname=the_domain);
+ address varchar(320) := localpart || '@' || the_domain;
+ BEGIN
+ FOR rec IN
+ SELECT address, domaindir||'/'||users.uid||'/'||directory||'/'
+ FROM domain_data, users, maillocation
+ WHERE domain_data.gid = did
+ AND users.gid = did
+ AND users.local_part = localpart
+ AND maillocation.mid = users.mid
+ LOOP
+ RETURN NEXT rec;
+ END LOOP;
+ RETURN;
+ END;
+$$ LANGUAGE plpgsql STABLE
+RETURNS NULL ON NULL INPUT
+EXTERNAL SECURITY INVOKER;
+
+
+DROP TYPE dovecotpassword CASCADE;
+-- ---
+-- Data type for function dovecotpassword(varchar, varchar)
+-- ---
+CREATE TYPE dovecotpassword AS (
+ userid varchar(320),
+ password varchar(270),
+ smtp boolean,
+ pop3 boolean,
+ imap boolean,
+ managesieve boolean
+);
+-- ---
+-- Parameters (from login name [localpart@the_domain]):
+-- varchar localpart
+-- varchar the_domain
+-- Returns: dovecotpassword records
+--
+-- Required access privileges for your dovecot database user:
+-- GRANT SELECT ON users, domain_name TO dovecot;
+--
+-- For more details see http://wiki.dovecot.org/AuthDatabase/SQL
+-- ---
+CREATE OR REPLACE FUNCTION dovecotpassword(
+ IN localpart varchar, IN the_domain varchar) RETURNS SETOF dovecotpassword
+AS $$
+ DECLARE
+ record dovecotpassword;
+ userid varchar(320) := localpart || '@' || the_domain;
+ BEGIN
+ FOR record IN
+ SELECT userid, passwd, smtp, pop3, imap, managesieve
+ FROM users
+ WHERE gid = (SELECT gid
+ FROM domain_name
+ WHERE domainname = the_domain)
+ AND local_part = localpart
+ LOOP
+ RETURN NEXT record;
+ END LOOP;
+ RETURN;
+ END;
+$$ LANGUAGE plpgsql STABLE
+RETURNS NULL ON NULL INPUT
+EXTERNAL SECURITY INVOKER;
+-- ---
+-- Parameters (from login name [localpart@the_domain]):
+-- varchar localpart
+-- varchar the_domain
+-- Returns: dovecotuser records
+--
+-- Required access privileges for your dovecot database user:
+-- GRANT SELECT
+-- ON users, domain_data, domain_name, maillocation, mailboxformat
+-- TO dovecot;
+--
+-- For more details see http://wiki.dovecot.org/UserDatabase
+-- ---
+CREATE OR REPLACE FUNCTION dovecotuser(
+ IN localpart varchar, IN the_domain varchar) RETURNS SETOF dovecotuser
+AS $$
+ DECLARE
+ record dovecotuser;
+ userid varchar(320) := localpart || '@' || the_domain;
+ did bigint := (SELECT gid FROM domain_name WHERE domainname=the_domain);
+ BEGIN
+ FOR record IN
+ SELECT userid, uid, did, domaindir || '/' || uid AS home,
+ format || ':~/' || directory AS mail
+ FROM users, domain_data, mailboxformat, maillocation
+ WHERE users.gid = did
+ AND users.local_part = localpart
+ AND maillocation.mid = users.mid
+ AND mailboxformat.fid = maillocation.fid
+ AND domain_data.gid = did
+ LOOP
+ RETURN NEXT record;
+ END LOOP;
+ RETURN;
+ END;
+$$ LANGUAGE plpgsql STABLE
+RETURNS NULL ON NULL INPUT
+EXTERNAL SECURITY INVOKER;
--- a/pgsql/update_types_and_functions_0.5.x_for_dovecot-1.2.x.pgsql Thu Jan 13 12:48:30 2011 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
--- ---
--- Clean out the old stuff
--- ---
-DROP TYPE dovecotpassword CASCADE;
-
--- ---
--- Data type for function dovecotpassword(varchar, varchar)
--- ---
-CREATE TYPE dovecotpassword AS (
- userid varchar(320),
- password varchar(74),
- smtp boolean,
- pop3 boolean,
- imap boolean,
- sieve boolean
-);
-
--- ---
--- Parameters (from login name [localpart@the_domain]):
--- varchar localpart
--- varchar the_domain
--- Returns: dovecotpassword records
---
--- Required access privileges for your dovecot database user:
--- GRANT SELECT ON users, domain_name TO dovecot;
---
--- For more details see http://wiki.dovecot.org/AuthDatabase/SQL
--- ---
-CREATE OR REPLACE FUNCTION dovecotpassword(
- IN localpart varchar, IN the_domain varchar) RETURNS SETOF dovecotpassword
-AS $$
- DECLARE
- record dovecotpassword;
- userid varchar(320) := localpart || '@' || the_domain;
- BEGIN
- FOR record IN
- SELECT userid, passwd, smtp, pop3, imap, sieve
- FROM users
- WHERE gid = (SELECT gid
- FROM domain_name
- WHERE domainname = the_domain)
- AND local_part = localpart
- LOOP
- RETURN NEXT record;
- END LOOP;
- RETURN;
- END;
-$$ LANGUAGE plpgsql STABLE
-RETURNS NULL ON NULL INPUT
-EXTERNAL SECURITY INVOKER;
-
--- a/po/de.po Thu Jan 13 12:48:30 2011 +0000
+++ b/po/de.po Thu Jan 13 12:54:53 2011 +0000
@@ -5,85 +5,90 @@
msgid ""
msgstr ""
"Project-Id-Version: vmm 0.5.2\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2009-08-25 06:07+0200\n"
+"Report-Msgid-Bugs-To: neverseen@users.sourceforge.net\n"
+"POT-Creation-Date: 2010-01-29 23:22+0100\n"
"PO-Revision-Date: 2009-08-25 06:11+0200\n"
-"Last-Translator: Pascal Volk <p.volk@veb-it.de>\n"
+"Last-Translator: Pascal Volk <neverseen@users.sourceforge.net>\n"
"Language-Team: German\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
-#: VirtualMailManager/Account.py:36 VirtualMailManager/Relocated.py:44
+#. TP: Hm, what quotation marks should be used?
+#. If you are unsure have a look at:
+#. http://en.wikipedia.org/wiki/Quotation_mark,_non-English_usage
+#: VirtualMailManager/Account.py:37 VirtualMailManager/Relocated.py:42
#, python-format
msgid "There is already an alias with the address “%s”."
msgstr "Es existiert bereits ein Alias mit der Adresse „%s“."
-#: VirtualMailManager/Account.py:41 VirtualMailManager/Alias.py:45
+#: VirtualMailManager/Account.py:42 VirtualMailManager/Alias.py:41
#, python-format
msgid "There is already a relocated user with the address “%s”."
msgstr "Es gibt bereits ein relocated User mit der Adresse „%s“."
-#: VirtualMailManager/Account.py:61 VirtualMailManager/Alias.py:61
-#: VirtualMailManager/Domain.py:163 VirtualMailManager/Domain.py:189
-#: VirtualMailManager/Domain.py:220 VirtualMailManager/Relocated.py:60
+#: VirtualMailManager/Account.py:62 VirtualMailManager/Alias.py:57
+#: VirtualMailManager/Domain.py:161 VirtualMailManager/Domain.py:187
+#: VirtualMailManager/Domain.py:218 VirtualMailManager/Relocated.py:58
#, python-format
-msgid "The domain “%s” doesn't exist yet."
-msgstr "Die Domain „%s“ existiert noch nicht."
+msgid "The domain “%s” doesn't exist."
+msgstr "Die Domain „%s“ existiert nicht."
-#: VirtualMailManager/Account.py:80
+#: VirtualMailManager/Account.py:81
#, python-format
msgid "Unknown service “%s”."
msgstr "Unbekannter Service „%s“."
-#: VirtualMailManager/Account.py:83 VirtualMailManager/Account.py:150
-#: VirtualMailManager/Account.py:178 VirtualMailManager/Account.py:212
+#: VirtualMailManager/Account.py:84 VirtualMailManager/Account.py:157
+#: VirtualMailManager/Account.py:188 VirtualMailManager/Account.py:223
#, python-format
-msgid "The account “%s” doesn't exists."
+msgid "The account “%s” doesn't exist."
msgstr "Der Account „%s“ existiert nicht."
-#: VirtualMailManager/Account.py:145
+#: VirtualMailManager/Account.py:152
#, python-format
msgid "The account “%s” already exists."
msgstr "Der Account „%s“ existiert bereits."
-#: VirtualMailManager/Account.py:186
+#. TP: A service (pop3/imap/…) is enabled/usable for a user
+#: VirtualMailManager/Account.py:197
msgid "enabled"
msgstr "aktiviert"
-#: VirtualMailManager/Account.py:188
+#. TP: A service (pop3/imap) isn't enabled/usable for a user
+#: VirtualMailManager/Account.py:200
msgid "disabled"
msgstr "deaktiviert"
-#: VirtualMailManager/Account.py:233
+#: VirtualMailManager/Account.py:244
#, python-format
msgid "There are %(count)d aliases with the destination address “%(address)s”."
msgstr "Es gibt %(count)d Alias(e) mit der Zieladresse „%(address)s“."
-#: VirtualMailManager/Account.py:241
+#: VirtualMailManager/Account.py:252
msgid "uid must be an int/long."
msgstr "Die UID muss eine Ganzzahl sein."
-#: VirtualMailManager/Account.py:243
+#: VirtualMailManager/Account.py:254
msgid "uid must be greater than 0."
msgstr "Die UID muss größer als 0 sein."
-#: VirtualMailManager/Account.py:251
+#: VirtualMailManager/Account.py:262
#, python-format
msgid "There is no account with the UID “%d”."
msgstr "Es existiert kein Account mit der UID „%d“."
-#: VirtualMailManager/Alias.py:30 VirtualMailManager/Relocated.py:30
+#: VirtualMailManager/Alias.py:28 VirtualMailManager/Relocated.py:28
msgid "Address and destination are identical."
msgstr "Alias- und Ziel-Adresse sind identisch."
-#: VirtualMailManager/Alias.py:40 VirtualMailManager/Relocated.py:39
+#: VirtualMailManager/Alias.py:37 VirtualMailManager/Relocated.py:37
#, python-format
msgid "There is already an account with address “%s”."
msgstr "Es gibt bereits einen Account mit der Adresse „%s“."
-#: VirtualMailManager/Alias.py:71
+#: VirtualMailManager/Alias.py:67
#, python-format
msgid ""
"Can't add new destination to alias “%(address)s”.\n"
@@ -96,147 +101,183 @@
"Eine weitere Ziel-Adresse würde diesen Alias unbrauchbar machen.\n"
"Tipp: Erhöhen Sie Postfix' virtual_alias_expansion_limit\n"
-#: VirtualMailManager/Alias.py:80
-msgid "No destination address for alias denoted."
+#: VirtualMailManager/Alias.py:76
+#, fuzzy
+msgid "No destination address specified for alias."
msgstr "Keine Ziel-Adresse für den Alias angegeben."
-#: VirtualMailManager/Alias.py:91
+#: VirtualMailManager/Alias.py:87
#, python-format
msgid "The alias “%(a)s” with destination “%(d)s” already exists."
msgstr "Der Alias „%(a)s“ mit der Ziel-Adresse „%(d)s“ existiert bereits."
-#: VirtualMailManager/Alias.py:106 VirtualMailManager/Alias.py:123
-#, python-format
-msgid "The alias “%s” doesn't exists."
+#: VirtualMailManager/Alias.py:100 VirtualMailManager/Alias.py:117
+#, fuzzy, python-format
+msgid "The alias “%s” doesn't exist."
msgstr "Der Alias „%s“ existiert nicht."
-#: VirtualMailManager/Alias.py:125
-#, python-format
-msgid "The alias “%(a)s” with destination “%(d)s” doesn't exists."
+#: VirtualMailManager/Alias.py:119
+#, fuzzy, python-format
+msgid "The alias “%(a)s” with destination “%(d)s” doesn't exist."
msgstr "Der Alias „%(a)s“ mit der Ziel-Adresse „%(d)s“ existiert nicht."
-#: VirtualMailManager/AliasDomain.py:32
+#: VirtualMailManager/AliasDomain.py:30
#, python-format
msgid "The domain “%s” is a primary domain."
msgstr "Die Domain „%s“ ist eine primäre Domain."
-#: VirtualMailManager/AliasDomain.py:37
+#: VirtualMailManager/AliasDomain.py:35
#, python-format
msgid "The alias domain “%s” already exists."
msgstr "Die Alias-Domain „%s“ existiert bereits."
-#: VirtualMailManager/AliasDomain.py:40 VirtualMailManager/AliasDomain.py:70
-msgid "No destination domain for alias domain denoted."
+#: VirtualMailManager/AliasDomain.py:38 VirtualMailManager/AliasDomain.py:68
+#, fuzzy
+msgid "No destination domain specified for alias domain."
msgstr "Keine Ziel-Domain für die Alias-Domain angegeben."
-#: VirtualMailManager/AliasDomain.py:43 VirtualMailManager/AliasDomain.py:73
-#, python-format
-msgid "The target domain “%s” doesn't exist yet."
+#: VirtualMailManager/AliasDomain.py:41 VirtualMailManager/AliasDomain.py:71
+#, fuzzy, python-format
+msgid "The target domain “%s” doesn't exist."
msgstr "Die Ziel-Domain „%s“ existiert noch nicht."
-#: VirtualMailManager/AliasDomain.py:62
+#: VirtualMailManager/AliasDomain.py:60
#, python-format
msgid "There is no primary domain for the alias domain “%s”."
msgstr "Es gibt keine primäre Domain für die Alias-Domain „%s“."
-#: VirtualMailManager/AliasDomain.py:65 VirtualMailManager/AliasDomain.py:76
-#: VirtualMailManager/AliasDomain.py:99
-#, python-format
-msgid "The alias domain “%s” doesn't exist yet."
+#: VirtualMailManager/AliasDomain.py:63 VirtualMailManager/AliasDomain.py:74
+#: VirtualMailManager/AliasDomain.py:97
+#, fuzzy, python-format
+msgid "The alias domain “%s” doesn't exist."
msgstr "Die Alias-Domain „%s“ existiert noch nicht."
-#: VirtualMailManager/AliasDomain.py:79
+#: VirtualMailManager/AliasDomain.py:77
#, python-format
msgid ""
"The alias domain “%(alias)s” is already assigned to the domain “%(domain)s”."
msgstr ""
"Die Alias-Domain „%(alias)s“ ist bereits der Domain „%(domain)s“ zugeordnet."
-#: VirtualMailManager/Config.py:102 VirtualMailManager/Config.py:137
+#: VirtualMailManager/Config.py:105
+#, python-format
+msgid "Not a boolean: “%s”"
+msgstr ""
+
+#: VirtualMailManager/Config.py:134
+#, python-format
+msgid "Bad format: “%s” - expected: section.option"
+msgstr ""
+
+#: VirtualMailManager/Config.py:347
+msgid "Missing options, which have no default value.\n"
+msgstr ""
+
+#: VirtualMailManager/Config.py:348 VirtualMailManager/Config.py:416
#, python-format
msgid "Using configuration file: %s\n"
msgstr "Verwende Konfigurationsdatei: %s\n"
-#: VirtualMailManager/Config.py:106
+#: VirtualMailManager/Config.py:351
#, python-format
-msgid "missing section: %s\n"
-msgstr "Fehlender Abschnitt: %s\n"
+msgid "* Section: %s\n"
+msgstr "* Sektion: %s\n"
+
+#: VirtualMailManager/Config.py:367
+#, python-format
+msgid "“%s” is not a directory"
+msgstr ""
-#: VirtualMailManager/Config.py:108
+#: VirtualMailManager/Config.py:379
#, python-format
-msgid "missing options in section %s:\n"
-msgstr "Fehlende Optionen im Abschnitt %s:\n"
+msgid "“%s” is not a file"
+msgstr "„%s“ ist keine Datei."
+
+#: VirtualMailManager/Config.py:382
+#, python-format
+msgid "File is not executable: “%s”"
+msgstr ""
-#: VirtualMailManager/Config.py:140
+#: VirtualMailManager/Config.py:408
#, python-format
-msgid "* Config section: “%s”"
-msgstr "* Konfigurations Abschnitt: „%s“"
+msgid "Enter new value for option %(option)s [%(current_value)s]: "
+msgstr "Neuer Wert für Option %(option)s [%(current_value)s]: "
+
+#: VirtualMailManager/Config.py:418
+#, python-format
+msgid "* Configuration section: “%s”"
+msgstr "* Konfigurations Sektion: „%s“"
-#: VirtualMailManager/Config.py:143
+#: VirtualMailManager/Config.py:429
#, python-format
-msgid "Enter new value for option %(opt)s [%(val)s]: "
-msgstr "Neuer Wert für Option %(opt)s [%(val)s]: "
+msgid "Warning: %s"
+msgstr "Warnungen: %s"
-#: VirtualMailManager/Domain.py:39
+#: VirtualMailManager/Config.py:433
+#: VirtualMailManager/VirtualMailManager.py:198
+msgid "Too many failures - try again later."
+msgstr ""
+
+#: VirtualMailManager/Domain.py:37
#, python-format
msgid "The domain “%s” is an alias domain."
msgstr "Die Domain „%s“ ist eine Alias-Domain."
-#: VirtualMailManager/Domain.py:124
+#: VirtualMailManager/Domain.py:122
msgid "There are accounts and aliases."
msgstr "Es sind noch Accounts und Aliase vorhanden."
-#: VirtualMailManager/Domain.py:127
+#: VirtualMailManager/Domain.py:125
msgid "There are accounts."
msgstr "Es sind noch Accounts vorhanden."
-#: VirtualMailManager/Domain.py:130
+#: VirtualMailManager/Domain.py:128
msgid "There are aliases."
msgstr "Es sind noch Aliase vorhanden."
-#: VirtualMailManager/Domain.py:145
+#: VirtualMailManager/Domain.py:143
#, python-format
msgid "The domain “%s” already exists."
msgstr "Die Domain „%s“ existiert bereits."
-#: VirtualMailManager/EmailAddress.py:46
+#: VirtualMailManager/EmailAddress.py:42
#, python-format
msgid "Missing '@' sign in e-mail address “%s”."
msgstr "In der E-Mail-Adresse „%s“ fehlt das '@'-Zeichen."
-#: VirtualMailManager/EmailAddress.py:49
+#: VirtualMailManager/EmailAddress.py:45
#, python-format
-msgid "“%s” looks not like an e-mail address."
+msgid "“%s” doesn't look like an e-mail address."
msgstr "„%s“ sieht nicht wie eine E-Mail-Adresse aus."
-#: VirtualMailManager/EmailAddress.py:54
+#: VirtualMailManager/EmailAddress.py:50
#, python-format
msgid "Missing domain name after “%s@”."
msgstr "Der Domain-Name nach „%s@“ fehlt."
-#: VirtualMailManager/EmailAddress.py:66
-msgid "No localpart specified."
+#: VirtualMailManager/EmailAddress.py:62
+msgid "No local-part specified."
msgstr "Kein local-part angegeben."
-#: VirtualMailManager/EmailAddress.py:69
+#: VirtualMailManager/EmailAddress.py:65
#, python-format
-msgid "The local part “%s” is too long"
+msgid "The local-part “%s” is too long"
msgstr "Der local-part „%s“ ist zu lang"
-#: VirtualMailManager/EmailAddress.py:76
+#: VirtualMailManager/EmailAddress.py:72
#, python-format
-msgid "The local part “%(lpart)s” contains invalid characters: %(ichrs)s"
+msgid "The local-part “%(lpart)s” contains invalid characters: %(ichrs)s"
msgstr "Der local-part „%(lpart)s“ enthält ungültige Zeichen: %(ichrs)s"
-#: VirtualMailManager/MailLocation.py:32
+#: VirtualMailManager/MailLocation.py:28
msgid "Either mid or maillocation must be specified."
msgstr "Entweder mid oder maillocation muss angegeben werden."
-#: VirtualMailManager/MailLocation.py:38
+#: VirtualMailManager/MailLocation.py:34
msgid "mid must be an int/long."
msgstr "Die MID muss eine Ganzzahl sein."
-#: VirtualMailManager/MailLocation.py:46
+#: VirtualMailManager/MailLocation.py:42
#, python-format
msgid ""
"Invalid folder name “%s”, it may consist only of\n"
@@ -245,37 +286,37 @@
"Unzulässiger Verzeichnisname „%s“, dieser darf nur aus\n"
"1 - 20 Einzelbytezeichen (A-Z, a-z, 0-9 und _) bestehen."
-#: VirtualMailManager/MailLocation.py:59
+#: VirtualMailManager/MailLocation.py:55
msgid "Unknown mid specified."
msgstr "Unbekannte MID angegeben."
-#: VirtualMailManager/Relocated.py:65
-msgid "No destination address for relocated user denoted."
+#: VirtualMailManager/Relocated.py:64
+msgid "No destination address specified for relocated user."
msgstr "Keine Ziel-Adresse für den relocated User angegeben."
-#: VirtualMailManager/Relocated.py:75
+#: VirtualMailManager/Relocated.py:74
#, python-format
msgid "The relocated user “%s” already exists."
msgstr "Der relocated User „%s“ existiert bereits."
-#: VirtualMailManager/Relocated.py:89 VirtualMailManager/Relocated.py:102
+#: VirtualMailManager/Relocated.py:88 VirtualMailManager/Relocated.py:101
#, python-format
-msgid "The relocated user “%s” doesn't exists."
+msgid "The relocated user “%s” doesn't exist."
msgstr "Der relocated User „%s“ existiert nicht."
-#: VirtualMailManager/Transport.py:29
+#: VirtualMailManager/Transport.py:27
msgid "Either tid or transport must be specified."
msgstr "Entweder tid oder transport muss angegeben werden."
-#: VirtualMailManager/Transport.py:35
+#: VirtualMailManager/Transport.py:33
msgid "tid must be an int/long."
msgstr "Die tid muss eine Ganzzahl sein."
-#: VirtualMailManager/Transport.py:63
+#: VirtualMailManager/Transport.py:61
msgid "Unknown tid specified."
msgstr "Unbekannte tid angegeben."
-#: VirtualMailManager/VirtualMailManager.py:54
+#: VirtualMailManager/VirtualMailManager.py:47
msgid ""
"You are not root.\n"
"\tGood bye!\n"
@@ -283,11 +324,11 @@
"Sie sind nicht root.\n"
"\tAuf Wiedersehen.\n"
-#: VirtualMailManager/VirtualMailManager.py:74
+#: VirtualMailManager/VirtualMailManager.py:66
msgid "No “vmm.cfg” found in: /root:/usr/local/etc:/etc"
msgstr "Keine „vmm.cfg“ gefunden in: /root:/usr/local/etc:/etc“"
-#: VirtualMailManager/VirtualMailManager.py:85
+#: VirtualMailManager/VirtualMailManager.py:77
#, python-format
msgid ""
"fix permissions (%(perms)s) for “%(file)s”\n"
@@ -296,104 +337,100 @@
"Bitte Zugriffsrechte (%(perms)s) für „%(file)s“ anpassen\n"
"`chmod 0600 %(file)s` wäre großartig."
-#: VirtualMailManager/VirtualMailManager.py:100
+#: VirtualMailManager/VirtualMailManager.py:92
#, python-format
msgid ""
"“%s” is not a directory.\n"
-"(vmm.cfg: section \"domdir\", option \"base\")"
+"(vmm.cfg: section \"misc\", option \"base_directory\")"
msgstr ""
"„%s“ ist kein Verzeichnis.\n"
-"(vmm.cfg: Abschnitt \"domdir\", Option \"base\")"
+"(vmm.cfg: Sektion \"misc\", Option \"base_directory\")"
-#: VirtualMailManager/VirtualMailManager.py:105
-#, python-format
+#: VirtualMailManager/VirtualMailManager.py:97
+#, fuzzy, python-format
msgid ""
-"“%(binary)s” doesn't exists.\n"
+"“%(binary)s” doesn't exist.\n"
"(vmm.cfg: section \"bin\", option \"%(option)s\")"
msgstr ""
"„%(binary)s“ existiert nicht.\n"
-"(vmm.cfg: Abschnitt \"bin\", Option \"%(option)s\")"
+"(vmm.cfg: Sektion \"bin\", Option \"%(option)s\")"
-#: VirtualMailManager/VirtualMailManager.py:109
+#: VirtualMailManager/VirtualMailManager.py:101
#, python-format
msgid ""
"“%(binary)s” is not executable.\n"
"(vmm.cfg: section \"bin\", option \"%(option)s\")"
msgstr ""
"„%(binary)s“ ist nicht ausführbar.\n"
-"(vmm.cfg: Abschnitt \"bin\", Option \"%(option)s\")"
+"(vmm.cfg: Sektion \"bin\", Option \"%(option)s\")"
-#: VirtualMailManager/VirtualMailManager.py:166
+#: VirtualMailManager/VirtualMailManager.py:149
msgid "The domain name is too long."
msgstr "Der Domain-Name ist zu lang."
-#: VirtualMailManager/VirtualMailManager.py:169
+#: VirtualMailManager/VirtualMailManager.py:152
#, python-format
msgid "The domain name “%s” is invalid."
msgstr "Der Domain-Name „%s“ ist ungültig."
-#: VirtualMailManager/VirtualMailManager.py:209
+#. TP: Please preserve the trailing space.
+#: VirtualMailManager/VirtualMailManager.py:191
msgid "Enter new password: "
msgstr "Neues Passwort eingeben: "
-#: VirtualMailManager/VirtualMailManager.py:210
+#. TP: Please preserve the trailing space.
+#: VirtualMailManager/VirtualMailManager.py:193
msgid "Retype new password: "
msgstr "Neues Passwort wiederholen: "
-#: VirtualMailManager/VirtualMailManager.py:212
+#: VirtualMailManager/VirtualMailManager.py:204
msgid "Sorry, passwords do not match"
msgstr "Entschuldigung, die Passwörter stimmen nicht überein"
-#: VirtualMailManager/VirtualMailManager.py:216
+#: VirtualMailManager/VirtualMailManager.py:208
msgid "Sorry, empty passwords are not permitted"
msgstr "Entschuldigung, leere Passwörter sind nicht zulässig"
-#: VirtualMailManager/VirtualMailManager.py:265
-#: VirtualMailManager/VirtualMailManager.py:352
+#: VirtualMailManager/VirtualMailManager.py:256
+#: VirtualMailManager/VirtualMailManager.py:343
#, python-format
msgid "No such directory: %s"
msgstr "Verzeichnis nicht gefunden: %s"
-#: VirtualMailManager/VirtualMailManager.py:340
+#: VirtualMailManager/VirtualMailManager.py:331
msgid "Found \"..\" in home directory path."
msgstr "\"..\" im Pfad zum Benutzerverzeichnis entdeckt."
-#: VirtualMailManager/VirtualMailManager.py:348
-msgid "Owner/group mismatch in home directory detected."
+#: VirtualMailManager/VirtualMailManager.py:339
+#, fuzzy
+msgid "Detected owner/group mismatch in home directory."
msgstr "Benutzerverzeichnis gehört dem/der falschen Benutzer/Gruppe."
-#: VirtualMailManager/VirtualMailManager.py:364
-msgid "FATAL: \"..\" in domain directory path detected."
-msgstr "FATAL: \"..\" im Pfad zum Domain-Verzeichnis entdeckt."
-
-#: VirtualMailManager/VirtualMailManager.py:370
-msgid "FATAL: group mismatch in domain directory detected"
-msgstr "FATAL: Domain-Verzeichnis gehört der falschen Gruppe"
+#: VirtualMailManager/VirtualMailManager.py:354
+#, fuzzy
+msgid "Found \"..\" in domain directory path."
+msgstr "\"..\" im Pfad zum Benutzerverzeichnis entdeckt."
-#: VirtualMailManager/VirtualMailManager.py:457
-#, python-format
-msgid ""
-"Configurtion error: \"%s\"\n"
-"(in section \"connfig\", option \"done\") see also: vmm.cfg(5)\n"
-msgstr ""
-"Konfigurations Fehler: \"%s\"\n"
-"(im Abschnitt \"connfig\", Option \"done\") Siehe auch: vmm.cfg(5)\n"
+#: VirtualMailManager/VirtualMailManager.py:360
+#, fuzzy
+msgid "Detected group mismatch in domain directory."
+msgstr "Domain-Verzeichnis gehört der falschen Gruppe"
-#: VirtualMailManager/VirtualMailManager.py:477
+#: VirtualMailManager/VirtualMailManager.py:455
#, python-format
msgid "Invalid section: “%s”"
-msgstr "Ungültiger Abschnitt: „%s“"
+msgstr "Ungültige Sektion: „%s“"
-#: VirtualMailManager/VirtualMailManager.py:487
-#: VirtualMailManager/VirtualMailManager.py:497
-#: VirtualMailManager/VirtualMailManager.py:516
-#: VirtualMailManager/VirtualMailManager.py:624
-#: VirtualMailManager/VirtualMailManager.py:655
+#: VirtualMailManager/VirtualMailManager.py:465
+#: VirtualMailManager/VirtualMailManager.py:475
+#: VirtualMailManager/VirtualMailManager.py:494
+#: VirtualMailManager/VirtualMailManager.py:602
+#: VirtualMailManager/VirtualMailManager.py:633
#, python-format
msgid "Invalid argument: “%s”"
msgstr "Ungültiges Argument: „%s“"
-#: VirtualMailManager/VirtualMailManager.py:520
+#: VirtualMailManager/VirtualMailManager.py:498
msgid ""
"The keyword “detailed” is deprecated and will be removed in a future "
"release.\n"
@@ -403,35 +440,36 @@
" Version entfernt werden.\n"
" Verwenden Sie bitte das Schlüsselwort „full“, um alle Details zu erhalten."
-#: VirtualMailManager/VirtualMailManager.py:593
+#: VirtualMailManager/VirtualMailManager.py:571
#, python-format
msgid "The pattern “%s” contains invalid characters."
msgstr "Das Muster „%s“ enthält ungültige Zeichen."
-#: VirtualMailManager/VirtualMailManager.py:619
-#, python-format
-msgid "The destination account/alias “%s” doesn't exists yet."
-msgstr "Der Ziel-Account/-Alias „%s“ existiert noch nicht."
+#: VirtualMailManager/VirtualMailManager.py:597
+#, fuzzy, python-format
+msgid "The destination account/alias “%s” doesn't exist."
+msgstr "Der Ziel-Account/-Alias „%s“ existiert nicht."
-#: VirtualMailManager/VirtualMailManager.py:636
-#, python-format
+#: VirtualMailManager/VirtualMailManager.py:614
+#, fuzzy, python-format
msgid ""
"The account has been successfully deleted from the database.\n"
" But an error occurred while deleting the following directory:\n"
" “%(directory)s”\n"
-" Reason: %(raeson)s"
+" Reason: %(reason)s"
msgstr ""
"Der Account wurde erfolgreich aus der Datenbank gelöscht.\n"
" Aber es trat ein Fehler auf beim Löschen des folgenden Verzeichnisses:\n"
" „%(directory)s“\n"
-" Grund: %(raeson)s"
+" Grund: %(reason)s"
-#: VirtualMailManager/VirtualMailManager.py:676
-msgid "Account doesn't exists"
+#: VirtualMailManager/VirtualMailManager.py:653
+#, fuzzy
+msgid "Account doesn't exist"
msgstr "Der Account existiert nicht"
-#: VirtualMailManager/VirtualMailManager.py:692
-#: VirtualMailManager/VirtualMailManager.py:702
+#: VirtualMailManager/VirtualMailManager.py:669
+#: VirtualMailManager/VirtualMailManager.py:679
msgid ""
"The service name “managesieve” is deprecated and will be removed\n"
" in a future release.\n"
@@ -441,14 +479,23 @@
" Version entfernt werden.\n"
" Verwenden Sie stattdessen bitte den Servicename „sieve“."
-#: VirtualMailManager/ext/Postconf.py:44
-#, python-format
+#: VirtualMailManager/ext/Postconf.py:41
+#, fuzzy, python-format
msgid ""
-"The value “%s” looks not like a valid postfix configuration parameter name."
+"The value “%s” doesn't look like a valid postfix configuration parameter "
+"name."
msgstr ""
"„%s“ sieht nicht wie ein gültiger Postfix Konfigurationsparametername aus."
-#: vmm:34
+#. TP: Please adjust translated words like the original text.
+#. (It's a table header.) Extract from usage text:
+#. Usage: vmm SUBCOMMAND OBJECT ARGS*
+#. short long
+#. subcommand object args (* = optional)
+#.
+#. da domainadd domain.tld transport*
+#. di domaininfo domain.tld details*
+#: vmm:26
#, python-format
msgid ""
"Usage: %s SUBCOMMAND OBJECT ARGS*\n"
@@ -459,57 +506,60 @@
" kurz lang\n"
" Unterbefehl Objekt args (* = optional)\n"
-#: vmm:73 vmm:84 vmm:494
-msgid "Error"
-msgstr "Fehler"
+#: vmm:65 vmm:76
+#, python-format
+msgid "Error: %s\n"
+msgstr "Fehler: %s\n"
-#: vmm:111
+#. TP: e.g. 'Domain information' or 'Account information'
+#: vmm:104
msgid "information"
msgstr "Informationen"
-#: vmm:121
+#. TP: e.g. 'Available alias addresses' or 'Available accounts'
+#: vmm:115
msgid "Available"
msgstr "Verfügbare"
-#: vmm:124 vmm:223 vmm:229
+#: vmm:118 vmm:218 vmm:224
msgid "alias domains"
msgstr "Alias-Domains"
-#: vmm:134 vmm:145 vmm:169
+#: vmm:128 vmm:139 vmm:163
msgid "\tNone"
msgstr "\tKeine"
-#: vmm:138
+#: vmm:132
msgid "Alias information"
msgstr "Alias Informationen"
-#: vmm:140
+#: vmm:134
#, python-format
msgid "\tMail for %s will be redirected to:"
msgstr "\tE-Mails für %s werden weitergeleitet an:"
-#: vmm:149
+#: vmm:143
msgid "Relocated information"
msgstr "Relocated Informationen"
-#: vmm:151
+#: vmm:145
#, python-format
msgid "\tUser “%(addr)s” has moved to “%(dest)s”"
msgstr "\tDer Benutzer „%(addr)s“ ist erreichbar unter „%(dest)s“"
-#: vmm:164
+#: vmm:158
msgid "Available domains"
msgstr "Verfügbare Domains"
-#: vmm:166
+#: vmm:160
msgid "Matching domains"
msgstr "Übereinstimmende Domains"
-#: vmm:180
+#: vmm:174
msgid "Alias domain information"
msgstr "Alias-Domain Informationen"
-#: vmm:186
+#: vmm:180
#, python-format
msgid ""
"\tThe alias domain %(alias)s belongs to:\n"
@@ -518,114 +568,142 @@
"\tDie Alias-Domain %(alias)s gehört zu:\n"
"\t * %(domain)s"
-#: vmm:197 vmm:205 vmm:213
+#: vmm:191 vmm:199 vmm:207
msgid "Missing domain name."
msgstr "Kein Domain-Name angegeben."
-#: vmm:215 vmm:219
+#: vmm:210 vmm:214
msgid "Domain"
msgstr "Domain"
-#: vmm:221 vmm:230
+#: vmm:216 vmm:225
msgid "accounts"
msgstr "Accounts"
-#: vmm:225 vmm:231
+#: vmm:220 vmm:226
msgid "aliases"
msgstr "Aliase"
-#: vmm:227 vmm:232
+#: vmm:222 vmm:227
msgid "relocated users"
msgstr "Relocated Users"
-#: vmm:236
+#: vmm:238
msgid "Missing domain name and new transport."
msgstr "Domain-Name und neuer Transport fehlen."
-#: vmm:238
+#: vmm:240
msgid "Missing new transport."
msgstr "Neuer Transport fehlt."
-#: vmm:247 vmm:262
+#: vmm:249 vmm:272
msgid "Missing alias domain name and target domain name."
msgstr "Domain-Namen für Alias- und Ziel-Domain fehlen."
-#: vmm:249 vmm:264
+#: vmm:251 vmm:274
msgid "Missing target domain name."
msgstr "Keine Ziel-Domain angegeben."
-#: vmm:255 vmm:270
+#: vmm:257 vmm:280
msgid "Missing alias domain name."
msgstr "Keine Alias-Domain angegeben."
-#: vmm:276 vmm:285 vmm:293 vmm:323 vmm:331 vmm:339
+#: vmm:286 vmm:295 vmm:303 vmm:345 vmm:353 vmm:361
msgid "Missing e-mail address."
msgstr "E-Mail-Adresse fehlt."
-#: vmm:301
+#: vmm:312
msgid "alias addresses"
msgstr "Alias-Adressen"
-#: vmm:307
-msgid "Missing e-mail address and users name."
+#: vmm:329
+#, fuzzy
+msgid "Missing e-mail address and user’s name."
msgstr "E-Mail-Adresse und der Name des Benutzers fehlen."
-#: vmm:309
-msgid "Missing users name."
+#: vmm:331
+#, fuzzy
+msgid "Missing user’s name."
msgstr "Name des Benutzers fehlt."
-#: vmm:315
+#: vmm:337
msgid "Missing e-mail address and transport."
msgstr "E-Mail-Adresse und Transport fehlen."
-#: vmm:317
+#: vmm:339
msgid "Missing transport."
msgstr "Transport fehlt."
-#: vmm:348
+#: vmm:370
msgid "Missing alias address and destination."
msgstr "Alias- und Ziel-Adresse fehlen."
-#: vmm:350 vmm:373
+#: vmm:372 vmm:407
msgid "Missing destination address."
msgstr "Die Ziel-Adresse fehlt."
-#: vmm:356 vmm:362
+#: vmm:378 vmm:396
msgid "Missing alias address"
msgstr "Die Alias-Adresse fehlt."
-#: vmm:371
+#: vmm:405
msgid "Missing relocated address and destination."
msgstr "Die Adresse des relocated Users und Ziel-Adresse fehlen."
-#: vmm:379 vmm:387
+#: vmm:413 vmm:431
msgid "Missing relocated address"
msgstr "Die Adresse des relocated Users fehlt."
-#: vmm:393
+#: vmm:437
msgid "Missing userid"
msgstr "Keine UID angegeben."
-#: vmm:406
+#: vmm:450
msgid "Warnings:"
msgstr "Warnungen:"
-#: vmm:412
+#: vmm:460
msgid "from"
msgstr "vom"
-#: vmm:412
+#. TP: The words 'from', 'version' and 'on' are used in the version
+#. information:
+#. vmm, version 0.5.2 (from 09/09/09)
+#. Python 2.5.4 on FreeBSD
+#: vmm:460
msgid "version"
msgstr "Version"
-#: vmm:414
+#: vmm:463
msgid "on"
msgstr "auf"
-#: vmm:488
-msgid "Unknown subcommand"
-msgstr "Unbekannter Unterbefehl"
+#: vmm:464
+msgid "is free software and comes with ABSOLUTELY NO WARRANTY."
+msgstr ""
+
+#: vmm:472
+#, python-format
+msgid "Plan A failed ... trying Plan B: %(subcommand)s %(object)s"
+msgstr ""
+
+#: vmm:535
+#, python-format
+msgid "Unknown subcommand: “%s”"
+msgstr "Unbekannter Unterbefehl „%s“"
-#: vmm:491
-msgid "Ouch"
-msgstr "Autsch"
+#. TP: We have to cry, because root has killed/interrupted vmm
+#. with Ctrl+C or Ctrl+D.
+#: vmm:540
+msgid ""
+"\n"
+"Ouch!\n"
+msgstr ""
+"\n"
+"Autsch!\n"
+
+#: vmm:543
+#, python-format
+msgid "Error: %s"
+msgstr "Fehler: %s"
+
--- a/po/vmm.pot Thu Jan 13 12:48:30 2011 +0000
+++ b/po/vmm.pot Thu Jan 13 12:54:53 2011 +0000
@@ -6,634 +6,871 @@
#, fuzzy
msgid ""
msgstr ""
-"Project-Id-Version: vmm 0.5.2\n"
+"Project-Id-Version: vmm 0.6.0\n"
"Report-Msgid-Bugs-To: neverseen@users.sourceforge.net\n"
-"POT-Creation-Date: 2009-10-20 19:19+0200\n"
+"POT-Creation-Date: 2010-08-05 23:17+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
+"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
-#. TP: Hm, what quotation marks should be used?
+#. TP: Hm, what “quotation marks” should be used?
#. If you are unsure have a look at:
#. http://en.wikipedia.org/wiki/Quotation_mark,_non-English_usage
-#: VirtualMailManager/Account.py:37 VirtualMailManager/Relocated.py:42
+#: VirtualMailManager/account.py:58 VirtualMailManager/alias.py:34
+#: VirtualMailManager/domain.py:109 VirtualMailManager/relocated.py:38
#, python-format
-msgid "There is already an alias with the address “%s”."
+msgid "The domain '%s' doesn't exist."
msgstr ""
-#: VirtualMailManager/Account.py:42 VirtualMailManager/Alias.py:41
+#: VirtualMailManager/account.py:99
+#, python-format
+msgid "The mailbox format '%(mbfmt)s' requires Dovecot >= v%(version)s"
+msgstr ""
+
+#: VirtualMailManager/account.py:105
#, python-format
-msgid "There is already a relocated user with the address “%s”."
+msgid "Invalid transport '%(transport)s' for mailbox format '%(mbfmt)s'"
+msgstr ""
+
+#: VirtualMailManager/account.py:128
+#, python-format
+msgid "Unknown service: '%s'"
msgstr ""
-#: VirtualMailManager/Account.py:62 VirtualMailManager/Alias.py:57
-#: VirtualMailManager/Domain.py:161 VirtualMailManager/Domain.py:187
-#: VirtualMailManager/Domain.py:218 VirtualMailManager/Relocated.py:58
+#: VirtualMailManager/account.py:160 VirtualMailManager/cli/handler.py:89
+#: VirtualMailManager/handler.py:543 VirtualMailManager/handler.py:593
+#: VirtualMailManager/handler.py:619 VirtualMailManager/handler.py:630
+#: VirtualMailManager/handler.py:641 VirtualMailManager/handler.py:653
+#: VirtualMailManager/handler.py:665
#, python-format
-msgid "The domain “%s” doesn't exist."
+msgid "The account '%s' doesn't exist."
msgstr ""
-#: VirtualMailManager/Account.py:81
+#: VirtualMailManager/account.py:211 VirtualMailManager/handler.py:615
#, python-format
-msgid "Unknown service “%s”."
+msgid "Could not accept password: '%s'"
msgstr ""
-#: VirtualMailManager/Account.py:84 VirtualMailManager/Account.py:157
-#: VirtualMailManager/Account.py:188 VirtualMailManager/Account.py:223
+#: VirtualMailManager/account.py:251 VirtualMailManager/cli/handler.py:76
+#: VirtualMailManager/handler.py:515
#, python-format
-msgid "The account “%s” doesn't exist."
+msgid "The account '%s' already exists."
msgstr ""
-#: VirtualMailManager/Account.py:152
+#: VirtualMailManager/account.py:254
#, python-format
-msgid "The account “%s” already exists."
+msgid "No password set for '%s'."
msgstr ""
-#. TP: A service (pop3/imap/…) is enabled/usable for a user
-#: VirtualMailManager/Account.py:197
+#: VirtualMailManager/account.py:289
+#, python-format
+msgid "Unknown field: '%s'"
+msgstr ""
+
+#. TP: A service (pop3/imap) is enabled/usable for a user
+#: VirtualMailManager/account.py:331
msgid "enabled"
msgstr ""
#. TP: A service (pop3/imap) isn't enabled/usable for a user
-#: VirtualMailManager/Account.py:200
+#: VirtualMailManager/account.py:334
msgid "disabled"
msgstr ""
-#: VirtualMailManager/Account.py:244
+#: VirtualMailManager/account.py:343
#, python-format
-msgid "There are %(count)d aliases with the destination address “%(address)s”."
+msgid "Could not fetch information for account: '%s'"
msgstr ""
-#: VirtualMailManager/Account.py:252
-msgid "uid must be an int/long."
+#: VirtualMailManager/account.py:387
+#, python-format
+msgid "There are %(count)d aliases with the destination address '%(address)s'."
msgstr ""
-#: VirtualMailManager/Account.py:254
-msgid "uid must be greater than 0."
+#: VirtualMailManager/account.py:416
+msgid "UID must be an int/long."
msgstr ""
-#: VirtualMailManager/Account.py:262
-#, python-format
-msgid "There is no account with the UID “%d”."
+#: VirtualMailManager/account.py:418
+msgid "UID must be greater than 0."
msgstr ""
-#: VirtualMailManager/Alias.py:28 VirtualMailManager/Relocated.py:28
-msgid "Address and destination are identical."
+#: VirtualMailManager/account.py:427
+#, python-format
+msgid "There is no account with the UID '%d'."
msgstr ""
-#: VirtualMailManager/Alias.py:37 VirtualMailManager/Relocated.py:37
+#: VirtualMailManager/alias.py:59
#, python-format
-msgid "There is already an account with address “%s”."
+msgid ""
+"Can't add %(count_new)i new destination(s) to alias '%(address)s'.\n"
+"Currently this alias expands into %(count)i/%(limit)i recipients.\n"
+"%(count_new)i additional destination(s) will render this alias unusable.\n"
+"Hint: Increase Postfix' virtual_alias_expansion_limit"
msgstr ""
-#: VirtualMailManager/Alias.py:67
+#: VirtualMailManager/alias.py:66
#, python-format
msgid ""
-"Can't add new destination to alias “%(address)s”.\n"
-"Currently this alias expands into %(count)i recipients.\n"
-"One more destination will render this alias unusable.\n"
-"Hint: Increase Postfix' virtual_alias_expansion_limit\n"
+"Can't add %(count_new)i new destination(s) to alias '%(address)s'.\n"
+"This alias already exceeds its expansion limit (%(count)i/%(limit)i).\n"
+"So its unusable, all messages addressed to this alias will be bounced.\n"
+"Hint: Delete some destination addresses."
msgstr ""
-#: VirtualMailManager/Alias.py:76
-msgid "No destination address specified for alias."
+#: VirtualMailManager/alias.py:140 VirtualMailManager/alias.py:152
+#: VirtualMailManager/alias.py:159 VirtualMailManager/handler.py:572
+#, python-format
+msgid "The alias '%s' doesn't exist."
msgstr ""
-#: VirtualMailManager/Alias.py:87
+#: VirtualMailManager/alias.py:143
#, python-format
-msgid "The alias “%(a)s” with destination “%(d)s” already exists."
+msgid "The address '%(addr)s' isn't a destination of the alias '%(alias)s'."
+msgstr ""
+
+#: VirtualMailManager/aliasdomain.py:50
+#, python-format
+msgid "The domain '%s' is a primary domain."
msgstr ""
-#: VirtualMailManager/Alias.py:100 VirtualMailManager/Alias.py:117
+#: VirtualMailManager/aliasdomain.py:69
#, python-format
-msgid "The alias “%s” doesn't exist."
+msgid "The alias domain '%s' already exists."
msgstr ""
-#: VirtualMailManager/Alias.py:119
-#, python-format
-msgid "The alias “%(a)s” with destination “%(d)s” doesn't exist."
+#: VirtualMailManager/aliasdomain.py:72 VirtualMailManager/aliasdomain.py:106
+msgid "No destination domain set for the alias domain."
msgstr ""
-#: VirtualMailManager/AliasDomain.py:30
+#: VirtualMailManager/aliasdomain.py:75 VirtualMailManager/aliasdomain.py:109
#, python-format
-msgid "The domain “%s” is a primary domain."
+msgid "The target domain '%s' doesn't exist."
msgstr ""
-#: VirtualMailManager/AliasDomain.py:35
+#: VirtualMailManager/aliasdomain.py:88 VirtualMailManager/aliasdomain.py:112
+#: VirtualMailManager/aliasdomain.py:133
#, python-format
-msgid "The alias domain “%s” already exists."
+msgid "The alias domain '%s' doesn't exist."
msgstr ""
-#: VirtualMailManager/AliasDomain.py:38 VirtualMailManager/AliasDomain.py:68
-msgid "No destination domain specified for alias domain."
+#: VirtualMailManager/aliasdomain.py:98
+#, python-format
+msgid "There is no primary domain for the alias domain '%s'."
msgstr ""
-#: VirtualMailManager/AliasDomain.py:41 VirtualMailManager/AliasDomain.py:71
+#: VirtualMailManager/aliasdomain.py:115
#, python-format
-msgid "The target domain “%s” doesn't exist."
+msgid ""
+"The alias domain '%(alias)s' is already assigned to the domain '%(domain)s'."
msgstr ""
-#: VirtualMailManager/AliasDomain.py:60
-#, python-format
-msgid "There is no primary domain for the alias domain “%s”."
+#. TP: Please preserve the trailing space.
+#: VirtualMailManager/cli/__init__.py:78
+msgid "Enter new password: "
+msgstr ""
+
+#. TP: Please preserve the trailing space.
+#: VirtualMailManager/cli/__init__.py:80
+msgid "Retype new password: "
msgstr ""
-#: VirtualMailManager/AliasDomain.py:63 VirtualMailManager/AliasDomain.py:74
-#: VirtualMailManager/AliasDomain.py:97
-#, python-format
-msgid "The alias domain “%s” doesn't exist."
+#: VirtualMailManager/cli/__init__.py:85 VirtualMailManager/cli/config.py:53
+msgid "Too many failures - try again later."
+msgstr ""
+
+#: VirtualMailManager/cli/__init__.py:91
+msgid "Sorry, passwords do not match"
msgstr ""
-#: VirtualMailManager/AliasDomain.py:77
-#, python-format
-msgid ""
-"The alias domain “%(alias)s” is already assigned to the domain “%(domain)s”."
+#: VirtualMailManager/cli/__init__.py:95
+msgid "Sorry, empty passwords are not permitted"
msgstr ""
-#: VirtualMailManager/Config.py:90 VirtualMailManager/Config.py:125
+#: VirtualMailManager/cli/config.py:32
+#, python-format
+msgid "Enter new value for option %(option)s [%(current_value)s]: "
+msgstr ""
+
+#: VirtualMailManager/cli/config.py:36 VirtualMailManager/config.py:377
#, python-format
msgid "Using configuration file: %s\n"
msgstr ""
-#: VirtualMailManager/Config.py:94
+#: VirtualMailManager/cli/config.py:38
#, python-format
-msgid "missing section: %s\n"
-msgstr ""
-
-#: VirtualMailManager/Config.py:96
-#, python-format
-msgid "missing options in section %s:\n"
+msgid "* Configuration section: '%s'"
msgstr ""
-#: VirtualMailManager/Config.py:128
+#: VirtualMailManager/cli/config.py:50
#, python-format
-msgid "* Config section: “%s”"
+msgid "Warning: %s"
msgstr ""
-#: VirtualMailManager/Config.py:131
+#: VirtualMailManager/cli/handler.py:68
#, python-format
-msgid "Enter new value for option %(opt)s [%(val)s]: "
-msgstr ""
-
-#: VirtualMailManager/Domain.py:37
-#, python-format
-msgid "The domain “%s” is an alias domain."
-msgstr ""
-
-#: VirtualMailManager/Domain.py:122
-msgid "There are accounts and aliases."
+msgid "Invalid section: '%s'"
msgstr ""
-#: VirtualMailManager/Domain.py:125
-msgid "There are accounts."
-msgstr ""
-
-#: VirtualMailManager/Domain.py:128
-msgid "There are aliases."
+#: VirtualMailManager/cli/main.py:29 VirtualMailManager/cli/main.py:60
+#: VirtualMailManager/cli/subcommands.py:477
+#: VirtualMailManager/cli/subcommands.py:497
+#, python-format
+msgid "Error: %s"
msgstr ""
-#: VirtualMailManager/Domain.py:143
-#, python-format
-msgid "The domain “%s” already exists."
-msgstr ""
-
-#: VirtualMailManager/EmailAddress.py:42
-#, python-format
-msgid "Missing '@' sign in e-mail address “%s”."
+#: VirtualMailManager/cli/main.py:36
+msgid "You must specify a subcommand at least"
msgstr ""
-#: VirtualMailManager/EmailAddress.py:45
+#: VirtualMailManager/cli/main.py:48
#, python-format
-msgid "“%s” doesn't look like an e-mail address."
+msgid "Unknown subcommand: '%s'"
msgstr ""
-#: VirtualMailManager/EmailAddress.py:50
-#, python-format
-msgid "Missing domain name after “%s@”."
+#. TP: We have to cry, because root has killed/interrupted vmm
+#. with Ctrl+C or Ctrl+D.
+#: VirtualMailManager/cli/main.py:57
+msgid "Ouch!"
msgstr ""
-#: VirtualMailManager/EmailAddress.py:62
-msgid "No local-part specified."
-msgstr ""
-
-#: VirtualMailManager/EmailAddress.py:65
-#, python-format
-msgid "The local-part “%s” is too long"
+#: VirtualMailManager/cli/main.py:63
+msgid "Warnings:"
msgstr ""
-#: VirtualMailManager/EmailAddress.py:72
+#: VirtualMailManager/cli/subcommands.py:74
#, python-format
-msgid "The local-part “%(lpart)s” contains invalid characters: %(ichrs)s"
+msgid "Plan A failed ... trying Plan B: %(subcommand)s %(object)s"
msgstr ""
-#: VirtualMailManager/MailLocation.py:28
-msgid "Either mid or maillocation must be specified."
-msgstr ""
-
-#: VirtualMailManager/MailLocation.py:34
-msgid "mid must be an int/long."
+#: VirtualMailManager/cli/subcommands.py:88
+msgid "Missing alias address and destination."
msgstr ""
-#: VirtualMailManager/MailLocation.py:42
-#, python-format
-msgid ""
-"Invalid folder name “%s”, it may consist only of\n"
-"1 - 20 single byte characters (A-Z, a-z, 0-9 and _)."
+#: VirtualMailManager/cli/subcommands.py:91
+#: VirtualMailManager/cli/subcommands.py:319
+msgid "Missing destination address."
msgstr ""
-#: VirtualMailManager/MailLocation.py:55
-msgid "Unknown mid specified."
+#: VirtualMailManager/cli/subcommands.py:98
+#: VirtualMailManager/cli/subcommands.py:108
+msgid "Missing alias address."
msgstr ""
-#: VirtualMailManager/Relocated.py:64
-msgid "No destination address specified for relocated user."
-msgstr ""
-
-#: VirtualMailManager/Relocated.py:74
-#, python-format
-msgid "The relocated user “%s” already exists."
+#: VirtualMailManager/cli/subcommands.py:130
+#: VirtualMailManager/cli/subcommands.py:164
+msgid "Missing alias domain name and destination domain name."
msgstr ""
-#: VirtualMailManager/Relocated.py:88 VirtualMailManager/Relocated.py:101
-#, python-format
-msgid "The relocated user “%s” doesn't exist."
+#: VirtualMailManager/cli/subcommands.py:133
+#: VirtualMailManager/cli/subcommands.py:167
+msgid "Missing destination domain name."
msgstr ""
-#: VirtualMailManager/Transport.py:27
-msgid "Either tid or transport must be specified."
-msgstr ""
-
-#: VirtualMailManager/Transport.py:33
-msgid "tid must be an int/long."
+#: VirtualMailManager/cli/subcommands.py:141
+#: VirtualMailManager/cli/subcommands.py:148
+msgid "Missing alias domain name."
msgstr ""
-#: VirtualMailManager/Transport.py:61
-msgid "Unknown tid specified."
-msgstr ""
-
-#: VirtualMailManager/VirtualMailManager.py:47
-msgid ""
-"You are not root.\n"
-"\tGood bye!\n"
+#: VirtualMailManager/cli/subcommands.py:183
+#: VirtualMailManager/cli/subcommands.py:193
+#: VirtualMailManager/cli/subcommands.py:206
+msgid "Missing domain name."
msgstr ""
-#: VirtualMailManager/VirtualMailManager.py:67
-msgid "No “vmm.cfg” found in: /root:/usr/local/etc:/etc"
-msgstr ""
-
-#: VirtualMailManager/VirtualMailManager.py:78
+#: VirtualMailManager/cli/subcommands.py:199
+#: VirtualMailManager/cli/subcommands.py:213
+#: VirtualMailManager/cli/subcommands.py:257
+#: VirtualMailManager/cli/subcommands.py:373
+#: VirtualMailManager/cli/subcommands.py:416 VirtualMailManager/handler.py:400
+#: VirtualMailManager/handler.py:429 VirtualMailManager/handler.py:588
#, python-format
-msgid ""
-"fix permissions (%(perms)s) for “%(file)s”\n"
-"`chmod 0600 %(file)s` would be great."
+msgid "Invalid argument: '%s'"
msgstr ""
-#: VirtualMailManager/VirtualMailManager.py:93
-#, python-format
-msgid ""
-"“%s” is not a directory.\n"
-"(vmm.cfg: section \"domdir\", option \"base\")"
+#: VirtualMailManager/cli/subcommands.py:227
+#: VirtualMailManager/cli/subcommands.py:229
+msgid "Domain"
msgstr ""
-#: VirtualMailManager/VirtualMailManager.py:98
-#, python-format
-msgid ""
-"“%(binary)s” doesn't exist.\n"
-"(vmm.cfg: section \"bin\", option \"%(option)s\")"
+#: VirtualMailManager/cli/subcommands.py:231
+#: VirtualMailManager/cli/subcommands.py:240
+msgid "accounts"
msgstr ""
-#: VirtualMailManager/VirtualMailManager.py:102
-#, python-format
-msgid ""
-"“%(binary)s” is not executable.\n"
-"(vmm.cfg: section \"bin\", option \"%(option)s\")"
+#: VirtualMailManager/cli/subcommands.py:233
+#: VirtualMailManager/cli/subcommands.py:239
+#: VirtualMailManager/cli/subcommands.py:634
+msgid "alias domains"
msgstr ""
-#: VirtualMailManager/VirtualMailManager.py:150
-msgid "The domain name is too long."
-msgstr ""
-
-#: VirtualMailManager/VirtualMailManager.py:153
-#, python-format
-msgid "The domain name “%s” is invalid."
+#: VirtualMailManager/cli/subcommands.py:235
+#: VirtualMailManager/cli/subcommands.py:241
+msgid "aliases"
msgstr ""
-#. TP: Please preserve the trailing space.
-#: VirtualMailManager/VirtualMailManager.py:192
-msgid "Enter new password: "
+#: VirtualMailManager/cli/subcommands.py:237
+#: VirtualMailManager/cli/subcommands.py:242
+msgid "relocated users"
msgstr ""
-#. TP: Please preserve the trailing space.
-#: VirtualMailManager/VirtualMailManager.py:194
-msgid "Retype new password: "
+#: VirtualMailManager/cli/subcommands.py:248
+msgid "Missing domain name and new transport."
msgstr ""
-#: VirtualMailManager/VirtualMailManager.py:200
-msgid "Sorry, passwords do not match"
+#: VirtualMailManager/cli/subcommands.py:251
+msgid "Missing new transport."
msgstr ""
-#: VirtualMailManager/VirtualMailManager.py:203
-msgid "Sorry, empty passwords are not permitted"
-msgstr ""
-
-#: VirtualMailManager/VirtualMailManager.py:251
-#: VirtualMailManager/VirtualMailManager.py:338
-#, python-format
-msgid "No such directory: %s"
+#: VirtualMailManager/cli/subcommands.py:265
+msgid "Missing userid."
msgstr ""
-#: VirtualMailManager/VirtualMailManager.py:326
-msgid "Found \"..\" in home directory path."
+#: VirtualMailManager/cli/subcommands.py:266
+#: VirtualMailManager/cli/subcommands.py:435
+#: VirtualMailManager/cli/subcommands.py:437
+msgid "Account"
msgstr ""
-#: VirtualMailManager/VirtualMailManager.py:334
-msgid "Detected owner/group mismatch in home directory."
-msgstr ""
-
-#: VirtualMailManager/VirtualMailManager.py:349
-msgid "Found \"..\" in domain directory path."
+#: VirtualMailManager/cli/subcommands.py:281
+#, python-format
+msgid "Unknown help topic: '%s'"
msgstr ""
-#: VirtualMailManager/VirtualMailManager.py:355
-msgid "Detected group mismatch in domain directory."
+#: VirtualMailManager/cli/subcommands.py:294
+msgid "List of available subcommands:"
msgstr ""
-#: VirtualMailManager/VirtualMailManager.py:439
-#, python-format
-msgid ""
-"Configuration error: \"%s\"\n"
-"(in section \"config\", option \"done\") see also: vmm.cfg(5)\n"
+#: VirtualMailManager/cli/subcommands.py:317
+msgid "Missing relocated address and destination."
msgstr ""
-#: VirtualMailManager/VirtualMailManager.py:459
-#, python-format
-msgid "Invalid section: “%s”"
+#: VirtualMailManager/cli/subcommands.py:326
+#: VirtualMailManager/cli/subcommands.py:333
+msgid "Missing relocated address."
msgstr ""
-#: VirtualMailManager/VirtualMailManager.py:469
-#: VirtualMailManager/VirtualMailManager.py:479
-#: VirtualMailManager/VirtualMailManager.py:498
-#: VirtualMailManager/VirtualMailManager.py:606
-#: VirtualMailManager/VirtualMailManager.py:637
-#, python-format
-msgid "Invalid argument: “%s”"
-msgstr ""
-
-#: VirtualMailManager/VirtualMailManager.py:502
-msgid ""
-"The keyword “detailed” is deprecated and will be removed in a future "
-"release.\n"
-" Please use the keyword “full” to get full details."
+#: VirtualMailManager/cli/subcommands.py:356
+#: VirtualMailManager/cli/subcommands.py:367
+#: VirtualMailManager/cli/subcommands.py:380
+#: VirtualMailManager/cli/subcommands.py:395
+#: VirtualMailManager/cli/subcommands.py:410
+#: VirtualMailManager/cli/subcommands.py:454
+msgid "Missing e-mail address."
msgstr ""
-#: VirtualMailManager/VirtualMailManager.py:575
+#: VirtualMailManager/cli/subcommands.py:387
+#: VirtualMailManager/cli/subcommands.py:402
#, python-format
-msgid "The pattern “%s” contains invalid characters."
+msgid "Invalid service arguments: %s"
msgstr ""
-#: VirtualMailManager/VirtualMailManager.py:601
-#, python-format
-msgid "The destination account/alias “%s” doesn't exist."
+#: VirtualMailManager/cli/subcommands.py:438
+msgid "alias addresses"
+msgstr ""
+
+#: VirtualMailManager/cli/subcommands.py:444
+msgid "Missing e-mail address and user's name."
msgstr ""
-#: VirtualMailManager/VirtualMailManager.py:618
-#, python-format
-msgid ""
-"The account has been successfully deleted from the database.\n"
-" But an error occurred while deleting the following directory:\n"
-" “%(directory)s”\n"
-" Reason: %(reason)s"
-msgstr ""
-
-#: VirtualMailManager/VirtualMailManager.py:658
-msgid "Account doesn't exist"
+#: VirtualMailManager/cli/subcommands.py:447
+msgid "Missing user's name."
msgstr ""
-#: VirtualMailManager/VirtualMailManager.py:674
-#: VirtualMailManager/VirtualMailManager.py:684
-msgid ""
-"The service name “managesieve” is deprecated and will be removed\n"
-" in a future release.\n"
-" Please use the service name “sieve” instead."
+#: VirtualMailManager/cli/subcommands.py:465
+msgid "Missing e-mail address and transport."
msgstr ""
-#: VirtualMailManager/ext/Postconf.py:41
-#, python-format
-msgid ""
-"The value “%s” doesn't look like a valid postfix configuration parameter "
-"name."
+#: VirtualMailManager/cli/subcommands.py:468
+msgid "Missing transport."
+msgstr ""
+
+#: VirtualMailManager/cli/subcommands.py:478
+msgid "usage: "
msgstr ""
#. TP: Please adjust translated words like the original text.
#. (It's a table header.) Extract from usage text:
-#. Usage: vmm SUBCOMMAND OBJECT ARGS*
+#. usage: vmm subcommand arguments
#. short long
-#. subcommand object args (* = optional)
+#. subcommand arguments
#.
-#. da domainadd domain.tld transport*
-#. di domaininfo domain.tld details*
-#: vmm:26
+#. da domainadd fqdn [transport]
+#. dd domaindelete fqdn [force]
+#: VirtualMailManager/cli/subcommands.py:488
#, python-format
msgid ""
-"Usage: %s SUBCOMMAND OBJECT ARGS*\n"
+"usage: %s subcommand arguments\n"
" short long\n"
-" subcommand object args (* = optional)\n"
+" subcommand arguments\n"
+msgstr ""
+
+#: VirtualMailManager/cli/subcommands.py:507
+msgid "from"
+msgstr ""
+
+#. TP: The words 'from', 'version' and 'on' are used in
+#. the version information, e.g.:
+#. vmm, version 0.5.2 (from 09/09/09)
+#. Python 2.5.4 on FreeBSD
+#: VirtualMailManager/cli/subcommands.py:507
+msgid "version"
+msgstr ""
+
+#: VirtualMailManager/cli/subcommands.py:510
+msgid "on"
+msgstr ""
+
+#: VirtualMailManager/cli/subcommands.py:512
+msgid "is free software and comes with ABSOLUTELY NO WARRANTY."
+msgstr ""
+
+#: VirtualMailManager/cli/subcommands.py:518
+msgid "get the address of the user with the given UID"
+msgstr ""
+
+#: VirtualMailManager/cli/subcommands.py:520
+msgid "create a new e-mail user with the given address"
+msgstr ""
+
+#: VirtualMailManager/cli/subcommands.py:522
+msgid "delete the specified user"
+msgstr ""
+
+#: VirtualMailManager/cli/subcommands.py:525
+msgid "deactivate all/the given service(s) for a user"
+msgstr ""
+
+#: VirtualMailManager/cli/subcommands.py:527
+msgid "activate all or the given service(s) for a user"
+msgstr ""
+
+#: VirtualMailManager/cli/subcommands.py:529
+msgid "display information about the given address"
+msgstr ""
+
+#: VirtualMailManager/cli/subcommands.py:531
+msgid "set or update the real name for an address"
+msgstr ""
+
+#: VirtualMailManager/cli/subcommands.py:534
+msgid "update the password for the given address"
+msgstr ""
+
+#: VirtualMailManager/cli/subcommands.py:537
+msgid "update the transport of the given address"
+msgstr ""
+
+#: VirtualMailManager/cli/subcommands.py:540
+msgid "create a new alias e-mail address"
msgstr ""
-#: vmm:65 vmm:76
-#, python-format
-msgid "Error: %s\n"
+#: VirtualMailManager/cli/subcommands.py:543
+msgid "delete the specified alias e-mail address or one of its destinations"
+msgstr ""
+
+#: VirtualMailManager/cli/subcommands.py:546
+msgid "show the destination(s) of the specified alias"
+msgstr ""
+
+#: VirtualMailManager/cli/subcommands.py:550
+msgid "create a new alias for an existing domain"
+msgstr ""
+
+#: VirtualMailManager/cli/subcommands.py:552
+msgid "delete the specified alias domain"
+msgstr ""
+
+#: VirtualMailManager/cli/subcommands.py:554
+msgid "show the destination of the given alias domain"
+msgstr ""
+
+#: VirtualMailManager/cli/subcommands.py:557
+msgid "assign the given alias domain to an other domain"
+msgstr ""
+
+#: VirtualMailManager/cli/subcommands.py:560
+msgid "create a new domain"
+msgstr ""
+
+#: VirtualMailManager/cli/subcommands.py:562
+msgid "delete the given domain and all its alias domains"
msgstr ""
-#. TP: e.g. 'Domain information' or 'Account information'
-#: vmm:104
+#: VirtualMailManager/cli/subcommands.py:564
+msgid "display information about the given domain"
+msgstr ""
+
+#: VirtualMailManager/cli/subcommands.py:567
+msgid "update the transport of the specified domain"
+msgstr ""
+
+#: VirtualMailManager/cli/subcommands.py:569
+msgid "list all domains / search domains by pattern"
+msgstr ""
+
+#: VirtualMailManager/cli/subcommands.py:573
+msgid "create a new record for a relocated user"
+msgstr ""
+
+#: VirtualMailManager/cli/subcommands.py:576
+msgid "delete the record of the relocated user"
+msgstr ""
+
+#: VirtualMailManager/cli/subcommands.py:578
+msgid "print information about a relocated user"
+msgstr ""
+
+#: VirtualMailManager/cli/subcommands.py:581
+msgid "start interactive configuration modus"
+msgstr ""
+
+#: VirtualMailManager/cli/subcommands.py:583
+msgid "show a help overview or help for the given subcommand"
+msgstr ""
+
+#: VirtualMailManager/cli/subcommands.py:585
+msgid "show version and copyright information"
+msgstr ""
+
+#. TP: used in e.g. 'Domain information' or 'Account information'
+#: VirtualMailManager/cli/subcommands.py:618
msgid "information"
msgstr ""
-#. TP: e.g. 'Available alias addresses' or 'Available accounts'
-#: vmm:115
+#. TP: used in e.g. 'Available alias addresses' or 'Available accounts'
+#: VirtualMailManager/cli/subcommands.py:631
msgid "Available"
msgstr ""
-#: vmm:118 vmm:218 vmm:224
-msgid "alias domains"
-msgstr ""
-
-#: vmm:128 vmm:139 vmm:163
+#: VirtualMailManager/cli/subcommands.py:644
+#: VirtualMailManager/cli/subcommands.py:686
msgid "\tNone"
msgstr ""
-#: vmm:132
+#: VirtualMailManager/cli/subcommands.py:649
msgid "Alias information"
msgstr ""
-#: vmm:134
+#: VirtualMailManager/cli/subcommands.py:651
#, python-format
msgid "\tMail for %s will be redirected to:"
msgstr ""
-#: vmm:143
+#: VirtualMailManager/cli/subcommands.py:658
msgid "Relocated information"
msgstr ""
-#: vmm:145
+#: VirtualMailManager/cli/subcommands.py:660
#, python-format
-msgid "\tUser “%(addr)s” has moved to “%(dest)s”"
+msgid "\tUser '%(addr)s' has moved to '%(dest)s'"
msgstr ""
-#: vmm:158
+#: VirtualMailManager/cli/subcommands.py:675
+msgid "Matching domains"
+msgstr ""
+
+#: VirtualMailManager/cli/subcommands.py:677
msgid "Available domains"
msgstr ""
-#: vmm:160
-msgid "Matching domains"
-msgstr ""
-
-#: vmm:174
+#: VirtualMailManager/cli/subcommands.py:692
msgid "Alias domain information"
msgstr ""
-#: vmm:180
+#: VirtualMailManager/cli/subcommands.py:697
#, python-format
msgid ""
"\tThe alias domain %(alias)s belongs to:\n"
"\t * %(domain)s"
msgstr ""
-#: vmm:191 vmm:199 vmm:207
-msgid "Missing domain name."
+#: VirtualMailManager/common.py:61
+#, python-format
+msgid "'%s' is not a file"
+msgstr ""
+
+#: VirtualMailManager/common.py:64
+#, python-format
+msgid "File is not executable: '%s'"
msgstr ""
-#: vmm:210 vmm:214
-msgid "Domain"
+#: VirtualMailManager/config.py:88
+#, python-format
+msgid "Not a boolean: '%s'"
msgstr ""
-#: vmm:216 vmm:225
-msgid "accounts"
+#: VirtualMailManager/config.py:126
+#, python-format
+msgid "Bad format: '%s' - expected: section.option"
+msgstr ""
+
+#: VirtualMailManager/config.py:376
+msgid "Missing options, which have no default value.\n"
+msgstr ""
+
+#: VirtualMailManager/config.py:380
+#, python-format
+msgid "* Section: %s\n"
msgstr ""
-#: vmm:220 vmm:226
-msgid "aliases"
+#: VirtualMailManager/config.py:423 VirtualMailManager/handler.py:244
+#: VirtualMailManager/handler.py:315 VirtualMailManager/handler.py:320
+#: VirtualMailManager/handler.py:348
+#, python-format
+msgid "No such directory: %s"
+msgstr ""
+
+#: VirtualMailManager/config.py:435 VirtualMailManager/maillocation.py:71
+#, python-format
+msgid "Unsupported mailbox format: '%s'"
+msgstr ""
+
+#: VirtualMailManager/config.py:446
+#, python-format
+msgid "Not a valid Dovecot version: '%s'"
msgstr ""
-#: vmm:222 vmm:227
-msgid "relocated users"
+#: VirtualMailManager/domain.py:72
+#, python-format
+msgid "The domain '%s' is an alias domain."
msgstr ""
-#: vmm:238
-msgid "Missing domain name and new transport."
+#: VirtualMailManager/domain.py:100
+#, python-format
+msgid ""
+"There are %(account_count)u accounts, %(alias_count)u aliases and "
+"%(relocated_count)u relocated users."
msgstr ""
-#: vmm:240
-msgid "Missing new transport."
+#: VirtualMailManager/domain.py:159
+#, python-format
+msgid "The domain '%s' already exists."
+msgstr ""
+
+#: VirtualMailManager/domain.py:310
+msgid "The domain name is too long"
msgstr ""
-#: vmm:249 vmm:272
-msgid "Missing alias domain name and target domain name."
+#: VirtualMailManager/domain.py:312
+#, python-format
+msgid "The domain name '%s' is invalid"
+msgstr ""
+
+#: VirtualMailManager/emailaddress.py:71
+#, python-format
+msgid "Missing the '@' sign in address '%s'"
+msgstr ""
+
+#: VirtualMailManager/emailaddress.py:74
+#, python-format
+msgid "Too many '@' signs in address '%s'"
msgstr ""
-#: vmm:251 vmm:274
-msgid "Missing target domain name."
+#: VirtualMailManager/emailaddress.py:77
+#, python-format
+msgid "Missing local-part in address '%s'"
msgstr ""
-#: vmm:257 vmm:280
-msgid "Missing alias domain name."
+#: VirtualMailManager/emailaddress.py:80
+#, python-format
+msgid "Missing domain name in address '%s'"
msgstr ""
-#: vmm:286 vmm:295 vmm:303 vmm:345 vmm:353 vmm:361
-msgid "Missing e-mail address."
+#: VirtualMailManager/emailaddress.py:93
+#, python-format
+msgid "The local-part '%s' is too long"
+msgstr ""
+
+#: VirtualMailManager/emailaddress.py:98
+#, python-format
+msgid "The local-part '%(l_part)s' contains invalid characters: %(i_chars)s"
msgstr ""
-#: vmm:312
-msgid "alias addresses"
+#: VirtualMailManager/ext/postconf.py:84
+#, python-format
+msgid ""
+"The value '%s' doesn't look like a valid postfix configuration parameter "
+"name."
msgstr ""
-#: vmm:329
-msgid "Missing e-mail address and user’s name."
+#: VirtualMailManager/handler.py:53
+msgid "an account"
+msgstr ""
+
+#: VirtualMailManager/handler.py:54
+msgid "an alias"
msgstr ""
-#: vmm:331
-msgid "Missing user’s name."
+#: VirtualMailManager/handler.py:55
+msgid "a relocated user"
+msgstr ""
+
+#: VirtualMailManager/handler.py:80
+msgid ""
+"You are not root.\n"
+"\tGood bye!\n"
msgstr ""
-#: vmm:337
-msgid "Missing e-mail address and transport."
+#: VirtualMailManager/handler.py:99
+#, python-format
+msgid "Could not find '%(cfg_file)s' in: '%(cfg_path)s'"
msgstr ""
-#: vmm:339
-msgid "Missing transport."
+#: VirtualMailManager/handler.py:110
+#, python-format
+msgid ""
+"wrong permissions for '%(file)s': %(perms)s\n"
+"`chmod 0600 %(file)s` would be great."
msgstr ""
-#: vmm:370
-msgid "Missing alias address and destination."
+#: VirtualMailManager/handler.py:130
+#, python-format
+msgid ""
+"'%(path)s' is not a directory.\n"
+"(%(cfg_file)s: section 'misc', option 'base_directory')"
+msgstr ""
+
+#: VirtualMailManager/handler.py:139
+#, python-format
+msgid ""
+"'%(binary)s' doesn't exist.\n"
+"(%(cfg_file)s: section 'bin', option '%(option)s')"
msgstr ""
-#: vmm:372 vmm:407
-msgid "Missing destination address."
+#: VirtualMailManager/handler.py:145
+#, python-format
+msgid ""
+"'%(binary)s' is not executable.\n"
+"(%(cfg_file)s: section 'bin', option '%(option)s')"
msgstr ""
-#: vmm:378 vmm:396
-msgid "Missing alias address"
+#. TP: %(a_type)s will be one of: 'an account', 'an alias' or
+#. 'a relocated user'
+#: VirtualMailManager/handler.py:205
+#, python-format
+msgid "There is already %(a_type)s with the address '%(address)s'."
+msgstr ""
+
+#: VirtualMailManager/handler.py:258
+#, python-format
+msgid "'%s' is not a directory."
msgstr ""
-#: vmm:405
-msgid "Missing relocated address and destination."
+#: VirtualMailManager/handler.py:287
+msgid "Skipped mailbox folders:"
msgstr ""
-#: vmm:413 vmm:431
-msgid "Missing relocated address"
+#: VirtualMailManager/handler.py:307
+#, python-format
+msgid ""
+"UID '%(uid)u' and/or GID '%(gid)u' are less than %(min_uid)u/%(min_gid)u."
+msgstr ""
+
+#: VirtualMailManager/handler.py:312 VirtualMailManager/handler.py:345
+#, python-format
+msgid "Found \"..\" in domain directory path: %s"
msgstr ""
-#: vmm:437
-msgid "Missing userid"
+#: VirtualMailManager/handler.py:325
+msgid "Detected owner/group mismatch in home directory."
+msgstr ""
+
+#: VirtualMailManager/handler.py:341
+#, python-format
+msgid "GID '%(gid)u' is less than '%(min_gid)u'."
msgstr ""
-#: vmm:450
-msgid "Warnings:"
+#: VirtualMailManager/handler.py:352
+#, python-format
+msgid "Detected group mismatch in domain directory: %s"
msgstr ""
-#: vmm:460
-msgid "from"
+#: VirtualMailManager/handler.py:506
+#, python-format
+msgid "The pattern '%s' contains invalid characters."
+msgstr ""
+
+#: VirtualMailManager/handler.py:529
+msgid "Ignored destination addresses:"
msgstr ""
-#. TP: The words 'from', 'version' and 'on' are used in the version
-#. information:
-#. vmm, version 0.5.2 (from 09/09/09)
-#. Python 2.5.4 on FreeBSD
-#: vmm:460
-msgid "version"
+#: VirtualMailManager/handler.py:534
+#, python-format
+msgid "The destination account/alias '%s' doesn't exist."
+msgstr ""
+
+#: VirtualMailManager/handler.py:556
+#, python-format
+msgid ""
+"The account has been successfully deleted from the database.\n"
+" But an error occurred while deleting the following directory:\n"
+" '%(directory)s'\n"
+" Reason: %(reason)s"
msgstr ""
-#: vmm:463
-msgid "on"
+#: VirtualMailManager/handler.py:626
+#, python-format
+msgid "Could not accept name: '%s'"
msgstr ""
-#: vmm:464
-msgid "is free software and comes with ABSOLUTELY NO WARRANTY."
+#: VirtualMailManager/handler.py:637
+#, python-format
+msgid "Could not accept transport: '%s'"
+msgstr ""
+
+#: VirtualMailManager/handler.py:683 VirtualMailManager/relocated.py:97
+#: VirtualMailManager/relocated.py:104
+#, python-format
+msgid "The relocated user '%s' doesn't exist."
+msgstr ""
+
+#: VirtualMailManager/maillocation.py:75
+msgid "Empty directory name"
msgstr ""
-#: vmm:472
+#: VirtualMailManager/maillocation.py:77
#, python-format
-msgid "Plan A failed ... trying Plan B: %(subcommand)s %(object)s"
+msgid "Directory name is too long: '%s'"
msgstr ""
-#: vmm:535
+#: VirtualMailManager/maillocation.py:123
+#, python-format
+msgid "Unknown mail_location id: %u"
+msgstr ""
+
+#: VirtualMailManager/password.py:370
#, python-format
-msgid "Unknown subcommand: “%s”"
+msgid "Unsupported password scheme: '%s'"
+msgstr ""
+
+#: VirtualMailManager/password.py:373
+#, python-format
+msgid "The password scheme '%(scheme)s' requires Dovecot >= v%(version)s"
msgstr ""
-#. TP: We have to cry, because root has killed/interrupted vmm
-#. with Ctrl+C or Ctrl+D.
-#: vmm:540
-msgid ""
-"\n"
-"Ouch!\n"
+#: VirtualMailManager/password.py:379
+msgid "Encoding suffixes for password schemes require Dovecot >= v1.1.alpha1"
+msgstr ""
+
+#: VirtualMailManager/password.py:382
+#, python-format
+msgid "Unsupported password encoding: '%s'"
msgstr ""
-#: vmm:543
+#: VirtualMailManager/relocated.py:71
+msgid "Address and destination are identical."
+msgstr ""
+
+#: VirtualMailManager/relocated.py:75
#, python-format
-msgid "Error: %s"
+msgid "The relocated user '%s' already exists."
msgstr ""
+
+#: VirtualMailManager/transport.py:78
+msgid "Unknown tid specified."
+msgstr ""
--- a/setup.py Thu Jan 13 12:48:30 2011 +0000
+++ b/setup.py Thu Jan 13 12:54:53 2011 +0000
@@ -5,51 +5,63 @@
import os
from distutils.core import setup
+from distutils.dist import DistributionMetadata
VERSION = '0.5.2'
+descr = 'Tool to manage mail domains/accounts/aliases for Dovecot and Postfix'
long_description = """
vmm, a virtual mail manager, is a command line tool for
administrators/postmasters to manage (alias-)domains, accounts,
aliases and relocated users.
It is designed for Dovecot and Postfix with a PostgreSQL backend.
"""
+packages = [
+ 'VirtualMailManager',
+ 'VirtualMailManager.cli',
+ 'VirtualMailManager.ext',
+ 'VirtualMailManager.pycompat',
+]
+# http://pypi.python.org/pypi?%3Aaction=list_classifiers
+classifiers = ['Development Status :: 5 - Production/Stable',
+ 'Environment :: Console',
+ 'Intended Audience :: System Administrators',
+ 'License :: OSI Approved :: BSD License',
+ 'Natural Language :: Dutch',
+ 'Natural Language :: English',
+ 'Natural Language :: French',
+ 'Natural Language :: German',
+ 'Operating System :: POSIX',
+ 'Operating System :: POSIX :: BSD',
+ 'Operating System :: POSIX :: Linux',
+ 'Operating System :: POSIX :: Other',
+ 'Programming Language :: Python',
+ 'Programming Language :: Python :: 2',
+ 'Topic :: Communications :: Email',
+ 'Topic :: System :: Systems Administration',
+ 'Topic :: Utilities']
+
+# sucessfuly tested on:
+platforms = ['freebsd7', 'linux2', 'openbsd4']
# remove existing MANIFEST
if os.path.exists('MANIFEST'):
os.remove('MANIFEST')
+setup_args = {'name': 'VirtualMailManager',
+ 'version': VERSION,
+ 'description': descr,
+ 'long_description': long_description,
+ 'packages': packages,
+ 'author': 'Pascal Volk',
+ 'author_email': 'neverseen@users.sourceforge.net',
+ 'license': 'BSD License',
+ 'url': 'http://vmm.localdomain.org/',
+ 'download_url':'http://sf.net/projects/vmm/files/',
+ 'platforms': platforms,
+ 'classifiers': classifiers}
-setup(name='VirtualMailManager',
- version=VERSION,
- description='Tool to manage mail domains/accounts/aliases for Dovecot and Postfix',
- long_description=long_description,
- packages=['VirtualMailManager', 'VirtualMailManager.ext',
- 'VirtualMailManager.constants'],
- author='Pascal Volk',
- author_email='neverseen@users.sourceforge.net',
- license='BSD License',
- url='http://vmm.localdomain.org/',
- download_url='http://sf.net/projects/vmm/files/',
- platforms=['freebsd7', 'linux2', 'openbsd4'],
- classifiers=[
- 'Development Status :: 4 - Beta',
- 'Development Status :: 5 - Production/Stable',
- 'Environment :: Console',
- 'Intended Audience :: System Administrators',
- 'License :: OSI Approved :: BSD License',
- 'Natural Language :: Dutch',
- 'Natural Language :: English',
- 'Natural Language :: French',
- 'Natural Language :: German',
- 'Operating System :: POSIX',
- 'Operating System :: POSIX :: BSD',
- 'Operating System :: POSIX :: Linux',
- 'Operating System :: POSIX :: Other',
- 'Programming Language :: Python',
- 'Topic :: Communications :: Email',
- 'Topic :: System :: Systems Administration',
- 'Topic :: Utilities'
- ],
- requires=['pyPgSQL']
- )
+if 'requires' in DistributionMetadata._METHOD_BASENAMES:
+ setup_args['requires'] = ['psycopg2>=2.0', 'pyPgSQL>=2.5.1']
+
+setup(**setup_args)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/update_config.py Thu Jan 13 12:54:53 2011 +0000
@@ -0,0 +1,142 @@
+#!/usr/bin/env python
+# -*- coding: UTF-8 -*-
+# Copyright (c) 2008 - 2010, Pascal Volk
+# See COPYING for distribution information.
+
+import os
+os.sys.path.remove(os.sys.path[0])
+from time import time
+from ConfigParser import ConfigParser
+from shutil import copy2
+from VirtualMailManager.constants.VERSION import VERSION
+
+
+def get_config_file():
+ f = None
+ for d in ('/root', '/usr/local/etc', '/etc'):
+ tmp = os.path.join(d, 'vmm.cfg')
+ if os.path.isfile(tmp):
+ f = tmp
+ break
+ if f:
+ return f
+ else:
+ os.sys.stderr.write('error: vmm.cfg not found\n')
+ raise SystemExit(2)
+
+def update(cp):
+ if VERSION == '0.5.2':
+ upd_052(cp)
+ elif VERSION == '0.6.0':
+ os.sys.stdout.write('info: nothing to do for version %s\n' % VERSION)
+ return
+ else:
+ os.sys.stderr.write(
+ 'error: the version %s is not supported by this script\n' % VERSION)
+ raise SystemExit(3)
+
+def get_cfg_parser(cf):
+ fh = open(cf, 'r')
+ cp = ConfigParser()
+ cp.readfp(fh)
+ fh.close()
+ return cp
+
+def update_cfg_file(cp, cf):
+ copy2(cf, cf+'.bak.'+str(time()))
+ fh = open(cf, 'w')
+ cp.write(fh)
+ fh.close()
+
+def add_sections(cp, sections):
+ for section in sections:
+ if not cp.has_section(section):
+ cp.add_section(section)
+
+def move_option(cp, src, dst):
+ ds, do = dst.split('.')
+ if not cp.has_option(ds, do):
+ ss, so = src.split('.')
+ cp.set(ds, do, cp.get(ss, so))
+ cp.remove_option(ss, so)
+ sect_opt.append((dst, 'R'))
+
+def add_option(cp, dst, val):
+ ds, do = dst.split('.')
+ if not cp.has_option(ds, do):
+ 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)
+
+def upd_052(cp):
+ global had_config
+ global had_gid_mail
+
+ had_config = cp.remove_section('config')
+ had_gid_mail = cp.remove_option('misc', 'gid_mail')
+ add_sections(cp, ('domain', 'account', 'mailbox'))
+ if cp.has_section('domdir'):
+ for src, dst in (('domdir.mode', 'domain.directory_mode'),
+ ('domdir.delete', 'domain.delete_directory'),
+ ('domdir.base', 'misc.base_directory')):
+ move_option(cp, src, dst)
+ cp.remove_section('domdir')
+ if cp.has_section('services'):
+ for service in cp.options('services'):
+ move_option(cp, 'services.%s'%service, 'account.%s'%service)
+ cp.remove_section('services')
+ for src, dst in (('maildir.mode', 'account.directory_mode'),
+ ('maildir.diskusage', 'account.disk_usage'),
+ ('maildir.delete', 'account.delete_directory'),
+ ('maildir.folders', 'mailbox.folders'),
+ ('maildir.name', 'mailbox.root'),
+ ('misc.forcedel', 'domain.force_deletion'),
+ ('misc.passwdscheme', 'misc.password_scheme'),
+ ('misc.dovecotvers', 'misc.dovecot_version')):
+ move_option(cp, src, dst)
+ cp.remove_section('maildir')
+ add_option(cp, 'database.module', 'pyPgSQL')
+ set_dovecot_version(cp)
+
+
+# def main():
+if __name__ == '__main__':
+ sect_opt = []
+ had_config = False
+ had_gid_mail = False
+ cf = get_config_file()
+ cp = get_cfg_parser(cf)
+ update(cp)
+ if len(sect_opt):
+ update_cfg_file(cp, cf)
+ sect_opt.sort()
+ print 'Please have a look at your configuration: %s' %cf
+ 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:
+ print '\nRemoved section "config" with option "done" (obsolte)'
+ if had_gid_mail:
+ print '\nRemoved option "gid_mail" from section "misc" (obsolte)\n'
+ os.sys.exit(0)
+ if had_config or had_gid_mail:
+ update_cfg_file(cp, cf)
+ if had_config:
+ print '\nRemoved section "config" with option "done" (obsolte)'
+ if had_gid_mail:
+ print '\nRemoved option "gid_mail" from section "misc" (obsolte)\n'
--- a/update_config_0.4.x-0.5.py Thu Jan 13 12:48:30 2011 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,113 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: UTF-8 -*-
-# Copyright (c) 2008 - 2010, Pascal Volk
-# See COPYING for distribution information.
-
-import os
-os.sys.path.remove(os.sys.path[0])
-from time import time
-from ConfigParser import ConfigParser
-from shutil import copy2
-from VirtualMailManager.constants.VERSION import VERSION
-
-
-def get_config_file():
- f = None
- for d in ('/root', '/usr/local/etc', '/etc'):
- tmp = os.path.join(d, 'vmm.cfg')
- if os.path.isfile(tmp):
- f = tmp
- break
- if f:
- return f
- else:
- os.sys.stderr.write('error: vmm.cfg not found\n')
- os.sys.exit(2)
-
-def update(cp):
- if VERSION == '0.4':
- upd_040(cp)
- elif VERSION == '0.5':
- upd_050(cp)
- elif VERSION == '0.5.1':
- upd_051(cp)
- elif VERSION == '0.5.2':
- os.sys.stdout.write('info: nothing to do for version %s\n' % VERSION)
- os.sys.exit(0)
- else:
- os.sys.stderr.write(
- 'error: the version %s is not supported by this script\n' % VERSION)
- os.sys.exit(3)
-
-def get_cfg_parser(cf):
- fh = file(cf, 'r')
- cp = ConfigParser()
- cp.readfp(fh)
- fh.close()
- return cp
-
-def update_cfg_file(cp, cf):
- copy2(cf, cf+'.bak.'+str(time()))
- fh = file(cf, 'w')
- cp.write(fh)
- fh.close()
-
-def upd_040(cp):
- if not cp.has_option('maildir', 'name') or not cp.has_option('maildir',
- 'folders') or cp.has_option('maildir', 'folder'):
- if not cp.has_option('maildir', 'name'):
- if cp.has_option('maildir', 'folder'):
- cp.set('maildir', 'name', cp.get('maildir', 'folder'))
- cp.remove_option('maildir', 'folder')
- sect_opt.append(('maildir', 'name'))
- else:
- cp.set('maildir', 'name', 'Maildir')
- sect_opt.append(('maildir', 'name'))
- if not cp.has_option('maildir', 'folders'):
- cp.set('maildir', 'folders', 'Drafts:Sent:Templates:Trash')
- sect_opt.append(('maildir', 'folders'))
- if cp.has_option('maildir', 'folder'):
- cp.remove_option('maildir', 'folder')
- upd_050(cp)
-
-def upd_050(cp):
- if not cp.has_option('bin', 'postconf'):
- try:
- postconf = os.sys.argv[1].strip()
- if len(postconf):
- cp.set('bin', 'postconf', postconf)
- sect_opt.append(('bin', 'postconf'))
- else: # possible?
- cp.set('bin', 'postconf', '/usr/sbin/postconf')
- sect_opt.append(('bin', 'postconf'))
- except IndexError:
- cp.set('bin', 'postconf', '/usr/sbin/postconf')
- sect_opt.append(('bin', 'postconf'))
- upd_051(cp)
-
-def upd_051(cp):
- if not cp.has_option('misc', 'dovecotvers') or cp.has_option('services',
- 'managesieve'):
- if not cp.has_option('misc', 'dovecotvers'):
- cp.set('misc', 'dovecotvers', os.sys.argv[2].strip())
- sect_opt.append(('misc', 'dovecotvers'))
- if cp.has_option('services', 'managesieve'):
- cp.set('services','sieve',cp.getboolean('services', 'managesieve'))
- cp.remove_option('services', 'managesieve')
- sect_opt.append(('services', 'sieve'))
-
-# def main():
-if __name__ == '__main__':
- sect_opt = []
- cf = get_config_file()
- cp = get_cfg_parser(cf)
- update(cp)
- if len(sect_opt):
- update_cfg_file(cp, cf)
- print 'Please have a look at your configuration: %s' %cf
- print 'and verify the value from:'
- for s_o in sect_opt:
- print ' [%s] %s' % s_o
- print
-
-
--- a/upgrade.sh Thu Jan 13 12:48:30 2011 +0000
+++ b/upgrade.sh Thu Jan 13 12:54:53 2011 +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_0.4.x-0.5.py ${POSTCONF} ${DOVECOT_VERS:-10}
+./update_config.py ${DOVECOT_VERS:-'1.2.11'}
rv=$?
if [ $rv -eq 2 ]; then
echo "please run the install.sh script"
@@ -43,7 +43,7 @@
exit 1
fi
-python setup.py -q install --prefix ${PREFIX}
+python setup.py -q install --force --prefix ${PREFIX}
python setup.py clean --all >/dev/null
install -m 0700 ${INSTALL_OPTS} vmm ${PREFIX}/sbin
@@ -58,14 +58,6 @@
done
cd - >/dev/null
-# remove misplaced manual pages
-if [ -f /usr/local/share/man/man1/vmm.1 ]; then
- rm -f /usr/local/share/man/man1/vmm.1
-fi
-if [ -f /usr/local/share/man/man5/vmm.cfg.5 ]; then
- rm -f /usr/local/share/man/man5/vmm.cfg.5
-fi
-
# install manual pages
cd man
[ -d ${MANDIR}/man1 ] || mkdir -m 0755 -p ${MANDIR}/man1
@@ -74,7 +66,7 @@
[ -d ${MANDIR}/man5 ] || mkdir -m 0755 -p ${MANDIR}/man5
install -m 0644 ${INSTALL_OPTS} man5/vmm.cfg.5 ${MANDIR}/man5
-for l in $(find . -maxdepth 1 -mindepth 1 -type d \! -name man\? \! -name .svn)
+for l in $(find . -maxdepth 1 -mindepth 1 -type d \! -name man\?)
do
for s in man1 man5; do
[ -d ${MANDIR}/${l}/${s} ] || mkdir -m 0755 -p ${MANDIR}/${l}/${s}
--- a/vmm Thu Jan 13 12:48:30 2011 +0000
+++ b/vmm Thu Jan 13 12:54:53 2011 +0000
@@ -5,541 +5,11 @@
"""This is the vmm main script."""
-import gettext
-from time import strftime, strptime
-
-from VirtualMailManager import *
-from VirtualMailManager.VirtualMailManager import VirtualMailManager
-import VirtualMailManager.Exceptions as VMME
-import VirtualMailManager.constants.EXIT as EXIT
-
-
-def usage(excode=0, errMsg=None):
- # TP: Please adjust translated words like the original text.
- # (It's a table header.) Extract from usage text:
- # Usage: vmm SUBCOMMAND OBJECT ARGS*
- # short long
- # subcommand object args (* = optional)
- #
- # da domainadd domain.tld transport*
- # di domaininfo domain.tld details*
- u_head = _(u"""\
-Usage: %s SUBCOMMAND OBJECT ARGS*
- short long
- subcommand object args (* = optional)\n""")\
- % __prog__
-
- u_body = u"""\
- da domainadd domain.tld transport*
- di domaininfo domain.tld details*
- dt domaintransport domain.tld transport force*
- dd domaindelete domain.tld delalias*|deluser*|delall*
- ada aliasdomainadd aliasdomain.tld domain.tld
- adi aliasdomaininfo aliasdomain.tld
- ads aliasdomainswitch aliasdomain.tld domain.tld
- add aliasdomaindelete aliasdomain.tld
- ua useradd user@domain.tld password*
- ui userinfo user@domain.tld details*
- un username user@domain.tld "user’s name"
- up userpassword user@domain.tld password*
- ut usertransport user@domain.tld transport
- u0 userdisable user@domain.tld service*
- u1 userenable user@domain.tld service*
- ud userdelete user@domain.tld delalias*
- aa aliasadd alias@domain.tld user@domain.tld
- ai aliasinfo alias@domain.tld
- ad aliasdelete alias@domain.tld user@domain.tld*
- ra relocatedadd exaddr@domain.tld user@domain.tld
- ri relocatedinfo exaddr@domain.tld
- rf relocateddelete exaddr@domain.tld
- gu getuser userid
- ld listdomains pattern*
- cf configure section*
- h help
- v version
-"""
- if excode > 0:
- if errMsg is None:
- w_err(excode, u_head, u_body)
- else:
- w_err(excode, u_head, u_body, _(u'Error: %s\n') % errMsg)
- else:
- w_std(u_head, u_body)
- os.sys.exit(excode)
-
-def get_vmm():
- try:
- vmm = VirtualMailManager()
- return vmm
- except (VMME.VMMException, VMME.VMMNotRootException, VMME.VMMPermException,
- VMME.VMMConfigException), e:
- w_err(e.code(), _(u'Error: %s\n') % e.msg())
-
-def _getOrder():
- order = ()
- if vmm.cfgGetInt('misc', 'dovecotvers') > 11:
- sieve_name = u'sieve'
- else:
- sieve_name = u'managesieve'
- if argv[1] in (u'di', u'domaininfo'):
- order = ((u'domainname', 0), (u'gid', 1), (u'transport', 0),
- (u'domaindir', 0), (u'aliasdomains', 0), (u'accounts', 0),
- (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'):
- 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))
- else:
- order = ((u'address', 0), (u'name', 0), (u'uid', 1), (u'gid', 1),
- (u'transport', 0), (u'maildir', 0), (u'smtp', 1),
- (u'pop3', 1), (u'imap', 1), (sieve_name, 1))
- elif argv[1] in (u'gu', u'getuser'):
- order = ((u'uid', 1), (u'gid', 1), (u'address', 0))
- return order
-
-def _printInfo(info, title):
- # TP: e.g. 'Domain information' or 'Account information'
- msg = u'%s %s' % (title, _(u'information'))
- w_std (u'%s\n%s' % (msg, u'-'*len(msg)))
- for k,u in _getOrder():
- if u:
- w_std(u'\t%s: %s' % (k.upper().ljust(15, u'.'), info[k]))
- else:
- w_std(u'\t%s: %s' % (k.title().ljust(15, u'.'), info[k]))
- print
-
-def _printList(alist, title):
- # TP: e.g. 'Available alias addresses' or 'Available accounts'
- msg = u'%s %s' % (_(u'Available'), title)
- w_std(u'%s\n%s' % (msg, u'-'*len(msg)))
- if len(alist) > 0:
- if title != _(u'alias domains'):
- for val in alist:
- w_std(u'\t%s' % val)
- else:
- for dom in alist:
- if not dom.startswith('xn--'):
- w_std(u'\t%s' % dom)
- else:
- w_std(u'\t%s (%s)' % (dom, vmm.ace2idna(dom)))
- else:
- w_std(_(u'\tNone'))
- print
-
-def _printAliases(alias, targets):
- msg = _(u'Alias information')
- w_std(u'%s\n%s' % (msg, u'-'*len(msg)))
- w_std(_(u'\tMail for %s will be redirected to:') % alias)
- if len(targets) > 0:
- for target in targets:
- w_std(u'\t * %s' % target)
- else:
- w_std(_(u'\tNone'))
- print
-
-def _printRelocated(addr_dest):
- msg = _(u'Relocated information')
- w_std(u'%s\n%s' % (msg, u'-'*len(msg)))
- w_std(_(u'\tUser “%(addr)s” has moved to “%(dest)s”') % addr_dest)
- print
-
-def _formatDom(domain, main=True):
- if domain.startswith('xn--'):
- domain = u'%s (%s)' % (domain, vmm.ace2idna(domain))
- if main:
- return u'\t[+] %s' % domain
- else:
- return u'\t[-] %s' % domain
-
-def _printDomList(dids, domains):
- if argc < 3:
- msg = _('Available domains')
- else:
- msg = _('Matching domains')
- w_std('%s\n%s' % (msg, '-'*len(msg)))
- if not len(domains):
- w_std(_('\tNone'))
- else:
- for id in dids:
- if domains[id][0] is not None:
- w_std(_formatDom(domains[id][0]))
- if len(domains[id]) > 1:
- for alias in domains[id][1:]:
- w_std(_formatDom(alias, main=False))
- print
-
-def _printAliasDomInfo(info):
- msg = _('Alias domain information')
- for k in ['alias', 'domain']:
- if info[k].startswith('xn--'):
- info[k] = "%s (%s)" % (info[k], vmm.ace2idna(info[k]))
- w_std('%s\n%s' % (msg, '-'*len(msg)))
- w_std(
- _('\tThe alias domain %(alias)s belongs to:\n\t * %(domain)s')%info)
- print
-
-def configure():
- if need_setup or len(argv) < 3:
- vmm.configure()
- else:
- vmm.configure(argv[2])
-
-def domain_add():
- if argc < 3:
- usage(EXIT.MISSING_ARGS, _(u'Missing domain name.'))
- elif argc < 4:
- vmm.domainAdd(argv[2].lower())
- else:
- vmm.domainAdd(argv[2].lower(), argv[3])
-
-def domain_delete():
- if argc < 3:
- usage(EXIT.MISSING_ARGS, _(u'Missing domain name.'))
- elif argc < 4:
- vmm.domainDelete(argv[2].lower())
- else:
- vmm.domainDelete(argv[2].lower(), argv[3])
-
-def domain_info():
- if argc < 3:
- usage(EXIT.MISSING_ARGS, _(u'Missing domain name.'))
- try:
- if argc < 4:
- _printInfo(vmm.domainInfo(argv[2].lower()), _(u'Domain'))
- else:
- details = argv[3].lower()
- infos = vmm.domainInfo(argv[2].lower(), details)
- _printInfo(infos[0], _(u'Domain'))
- if details == u'accounts':
- _printList(infos[1], _(u'accounts'))
- elif details == u'aliasdomains':
- _printList(infos[1], _(u'alias domains'))
- elif details == u'aliases':
- _printList(infos[1], _(u'aliases'))
- elif details == u'relocated':
- _printList(infos[1], _(u'relocated users'))
- else:
- _printList(infos[1], _(u'alias domains'))
- _printList(infos[2], _(u'accounts'))
- _printList(infos[3], _(u'aliases'))
- _printList(infos[4], _(u'relocated users'))
- except VMME.VMMDomainException, e:
- if e.code() is ERR.DOMAIN_ALIAS_EXISTS:
- w_std(plan_a_b % {'subcommand': u'aliasdomaininfo',
- 'object': argv[2].lower()})
- alias_domain_info()
- else:
- raise e
-
-def domain_transport():
- if argc < 3:
- usage(EXIT.MISSING_ARGS, _(u'Missing domain name and new transport.'))
- if argc < 4:
- usage(EXIT.MISSING_ARGS, _(u'Missing new transport.'))
- elif argc < 5:
- vmm.domainTransport(argv[2].lower(), argv[3])
- else:
- vmm.domainTransport(argv[2].lower(), argv[3], argv[4])
-
-def alias_domain_add():
- if argc < 3:
- usage(EXIT.MISSING_ARGS,
- _(u'Missing alias domain name and target domain name.'))
- elif argc < 4:
- usage(EXIT.MISSING_ARGS, _(u'Missing target domain name.'))
- else:
- vmm.aliasDomainAdd(argv[2].lower(), argv[3].lower())
-
-def alias_domain_info():
- if argc < 3:
- usage(EXIT.MISSING_ARGS, _(u'Missing alias domain name.'))
- try:
- _printAliasDomInfo(vmm.aliasDomainInfo(argv[2].lower()))
- except VMME.VMMAliasDomainException, e:
- if e.code() is ERR.ALIASDOMAIN_ISDOMAIN:
- w_std(plan_a_b % {'subcommand': u'domaininfo',
- 'object': argv[2].lower()})
- argv[1] = u'di' # necessary manipulation to get the order
- domain_info()
- else:
- raise e
+import sys
-def alias_domain_switch():
- if argc < 3:
- usage(EXIT.MISSING_ARGS,
- _(u'Missing alias domain name and target domain name.'))
- elif argc < 4:
- usage(EXIT.MISSING_ARGS, _(u'Missing target domain name.'))
- else:
- vmm.aliasDomainSwitch(argv[2].lower(), argv[3].lower())
-
-def alias_domain_delete():
- if argc < 3:
- usage(EXIT.MISSING_ARGS, _(u'Missing alias domain name.'))
- else:
- vmm.aliasDomainDelete(argv[2].lower())
-
-def user_add():
- if argc < 3:
- usage(EXIT.MISSING_ARGS, _(u'Missing e-mail address.'))
- elif argc < 4:
- password = None
- else:
- password = argv[3]
- vmm.userAdd(argv[2].lower(), password)
-
-def user_delete():
- if argc < 3:
- usage(EXIT.MISSING_ARGS, _(u'Missing e-mail address.'))
- elif argc < 4:
- vmm.userDelete(argv[2].lower())
- else:
- vmm.userDelete(argv[2].lower(), argv[3].lower())
-
-def user_info():
- if argc < 3:
- usage(EXIT.MISSING_ARGS, _(u'Missing e-mail address.'))
- try:
- if argc < 4:
- _printInfo(vmm.userInfo(argv[2].lower()), u'Account')
- else:
- arg3 = argv[3].lower()
- info = vmm.userInfo(argv[2].lower(), arg3)
- if arg3 in ['aliases', 'full']:
- _printInfo(info[0], u'Account')
- _printList(info[1], _(u'alias addresses'))
- else:
- _printInfo(info, u'Account')
- except VMME.VMMAccountException, e:
- if e.code() is ERR.ALIAS_EXISTS:
- w_std(plan_a_b % {'subcommand': u'aliasinfo',
- 'object': argv[2].lower()})
- alias_info()
- elif e.code() is ERR.RELOCATED_EXISTS:
- w_std(plan_a_b % {'subcommand': u'relocatedinfo',
- 'object': argv[2].lower()})
- relocated_info()
- else:
- raise e
-
-def user_name():
- if argc < 3:
- usage(EXIT.MISSING_ARGS, _(u'Missing e-mail address and user’s name.'))
- if argc < 4:
- usage(EXIT.MISSING_ARGS, _(u'Missing user’s name.'))
- else:
- vmm.userName(argv[2].lower(), argv[3])
-
-def user_transport():
- if argc < 3:
- usage(EXIT.MISSING_ARGS, _(u'Missing e-mail address and transport.'))
- if argc <4:
- usage(EXIT.MISSING_ARGS, _(u'Missing transport.'))
- else:
- vmm.userTransport(argv[2].lower(), argv[3])
-
-def user_enable():
- if argc < 3:
- usage(EXIT.MISSING_ARGS, _(u'Missing e-mail address.'))
- elif argc < 4:
- vmm.userEnable(argv[2].lower())
- else:
- vmm.userEnable(argv[2].lower(), argv[3].lower())
-
-def user_disable():
- if argc < 3:
- usage(EXIT.MISSING_ARGS, _(u'Missing e-mail address.'))
- elif argc < 4:
- vmm.userDisable(argv[2].lower())
- else:
- vmm.userDisable(argv[2].lower(), argv[3].lower())
-
-def user_password():
- if argc < 3:
- usage(EXIT.MISSING_ARGS, _(u'Missing e-mail address.'))
- elif argc < 4:
- password = None
- else:
- password = argv[3]
- vmm.userPassword(argv[2].lower(), password)
-
-def alias_add():
- if argc < 3:
- usage(EXIT.MISSING_ARGS, _(u'Missing alias address and destination.'))
- elif argc < 4:
- usage(EXIT.MISSING_ARGS, _(u'Missing destination address.'))
- else:
- vmm.aliasAdd(argv[2].lower(), argv[3])
-
-def alias_info():
- if argc < 3:
- usage(EXIT.MISSING_ARGS, _(u'Missing alias address'))
- try:
- _printAliases(argv[2].lower(), vmm.aliasInfo(argv[2].lower()))
- except VMME.VMMAliasException, e:
- if e.code() is ERR.ACCOUNT_EXISTS:
- w_std(plan_a_b % {'subcommand': u'userinfo',
- 'object': argv[2].lower()})
- argv[1] = u'ui' # necessary manipulation to get the order
- user_info()
- elif e.code() is ERR.RELOCATED_EXISTS:
- w_std(plan_a_b % {'subcommand': u'relocatedinfo',
- 'object': argv[2].lower()})
- relocated_info()
- else:
- raise e
-
-def alias_delete():
- if argc < 3:
- usage(EXIT.MISSING_ARGS, _(u'Missing alias address'))
- elif argc < 4:
- vmm.aliasDelete(argv[2].lower())
- else:
- vmm.aliasDelete(argv[2].lower(), argv[3].lower())
-
-def relocated_add():
- if argc < 3:
- usage(EXIT.MISSING_ARGS,
- _(u'Missing relocated address and destination.'))
- elif argc < 4:
- usage(EXIT.MISSING_ARGS, _(u'Missing destination address.'))
- else:
- vmm.relocatedAdd(argv[2].lower(), argv[3])
-
-def relocated_info():
- if argc < 3:
- usage(EXIT.MISSING_ARGS, _(u'Missing relocated address'))
- relocated = argv[2].lower()
- try:
- _printRelocated({'addr': relocated,
- 'dest': vmm.relocatedInfo(relocated)})
- except VMME.VMMRelocatedException, e:
- if e.code() is ERR.ACCOUNT_EXISTS:
- w_std(plan_a_b % {'subcommand': u'userinfo', 'object': relocated})
- argv[1] = u'ui' # necessary manipulation to get the order
- user_info()
- elif e.code() is ERR.ALIAS_EXISTS:
- w_std(plan_a_b % {'subcommand': u'aliasinfo', 'object': relocated})
- alias_info()
- else:
- raise e
-
-def relocated_delete():
- if argc < 3:
- usage(EXIT.MISSING_ARGS, _(u'Missing relocated address'))
- else:
- vmm.relocatedDelete(argv[2].lower())
-
-def user_byID():
- if argc < 3:
- usage(EXIT.MISSING_ARGS, _(u'Missing userid'))
- else:
- _printInfo(vmm.userByID(argv[2]), u'Account')
-
-def domain_list():
- if argc < 3:
- order, doms = vmm.domainList()
- else:
- order, doms = vmm.domainList(argv[2].lower())
- _printDomList(order, doms)
-
-def show_warnings():
- if vmm.hasWarnings():
- w_std(_(u'Warnings:'))
- for warning in vmm.getWarnings():
- w_std( " * %s" % warning)
-
-def show_version():
- w_std('%s, %s %s (%s %s)\nPython %s %s %s\n\n%s %s' % (__prog__,
- # TP: The words 'from', 'version' and 'on' are used in the version
- # information:
- # vmm, version 0.5.2 (from 09/09/09)
- # Python 2.5.4 on FreeBSD
- _(u'version'), __version__, _(u'from'),
- strftime(locale.nl_langinfo(locale.D_FMT),
- strptime(__date__, '%Y-%m-%d')).decode(ENCODING, 'replace'),
- os.sys.version.split()[0], _(u'on'), os.uname()[0], __prog__,
- _(u'is free software and comes with ABSOLUTELY NO WARRANTY.')))
-
-#def main():
if __name__ == '__main__':
- __prog__ = os.path.basename(os.sys.argv[0])
- gettext.install(__prog__, '/usr/local/share/locale', unicode=1)
- argv = [unicode(arg, ENCODING) for arg in os.sys.argv]
- argc = len(os.sys.argv)
- plan_a_b =_(u'Plan A failed ... trying Plan B: %(subcommand)s %(object)s')
-
- if argc < 2:
- usage(EXIT.MISSING_ARGS)
-
- vmm = get_vmm()
- try:
- need_setup = not vmm.setupIsDone()
- if argv[1] in (u'cf', u'configure') or need_setup:
- configure()
- elif argv[1] in (u'da', u'domainadd'):
- domain_add()
- elif argv[1] in (u'di', u'domaininfo'):
- domain_info()
- elif argv[1] in (u'dt', u'domaintransport'):
- domain_transport()
- elif argv[1] in (u'dd', u'domaindelete'):
- domain_delete()
- elif argv[1] in (u'ada', u'aliasdomainadd'):
- alias_domain_add()
- elif argv[1] in (u'adi', u'aliasdomaininfo'):
- alias_domain_info()
- elif argv[1] in (u'ads', u'aliasdomainswitch'):
- alias_domain_switch()
- elif argv[1] in (u'add', u'aliasdomaindelete'):
- alias_domain_delete()
- elif argv[1] in (u'ua', u'useradd'):
- user_add()
- elif argv[1] in (u'ui', u'userinfo'):
- user_info()
- elif argv[1] in (u'un', u'username'):
- user_name()
- elif argv[1] in (u'up', u'userpassword'):
- user_password()
- elif argv[1] in (u'ut', u'usertransport'):
- user_transport()
- elif argv[1] in (u'u0', u'userdisable'):
- user_disable()
- elif argv[1] in (u'u1', u'userenable'):
- user_enable()
- elif argv[1] in (u'ud', u'userdelete'):
- user_delete()
- elif argv[1] in (u'aa', u'aliasadd'):
- alias_add()
- elif argv[1] in (u'ai', u'aliasinfo'):
- alias_info()
- elif argv[1] in (u'ad', u'aliasdelete'):
- alias_delete()
- elif argv[1] in (u'ra', u'relocatedadd'):
- relocated_add()
- elif argv[1] in (u'ri', u'relocatedinfo'):
- relocated_info()
- elif argv[1] in (u'rd', u'relocateddelete'):
- relocated_delete()
- elif argv[1] in (u'gu', u'getuser'):
- user_byID()
- elif argv[1] in (u'ld', u'listdomains'):
- domain_list()
- elif argv[1] in (u'h', u'help'):
- usage()
- elif argv[1] in (u'v', u'version'):
- show_version()
- else:
- usage(EXIT.UNKNOWN_COMMAND, _(u'Unknown subcommand: “%s”')% argv[1])
- show_warnings()
- except (EOFError, KeyboardInterrupt):
- # TP: We have to cry, because root has killed/interrupted vmm
- # with Ctrl+C or Ctrl+D.
- w_err(EXIT.USER_INTERRUPT, _(u'\nOuch!\n'))
- except (VMME.VMMConfigException, VMME.VMMException), e:
- if e.code() != ERR.DATABASE_ERROR:
- w_err(e.code(), _(u'Error: %s') % e.msg())
- else:
- w_err(e.code(), unicode(e.msg(), ENCODING, 'replace'))
+ # replace the script's cwd (/usr/local/sbin) with our module dir
+ # (the location of the VirtualMailManager directory)
+ sys.path[0] = '/usr/local/lib/vmm'
+ from VirtualMailManager.cli.main import run
+ sys.exit(run(sys.argv))
--- a/vmm.cfg Thu Jan 13 12:48:30 2011 +0000
+++ b/vmm.cfg Thu Jan 13 12:54:53 2011 +0000
@@ -7,55 +7,76 @@
#
[database]
; Hostname or IP address of the database server (String)
-host = 127.0.0.1
+host = localhost
; Database user name (String)
user = dbuser
; Database password (String)
pass = dbpassword
-; database name (String)
+; Database name (String)
name = mailsys
#
-# Mail directories
+# mailbox settings
#
-[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
+[mailbox]
+; The mailbox format to be used for user's mailboxes. (String)
+; Depending on the used Dovecot version there are up to 3 supported formats:
+; * maildir - since Dovecot v1.0.0
+; * mdbox - since Dovecot v2.0.beta5
+; * sdbox - since Dovecot v2.0.rc3
+format = maildir
+; A colon separated list of mailbox names, that should be created (String)
+; 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
+; Name of the mailbox root directory in a user's home. (String)
+; Usually used names (format: name):
+; * maildir: Maildir
+; * mdbox: mdbox
+; * sdbox: sdbox
+root = Maildir
+; Set to true if the mailboxes from the folders option should be listed in
+; the subscriptions file. (Boolean)
+subscribe = true
#
-# Services per user
+# Domain settings
#
-[services]
-; allow smtp by default? (Boolean)
-smtp = true
-; allow pop3 by default? (Boolean)
-pop3 = true
-; allow imap by default? (Boolean)
-imap = true
-; allow managesieve by default? (Boolean)
-sieve = true
+[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_deletion = false
#
-# domain directory settings
+# Account 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
+[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_length = 8
+; Allow smtp by default? (Boolean)
+smtp = true
+; Allow pop3 by default? (Boolean)
+pop3 = true
+; Allow imap by default? (Boolean)
+imap = true
+; Allow managesieve by default? (Boolean)
+sieve = true
#
# external binaries
@@ -72,21 +93,13 @@
# misc settings
#
[misc]
+; The base directory for all domains/accounts (String)
+base_directory = /srv/mail
; Password scheme to use (see also: dovecotpw -l) (String)
-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
-; default transport for domains and accounts
+password_scheme = CRAM-MD5
+; 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
+; 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
-#
-[config]
-; finally set this to true (Boolean)
-done = false