Index: debian/rules =================================================================== --- debian/rules (Revision 13073) +++ debian/rules (Arbeitskopie) @@ -69,6 +69,7 @@ install -m 0755 usr/sbin/univention-cyrus-set-foldertype-shared ${D}/usr/sbin/univention-cyrus-set-foldertype-shared install -m 0755 cyrus.py ${D}/usr/lib/univention-directory-listener/system/ + install -m 0755 mailMailQuota.py ${D}/usr/lib/univention-directory-listener/system/ install -m 0755 cyrus-sieve.py ${D}/usr/lib/univention-directory-listener/system/ install -m 0755 cyrus-shared-folder.py ${D}/usr/lib/univention-directory-listener/system/ Index: mailMailQuota.py =================================================================== --- mailMailQuota.py (Revision 0) +++ mailMailQuota.py (Revision 0) @@ -0,0 +1,75 @@ +#!/usr/bin/python2.4 +# -*- coding: utf-8 -*- +# +# Univention mailMailQuota +# Univention Listener Module +# +# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Univention GmbH +# +# http://www.univention.de/ +# +# All rights reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# Binary versions of this file provided by Univention to you as +# well as other copyrighted, protected or trademarked materials like +# Logos, graphics, fonts, specific documentations and configurations, +# cryptographic keys etc. are subject to a license agreement between +# you and Univention. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +name='mailMailQuota' +description='sets MailQuota from LDAP Entry' +filter='(objectClass=univentionMail)' +attributes=['mailMailQuota', 'mailPrimaryAddress'] + +import os, string, pwd, grp, sys, ldap, tempfile, posix +import listener +import univention_baseconfig +import univention.debug + +def handler(dn, new, old): + + mail = new['mailPrimaryAddress'][0] + quota = new['mailMailQuota'][0] + quota = quota + "000" + cyrus_user = 'cyrus' + hostname = 'localhost' + + baseConfig = univention_baseconfig.baseConfig() + baseConfig.load() + + try: + if quota != '0': + password=open('/etc/cyrus.secret').read() + if password[-1] == '\n': + password=password[0:-1] + + if baseConfig.has_key('mail/cyrus/murder/backend/hostname') and baseConfig['mail/cyrus/murder/backend/hostname']: + hostname = baseConfig['mail/cyrus/murder/backend/hostname'] + + child = spawn('/usr/bin/cyradm -u %s %s' % (cyrus_user, hostname)) + i=0 + while not i == 3: + i = child.expect(['IMAP Password:', '>', 'cyradm: cannot connect to server', EOF], timeout=60) + if i == 0: + child.sendline(password) + elif i == 1: + child.sendline('setquota user/%s %s' % (mail, quota)) + child.sendline('disc') + child.sendline('exit') + elif i == 2: + sys.exit(1) + except: + univention.debug.debug(univention.debug.LISTENER, univention.debug.ERROR, "MailQuota could not be set")