pgsql: Added support for different mailbox formats.
- users.passwd can store sha512-crypt.hex hashes now
- Added new update scripts.
# -*- 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."""fromVirtualMailManager.pycompatimportany__all__=('MailLocation','known_format','ID_MAILDIR','ID_MBOX','ID_MDBOX','ID_SDBOX')ID_MAILDIR=0x1ID_MBOX=0x2ID_MDBOX=0x3ID_SDBOX=0x4_storage={ID_MAILDIR:dict(dovecot_version=0x10000f00,postfix=True,prefix='maildir:',directory='Maildir',mid=ID_MAILDIR),ID_MBOX:dict(dovecot_version=0x10000f00,postfix=True,prefix='mbox:',directory='mail',mid=ID_MBOX),ID_MDBOX:dict(dovecot_version=0x20000a01,postfix=False,prefix='mdbox:',directory='mdbox',mid=ID_MDBOX),ID_SDBOX:dict(dovecot_version=0x10000f00,postfix=False,prefix='dbox:',directory='dbox',mid=ID_SDBOX),}_format_id={'maildir':ID_MAILDIR,'mbox':ID_MBOX,'mdbox':ID_MDBOX,'dbox':ID_SDBOX,}classMailLocation(object):"""A small class for mail_location relevant information."""__slots__=('_info')def__init__(self,mid=None,format=None):"""Creates a new MailLocation instance. Either a mid or the format must be specified. Keyword arguments: mid -- the id of a mail_location (int) one of the maillocation constants: `ID_MAILDIR`, `ID_MBOX`, `ID_MDBOX` and `ID_SDBOX` format -- the mailbox format of the mail_location. One out of: ``maildir``, ``mbox``, ``dbox`` and ``mdbox``. """assertany((mid,format))ifmid:assertisinstance(mid,(int,long))andmidin_storageself._info=_storage[mid]else:assertisinstance(format,basestring)and \format.lower()in_format_idself._info=_storage[_format_id[format.lower()]]def__str__(self):return'%(prefix)s~/%(directory)s'%self._info@propertydefdirectory(self):"""The mail_location's directory name."""returnself._info['directory']@propertydefdovecot_version(self):"""The required Dovecot version (concatenated major and minor parts) for this mailbox format."""returnself._info['dovecot_version']@propertydefpostfix(self):"""`True` if Postfix supports this mailbox format, else `False`."""returnself._info['postfix']@propertydefprefix(self):"""The prefix of the mail_location."""returnself._info['prefix']@propertydefmail_location(self):"""The mail_location, e.g. ``maildir:~/Maildir``"""returnself.__str__()@propertydefmid(self):"""The mail_location's unique ID."""returnself._info['mid']defknown_format(format):"""Checks if the mailbox *format* is known, returns bool."""returnformat.lower()in_format_id