author | Pascal Volk <neverseen@users.sourceforge.net> |
Fri, 26 Feb 2010 02:35:25 +0000 | |
branch | v0.6.x |
changeset 216 | 0c8c053b451c |
parent 215 | 33f727efa7c4 |
child 221 | 371ae0b4443d |
permissions | -rw-r--r-- |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1 |
# -*- coding: UTF-8 -*- |
162
0ac9ef587769
Updated copyright notices to include the year 2010.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
158
diff
changeset
|
2 |
# Copyright (c) 2007 - 2010, Pascal Volk |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
3 |
# See COPYING for distribution information. |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
4 |
|
185
6e1ef32fbd82
VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
184
diff
changeset
|
5 |
""" |
6e1ef32fbd82
VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
184
diff
changeset
|
6 |
VirtualMailManager.Handler |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
7 |
|
185
6e1ef32fbd82
VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
184
diff
changeset
|
8 |
A wrapper class. It wraps round all other classes and does some |
6e1ef32fbd82
VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
184
diff
changeset
|
9 |
dependencies checks. |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
10 |
|
185
6e1ef32fbd82
VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
184
diff
changeset
|
11 |
Additionally it communicates with the PostgreSQL database, creates |
6e1ef32fbd82
VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
184
diff
changeset
|
12 |
or deletes directories of domains or users. |
6e1ef32fbd82
VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
184
diff
changeset
|
13 |
""" |
6e1ef32fbd82
VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
184
diff
changeset
|
14 |
|
6e1ef32fbd82
VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
184
diff
changeset
|
15 |
import os |
6e1ef32fbd82
VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
184
diff
changeset
|
16 |
import re |
6e1ef32fbd82
VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
184
diff
changeset
|
17 |
|
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
18 |
from shutil import rmtree |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
19 |
from subprocess import Popen, PIPE |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
20 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
21 |
from pyPgSQL import PgSQL # python-pgsql - http://pypgsql.sourceforge.net |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
22 |
|
185
6e1ef32fbd82
VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
184
diff
changeset
|
23 |
import VirtualMailManager.constants.ERROR as ERR |
188
cf1b5f22dbd2
VMM/Handler: __init__ accepts now a config_type ('default'||'cli').
Pascal Volk <neverseen@users.sourceforge.net>
parents:
187
diff
changeset
|
24 |
from VirtualMailManager import ENCODING, ace2idna, exec_ok |
185
6e1ef32fbd82
VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
184
diff
changeset
|
25 |
from VirtualMailManager.Account import Account |
6e1ef32fbd82
VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
184
diff
changeset
|
26 |
from VirtualMailManager.Alias import Alias |
6e1ef32fbd82
VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
184
diff
changeset
|
27 |
from VirtualMailManager.AliasDomain import AliasDomain |
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
28 |
from VirtualMailManager.Config import Config as Cfg |
185
6e1ef32fbd82
VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
184
diff
changeset
|
29 |
from VirtualMailManager.Domain import Domain |
6e1ef32fbd82
VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
184
diff
changeset
|
30 |
from VirtualMailManager.EmailAddress import EmailAddress |
216
0c8c053b451c
Moved VirtualMailManager/Exceptions to VirtualMailManager/errors.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
215
diff
changeset
|
31 |
from VirtualMailManager.errors import VMMError, AliasError |
185
6e1ef32fbd82
VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
184
diff
changeset
|
32 |
from VirtualMailManager.Relocated import Relocated |
6e1ef32fbd82
VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
184
diff
changeset
|
33 |
from VirtualMailManager.ext.Postconf import Postconf |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
34 |
|
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
35 |
|
16
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
36 |
SALTCHARS = './0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' |
35
22cc616aef61
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
34
diff
changeset
|
37 |
RE_DOMAIN_SRCH = """^[a-z0-9-\.]+$""" |
68
7ae95b9938c4
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
66
diff
changeset
|
38 |
RE_MBOX_NAMES = """^[\x20-\x25\x27-\x7E]*$""" |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
39 |
|
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
40 |
|
185
6e1ef32fbd82
VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
184
diff
changeset
|
41 |
class Handler(object): |
6e1ef32fbd82
VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
184
diff
changeset
|
42 |
"""Wrapper class to simplify the access on all the stuff from |
6e1ef32fbd82
VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
184
diff
changeset
|
43 |
VirtualMailManager""" |
196
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
44 |
__slots__ = ('_Cfg', '_cfgFileName', '_dbh', '_scheme', '__warnings', |
174
974bafa59330
VMM/Config: reworked configuration handling.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
168
diff
changeset
|
45 |
'_postconf') |
191
db77501aeaed
VMM/Handler: __mailDirMake() add warning for skipped mailboxes.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
190
diff
changeset
|
46 |
|
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
47 |
def __init__(self, skip_some_checks=False): |
185
6e1ef32fbd82
VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
184
diff
changeset
|
48 |
"""Creates a new Handler instance. |
188
cf1b5f22dbd2
VMM/Handler: __init__ accepts now a config_type ('default'||'cli').
Pascal Volk <neverseen@users.sourceforge.net>
parents:
187
diff
changeset
|
49 |
|
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
50 |
``skip_some_checks`` : bool |
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
51 |
When a derived class knows how to handle all checks this |
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
52 |
argument may be ``True``. By default it is ``False`` and |
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
53 |
all checks will be performed. |
188
cf1b5f22dbd2
VMM/Handler: __init__ accepts now a config_type ('default'||'cli').
Pascal Volk <neverseen@users.sourceforge.net>
parents:
187
diff
changeset
|
54 |
|
216
0c8c053b451c
Moved VirtualMailManager/Exceptions to VirtualMailManager/errors.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
215
diff
changeset
|
55 |
Throws a NotRootError if your uid is greater 0. |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
56 |
""" |
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
57 |
self._cfgFileName = '' |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
58 |
self.__warnings = [] |
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
59 |
self._Cfg = None |
196
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
60 |
self._dbh = None |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
61 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
62 |
if os.geteuid(): |
216
0c8c053b451c
Moved VirtualMailManager/Exceptions to VirtualMailManager/errors.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
215
diff
changeset
|
63 |
raise NotRootError(_(u"You are not root.\n\tGood bye!\n"), |
48
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
64 |
ERR.CONF_NOPERM) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
65 |
if self.__chkCfgFile(): |
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
66 |
self._Cfg = Cfg(self._cfgFileName) |
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
67 |
self._Cfg.load() |
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
68 |
if not skip_some_checks: |
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
69 |
self._Cfg.check() |
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
70 |
self._chkenv() |
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
71 |
self._scheme = self._Cfg.dget('misc.password_scheme') |
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
72 |
self._postconf = Postconf(self._Cfg.dget('bin.postconf')) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
73 |
|
94
0d303d15549e
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
90
diff
changeset
|
74 |
def __findCfgFile(self): |
0d303d15549e
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
90
diff
changeset
|
75 |
for path in ['/root', '/usr/local/etc', '/etc']: |
119
014335f38962
Small code cleanups (replaced dir+'/'+file by os.path.join()).
Pascal Volk <neverseen@users.sourceforge.net>
parents:
115
diff
changeset
|
76 |
tmp = os.path.join(path, 'vmm.cfg') |
014335f38962
Small code cleanups (replaced dir+'/'+file by os.path.join()).
Pascal Volk <neverseen@users.sourceforge.net>
parents:
115
diff
changeset
|
77 |
if os.path.isfile(tmp): |
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
78 |
self._cfgFileName = tmp |
94
0d303d15549e
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
90
diff
changeset
|
79 |
break |
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
80 |
if not len(self._cfgFileName): |
216
0c8c053b451c
Moved VirtualMailManager/Exceptions to VirtualMailManager/errors.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
215
diff
changeset
|
81 |
raise VMMError( |
133
2d5c4745efec
Replaced angle quotes by quotation marks.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
132
diff
changeset
|
82 |
_(u"No “vmm.cfg” found in: /root:/usr/local/etc:/etc"), |
94
0d303d15549e
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
90
diff
changeset
|
83 |
ERR.CONF_NOFILE) |
0d303d15549e
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
90
diff
changeset
|
84 |
|
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
85 |
def __chkCfgFile(self): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
86 |
"""Checks the configuration file, returns bool""" |
94
0d303d15549e
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
90
diff
changeset
|
87 |
self.__findCfgFile() |
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
88 |
fstat = os.stat(self._cfgFileName) |
48
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
89 |
fmode = int(oct(fstat.st_mode & 0777)) |
187
38b9a9859749
VMM/{,cli/Cli}Config: Moved interactive stuff to new CliConfig class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
186
diff
changeset
|
90 |
if fmode % 100 and fstat.st_uid != fstat.st_gid or \ |
38b9a9859749
VMM/{,cli/Cli}Config: Moved interactive stuff to new CliConfig class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
186
diff
changeset
|
91 |
fmode % 10 and fstat.st_uid == fstat.st_gid: |
216
0c8c053b451c
Moved VirtualMailManager/Exceptions to VirtualMailManager/errors.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
215
diff
changeset
|
92 |
raise PermissionError(_( |
187
38b9a9859749
VMM/{,cli/Cli}Config: Moved interactive stuff to new CliConfig class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
186
diff
changeset
|
93 |
u'fix permissions (%(perms)s) for “%(file)s”\n\ |
128
cf8116625866
Converted VirtualMailManager and Postconf to new-style classes.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
119
diff
changeset
|
94 |
`chmod 0600 %(file)s` would be great.') % {'file': |
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
95 |
self._cfgFileName, 'perms': fmode}, ERR.CONF_WRONGPERM) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
96 |
else: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
97 |
return True |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
98 |
|
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
99 |
def _chkenv(self): |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
100 |
"""""" |
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
101 |
basedir = self._Cfg.dget('misc.base_directory') |
168
fd496561acc6
vmm.cfg: a few re-renamed configuration options.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
166
diff
changeset
|
102 |
if not os.path.exists(basedir): |
28
87da30d30fde
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
24
diff
changeset
|
103 |
old_umask = os.umask(0006) |
168
fd496561acc6
vmm.cfg: a few re-renamed configuration options.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
166
diff
changeset
|
104 |
os.makedirs(basedir, 0771) |
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
105 |
os.chown(basedir, 0, self._Cfg.dget('misc.gid_mail')) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
106 |
os.umask(old_umask) |
168
fd496561acc6
vmm.cfg: a few re-renamed configuration options.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
166
diff
changeset
|
107 |
elif not os.path.isdir(basedir): |
216
0c8c053b451c
Moved VirtualMailManager/Exceptions to VirtualMailManager/errors.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
215
diff
changeset
|
108 |
raise VMMError(_(u'“%s” is not a directory.\n\ |
168
fd496561acc6
vmm.cfg: a few re-renamed configuration options.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
166
diff
changeset
|
109 |
(vmm.cfg: section "misc", option "base_directory")') % |
fd496561acc6
vmm.cfg: a few re-renamed configuration options.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
166
diff
changeset
|
110 |
basedir, ERR.NO_SUCH_DIRECTORY) |
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
111 |
for opt, val in self._Cfg.items('bin'): |
185
6e1ef32fbd82
VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
184
diff
changeset
|
112 |
try: |
6e1ef32fbd82
VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
184
diff
changeset
|
113 |
exec_ok(val) |
216
0c8c053b451c
Moved VirtualMailManager/Exceptions to VirtualMailManager/errors.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
215
diff
changeset
|
114 |
except VMMError, e: |
0c8c053b451c
Moved VirtualMailManager/Exceptions to VirtualMailManager/errors.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
215
diff
changeset
|
115 |
if e.code is ERR.NO_SUCH_BINARY: |
0c8c053b451c
Moved VirtualMailManager/Exceptions to VirtualMailManager/errors.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
215
diff
changeset
|
116 |
raise VMMError(_(u'“%(binary)s” doesn\'t exist.\n\ |
191
db77501aeaed
VMM/Handler: __mailDirMake() add warning for skipped mailboxes.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
190
diff
changeset
|
117 |
(vmm.cfg: section "bin", option "%(option)s")') % |
db77501aeaed
VMM/Handler: __mailDirMake() add warning for skipped mailboxes.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
190
diff
changeset
|
118 |
{'binary': val, 'option': opt}, |
185
6e1ef32fbd82
VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
184
diff
changeset
|
119 |
ERR.NO_SUCH_BINARY) |
216
0c8c053b451c
Moved VirtualMailManager/Exceptions to VirtualMailManager/errors.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
215
diff
changeset
|
120 |
elif e.code is ERR.NOT_EXECUTABLE: |
0c8c053b451c
Moved VirtualMailManager/Exceptions to VirtualMailManager/errors.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
215
diff
changeset
|
121 |
raise VMMError(_(u'“%(binary)s” is not executable.\ |
191
db77501aeaed
VMM/Handler: __mailDirMake() add warning for skipped mailboxes.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
190
diff
changeset
|
122 |
\n(vmm.cfg: section "bin", option "%(option)s")') % |
db77501aeaed
VMM/Handler: __mailDirMake() add warning for skipped mailboxes.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
190
diff
changeset
|
123 |
{'binary': val, 'option': opt}, |
185
6e1ef32fbd82
VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
184
diff
changeset
|
124 |
ERR.NOT_EXECUTABLE) |
6e1ef32fbd82
VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
184
diff
changeset
|
125 |
else: |
6e1ef32fbd82
VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
184
diff
changeset
|
126 |
raise |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
127 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
128 |
def __dbConnect(self): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
129 |
"""Creates a pyPgSQL.PgSQL.connection instance.""" |
196
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
130 |
if self._dbh is None or (isinstance(self._dbh, PgSQL.Connection) and |
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
131 |
not self._dbh._isOpen): |
83
cc195af37de0
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
80
diff
changeset
|
132 |
try: |
196
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
133 |
self._dbh = PgSQL.connect( |
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
134 |
database=self._Cfg.dget('database.name'), |
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
135 |
user=self._Cfg.pget('database.user'), |
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
136 |
host=self._Cfg.dget('database.host'), |
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
137 |
password=self._Cfg.pget('database.pass'), |
83
cc195af37de0
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
80
diff
changeset
|
138 |
client_encoding='utf8', unicode_results=True) |
196
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
139 |
dbc = self._dbh.cursor() |
83
cc195af37de0
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
80
diff
changeset
|
140 |
dbc.execute("SET NAMES 'UTF8'") |
cc195af37de0
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
80
diff
changeset
|
141 |
dbc.close() |
cc195af37de0
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
80
diff
changeset
|
142 |
except PgSQL.libpq.DatabaseError, e: |
216
0c8c053b451c
Moved VirtualMailManager/Exceptions to VirtualMailManager/errors.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
215
diff
changeset
|
143 |
raise VMMError(str(e), ERR.DATABASE_ERROR) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
144 |
|
76
14c0a092d7d2
* 'VirtualMailManager/EmailAddress.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
70
diff
changeset
|
145 |
def _exists(dbh, query): |
14c0a092d7d2
* 'VirtualMailManager/EmailAddress.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
70
diff
changeset
|
146 |
dbc = dbh.cursor() |
14c0a092d7d2
* 'VirtualMailManager/EmailAddress.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
70
diff
changeset
|
147 |
dbc.execute(query) |
14c0a092d7d2
* 'VirtualMailManager/EmailAddress.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
70
diff
changeset
|
148 |
gid = dbc.fetchone() |
14c0a092d7d2
* 'VirtualMailManager/EmailAddress.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
70
diff
changeset
|
149 |
dbc.close() |
14c0a092d7d2
* 'VirtualMailManager/EmailAddress.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
70
diff
changeset
|
150 |
if gid is None: |
14c0a092d7d2
* 'VirtualMailManager/EmailAddress.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
70
diff
changeset
|
151 |
return False |
52
c152d7714802
* 'VirtualMailManager/Alias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
51
diff
changeset
|
152 |
else: |
76
14c0a092d7d2
* 'VirtualMailManager/EmailAddress.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
70
diff
changeset
|
153 |
return True |
14c0a092d7d2
* 'VirtualMailManager/EmailAddress.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
70
diff
changeset
|
154 |
_exists = staticmethod(_exists) |
14c0a092d7d2
* 'VirtualMailManager/EmailAddress.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
70
diff
changeset
|
155 |
|
14c0a092d7d2
* 'VirtualMailManager/EmailAddress.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
70
diff
changeset
|
156 |
def accountExists(dbh, address): |
14c0a092d7d2
* 'VirtualMailManager/EmailAddress.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
70
diff
changeset
|
157 |
sql = "SELECT gid FROM users WHERE gid = (SELECT gid FROM domain_name\ |
196
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
158 |
WHERE domainname = '%s') AND local_part = '%s'" % (address.domainname, |
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
159 |
address.localpart) |
185
6e1ef32fbd82
VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
184
diff
changeset
|
160 |
return Handler._exists(dbh, sql) |
76
14c0a092d7d2
* 'VirtualMailManager/EmailAddress.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
70
diff
changeset
|
161 |
accountExists = staticmethod(accountExists) |
14c0a092d7d2
* 'VirtualMailManager/EmailAddress.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
70
diff
changeset
|
162 |
|
14c0a092d7d2
* 'VirtualMailManager/EmailAddress.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
70
diff
changeset
|
163 |
def aliasExists(dbh, address): |
14c0a092d7d2
* 'VirtualMailManager/EmailAddress.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
70
diff
changeset
|
164 |
sql = "SELECT DISTINCT gid FROM alias WHERE gid = (SELECT gid FROM\ |
188
cf1b5f22dbd2
VMM/Handler: __init__ accepts now a config_type ('default'||'cli').
Pascal Volk <neverseen@users.sourceforge.net>
parents:
187
diff
changeset
|
165 |
domain_name WHERE domainname = '%s') AND address = '%s'" % ( |
196
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
166 |
address.domainname, address.localpart) |
185
6e1ef32fbd82
VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
184
diff
changeset
|
167 |
return Handler._exists(dbh, sql) |
76
14c0a092d7d2
* 'VirtualMailManager/EmailAddress.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
70
diff
changeset
|
168 |
aliasExists = staticmethod(aliasExists) |
14c0a092d7d2
* 'VirtualMailManager/EmailAddress.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
70
diff
changeset
|
169 |
|
14c0a092d7d2
* 'VirtualMailManager/EmailAddress.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
70
diff
changeset
|
170 |
def relocatedExists(dbh, address): |
14c0a092d7d2
* 'VirtualMailManager/EmailAddress.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
70
diff
changeset
|
171 |
sql = "SELECT gid FROM relocated WHERE gid = (SELECT gid FROM\ |
188
cf1b5f22dbd2
VMM/Handler: __init__ accepts now a config_type ('default'||'cli').
Pascal Volk <neverseen@users.sourceforge.net>
parents:
187
diff
changeset
|
172 |
domain_name WHERE domainname = '%s') AND address = '%s'" % ( |
196
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
173 |
address.domainname, address.localpart) |
185
6e1ef32fbd82
VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
184
diff
changeset
|
174 |
return Handler._exists(dbh, sql) |
76
14c0a092d7d2
* 'VirtualMailManager/EmailAddress.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
70
diff
changeset
|
175 |
relocatedExists = staticmethod(relocatedExists) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
176 |
|
80
5dedc673524e
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
78
diff
changeset
|
177 |
def __getAccount(self, address, password=None): |
5dedc673524e
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
78
diff
changeset
|
178 |
address = EmailAddress(address) |
5dedc673524e
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
78
diff
changeset
|
179 |
if not password is None: |
5dedc673524e
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
78
diff
changeset
|
180 |
password = self.__pwhash(password) |
197
d2712e8c724e
VMM/{Relocated,Handler}: reworked Relocated class, adjusted Handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
196
diff
changeset
|
181 |
self.__dbConnect() |
196
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
182 |
return Account(self._dbh, address, password) |
80
5dedc673524e
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
78
diff
changeset
|
183 |
|
196
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
184 |
def __getAlias(self, address): |
197
d2712e8c724e
VMM/{Relocated,Handler}: reworked Relocated class, adjusted Handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
196
diff
changeset
|
185 |
address = EmailAddress(address) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
186 |
self.__dbConnect() |
196
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
187 |
return Alias(self._dbh, address) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
188 |
|
197
d2712e8c724e
VMM/{Relocated,Handler}: reworked Relocated class, adjusted Handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
196
diff
changeset
|
189 |
def __getRelocated(self, address): |
80
5dedc673524e
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
78
diff
changeset
|
190 |
address = EmailAddress(address) |
197
d2712e8c724e
VMM/{Relocated,Handler}: reworked Relocated class, adjusted Handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
196
diff
changeset
|
191 |
self.__dbConnect() |
d2712e8c724e
VMM/{Relocated,Handler}: reworked Relocated class, adjusted Handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
196
diff
changeset
|
192 |
return Relocated(self._dbh, address) |
80
5dedc673524e
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
78
diff
changeset
|
193 |
|
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
194 |
def __getDomain(self, domainname, transport=None): |
9
e3d3dbeb5b84
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
8
diff
changeset
|
195 |
if transport is None: |
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
196 |
transport = self._Cfg.dget('misc.transport') |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
197 |
self.__dbConnect() |
196
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
198 |
return Domain(self._dbh, domainname, |
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
199 |
self._Cfg.dget('misc.base_directory'), transport) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
200 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
201 |
def __getDiskUsage(self, directory): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
202 |
"""Estimate file space usage for the given directory. |
128
cf8116625866
Converted VirtualMailManager and Postconf to new-style classes.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
119
diff
changeset
|
203 |
|
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
204 |
Keyword arguments: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
205 |
directory -- the directory to summarize recursively disk usage for |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
206 |
""" |
40 | 207 |
if self.__isdir(directory): |
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
208 |
return Popen([self._Cfg.dget('bin.du'), "-hs", directory], |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
209 |
stdout=PIPE).communicate()[0].split('\t')[0] |
40 | 210 |
else: |
211 |
return 0 |
|
212 |
||
213 |
def __isdir(self, directory): |
|
214 |
isdir = os.path.isdir(directory) |
|
215 |
if not isdir: |
|
216 |
self.__warnings.append(_('No such directory: %s') % directory) |
|
217 |
return isdir |
|
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
218 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
219 |
def __makedir(self, directory, mode=None, uid=None, gid=None): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
220 |
if mode is None: |
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
221 |
mode = self._Cfg.dget('account.directory_mode') |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
222 |
if uid is None: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
223 |
uid = 0 |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
224 |
if gid is None: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
225 |
gid = 0 |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
226 |
os.makedirs(directory, mode) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
227 |
os.chown(directory, uid, gid) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
228 |
|
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
229 |
def __domDirMake(self, domdir, gid): |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
230 |
os.umask(0006) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
231 |
oldpwd = os.getcwd() |
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
232 |
basedir = self._Cfg.dget('misc.base_directory') |
191
db77501aeaed
VMM/Handler: __mailDirMake() add warning for skipped mailboxes.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
190
diff
changeset
|
233 |
domdirdirs = domdir.replace(basedir + '/', '').split('/') |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
234 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
235 |
os.chdir(basedir) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
236 |
if not os.path.isdir(domdirdirs[0]): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
237 |
self.__makedir(domdirdirs[0], 489, 0, |
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
238 |
self._Cfg.dget('misc.gid_mail')) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
239 |
os.chdir(domdirdirs[0]) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
240 |
os.umask(0007) |
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
241 |
self.__makedir(domdirdirs[1], self._Cfg.dget('domain.directory_mode'), |
174
974bafa59330
VMM/Config: reworked configuration handling.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
168
diff
changeset
|
242 |
0, gid) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
243 |
os.chdir(oldpwd) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
244 |
|
191
db77501aeaed
VMM/Handler: __mailDirMake() add warning for skipped mailboxes.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
190
diff
changeset
|
245 |
def __subscribe(self, folderlist, uid, gid): |
db77501aeaed
VMM/Handler: __mailDirMake() add warning for skipped mailboxes.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
190
diff
changeset
|
246 |
"""Creates a subscriptions file with the mailboxes from `folderlist`""" |
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
247 |
fname = os.path.join(self._Cfg.dget('maildir.name'), 'subscriptions') |
191
db77501aeaed
VMM/Handler: __mailDirMake() add warning for skipped mailboxes.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
190
diff
changeset
|
248 |
sf = open(fname, 'w') |
68
7ae95b9938c4
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
66
diff
changeset
|
249 |
for f in folderlist: |
191
db77501aeaed
VMM/Handler: __mailDirMake() add warning for skipped mailboxes.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
190
diff
changeset
|
250 |
sf.write('%s\n' % f) |
68
7ae95b9938c4
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
66
diff
changeset
|
251 |
sf.flush() |
7ae95b9938c4
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
66
diff
changeset
|
252 |
sf.close() |
7ae95b9938c4
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
66
diff
changeset
|
253 |
os.chown(fname, uid, gid) |
7ae95b9938c4
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
66
diff
changeset
|
254 |
os.chmod(fname, 384) |
7ae95b9938c4
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
66
diff
changeset
|
255 |
|
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
256 |
def __mailDirMake(self, domdir, uid, gid): |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
257 |
"""Creates maildirs and maildir subfolders. |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
258 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
259 |
Keyword arguments: |
68
7ae95b9938c4
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
66
diff
changeset
|
260 |
domdir -- the path to the domain directory |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
261 |
uid -- user id from the account |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
262 |
gid -- group id from the account |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
263 |
""" |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
264 |
os.umask(0007) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
265 |
oldpwd = os.getcwd() |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
266 |
os.chdir(domdir) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
267 |
|
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
268 |
maildir = self._Cfg.dget('maildir.name') |
68
7ae95b9938c4
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
66
diff
changeset
|
269 |
folders = [maildir] |
191
db77501aeaed
VMM/Handler: __mailDirMake() add warning for skipped mailboxes.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
190
diff
changeset
|
270 |
append = folders.append |
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
271 |
for folder in self._Cfg.dget('maildir.folders').split(':'): |
68
7ae95b9938c4
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
66
diff
changeset
|
272 |
folder = folder.strip() |
191
db77501aeaed
VMM/Handler: __mailDirMake() add warning for skipped mailboxes.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
190
diff
changeset
|
273 |
if len(folder) and not folder.count('..'): |
db77501aeaed
VMM/Handler: __mailDirMake() add warning for skipped mailboxes.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
190
diff
changeset
|
274 |
if re.match(RE_MBOX_NAMES, folder): |
db77501aeaed
VMM/Handler: __mailDirMake() add warning for skipped mailboxes.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
190
diff
changeset
|
275 |
append('%s/.%s' % (maildir, folder)) |
db77501aeaed
VMM/Handler: __mailDirMake() add warning for skipped mailboxes.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
190
diff
changeset
|
276 |
else: |
db77501aeaed
VMM/Handler: __mailDirMake() add warning for skipped mailboxes.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
190
diff
changeset
|
277 |
self.__warnings.append(_('Skipped mailbox folder: %r') % |
db77501aeaed
VMM/Handler: __mailDirMake() add warning for skipped mailboxes.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
190
diff
changeset
|
278 |
folder) |
db77501aeaed
VMM/Handler: __mailDirMake() add warning for skipped mailboxes.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
190
diff
changeset
|
279 |
else: |
db77501aeaed
VMM/Handler: __mailDirMake() add warning for skipped mailboxes.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
190
diff
changeset
|
280 |
self.__warnings.append(_('Skipped mailbox folder: %r') % |
db77501aeaed
VMM/Handler: __mailDirMake() add warning for skipped mailboxes.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
190
diff
changeset
|
281 |
folder) |
db77501aeaed
VMM/Handler: __mailDirMake() add warning for skipped mailboxes.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
190
diff
changeset
|
282 |
|
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
283 |
subdirs = ['cur', 'new', 'tmp'] |
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
284 |
mode = self._Cfg.dget('account.directory_mode') |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
285 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
286 |
self.__makedir('%s' % uid, mode, uid, gid) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
287 |
os.chdir('%s' % uid) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
288 |
for folder in folders: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
289 |
self.__makedir(folder, mode, uid, gid) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
290 |
for subdir in subdirs: |
119
014335f38962
Small code cleanups (replaced dir+'/'+file by os.path.join()).
Pascal Volk <neverseen@users.sourceforge.net>
parents:
115
diff
changeset
|
291 |
self.__makedir(os.path.join(folder, subdir), mode, uid, gid) |
191
db77501aeaed
VMM/Handler: __mailDirMake() add warning for skipped mailboxes.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
190
diff
changeset
|
292 |
self.__subscribe((f.replace(maildir + '/.', '') for f in folders[1:]), |
db77501aeaed
VMM/Handler: __mailDirMake() add warning for skipped mailboxes.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
190
diff
changeset
|
293 |
uid, gid) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
294 |
os.chdir(oldpwd) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
295 |
|
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
296 |
def __userDirDelete(self, domdir, uid, gid): |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
297 |
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
|
298 |
userdir = '%s' % uid |
f5ca21303871
* Switched from pygettext to xgettext -> small adjustments to these files:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
50
diff
changeset
|
299 |
if userdir.count('..') or domdir.count('..'): |
216
0c8c053b451c
Moved VirtualMailManager/Exceptions to VirtualMailManager/errors.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
215
diff
changeset
|
300 |
raise VMMError(_(u'Found ".." in home directory path.'), |
191
db77501aeaed
VMM/Handler: __mailDirMake() add warning for skipped mailboxes.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
190
diff
changeset
|
301 |
ERR.FOUND_DOTS_IN_PATH) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
302 |
if os.path.isdir(domdir): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
303 |
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
|
304 |
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
|
305 |
mdstat = os.stat(userdir) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
306 |
if (mdstat.st_uid, mdstat.st_gid) != (uid, gid): |
216
0c8c053b451c
Moved VirtualMailManager/Exceptions to VirtualMailManager/errors.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
215
diff
changeset
|
307 |
raise VMMError(_( |
191
db77501aeaed
VMM/Handler: __mailDirMake() add warning for skipped mailboxes.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
190
diff
changeset
|
308 |
u'Detected owner/group mismatch in home directory.'), |
db77501aeaed
VMM/Handler: __mailDirMake() add warning for skipped mailboxes.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
190
diff
changeset
|
309 |
ERR.MAILDIR_PERM_MISMATCH) |
51
f5ca21303871
* Switched from pygettext to xgettext -> small adjustments to these files:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
50
diff
changeset
|
310 |
rmtree(userdir, ignore_errors=True) |
40 | 311 |
else: |
216
0c8c053b451c
Moved VirtualMailManager/Exceptions to VirtualMailManager/errors.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
215
diff
changeset
|
312 |
raise VMMError(_(u"No such directory: %s") % |
119
014335f38962
Small code cleanups (replaced dir+'/'+file by os.path.join()).
Pascal Volk <neverseen@users.sourceforge.net>
parents:
115
diff
changeset
|
313 |
os.path.join(domdir, userdir), ERR.NO_SUCH_DIRECTORY) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
314 |
|
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
315 |
def __domDirDelete(self, domdir, gid): |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
316 |
if gid > 0: |
40 | 317 |
if not self.__isdir(domdir): |
318 |
return |
|
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
319 |
basedir = self._Cfg.dget('misc.base_directory') |
191
db77501aeaed
VMM/Handler: __mailDirMake() add warning for skipped mailboxes.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
190
diff
changeset
|
320 |
domdirdirs = domdir.replace(basedir + '/', '').split('/') |
119
014335f38962
Small code cleanups (replaced dir+'/'+file by os.path.join()).
Pascal Volk <neverseen@users.sourceforge.net>
parents:
115
diff
changeset
|
321 |
domdirparent = os.path.join(basedir, domdirdirs[0]) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
322 |
if basedir.count('..') or domdir.count('..'): |
216
0c8c053b451c
Moved VirtualMailManager/Exceptions to VirtualMailManager/errors.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
215
diff
changeset
|
323 |
raise VMMError(_(u'Found ".." in domain directory path.'), |
155
eb866ebb9f2e
Fixed some grammar errors and typos. (Reported by Clytie Siddall)
Pascal Volk <neverseen@users.sourceforge.net>
parents:
143
diff
changeset
|
324 |
ERR.FOUND_DOTS_IN_PATH) |
119
014335f38962
Small code cleanups (replaced dir+'/'+file by os.path.join()).
Pascal Volk <neverseen@users.sourceforge.net>
parents:
115
diff
changeset
|
325 |
if os.path.isdir(domdirparent): |
014335f38962
Small code cleanups (replaced dir+'/'+file by os.path.join()).
Pascal Volk <neverseen@users.sourceforge.net>
parents:
115
diff
changeset
|
326 |
os.chdir(domdirparent) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
327 |
if os.lstat(domdirdirs[1]).st_gid != gid: |
216
0c8c053b451c
Moved VirtualMailManager/Exceptions to VirtualMailManager/errors.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
215
diff
changeset
|
328 |
raise VMMError(_( |
155
eb866ebb9f2e
Fixed some grammar errors and typos. (Reported by Clytie Siddall)
Pascal Volk <neverseen@users.sourceforge.net>
parents:
143
diff
changeset
|
329 |
u'Detected group mismatch in domain directory.'), |
48
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
330 |
ERR.DOMAINDIR_GROUP_MISMATCH) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
331 |
rmtree(domdirdirs[1], ignore_errors=True) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
332 |
|
16
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
333 |
def __getSalt(self): |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
334 |
from random import choice |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
335 |
salt = None |
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
336 |
if self._scheme == 'CRYPT': |
16
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
337 |
salt = '%s%s' % (choice(SALTCHARS), choice(SALTCHARS)) |
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
338 |
elif self._scheme in ['MD5', 'MD5-CRYPT']: |
140
ffac064bd728
Code cleanup/optimization in VirtualMailManager's __getSalt().
Pascal Volk <neverseen@users.sourceforge.net>
parents:
138
diff
changeset
|
339 |
salt = '$1$%s$' % ''.join([choice(SALTCHARS) for x in xrange(8)]) |
16
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
340 |
return salt |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
341 |
|
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
342 |
def __pwCrypt(self, password): |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
343 |
# for: CRYPT, MD5 and MD5-CRYPT |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
344 |
from crypt import crypt |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
345 |
return crypt(password, self.__getSalt()) |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
346 |
|
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
347 |
def __pwSHA1(self, password): |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
348 |
# for: SHA/SHA1 |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
349 |
import sha |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
350 |
from base64 import standard_b64encode |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
351 |
sha1 = sha.new(password) |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
352 |
return standard_b64encode(sha1.digest()) |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
353 |
|
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
354 |
def __pwMD5(self, password, emailaddress=None): |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
355 |
import md5 |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
356 |
_md5 = md5.new(password) |
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
357 |
if self._scheme == 'LDAP-MD5': |
16
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
358 |
from base64 import standard_b64encode |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
359 |
return standard_b64encode(_md5.digest()) |
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
360 |
elif self._scheme == 'PLAIN-MD5': |
16
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
361 |
return _md5.hexdigest() |
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
362 |
elif self._scheme == 'DIGEST-MD5' and emailaddress is not None: |
70
a3663ad491bf
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
69
diff
changeset
|
363 |
# use an empty realm - works better with usenames like user@dom |
a3663ad491bf
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
69
diff
changeset
|
364 |
_md5 = md5.new('%s::%s' % (emailaddress, password)) |
16
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
365 |
return _md5.hexdigest() |
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 __pwMD4(self, password): |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
368 |
# for: PLAIN-MD4 |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
369 |
from Crypto.Hash import MD4 |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
370 |
_md4 = MD4.new(password) |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
371 |
return _md4.hexdigest() |
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
372 |
|
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
373 |
def __pwhash(self, password, scheme=None, user=None): |
16
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
374 |
if scheme is not None: |
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
375 |
self._scheme = scheme |
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
376 |
if self._scheme in ['CRYPT', 'MD5', 'MD5-CRYPT']: |
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
377 |
return '{%s}%s' % (self._scheme, self.__pwCrypt(password)) |
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
378 |
elif self._scheme in ['SHA', 'SHA1']: |
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
379 |
return '{%s}%s' % (self._scheme, self.__pwSHA1(password)) |
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
380 |
elif self._scheme in ['PLAIN-MD5', 'LDAP-MD5', 'DIGEST-MD5']: |
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
381 |
return '{%s}%s' % (self._scheme, self.__pwMD5(password, user)) |
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
382 |
elif self._scheme == 'MD4': |
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
383 |
return '{%s}%s' % (self._scheme, self.__pwMD4(password)) |
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
384 |
elif self._scheme in ['SMD5', 'SSHA', 'CRAM-MD5', 'HMAC-MD5', |
16
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
385 |
'LANMAN', 'NTLM', 'RPA']: |
191
db77501aeaed
VMM/Handler: __mailDirMake() add warning for skipped mailboxes.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
190
diff
changeset
|
386 |
return Popen([self._Cfg.dget('bin.dovecotpw'), |
db77501aeaed
VMM/Handler: __mailDirMake() add warning for skipped mailboxes.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
190
diff
changeset
|
387 |
'-s', self._scheme, '-p', password], |
db77501aeaed
VMM/Handler: __mailDirMake() add warning for skipped mailboxes.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
190
diff
changeset
|
388 |
stdout=PIPE).communicate()[0][:-1] |
16
3388b96fd3ed
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
14
diff
changeset
|
389 |
else: |
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
390 |
return '{%s}%s' % (self._scheme, password) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
391 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
392 |
def hasWarnings(self): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
393 |
"""Checks if warnings are present, returns bool.""" |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
394 |
return bool(len(self.__warnings)) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
395 |
|
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
396 |
def getWarnings(self): |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
397 |
"""Returns a list with all available warnings.""" |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
398 |
return self.__warnings |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
399 |
|
174
974bafa59330
VMM/Config: reworked configuration handling.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
168
diff
changeset
|
400 |
def cfgDget(self, option): |
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
401 |
return self._Cfg.dget(option) |
40 | 402 |
|
174
974bafa59330
VMM/Config: reworked configuration handling.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
168
diff
changeset
|
403 |
def cfgPget(self, option): |
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
404 |
return self._Cfg.pget(option) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
405 |
|
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
406 |
def domainAdd(self, domainname, transport=None): |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
407 |
dom = self.__getDomain(domainname, transport) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
408 |
dom.save() |
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
409 |
self.__domDirMake(dom.getDir(), dom.getID()) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
410 |
|
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
411 |
def domainTransport(self, domainname, transport, force=None): |
18
c98e08791ee8
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
17
diff
changeset
|
412 |
if force is not None and force != 'force': |
216
0c8c053b451c
Moved VirtualMailManager/Exceptions to VirtualMailManager/errors.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
215
diff
changeset
|
413 |
raise DomainError(_(u"Invalid argument: “%s”") % force, |
48
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
414 |
ERR.INVALID_OPTION) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
415 |
dom = self.__getDomain(domainname, None) |
18
c98e08791ee8
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
17
diff
changeset
|
416 |
if force is None: |
c98e08791ee8
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
17
diff
changeset
|
417 |
dom.updateTransport(transport) |
c98e08791ee8
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
17
diff
changeset
|
418 |
else: |
c98e08791ee8
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
17
diff
changeset
|
419 |
dom.updateTransport(transport, force=True) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
420 |
|
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
421 |
def domainDelete(self, domainname, force=None): |
191
db77501aeaed
VMM/Handler: __mailDirMake() add warning for skipped mailboxes.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
190
diff
changeset
|
422 |
if not force is None and force not in ['deluser', 'delalias', |
db77501aeaed
VMM/Handler: __mailDirMake() add warning for skipped mailboxes.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
190
diff
changeset
|
423 |
'delall']: |
216
0c8c053b451c
Moved VirtualMailManager/Exceptions to VirtualMailManager/errors.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
215
diff
changeset
|
424 |
raise DomainError(_(u'Invalid argument: “%s”') % |
191
db77501aeaed
VMM/Handler: __mailDirMake() add warning for skipped mailboxes.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
190
diff
changeset
|
425 |
force, ERR.INVALID_OPTION) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
426 |
dom = self.__getDomain(domainname) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
427 |
gid = dom.getID() |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
428 |
domdir = dom.getDir() |
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
429 |
if self._Cfg.dget('domain.force_deletion') or force == 'delall': |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
430 |
dom.delete(True, True) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
431 |
elif force == 'deluser': |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
432 |
dom.delete(delUser=True) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
433 |
elif force == 'delalias': |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
434 |
dom.delete(delAlias=True) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
435 |
else: |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
436 |
dom.delete() |
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
437 |
if self._Cfg.dget('domain.delete_directory'): |
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
438 |
self.__domDirDelete(domdir, gid) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
439 |
|
62
869de537a020
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
55
diff
changeset
|
440 |
def domainInfo(self, domainname, details=None): |
869de537a020
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
55
diff
changeset
|
441 |
if details not in [None, 'accounts', 'aliasdomains', 'aliases', 'full', |
191
db77501aeaed
VMM/Handler: __mailDirMake() add warning for skipped mailboxes.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
190
diff
changeset
|
442 |
'relocated']: |
216
0c8c053b451c
Moved VirtualMailManager/Exceptions to VirtualMailManager/errors.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
215
diff
changeset
|
443 |
raise VMMError(_(u'Invalid argument: “%s”') % details, |
191
db77501aeaed
VMM/Handler: __mailDirMake() add warning for skipped mailboxes.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
190
diff
changeset
|
444 |
ERR.INVALID_AGUMENT) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
445 |
dom = self.__getDomain(domainname) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
446 |
dominfo = dom.getInfo() |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
447 |
if dominfo['domainname'].startswith('xn--'): |
185
6e1ef32fbd82
VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
184
diff
changeset
|
448 |
dominfo['domainname'] += ' (%s)' % ace2idna(dominfo['domainname']) |
62
869de537a020
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
55
diff
changeset
|
449 |
if details is None: |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
450 |
return dominfo |
62
869de537a020
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
55
diff
changeset
|
451 |
elif details == 'accounts': |
869de537a020
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
55
diff
changeset
|
452 |
return (dominfo, dom.getAccounts()) |
869de537a020
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
55
diff
changeset
|
453 |
elif details == 'aliasdomains': |
869de537a020
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
55
diff
changeset
|
454 |
return (dominfo, dom.getAliaseNames()) |
869de537a020
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
55
diff
changeset
|
455 |
elif details == 'aliases': |
869de537a020
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
55
diff
changeset
|
456 |
return (dominfo, dom.getAliases()) |
80
5dedc673524e
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
78
diff
changeset
|
457 |
elif details == 'relocated': |
5dedc673524e
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
78
diff
changeset
|
458 |
return(dominfo, dom.getRelocated()) |
62
869de537a020
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
55
diff
changeset
|
459 |
else: |
44
c9ab6900ede9
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
40
diff
changeset
|
460 |
return (dominfo, dom.getAliaseNames(), dom.getAccounts(), |
80
5dedc673524e
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
78
diff
changeset
|
461 |
dom.getAliases(), dom.getRelocated()) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
462 |
|
55
15c873f94ba6
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
54
diff
changeset
|
463 |
def aliasDomainAdd(self, aliasname, domainname): |
15c873f94ba6
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
54
diff
changeset
|
464 |
"""Adds an alias domain to the domain. |
53
5b50eb306d37
* 'VirtualMailManager/DomainAlias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
52
diff
changeset
|
465 |
|
45
9e66138aad0b
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
44
diff
changeset
|
466 |
Keyword arguments: |
55
15c873f94ba6
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
54
diff
changeset
|
467 |
aliasname -- the name of the alias domain (str) |
45
9e66138aad0b
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
44
diff
changeset
|
468 |
domainname -- name of the target domain (str) |
9e66138aad0b
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
44
diff
changeset
|
469 |
""" |
9e66138aad0b
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
44
diff
changeset
|
470 |
dom = self.__getDomain(domainname) |
196
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
471 |
aliasDom = AliasDomain(self._dbh, aliasname, dom) |
55
15c873f94ba6
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
54
diff
changeset
|
472 |
aliasDom.save() |
53
5b50eb306d37
* 'VirtualMailManager/DomainAlias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
52
diff
changeset
|
473 |
|
55
15c873f94ba6
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
54
diff
changeset
|
474 |
def aliasDomainInfo(self, aliasname): |
53
5b50eb306d37
* 'VirtualMailManager/DomainAlias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
52
diff
changeset
|
475 |
self.__dbConnect() |
196
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
476 |
aliasDom = AliasDomain(self._dbh, aliasname, None) |
55
15c873f94ba6
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
54
diff
changeset
|
477 |
return aliasDom.info() |
45
9e66138aad0b
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
44
diff
changeset
|
478 |
|
78
8f1e501b1bb1
* 'VirtualMailManager/Account.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
76
diff
changeset
|
479 |
def aliasDomainSwitch(self, aliasname, domainname): |
8f1e501b1bb1
* 'VirtualMailManager/Account.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
76
diff
changeset
|
480 |
"""Modifies the target domain of an existing alias domain. |
8f1e501b1bb1
* 'VirtualMailManager/Account.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
76
diff
changeset
|
481 |
|
8f1e501b1bb1
* 'VirtualMailManager/Account.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
76
diff
changeset
|
482 |
Keyword arguments: |
8f1e501b1bb1
* 'VirtualMailManager/Account.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
76
diff
changeset
|
483 |
aliasname -- the name of the alias domain (str) |
8f1e501b1bb1
* 'VirtualMailManager/Account.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
76
diff
changeset
|
484 |
domainname -- name of the new target domain (str) |
8f1e501b1bb1
* 'VirtualMailManager/Account.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
76
diff
changeset
|
485 |
""" |
8f1e501b1bb1
* 'VirtualMailManager/Account.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
76
diff
changeset
|
486 |
dom = self.__getDomain(domainname) |
196
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
487 |
aliasDom = AliasDomain(self._dbh, aliasname, dom) |
78
8f1e501b1bb1
* 'VirtualMailManager/Account.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
76
diff
changeset
|
488 |
aliasDom.switch() |
8f1e501b1bb1
* 'VirtualMailManager/Account.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
76
diff
changeset
|
489 |
|
55
15c873f94ba6
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
54
diff
changeset
|
490 |
def aliasDomainDelete(self, aliasname): |
15c873f94ba6
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
54
diff
changeset
|
491 |
"""Deletes the specified alias domain. |
53
5b50eb306d37
* 'VirtualMailManager/DomainAlias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
52
diff
changeset
|
492 |
|
45
9e66138aad0b
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
44
diff
changeset
|
493 |
Keyword arguments: |
55
15c873f94ba6
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
54
diff
changeset
|
494 |
aliasname -- the name of the alias domain (str) |
45
9e66138aad0b
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
44
diff
changeset
|
495 |
""" |
9e66138aad0b
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
44
diff
changeset
|
496 |
self.__dbConnect() |
196
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
497 |
aliasDom = AliasDomain(self._dbh, aliasname, None) |
55
15c873f94ba6
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
54
diff
changeset
|
498 |
aliasDom.delete() |
45
9e66138aad0b
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
44
diff
changeset
|
499 |
|
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
500 |
def domainList(self, pattern=None): |
35
22cc616aef61
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
34
diff
changeset
|
501 |
from Domain import search |
22cc616aef61
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
34
diff
changeset
|
502 |
like = False |
22cc616aef61
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
34
diff
changeset
|
503 |
if pattern is not None: |
22cc616aef61
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
34
diff
changeset
|
504 |
if pattern.startswith('%') or pattern.endswith('%'): |
22cc616aef61
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
34
diff
changeset
|
505 |
like = True |
22cc616aef61
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
34
diff
changeset
|
506 |
if pattern.startswith('%') and pattern.endswith('%'): |
22cc616aef61
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
34
diff
changeset
|
507 |
domain = pattern[1:-1] |
22cc616aef61
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
34
diff
changeset
|
508 |
elif pattern.startswith('%'): |
22cc616aef61
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
34
diff
changeset
|
509 |
domain = pattern[1:] |
22cc616aef61
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
34
diff
changeset
|
510 |
elif pattern.endswith('%'): |
22cc616aef61
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
34
diff
changeset
|
511 |
domain = pattern[:-1] |
22cc616aef61
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
34
diff
changeset
|
512 |
if not re.match(RE_DOMAIN_SRCH, domain): |
216
0c8c053b451c
Moved VirtualMailManager/Exceptions to VirtualMailManager/errors.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
215
diff
changeset
|
513 |
raise VMMError( |
133
2d5c4745efec
Replaced angle quotes by quotation marks.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
132
diff
changeset
|
514 |
_(u"The pattern “%s” contains invalid characters.") % |
48
0d5f58f8b8f5
* 'VirtualMailManager/Exceptions.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
47
diff
changeset
|
515 |
pattern, ERR.DOMAIN_INVALID) |
35
22cc616aef61
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
34
diff
changeset
|
516 |
self.__dbConnect() |
196
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
517 |
return search(self._dbh, pattern=pattern, like=like) |
35
22cc616aef61
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
34
diff
changeset
|
518 |
|
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
519 |
def userAdd(self, emailaddress, password): |
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
520 |
if password is None or (isinstance(password, basestring) and |
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
521 |
not len(password)): |
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
522 |
raise ValueError('could not accept password: %r' % password) |
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
523 |
acc = self.__getAccount(emailaddress, self.__pwhash(password)) |
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
524 |
acc.save(self._Cfg.dget('maildir.name'), |
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
525 |
self._Cfg.dget('misc.dovecot_version'), |
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
526 |
self._Cfg.dget('account.smtp'), |
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
527 |
self._Cfg.dget('account.pop3'), |
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
528 |
self._Cfg.dget('account.imap'), |
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
529 |
self._Cfg.dget('account.sieve')) |
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
530 |
self.__mailDirMake(acc.getDir('domain'), acc.getUID(), acc.getGID()) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
531 |
|
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
532 |
def aliasAdd(self, aliasaddress, targetaddress): |
196
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
533 |
"""Creates a new `Alias` entry for the given *aliasaddress* with |
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
534 |
the given *targetaddress*.""" |
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
535 |
alias = self.__getAlias(aliasaddress) |
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
536 |
destination = EmailAddress(targetaddress) |
215
33f727efa7c4
PEP-8-ified the work of the last days.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
208
diff
changeset
|
537 |
alias.add_destination(destination, |
196
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
538 |
long(self._postconf.read('virtual_alias_expansion_limit'))) |
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
539 |
gid = self.__getDomain(destination.domainname).getID() |
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
540 |
if gid > 0 and (not Handler.accountExists(self._dbh, destination) and |
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
541 |
not Handler.aliasExists(self._dbh, destination)): |
83
cc195af37de0
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
80
diff
changeset
|
542 |
self.__warnings.append( |
191
db77501aeaed
VMM/Handler: __mailDirMake() add warning for skipped mailboxes.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
190
diff
changeset
|
543 |
_(u"The destination account/alias “%s” doesn't exist.") % |
196
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
544 |
destination) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
545 |
|
66
995d538a6eb5
* 'VirtualMailManager/Account.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
62
diff
changeset
|
546 |
def userDelete(self, emailaddress, force=None): |
995d538a6eb5
* 'VirtualMailManager/Account.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
62
diff
changeset
|
547 |
if force not in [None, 'delalias']: |
216
0c8c053b451c
Moved VirtualMailManager/Exceptions to VirtualMailManager/errors.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
215
diff
changeset
|
548 |
raise VMMError(_(u"Invalid argument: “%s”") % force, |
66
995d538a6eb5
* 'VirtualMailManager/Account.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
62
diff
changeset
|
549 |
ERR.INVALID_AGUMENT) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
550 |
acc = self.__getAccount(emailaddress) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
551 |
uid = acc.getUID() |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
552 |
gid = acc.getGID() |
66
995d538a6eb5
* 'VirtualMailManager/Account.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
62
diff
changeset
|
553 |
acc.delete(force) |
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
554 |
if self._Cfg.dget('account.delete_directory'): |
47
191d5a5adc4a
* Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
45
diff
changeset
|
555 |
try: |
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
556 |
self.__userDirDelete(acc.getDir('domain'), uid, gid) |
216
0c8c053b451c
Moved VirtualMailManager/Exceptions to VirtualMailManager/errors.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
215
diff
changeset
|
557 |
except VMMError, e: |
0c8c053b451c
Moved VirtualMailManager/Exceptions to VirtualMailManager/errors.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
215
diff
changeset
|
558 |
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
|
559 |
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
|
560 |
warning = _(u"""\ |
191d5a5adc4a
* Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
45
diff
changeset
|
561 |
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
|
562 |
But an error occurred while deleting the following directory: |
133
2d5c4745efec
Replaced angle quotes by quotation marks.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
132
diff
changeset
|
563 |
“%(directory)s” |
192
0854fb9f3bc5
VMM/Handler: fixed a SyntaxError. Oops
Pascal Volk <neverseen@users.sourceforge.net>
parents:
191
diff
changeset
|
564 |
Reason: %(reason)s""") % \ |
216
0c8c053b451c
Moved VirtualMailManager/Exceptions to VirtualMailManager/errors.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
215
diff
changeset
|
565 |
{'directory': acc.getDir('home'), 'reason': e.msg} |
47
191d5a5adc4a
* Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
45
diff
changeset
|
566 |
self.__warnings.append(warning) |
191d5a5adc4a
* Removed gettext import and setup in VirtualMailManager/:
Pascal Volk <neverseen@users.sourceforge.net>
parents:
45
diff
changeset
|
567 |
else: |
191
db77501aeaed
VMM/Handler: __mailDirMake() add warning for skipped mailboxes.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
190
diff
changeset
|
568 |
raise |
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 aliasInfo(self, aliasaddress): |
196
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
571 |
"""Returns an iterator object for all destinations (`EmailAddress` |
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
572 |
instances) for the `Alias` with the given *aliasaddress*.""" |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
573 |
alias = self.__getAlias(aliasaddress) |
196
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
574 |
try: |
215
33f727efa7c4
PEP-8-ified the work of the last days.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
208
diff
changeset
|
575 |
return alias.get_destinations() |
216
0c8c053b451c
Moved VirtualMailManager/Exceptions to VirtualMailManager/errors.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
215
diff
changeset
|
576 |
except AliasError, e: |
0c8c053b451c
Moved VirtualMailManager/Exceptions to VirtualMailManager/errors.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
215
diff
changeset
|
577 |
if e.code == ERR.NO_SUCH_ALIAS: |
196
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
578 |
if Handler.accountExists(self._dbh, alias._addr): |
216
0c8c053b451c
Moved VirtualMailManager/Exceptions to VirtualMailManager/errors.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
215
diff
changeset
|
579 |
raise VMMError( |
196
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
580 |
_(u'There is already an account with address “%s”.') % |
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
581 |
aliasaddress, ERR.ACCOUNT_EXISTS) |
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
582 |
if Handler.relocatedExists(self._dbh, alias._addr): |
216
0c8c053b451c
Moved VirtualMailManager/Exceptions to VirtualMailManager/errors.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
215
diff
changeset
|
583 |
raise VMMError(_(u'There is already a relocated user \ |
196
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
584 |
with the address “%s”.') % |
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
585 |
aliasaddress, ERR.RELOCATED_EXISTS) |
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
586 |
raise |
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
587 |
else: |
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
588 |
raise |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
589 |
|
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
590 |
def aliasDelete(self, aliasaddress, targetaddress=None): |
196
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
591 |
"""Deletes the `Alias` *aliasaddress* with all its destinations from |
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
592 |
the database. If *targetaddress* is not ``None``, only this |
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
593 |
destination will be removed from the alias.""" |
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
594 |
alias = self.__getAlias(aliasaddress) |
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
595 |
if targetaddress is None: |
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
596 |
alias.delete() |
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
597 |
else: |
215
33f727efa7c4
PEP-8-ified the work of the last days.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
208
diff
changeset
|
598 |
alias.del_destination(EmailAddress(targetaddress)) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
599 |
|
90
1734eb5101c6
* 'VirtualMailManager/Account.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
88
diff
changeset
|
600 |
def userInfo(self, emailaddress, details=None): |
174
974bafa59330
VMM/Config: reworked configuration handling.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
168
diff
changeset
|
601 |
if details not in (None, 'du', 'aliases', 'full'): |
216
0c8c053b451c
Moved VirtualMailManager/Exceptions to VirtualMailManager/errors.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
215
diff
changeset
|
602 |
raise VMMError(_(u'Invalid argument: “%s”') % details, |
174
974bafa59330
VMM/Config: reworked configuration handling.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
168
diff
changeset
|
603 |
ERR.INVALID_AGUMENT) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
604 |
acc = self.__getAccount(emailaddress) |
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
605 |
info = acc.getInfo(self._Cfg.dget('misc.dovecot_version')) |
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
606 |
if self._Cfg.dget('account.disk_usage') or details in ('du', 'full'): |
9
e3d3dbeb5b84
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
8
diff
changeset
|
607 |
info['disk usage'] = self.__getDiskUsage('%(maildir)s' % info) |
174
974bafa59330
VMM/Config: reworked configuration handling.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
168
diff
changeset
|
608 |
if details in (None, 'du'): |
90
1734eb5101c6
* 'VirtualMailManager/Account.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
88
diff
changeset
|
609 |
return info |
174
974bafa59330
VMM/Config: reworked configuration handling.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
168
diff
changeset
|
610 |
if details in ('aliases', 'full'): |
90
1734eb5101c6
* 'VirtualMailManager/Account.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
88
diff
changeset
|
611 |
return (info, acc.getAliases()) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
612 |
return info |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
613 |
|
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
614 |
def userByID(self, uid): |
185
6e1ef32fbd82
VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
184
diff
changeset
|
615 |
from Handler.Account import getAccountByID |
19
bf9a03c476fc
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
18
diff
changeset
|
616 |
self.__dbConnect() |
196
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
617 |
return getAccountByID(uid, self._dbh) |
19
bf9a03c476fc
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
18
diff
changeset
|
618 |
|
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
619 |
def userPassword(self, emailaddress, password): |
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
620 |
if password is None or (isinstance(password, basestring) and |
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
621 |
not len(password)): |
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
622 |
raise ValueError('could not accept password: %r' % password) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
623 |
acc = self.__getAccount(emailaddress) |
38
c44ea4526546
* 'VirtualMailManager/Alias.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
35
diff
changeset
|
624 |
if acc.getUID() == 0: |
216
0c8c053b451c
Moved VirtualMailManager/Exceptions to VirtualMailManager/errors.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
215
diff
changeset
|
625 |
raise VMMError(_(u"Account doesn't exist"), |
191
db77501aeaed
VMM/Handler: __mailDirMake() add warning for skipped mailboxes.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
190
diff
changeset
|
626 |
ERR.NO_SUCH_ACCOUNT) |
70
a3663ad491bf
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
69
diff
changeset
|
627 |
acc.modify('password', self.__pwhash(password, user=emailaddress)) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
628 |
|
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
629 |
def userName(self, emailaddress, name): |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
630 |
acc = self.__getAccount(emailaddress) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
631 |
acc.modify('name', name) |
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
632 |
|
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
633 |
def userTransport(self, emailaddress, transport): |
17
fe9be0081e5f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
16
diff
changeset
|
634 |
acc = self.__getAccount(emailaddress) |
fe9be0081e5f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
16
diff
changeset
|
635 |
acc.modify('transport', transport) |
fe9be0081e5f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
16
diff
changeset
|
636 |
|
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
637 |
def userDisable(self, emailaddress, service=None): |
132
fa22bd13b4d1
Added a deprecated warning for managesieve. Updated translation.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
128
diff
changeset
|
638 |
if service == 'managesieve': |
fa22bd13b4d1
Added a deprecated warning for managesieve. Updated translation.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
128
diff
changeset
|
639 |
service = 'sieve' |
fa22bd13b4d1
Added a deprecated warning for managesieve. Updated translation.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
128
diff
changeset
|
640 |
self.__warnings.append(_(u'\ |
133
2d5c4745efec
Replaced angle quotes by quotation marks.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
132
diff
changeset
|
641 |
The service name “managesieve” is deprecated and will be removed\n\ |
132
fa22bd13b4d1
Added a deprecated warning for managesieve. Updated translation.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
128
diff
changeset
|
642 |
in a future release.\n\ |
133
2d5c4745efec
Replaced angle quotes by quotation marks.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
132
diff
changeset
|
643 |
Please use the service name “sieve” instead.')) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
644 |
acc = self.__getAccount(emailaddress) |
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
645 |
acc.disable(self._Cfg.dget('misc.dovecot_version'), service) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
646 |
|
54
1fc1f82c662f
* 'VirtualMailManager/VirtualMailManager.py'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
53
diff
changeset
|
647 |
def userEnable(self, emailaddress, service=None): |
132
fa22bd13b4d1
Added a deprecated warning for managesieve. Updated translation.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
128
diff
changeset
|
648 |
if service == 'managesieve': |
fa22bd13b4d1
Added a deprecated warning for managesieve. Updated translation.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
128
diff
changeset
|
649 |
service = 'sieve' |
fa22bd13b4d1
Added a deprecated warning for managesieve. Updated translation.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
128
diff
changeset
|
650 |
self.__warnings.append(_(u'\ |
133
2d5c4745efec
Replaced angle quotes by quotation marks.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
132
diff
changeset
|
651 |
The service name “managesieve” is deprecated and will be removed\n\ |
132
fa22bd13b4d1
Added a deprecated warning for managesieve. Updated translation.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
128
diff
changeset
|
652 |
in a future release.\n\ |
133
2d5c4745efec
Replaced angle quotes by quotation marks.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
132
diff
changeset
|
653 |
Please use the service name “sieve” instead.')) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
654 |
acc = self.__getAccount(emailaddress) |
190
1903d4ce97d7
VMM/{,cli/}Handler: reverted most of cs cf1b5f22dbd2 added a cli handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
188
diff
changeset
|
655 |
acc.enable(self._Cfg.dget('misc.dovecot_version'), service) |
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
656 |
|
80
5dedc673524e
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
78
diff
changeset
|
657 |
def relocatedAdd(self, emailaddress, targetaddress): |
197
d2712e8c724e
VMM/{Relocated,Handler}: reworked Relocated class, adjusted Handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
196
diff
changeset
|
658 |
"""Creates a new `Relocated` entry in the database. If there is |
d2712e8c724e
VMM/{Relocated,Handler}: reworked Relocated class, adjusted Handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
196
diff
changeset
|
659 |
already a relocated user with the given *emailaddress*, only the |
d2712e8c724e
VMM/{Relocated,Handler}: reworked Relocated class, adjusted Handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
196
diff
changeset
|
660 |
*targetaddress* for the relocated user will be updated.""" |
d2712e8c724e
VMM/{Relocated,Handler}: reworked Relocated class, adjusted Handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
196
diff
changeset
|
661 |
relocated = self.__getRelocated(emailaddress) |
215
33f727efa7c4
PEP-8-ified the work of the last days.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
208
diff
changeset
|
662 |
relocated.set_destination(EmailAddress(targetaddress)) |
80
5dedc673524e
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
78
diff
changeset
|
663 |
|
5dedc673524e
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
78
diff
changeset
|
664 |
def relocatedInfo(self, emailaddress): |
197
d2712e8c724e
VMM/{Relocated,Handler}: reworked Relocated class, adjusted Handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
196
diff
changeset
|
665 |
"""Returns the target address of the relocated user with the given |
d2712e8c724e
VMM/{Relocated,Handler}: reworked Relocated class, adjusted Handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
196
diff
changeset
|
666 |
*emailaddress*.""" |
80
5dedc673524e
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
78
diff
changeset
|
667 |
relocated = self.__getRelocated(emailaddress) |
215
33f727efa7c4
PEP-8-ified the work of the last days.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
208
diff
changeset
|
668 |
return relocated.get_info() |
80
5dedc673524e
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
78
diff
changeset
|
669 |
|
5dedc673524e
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
78
diff
changeset
|
670 |
def relocatedDelete(self, emailaddress): |
197
d2712e8c724e
VMM/{Relocated,Handler}: reworked Relocated class, adjusted Handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
196
diff
changeset
|
671 |
"""Deletes the relocated user with the given *emailaddress* from |
d2712e8c724e
VMM/{Relocated,Handler}: reworked Relocated class, adjusted Handler.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
196
diff
changeset
|
672 |
the database.""" |
80
5dedc673524e
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
78
diff
changeset
|
673 |
relocated = self.__getRelocated(emailaddress) |
5dedc673524e
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
78
diff
changeset
|
674 |
relocated.delete() |
5dedc673524e
* 'create_tables.pgsql'
Pascal Volk <neverseen@users.sourceforge.net>
parents:
78
diff
changeset
|
675 |
|
0
bb0aa2102206
Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
676 |
def __del__(self): |
196
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
677 |
if isinstance(self._dbh, PgSQL.Connection) and self._dbh._isOpen: |
65a3163bd113
VMM/{Alias,Handler}: reworked Alias class, adjusted Handler class.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
192
diff
changeset
|
678 |
self._dbh.close() |