author | Pascal Volk <neverseen@users.sourceforge.net> |
Sun, 24 Aug 2008 04:57:11 +0000 | |
changeset 62 | 869de537a020 |
parent 55 | 15c873f94ba6 |
child 66 | 995d538a6eb5 |
permissions | -rw-r--r-- |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1 |
#!/usr/bin/env python |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
2 |
# -*- coding: UTF-8 -*- |
8
7e3ce56f49e6
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
4
diff
changeset
|
3 |
# Copyright 2007-2008 VEB IT |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
4 |
# See COPYING for distribution information. |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
5 |
# $Id$ |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
6 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
7 |
"""The main class for vmm.""" |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
8 |
|
4 | 9 |
from constants.VERSION import VERSION |
10 |
||
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
11 |
__author__ = 'Pascal Volk <p.volk@veb-it.de>' |
4 | 12 |
__version__ = VERSION |
13 |
__revision__ = 'rev '+'$Rev$'.split()[1] |
|
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
14 |
__date__ = '$Date$'.split()[1] |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
15 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
16 |
import os |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
17 |
import re |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
18 |
import sys |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
19 |
from encodings.idna import ToASCII, ToUnicode |
38
c44ea4526546
* 'VirtualMailManager/Alias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
35
diff
changeset
|
20 |
from getpass import getpass |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
21 |
from shutil import rmtree |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
22 |
from subprocess import Popen, PIPE |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
23 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
24 |
from pyPgSQL import PgSQL # python-pgsql - http://pypgsql.sourceforge.net |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
25 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
26 |
from Exceptions import * |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
27 |
import constants.ERROR as ERR |
49
9bd033177377
* 'VirtualMailManager/Config.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
48
diff
changeset
|
28 |
from Config import Config as Cfg |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
29 |
from Account import Account |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
30 |
from Alias import Alias |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
31 |
from Domain import Domain |
55
15c873f94ba6
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
54
diff
changeset
|
32 |
from AliasDomain import AliasDomain |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
33 |
|
16
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
34 |
SALTCHARS = './0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
35 |
RE_ASCII_CHARS = """^[\x20-\x7E]*$""" |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
36 |
RE_DOMAIN = """^(?:[a-z0-9-]{1,63}\.){1,}[a-z]{2,6}$""" |
35
22cc616aef61
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
34
diff
changeset
|
37 |
RE_DOMAIN_SRCH = """^[a-z0-9-\.]+$""" |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
38 |
RE_LOCALPART = """[^\w!#$%&'\*\+-\.\/=?^_`{\|}~]""" |
8
7e3ce56f49e6
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
4
diff
changeset
|
39 |
RE_MAILLOCATION = """^[\w]{1,20}$""" |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
40 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
41 |
class VirtualMailManager: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
42 |
"""The main class for vmm""" |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
43 |
def __init__(self): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
44 |
"""Creates a new VirtualMailManager instance. |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
45 |
Throws a VMMNotRootException if your uid is greater 0. |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
46 |
""" |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
47 |
self.__cfgFileName = '/usr/local/etc/vmm.cfg' |
51
f5ca21303871
* Switched from pygettext to xgettext -> small adjustments to these files:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
50
diff
changeset
|
48 |
self.__permWarnMsg = _(u"fix permissions for »%(cfgFileName)s«\n\ |
f5ca21303871
* Switched from pygettext to xgettext -> small adjustments to these files:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
50
diff
changeset
|
49 |
`chmod 0600 %(cfgFileName)s` would be great.") % {'cfgFileName': |
f5ca21303871
* Switched from pygettext to xgettext -> small adjustments to these files:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
50
diff
changeset
|
50 |
self.__cfgFileName} |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
51 |
self.__warnings = [] |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
52 |
self.__Cfg = None |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
53 |
self.__dbh = None |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
54 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
55 |
if os.geteuid(): |
48
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
56 |
raise VMMNotRootException(_(u"You are not root.\n\tGood bye!\n"), |
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
57 |
ERR.CONF_NOPERM) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
58 |
if self.__chkCfgFile(): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
59 |
self.__Cfg = Cfg(self.__cfgFileName) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
60 |
self.__Cfg.load() |
2
9b39f828aa8a
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
0
diff
changeset
|
61 |
self.__Cfg.check() |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
62 |
self.__cfgSections = self.__Cfg.getsections() |
16
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
63 |
self.__scheme = self.__Cfg.get('misc', 'passwdscheme') |
14
ebc9b864bc9a
* 'update_config_0.3.x-0.4.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
12
diff
changeset
|
64 |
if not sys.argv[1] in ['cf', 'configure']: |
ebc9b864bc9a
* 'update_config_0.3.x-0.4.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
12
diff
changeset
|
65 |
self.__chkenv() |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
66 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
67 |
def __chkCfgFile(self): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
68 |
"""Checks the configuration file, returns bool""" |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
69 |
if not os.path.isfile(self.__cfgFileName): |
48
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
70 |
raise VMMException(_(u"The file »%s« does not exists.") % |
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
71 |
self.__cfgFileName, ERR.CONF_NOFILE) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
72 |
fstat = os.stat(self.__cfgFileName) |
48
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
73 |
fmode = int(oct(fstat.st_mode & 0777)) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
74 |
if fmode % 100 and fstat.st_uid != fstat.st_gid \ |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
75 |
or fmode % 10 and fstat.st_uid == fstat.st_gid: |
48
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
76 |
raise VMMPermException(self.__permWarnMsg, ERR.CONF_ERROR) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
77 |
else: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
78 |
return True |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
79 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
80 |
def __chkenv(self): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
81 |
"""""" |
24 | 82 |
if not os.path.exists(self.__Cfg.get('domdir', 'base')): |
28
87da30d30fde
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
24
diff
changeset
|
83 |
old_umask = os.umask(0006) |
87da30d30fde
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
24
diff
changeset
|
84 |
os.makedirs(self.__Cfg.get('domdir', 'base'), 0771) |
87da30d30fde
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
24
diff
changeset
|
85 |
os.chown(self.__Cfg.get('domdir', 'base'), 0, |
87da30d30fde
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
24
diff
changeset
|
86 |
self.__Cfg.getint('misc', 'gid_mail')) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
87 |
os.umask(old_umask) |
24 | 88 |
elif not os.path.isdir(self.__Cfg.get('domdir', 'base')): |
48
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
89 |
raise VMMException(_(u'»%s« is not a directory.\n\ |
47
191d5a5adc4a
* Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
45
diff
changeset
|
90 |
(vmm.cfg: section "domdir", option "base")') % |
48
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
91 |
self.__Cfg.get('domdir', 'base'), ERR.NO_SUCH_DIRECTORY) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
92 |
for opt, val in self.__Cfg.items('bin'): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
93 |
if not os.path.exists(val): |
51
f5ca21303871
* Switched from pygettext to xgettext -> small adjustments to these files:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
50
diff
changeset
|
94 |
raise VMMException(_(u'»%(binary)s« doesn\'t exists.\n\ |
f5ca21303871
* Switched from pygettext to xgettext -> small adjustments to these files:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
50
diff
changeset
|
95 |
(vmm.cfg: section "bin", option "%(option)s")') %{'binary': val,'option': opt}, |
f5ca21303871
* Switched from pygettext to xgettext -> small adjustments to these files:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
50
diff
changeset
|
96 |
ERR.NO_SUCH_BINARY) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
97 |
elif not os.access(val, os.X_OK): |
51
f5ca21303871
* Switched from pygettext to xgettext -> small adjustments to these files:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
50
diff
changeset
|
98 |
raise VMMException(_(u'»%(binary)s« is not executable.\n\ |
f5ca21303871
* Switched from pygettext to xgettext -> small adjustments to these files:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
50
diff
changeset
|
99 |
(vmm.cfg: section "bin", option "%(option)s")') %{'binary': val,'option': opt}, |
f5ca21303871
* Switched from pygettext to xgettext -> small adjustments to these files:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
50
diff
changeset
|
100 |
ERR.NOT_EXECUTABLE) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
101 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
102 |
def __dbConnect(self): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
103 |
"""Creates a pyPgSQL.PgSQL.connection instance.""" |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
104 |
try: |
35
22cc616aef61
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
34
diff
changeset
|
105 |
self.__dbh = PgSQL.connect( |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
106 |
database=self.__Cfg.get('database', 'name'), |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
107 |
user=self.__Cfg.get('database', 'user'), |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
108 |
host=self.__Cfg.get('database', 'host'), |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
109 |
password=self.__Cfg.get('database', 'pass'), |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
110 |
client_encoding='utf8', unicode_results=True) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
111 |
dbc = self.__dbh.cursor() |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
112 |
dbc.execute("SET NAMES 'UTF8'") |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
113 |
dbc.close() |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
114 |
except PgSQL.libpq.DatabaseError, e: |
48
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
115 |
raise VMMException(str(e), ERR.DATABASE_ERROR) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
116 |
|
47
191d5a5adc4a
* Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
45
diff
changeset
|
117 |
def chkLocalpart(localpart): |
3
a9b44e04bf01
* VirtualMailManager/Account.py:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
2
diff
changeset
|
118 |
"""Validates the local part of an e-mail address. |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
119 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
120 |
Keyword arguments: |
3
a9b44e04bf01
* VirtualMailManager/Account.py:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
2
diff
changeset
|
121 |
localpart -- the e-mail address that should be validated (str) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
122 |
""" |
47
191d5a5adc4a
* Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
45
diff
changeset
|
123 |
if len(localpart) < 1: |
48
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
124 |
raise VMMException(_(u'No localpart specified.'), |
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
125 |
ERR.LOCALPART_INVALID) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
126 |
if len(localpart) > 64: |
48
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
127 |
raise VMMException(_(u'The local part »%s« is too long') % |
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
128 |
localpart, ERR.LOCALPART_TOO_LONG) |
47
191d5a5adc4a
* Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
45
diff
changeset
|
129 |
ic = re.compile(RE_LOCALPART).findall(localpart) |
191d5a5adc4a
* Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
45
diff
changeset
|
130 |
if len(ic): |
191d5a5adc4a
* Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
45
diff
changeset
|
131 |
ichrs = '' |
191d5a5adc4a
* Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
45
diff
changeset
|
132 |
for c in set(ic): |
191d5a5adc4a
* Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
45
diff
changeset
|
133 |
ichrs += u"»%s« " % c |
51
f5ca21303871
* Switched from pygettext to xgettext -> small adjustments to these files:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
50
diff
changeset
|
134 |
raise VMMException(_(u"The local part »%(lpart)s« contains invalid\ |
f5ca21303871
* Switched from pygettext to xgettext -> small adjustments to these files:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
50
diff
changeset
|
135 |
characters: %(ichrs)s") % {'lpart': localpart, 'ichrs': ichrs}, |
f5ca21303871
* Switched from pygettext to xgettext -> small adjustments to these files:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
50
diff
changeset
|
136 |
ERR.LOCALPART_INVALID) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
137 |
return localpart |
47
191d5a5adc4a
* Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
45
diff
changeset
|
138 |
chkLocalpart = staticmethod(chkLocalpart) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
139 |
|
47
191d5a5adc4a
* Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
45
diff
changeset
|
140 |
def idn2ascii(domainname): |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
141 |
"""Converts an idn domainname in punycode. |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
142 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
143 |
Keyword arguments: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
144 |
domainname -- the domainname to convert (str) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
145 |
""" |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
146 |
tmp = [] |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
147 |
for label in domainname.split('.'): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
148 |
if len(label) == 0: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
149 |
continue |
47
191d5a5adc4a
* Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
45
diff
changeset
|
150 |
tmp.append(ToASCII(label)) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
151 |
return '.'.join(tmp) |
47
191d5a5adc4a
* Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
45
diff
changeset
|
152 |
idn2ascii = staticmethod(idn2ascii) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
153 |
|
47
191d5a5adc4a
* Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
45
diff
changeset
|
154 |
def ace2idna(domainname): |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
155 |
"""Convertis a domainname from ACE according to IDNA |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
156 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
157 |
Keyword arguments: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
158 |
domainname -- the domainname to convert (str) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
159 |
""" |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
160 |
tmp = [] |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
161 |
for label in domainname.split('.'): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
162 |
if len(label) == 0: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
163 |
continue |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
164 |
tmp.append(ToUnicode(label)) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
165 |
return '.'.join(tmp) |
47
191d5a5adc4a
* Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
45
diff
changeset
|
166 |
ace2idna = staticmethod(ace2idna) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
167 |
|
47
191d5a5adc4a
* Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
45
diff
changeset
|
168 |
def chkDomainname(domainname): |
3
a9b44e04bf01
* VirtualMailManager/Account.py:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
2
diff
changeset
|
169 |
"""Validates the domain name of an e-mail address. |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
170 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
171 |
Keyword arguments: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
172 |
domainname -- the domain name that should be validated |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
173 |
""" |
35
22cc616aef61
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
34
diff
changeset
|
174 |
re.compile(RE_ASCII_CHARS) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
175 |
if not re.match(RE_ASCII_CHARS, domainname): |
47
191d5a5adc4a
* Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
45
diff
changeset
|
176 |
domainname = VirtualMailManager.idn2ascii(domainname) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
177 |
if len(domainname) > 255: |
48
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
178 |
raise VMMException(_(u'The domain name is too long.'), |
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
179 |
ERR.DOMAIN_TOO_LONG) |
35
22cc616aef61
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
34
diff
changeset
|
180 |
re.compile(RE_DOMAIN) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
181 |
if not re.match(RE_DOMAIN, domainname): |
48
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
182 |
raise VMMException(_(u'The domain name is invalid.'), |
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
183 |
ERR.DOMAIN_INVALID) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
184 |
return domainname |
47
191d5a5adc4a
* Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
45
diff
changeset
|
185 |
chkDomainname = staticmethod(chkDomainname) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
186 |
|
47
191d5a5adc4a
* Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
45
diff
changeset
|
187 |
def chkEmailAddress(address): |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
188 |
try: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
189 |
localpart, domain = address.split('@') |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
190 |
except ValueError: |
48
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
191 |
raise VMMException(_(u"Missing '@' sign in e-mail address »%s«.") % |
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
192 |
address, ERR.INVALID_ADDRESS) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
193 |
except AttributeError: |
48
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
194 |
raise VMMException(_(u"»%s« looks not like an e-mail address.") % |
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
195 |
address, ERR.INVALID_ADDRESS) |
52
c152d7714802
* 'VirtualMailManager/Alias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
51
diff
changeset
|
196 |
if len(domain) > 0: |
c152d7714802
* 'VirtualMailManager/Alias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
51
diff
changeset
|
197 |
domain = VirtualMailManager.chkDomainname(domain) |
c152d7714802
* 'VirtualMailManager/Alias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
51
diff
changeset
|
198 |
else: |
c152d7714802
* 'VirtualMailManager/Alias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
51
diff
changeset
|
199 |
raise VMMException(_(u"Missing domain name after »%s@«.") % |
c152d7714802
* 'VirtualMailManager/Alias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
51
diff
changeset
|
200 |
localpart, ERR.DOMAIN_NO_NAME) |
47
191d5a5adc4a
* Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
45
diff
changeset
|
201 |
localpart = VirtualMailManager.chkLocalpart(localpart) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
202 |
return '%s@%s' % (localpart, domain) |
47
191d5a5adc4a
* Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
45
diff
changeset
|
203 |
chkEmailAddress = staticmethod(chkEmailAddress) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
204 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
205 |
def __getAccount(self, address, password=None): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
206 |
self.__dbConnect() |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
207 |
if not password is None: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
208 |
password = self.__pwhash(password) |
9
e3d3dbeb5b84
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
8
diff
changeset
|
209 |
return Account(self.__dbh, address, password) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
210 |
|
38
c44ea4526546
* 'VirtualMailManager/Alias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
35
diff
changeset
|
211 |
def _readpass(self): |
c44ea4526546
* 'VirtualMailManager/Alias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
35
diff
changeset
|
212 |
clear0 = '' |
c44ea4526546
* 'VirtualMailManager/Alias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
35
diff
changeset
|
213 |
clear1 = '1' |
c44ea4526546
* 'VirtualMailManager/Alias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
35
diff
changeset
|
214 |
while clear0 != clear1: |
c44ea4526546
* 'VirtualMailManager/Alias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
35
diff
changeset
|
215 |
while len(clear0) < 1: |
c44ea4526546
* 'VirtualMailManager/Alias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
35
diff
changeset
|
216 |
clear0 = getpass(prompt=_('Enter new password: ')) |
c44ea4526546
* 'VirtualMailManager/Alias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
35
diff
changeset
|
217 |
if len(clear0) < 1: |
c44ea4526546
* 'VirtualMailManager/Alias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
35
diff
changeset
|
218 |
sys.stderr.write('%s\n' |
c44ea4526546
* 'VirtualMailManager/Alias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
35
diff
changeset
|
219 |
% _('Sorry, empty passwords are not permitted')) |
c44ea4526546
* 'VirtualMailManager/Alias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
35
diff
changeset
|
220 |
clear1 = getpass(prompt=_('Retype new password: ')) |
c44ea4526546
* 'VirtualMailManager/Alias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
35
diff
changeset
|
221 |
if clear0 != clear1: |
c44ea4526546
* 'VirtualMailManager/Alias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
35
diff
changeset
|
222 |
clear0 = '' |
c44ea4526546
* 'VirtualMailManager/Alias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
35
diff
changeset
|
223 |
sys.stderr.write('%s\n' % _('Sorry, passwords do not match')) |
c44ea4526546
* 'VirtualMailManager/Alias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
35
diff
changeset
|
224 |
return clear0 |
c44ea4526546
* 'VirtualMailManager/Alias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
35
diff
changeset
|
225 |
|
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
226 |
def __getAlias(self, address, destination=None): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
227 |
self.__dbConnect() |
9
e3d3dbeb5b84
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
8
diff
changeset
|
228 |
return Alias(self.__dbh, address, destination) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
229 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
230 |
def __getDomain(self, domainname, transport=None): |
9
e3d3dbeb5b84
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
8
diff
changeset
|
231 |
if transport is None: |
e3d3dbeb5b84
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
8
diff
changeset
|
232 |
transport = self.__Cfg.get('misc', 'transport') |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
233 |
self.__dbConnect() |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
234 |
return Domain(self.__dbh, domainname, |
24 | 235 |
self.__Cfg.get('domdir', 'base'), transport) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
236 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
237 |
def __getDiskUsage(self, directory): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
238 |
"""Estimate file space usage for the given directory. |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
239 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
240 |
Keyword arguments: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
241 |
directory -- the directory to summarize recursively disk usage for |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
242 |
""" |
40 | 243 |
if self.__isdir(directory): |
244 |
return Popen([self.__Cfg.get('bin', 'du'), "-hs", directory], |
|
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
245 |
stdout=PIPE).communicate()[0].split('\t')[0] |
40 | 246 |
else: |
247 |
return 0 |
|
248 |
||
249 |
def __isdir(self, directory): |
|
250 |
isdir = os.path.isdir(directory) |
|
251 |
if not isdir: |
|
252 |
self.__warnings.append(_('No such directory: %s') % directory) |
|
253 |
return isdir |
|
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
254 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
255 |
def __makedir(self, directory, mode=None, uid=None, gid=None): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
256 |
if mode is None: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
257 |
mode = self.__Cfg.getint('maildir', 'mode') |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
258 |
if uid is None: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
259 |
uid = 0 |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
260 |
if gid is None: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
261 |
gid = 0 |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
262 |
os.makedirs(directory, mode) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
263 |
os.chown(directory, uid, gid) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
264 |
|
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
265 |
def __domDirMake(self, domdir, gid): |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
266 |
os.umask(0006) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
267 |
oldpwd = os.getcwd() |
24 | 268 |
basedir = self.__Cfg.get('domdir', 'base') |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
269 |
domdirdirs = domdir.replace(basedir+'/', '').split('/') |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
270 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
271 |
os.chdir(basedir) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
272 |
if not os.path.isdir(domdirdirs[0]): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
273 |
self.__makedir(domdirdirs[0], 489, 0, |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
274 |
self.__Cfg.getint('misc', 'gid_mail')) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
275 |
os.chdir(domdirdirs[0]) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
276 |
os.umask(0007) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
277 |
self.__makedir(domdirdirs[1], self.__Cfg.getint('domdir', 'mode'), 0, |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
278 |
gid) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
279 |
os.chdir(oldpwd) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
280 |
|
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
281 |
def __mailDirMake(self, domdir, uid, gid): |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
282 |
"""Creates maildirs and maildir subfolders. |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
283 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
284 |
Keyword arguments: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
285 |
uid -- user id from the account |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
286 |
gid -- group id from the account |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
287 |
""" |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
288 |
os.umask(0007) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
289 |
oldpwd = os.getcwd() |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
290 |
os.chdir(domdir) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
291 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
292 |
maildir = '%s' % self.__Cfg.get('maildir', 'folder') |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
293 |
folders = [maildir , maildir+'/.Drafts', maildir+'/.Sent', |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
294 |
maildir+'/.Templates', maildir+'/.Trash'] |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
295 |
subdirs = ['cur', 'new', 'tmp'] |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
296 |
mode = self.__Cfg.getint('maildir', 'mode') |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
297 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
298 |
self.__makedir('%s' % uid, mode, uid, gid) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
299 |
os.chdir('%s' % uid) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
300 |
for folder in folders: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
301 |
self.__makedir(folder, mode, uid, gid) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
302 |
for subdir in subdirs: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
303 |
self.__makedir(folder+'/'+subdir, mode, uid, gid) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
304 |
os.chdir(oldpwd) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
305 |
|
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
306 |
def __userDirDelete(self, domdir, uid, gid): |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
307 |
if uid > 0 and gid > 0: |
51
f5ca21303871
* Switched from pygettext to xgettext -> small adjustments to these files:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
50
diff
changeset
|
308 |
userdir = '%s' % uid |
f5ca21303871
* Switched from pygettext to xgettext -> small adjustments to these files:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
50
diff
changeset
|
309 |
if userdir.count('..') or domdir.count('..'): |
f5ca21303871
* Switched from pygettext to xgettext -> small adjustments to these files:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
50
diff
changeset
|
310 |
raise VMMException(_(u'Found ".." in home directory path.'), |
48
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
311 |
ERR.FOUND_DOTS_IN_PATH) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
312 |
if os.path.isdir(domdir): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
313 |
os.chdir(domdir) |
51
f5ca21303871
* Switched from pygettext to xgettext -> small adjustments to these files:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
50
diff
changeset
|
314 |
if os.path.isdir(userdir): |
f5ca21303871
* Switched from pygettext to xgettext -> small adjustments to these files:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
50
diff
changeset
|
315 |
mdstat = os.stat(userdir) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
316 |
if (mdstat.st_uid, mdstat.st_gid) != (uid, gid): |
48
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
317 |
raise VMMException( |
51
f5ca21303871
* Switched from pygettext to xgettext -> small adjustments to these files:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
50
diff
changeset
|
318 |
_(u'Owner/group mismatch in home directory detected.'), |
f5ca21303871
* Switched from pygettext to xgettext -> small adjustments to these files:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
50
diff
changeset
|
319 |
ERR.MAILDIR_PERM_MISMATCH) |
f5ca21303871
* Switched from pygettext to xgettext -> small adjustments to these files:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
50
diff
changeset
|
320 |
rmtree(userdir, ignore_errors=True) |
40 | 321 |
else: |
51
f5ca21303871
* Switched from pygettext to xgettext -> small adjustments to these files:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
50
diff
changeset
|
322 |
raise VMMException(_(u"No such directory: %s") % |
f5ca21303871
* Switched from pygettext to xgettext -> small adjustments to these files:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
50
diff
changeset
|
323 |
domdir+'/'+userdir, ERR.NO_SUCH_DIRECTORY) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
324 |
|
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
325 |
def __domDirDelete(self, domdir, gid): |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
326 |
if gid > 0: |
40 | 327 |
if not self.__isdir(domdir): |
328 |
return |
|
24 | 329 |
basedir = '%s' % self.__Cfg.get('domdir', 'base') |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
330 |
domdirdirs = domdir.replace(basedir+'/', '').split('/') |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
331 |
if basedir.count('..') or domdir.count('..'): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
332 |
raise VMMException( |
48
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
333 |
_(u'FATAL: ".." in domain directory path detected.'), |
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
334 |
ERR.FOUND_DOTS_IN_PATH) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
335 |
if os.path.isdir('%s/%s' % (basedir, domdirdirs[0])): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
336 |
os.chdir('%s/%s' % (basedir, domdirdirs[0])) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
337 |
if os.lstat(domdirdirs[1]).st_gid != gid: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
338 |
raise VMMException( |
48
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
339 |
_(u'FATAL: group mismatch in domain directory detected'), |
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
340 |
ERR.DOMAINDIR_GROUP_MISMATCH) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
341 |
rmtree(domdirdirs[1], ignore_errors=True) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
342 |
|
16
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
343 |
def __getSalt(self): |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
344 |
from random import choice |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
345 |
salt = None |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
346 |
if self.__scheme == 'CRYPT': |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
347 |
salt = '%s%s' % (choice(SALTCHARS), choice(SALTCHARS)) |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
348 |
elif self.__scheme in ['MD5', 'MD5-CRYPT']: |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
349 |
salt = '$1$' |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
350 |
for i in range(8): |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
351 |
salt += choice(SALTCHARS) |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
352 |
salt += '$' |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
353 |
return salt |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
354 |
|
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
355 |
def __pwCrypt(self, password): |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
356 |
# for: CRYPT, MD5 and MD5-CRYPT |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
357 |
from crypt import crypt |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
358 |
return crypt(password, self.__getSalt()) |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
359 |
|
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
360 |
def __pwSHA1(self, password): |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
361 |
# for: SHA/SHA1 |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
362 |
import sha |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
363 |
from base64 import standard_b64encode |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
364 |
sha1 = sha.new(password) |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
365 |
return standard_b64encode(sha1.digest()) |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
366 |
|
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
367 |
def __pwMD5(self, password, emailaddress=None): |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
368 |
import md5 |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
369 |
_md5 = md5.new(password) |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
370 |
if self.__scheme == 'LDAP-MD5': |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
371 |
from base64 import standard_b64encode |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
372 |
return standard_b64encode(_md5.digest()) |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
373 |
elif self.__scheme == 'PLAIN-MD5': |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
374 |
return _md5.hexdigest() |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
375 |
elif self.__scheme == 'DIGEST-MD5' and emailaddress is not None: |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
376 |
_md5 = md5.new('%s:%s:' % tuple(emailaddress.split('@'))) |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
377 |
_md5.update(password) |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
378 |
return _md5.hexdigest() |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
379 |
|
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
380 |
def __pwMD4(self, password): |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
381 |
# for: PLAIN-MD4 |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
382 |
from Crypto.Hash import MD4 |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
383 |
_md4 = MD4.new(password) |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
384 |
return _md4.hexdigest() |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
385 |
|
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
386 |
def __pwhash(self, password, scheme=None, user=None): |
16
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
387 |
if scheme is not None: |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
388 |
self.__scheme = scheme |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
389 |
if self.__scheme in ['CRYPT', 'MD5', 'MD5-CRYPT']: |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
390 |
return '{%s}%s' % (self.__scheme, self.__pwCrypt(password)) |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
391 |
elif self.__scheme in ['SHA', 'SHA1']: |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
392 |
return '{%s}%s' % (self.__scheme, self.__pwSHA1(password)) |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
393 |
elif self.__scheme in ['PLAIN-MD5', 'LDAP-MD5', 'DIGEST-MD5']: |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
394 |
return '{%s}%s' % (self.__scheme, self.__pwMD5(password, user)) |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
395 |
elif self.__scheme == 'MD4': |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
396 |
return '{%s}%s' % (self.__scheme, self.__pwMD4(password)) |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
397 |
elif self.__scheme in ['SMD5', 'SSHA', 'CRAM-MD5', 'HMAC-MD5', |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
398 |
'LANMAN', 'NTLM', 'RPA']: |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
399 |
return Popen([self.__Cfg.get('bin', 'dovecotpw'), '-s', |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
400 |
self.__scheme,'-p',password],stdout=PIPE).communicate()[0][:-1] |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
401 |
else: |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
402 |
return '{%s}%s' % (self.__scheme, password) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
403 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
404 |
def hasWarnings(self): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
405 |
"""Checks if warnings are present, returns bool.""" |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
406 |
return bool(len(self.__warnings)) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
407 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
408 |
def getWarnings(self): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
409 |
"""Returns a list with all available warnings.""" |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
410 |
return self.__warnings |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
411 |
|
40 | 412 |
def cfgGetBoolean(self, section, option): |
413 |
return self.__Cfg.getboolean(section, option) |
|
414 |
||
415 |
def cfgGetInt(self, section, option): |
|
416 |
return self.__Cfg.getint(section, option) |
|
417 |
||
418 |
def cfgGetString(self, section, option): |
|
419 |
return self.__Cfg.get(section, option) |
|
420 |
||
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
421 |
def setupIsDone(self): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
422 |
"""Checks if vmm is configured, returns bool""" |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
423 |
try: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
424 |
return self.__Cfg.getboolean('config', 'done') |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
425 |
except ValueError, e: |
47
191d5a5adc4a
* Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
45
diff
changeset
|
426 |
raise VMMConfigException(_(u"""Configurtion error: "%s" |
48
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
427 |
(in section "connfig", option "done") see also: vmm.cfg(5)\n""") % str(e), |
50
927b0705d31a
* 'VirtualMailManager/Domain.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
49
diff
changeset
|
428 |
ERR.CONF_ERROR) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
429 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
430 |
def configure(self, section=None): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
431 |
"""Starts interactive configuration. |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
432 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
433 |
Configures in interactive mode options in the given section. |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
434 |
If no section is given (default) all options from all sections |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
435 |
will be prompted. |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
436 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
437 |
Keyword arguments: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
438 |
section -- the section to configure (default None): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
439 |
'database', 'maildir', 'bin' or 'misc' |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
440 |
""" |
48
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
441 |
if section is None: |
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
442 |
self.__Cfg.configure(self.__cfgSections) |
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
443 |
elif section in self.__cfgSections: |
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
444 |
self.__Cfg.configure([section]) |
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
445 |
else: |
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
446 |
raise VMMException(_(u"Invalid section: '%s'") % section, |
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
447 |
ERR.INVALID_SECTION) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
448 |
|
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
449 |
def domainAdd(self, domainname, transport=None): |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
450 |
dom = self.__getDomain(domainname, transport) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
451 |
dom.save() |
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
452 |
self.__domDirMake(dom.getDir(), dom.getID()) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
453 |
|
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
454 |
def domainTransport(self, domainname, transport, force=None): |
18
c98e08791ee8
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
17
diff
changeset
|
455 |
if force is not None and force != 'force': |
48
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
456 |
raise VMMDomainException(_(u"Invalid argument: '%s'") % force, |
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
457 |
ERR.INVALID_OPTION) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
458 |
dom = self.__getDomain(domainname, None) |
18
c98e08791ee8
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
17
diff
changeset
|
459 |
if force is None: |
c98e08791ee8
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
17
diff
changeset
|
460 |
dom.updateTransport(transport) |
c98e08791ee8
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
17
diff
changeset
|
461 |
else: |
c98e08791ee8
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
17
diff
changeset
|
462 |
dom.updateTransport(transport, force=True) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
463 |
|
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
464 |
def domainDelete(self, domainname, force=None): |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
465 |
if not force is None and force not in ['deluser','delalias','delall']: |
48
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
466 |
raise VMMDomainException(_(u"Invalid argument: »%s«") % force, |
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
467 |
ERR.INVALID_OPTION) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
468 |
dom = self.__getDomain(domainname) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
469 |
gid = dom.getID() |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
470 |
domdir = dom.getDir() |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
471 |
if self.__Cfg.getboolean('misc', 'forcedel') or force == 'delall': |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
472 |
dom.delete(True, True) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
473 |
elif force == 'deluser': |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
474 |
dom.delete(delUser=True) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
475 |
elif force == 'delalias': |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
476 |
dom.delete(delAlias=True) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
477 |
else: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
478 |
dom.delete() |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
479 |
if self.__Cfg.getboolean('domdir', 'delete'): |
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
480 |
self.__domDirDelete(domdir, gid) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
481 |
|
62
869de537a020
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
55
diff
changeset
|
482 |
def domainInfo(self, domainname, details=None): |
869de537a020
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
55
diff
changeset
|
483 |
if details not in [None, 'accounts', 'aliasdomains', 'aliases', 'full', |
869de537a020
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
55
diff
changeset
|
484 |
'detailed']: |
869de537a020
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
55
diff
changeset
|
485 |
raise VMMDomainException(_(u'Invalid argument: »%s«') % details, |
869de537a020
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
55
diff
changeset
|
486 |
ERR.INVALID_OPTION) |
869de537a020
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
55
diff
changeset
|
487 |
if details == 'detailed': |
869de537a020
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
55
diff
changeset
|
488 |
details = 'full' |
869de537a020
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
55
diff
changeset
|
489 |
warning = _(u"""\ |
869de537a020
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
55
diff
changeset
|
490 |
The keyword »detailed« is deprecated and will be removed in a future release. |
869de537a020
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
55
diff
changeset
|
491 |
Please use the keyword »full« to get full details.""") |
869de537a020
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
55
diff
changeset
|
492 |
self.__warnings.append(warning) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
493 |
dom = self.__getDomain(domainname) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
494 |
dominfo = dom.getInfo() |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
495 |
if dominfo['domainname'].startswith('xn--'): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
496 |
dominfo['domainname'] += ' (%s)'\ |
47
191d5a5adc4a
* Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
45
diff
changeset
|
497 |
% VirtualMailManager.ace2idna(dominfo['domainname']) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
498 |
if dominfo['aliases'] is None: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
499 |
dominfo['aliases'] = 0 |
62
869de537a020
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
55
diff
changeset
|
500 |
if details is None: |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
501 |
return dominfo |
62
869de537a020
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
55
diff
changeset
|
502 |
elif details == 'accounts': |
869de537a020
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
55
diff
changeset
|
503 |
return (dominfo, dom.getAccounts()) |
869de537a020
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
55
diff
changeset
|
504 |
elif details == 'aliasdomains': |
869de537a020
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
55
diff
changeset
|
505 |
return (dominfo, dom.getAliaseNames()) |
869de537a020
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
55
diff
changeset
|
506 |
elif details == 'aliases': |
869de537a020
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
55
diff
changeset
|
507 |
return (dominfo, dom.getAliases()) |
869de537a020
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
55
diff
changeset
|
508 |
else: |
44
c9ab6900ede9
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
40
diff
changeset
|
509 |
return (dominfo, dom.getAliaseNames(), dom.getAccounts(), |
c9ab6900ede9
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
40
diff
changeset
|
510 |
dom.getAliases()) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
511 |
|
55
15c873f94ba6
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
54
diff
changeset
|
512 |
def aliasDomainAdd(self, aliasname, domainname): |
15c873f94ba6
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
54
diff
changeset
|
513 |
"""Adds an alias domain to the domain. |
53
5b50eb306d37
* 'VirtualMailManager/DomainAlias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
52
diff
changeset
|
514 |
|
45
9e66138aad0b
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
44
diff
changeset
|
515 |
Keyword arguments: |
55
15c873f94ba6
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
54
diff
changeset
|
516 |
aliasname -- the name of the alias domain (str) |
45
9e66138aad0b
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
44
diff
changeset
|
517 |
domainname -- name of the target domain (str) |
9e66138aad0b
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
44
diff
changeset
|
518 |
""" |
9e66138aad0b
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
44
diff
changeset
|
519 |
dom = self.__getDomain(domainname) |
55
15c873f94ba6
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
54
diff
changeset
|
520 |
aliasDom = AliasDomain(self.__dbh, aliasname, dom) |
15c873f94ba6
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
54
diff
changeset
|
521 |
aliasDom.save() |
53
5b50eb306d37
* 'VirtualMailManager/DomainAlias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
52
diff
changeset
|
522 |
|
55
15c873f94ba6
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
54
diff
changeset
|
523 |
def aliasDomainInfo(self, aliasname): |
53
5b50eb306d37
* 'VirtualMailManager/DomainAlias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
52
diff
changeset
|
524 |
self.__dbConnect() |
55
15c873f94ba6
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
54
diff
changeset
|
525 |
aliasDom = AliasDomain(self.__dbh, aliasname, None) |
15c873f94ba6
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
54
diff
changeset
|
526 |
return aliasDom.info() |
45
9e66138aad0b
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
44
diff
changeset
|
527 |
|
55
15c873f94ba6
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
54
diff
changeset
|
528 |
def aliasDomainDelete(self, aliasname): |
15c873f94ba6
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
54
diff
changeset
|
529 |
"""Deletes the specified alias domain. |
53
5b50eb306d37
* 'VirtualMailManager/DomainAlias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
52
diff
changeset
|
530 |
|
45
9e66138aad0b
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
44
diff
changeset
|
531 |
Keyword arguments: |
55
15c873f94ba6
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
54
diff
changeset
|
532 |
aliasname -- the name of the alias domain (str) |
45
9e66138aad0b
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
44
diff
changeset
|
533 |
""" |
9e66138aad0b
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
44
diff
changeset
|
534 |
self.__dbConnect() |
55
15c873f94ba6
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
54
diff
changeset
|
535 |
aliasDom = AliasDomain(self.__dbh, aliasname, None) |
15c873f94ba6
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
54
diff
changeset
|
536 |
aliasDom.delete() |
45
9e66138aad0b
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
44
diff
changeset
|
537 |
|
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
538 |
def domainList(self, pattern=None): |
35
22cc616aef61
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
34
diff
changeset
|
539 |
from Domain import search |
22cc616aef61
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
34
diff
changeset
|
540 |
like = False |
22cc616aef61
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
34
diff
changeset
|
541 |
if pattern is not None: |
22cc616aef61
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
34
diff
changeset
|
542 |
if pattern.startswith('%') or pattern.endswith('%'): |
22cc616aef61
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
34
diff
changeset
|
543 |
like = True |
22cc616aef61
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
34
diff
changeset
|
544 |
if pattern.startswith('%') and pattern.endswith('%'): |
22cc616aef61
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
34
diff
changeset
|
545 |
domain = pattern[1:-1] |
22cc616aef61
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
34
diff
changeset
|
546 |
elif pattern.startswith('%'): |
22cc616aef61
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
34
diff
changeset
|
547 |
domain = pattern[1:] |
22cc616aef61
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
34
diff
changeset
|
548 |
elif pattern.endswith('%'): |
22cc616aef61
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
34
diff
changeset
|
549 |
domain = pattern[:-1] |
22cc616aef61
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
34
diff
changeset
|
550 |
re.compile(RE_DOMAIN_SRCH) |
22cc616aef61
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
34
diff
changeset
|
551 |
if not re.match(RE_DOMAIN_SRCH, domain): |
48
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
552 |
raise VMMException( |
50
927b0705d31a
* 'VirtualMailManager/Domain.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
49
diff
changeset
|
553 |
_(u"The pattern »%s« contains invalid characters.") % |
48
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
554 |
pattern, ERR.DOMAIN_INVALID) |
35
22cc616aef61
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
34
diff
changeset
|
555 |
self.__dbConnect() |
22cc616aef61
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
34
diff
changeset
|
556 |
return search(self.__dbh, pattern=pattern, like=like) |
22cc616aef61
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
34
diff
changeset
|
557 |
|
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
558 |
def userAdd(self, emailaddress, password): |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
559 |
acc = self.__getAccount(emailaddress, password) |
38
c44ea4526546
* 'VirtualMailManager/Alias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
35
diff
changeset
|
560 |
if password is None: |
c44ea4526546
* 'VirtualMailManager/Alias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
35
diff
changeset
|
561 |
password = self._readpass() |
c44ea4526546
* 'VirtualMailManager/Alias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
35
diff
changeset
|
562 |
acc.setPassword(self.__pwhash(password)) |
20
55146c78b3fb
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
19
diff
changeset
|
563 |
acc.save(self.__Cfg.get('maildir', 'folder'), |
55146c78b3fb
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
19
diff
changeset
|
564 |
self.__Cfg.getboolean('services', 'smtp'), |
55146c78b3fb
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
19
diff
changeset
|
565 |
self.__Cfg.getboolean('services', 'pop3'), |
55146c78b3fb
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
19
diff
changeset
|
566 |
self.__Cfg.getboolean('services', 'imap'), |
55146c78b3fb
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
19
diff
changeset
|
567 |
self.__Cfg.getboolean('services', 'managesieve')) |
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
568 |
self.__mailDirMake(acc.getDir('domain'), acc.getUID(), acc.getGID()) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
569 |
|
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
570 |
def aliasAdd(self, aliasaddress, targetaddress): |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
571 |
alias = self.__getAlias(aliasaddress, targetaddress) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
572 |
alias.save() |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
573 |
|
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
574 |
def userDelete(self, emailaddress): |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
575 |
acc = self.__getAccount(emailaddress) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
576 |
uid = acc.getUID() |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
577 |
gid = acc.getGID() |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
578 |
acc.delete() |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
579 |
if self.__Cfg.getboolean('maildir', 'delete'): |
47
191d5a5adc4a
* Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
45
diff
changeset
|
580 |
try: |
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
581 |
self.__userDirDelete(acc.getDir('domain'), uid, gid) |
48
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
582 |
except VMMException, e: |
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
583 |
if e.code() in [ERR.FOUND_DOTS_IN_PATH, |
47
191d5a5adc4a
* Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
45
diff
changeset
|
584 |
ERR.MAILDIR_PERM_MISMATCH, ERR.NO_SUCH_DIRECTORY]: |
191d5a5adc4a
* Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
45
diff
changeset
|
585 |
warning = _(u"""\ |
191d5a5adc4a
* Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
45
diff
changeset
|
586 |
The account has been successfully deleted from the database. |
191d5a5adc4a
* Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
45
diff
changeset
|
587 |
But an error occurred while deleting the following directory: |
51
f5ca21303871
* Switched from pygettext to xgettext -> small adjustments to these files:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
50
diff
changeset
|
588 |
»%(directory)s« |
f5ca21303871
* Switched from pygettext to xgettext -> small adjustments to these files:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
50
diff
changeset
|
589 |
Reason: %(raeson)s""") % {'directory': acc.getDir('home'),'raeson': e.msg()} |
47
191d5a5adc4a
* Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
45
diff
changeset
|
590 |
self.__warnings.append(warning) |
191d5a5adc4a
* Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
45
diff
changeset
|
591 |
else: |
191d5a5adc4a
* Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
45
diff
changeset
|
592 |
raise e |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
593 |
|
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
594 |
def aliasInfo(self, aliasaddress): |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
595 |
alias = self.__getAlias(aliasaddress) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
596 |
return alias.getInfo() |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
597 |
|
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
598 |
def aliasDelete(self, aliasaddress, targetaddress=None): |
12
44161dbb1518
* 'VirtualMailManager/Alias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
9
diff
changeset
|
599 |
alias = self.__getAlias(aliasaddress, targetaddress) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
600 |
alias.delete() |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
601 |
|
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
602 |
def userInfo(self, emailaddress, diskusage=False): |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
603 |
acc = self.__getAccount(emailaddress) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
604 |
info = acc.getInfo() |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
605 |
if self.__Cfg.getboolean('maildir', 'diskusage') or diskusage: |
9
e3d3dbeb5b84
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
8
diff
changeset
|
606 |
info['disk usage'] = self.__getDiskUsage('%(maildir)s' % info) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
607 |
return info |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
608 |
|
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
609 |
def userByID(self, uid): |
19
bf9a03c476fc
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
18
diff
changeset
|
610 |
from Account import getAccountByID |
bf9a03c476fc
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
18
diff
changeset
|
611 |
self.__dbConnect() |
bf9a03c476fc
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
18
diff
changeset
|
612 |
return getAccountByID(uid, self.__dbh) |
bf9a03c476fc
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
18
diff
changeset
|
613 |
|
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
614 |
def userPassword(self, emailaddress, password): |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
615 |
acc = self.__getAccount(emailaddress) |
38
c44ea4526546
* 'VirtualMailManager/Alias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
35
diff
changeset
|
616 |
if acc.getUID() == 0: |
48
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
617 |
raise VMMException(_(u"Account doesn't exists"), |
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
618 |
ERR.NO_SUCH_ACCOUNT) |
38
c44ea4526546
* 'VirtualMailManager/Alias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
35
diff
changeset
|
619 |
if password is None: |
c44ea4526546
* 'VirtualMailManager/Alias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
35
diff
changeset
|
620 |
password = self._readpass() |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
621 |
acc.modify('password', self.__pwhash(password)) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
622 |
|
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
623 |
def userName(self, emailaddress, name): |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
624 |
acc = self.__getAccount(emailaddress) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
625 |
acc.modify('name', name) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
626 |
|
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
627 |
def userTransport(self, emailaddress, transport): |
17
fe9be0081e5f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
16
diff
changeset
|
628 |
acc = self.__getAccount(emailaddress) |
fe9be0081e5f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
16
diff
changeset
|
629 |
acc.modify('transport', transport) |
fe9be0081e5f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
16
diff
changeset
|
630 |
|
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
631 |
def userDisable(self, emailaddress, service=None): |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
632 |
acc = self.__getAccount(emailaddress) |
20
55146c78b3fb
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
19
diff
changeset
|
633 |
acc.disable(service) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
634 |
|
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
635 |
def userEnable(self, emailaddress, service=None): |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
636 |
acc = self.__getAccount(emailaddress) |
20
55146c78b3fb
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
19
diff
changeset
|
637 |
acc.enable(service) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
638 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
639 |
def __del__(self): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
640 |
if not self.__dbh is None and self.__dbh._isOpen: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
641 |
self.__dbh.close() |