Update of /cvsroot/mailman/mailman3/src/mailman/config
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29190/src/mailman/config
Modified Files:
__init__.py datatypes.py
Removed Files:
logs.py
Log Message:
Updates for the new configuration regime.
Index: __init__.py
===================================================================
RCS file: /cvsroot/mailman/mailman3/src/mailman/config/__init__.py,v
retrieving revision 3.1
retrieving revision 3.2
diff -u -d -r3.1 -r3.2
--- __init__.py 30 Mar 2004 02:57:29 -0000 3.1
+++ __init__.py 20 Apr 2004 04:15:24 -0000 3.2
@@ -20,75 +20,67 @@
import sys
from mailman.config.datatypes import *
-from mailman.config.logs import *
import ZConfig
class Configuration:
- def configure(self, schemaname, configfile):
+ def __init__(self):
+ self._conf = None
+ self._dirs = []
+
+ def __getattr__(self, attr):
+ if attr.startswith('getSection'):
+ raise AttributeError(attr)
+ return getattr(self._conf, attr)
+
+ def add_deferred_mkdir(self, dir):
+ self._dirs.append(dir)
+
+ def configure(self, configfile):
# Load the schema definition
schemadir = os.path.join(os.path.dirname(__file__), 'schemas')
- schemapath = os.path.join(schemadir, schemaname + '.xml')
+ schemapath = os.path.join(schemadir, 'mailman.xml')
schema = ZConfig.loadSchema(schemapath)
# Load configuration file
- conf, ignore = ZConfig.loadConfig(schema, configfile)
- # Get the names of the types defined in the configuration file, and
- # assign them as attributes on the global configuration object.
- secdef = conf.getSectionDefinition()
- for typename in secdef.gettypenames():
- secval = getattr(conf, typename, None)
- setattr(self, typename, secval)
- # Perform any section-specific post-processing
- for typename in secdef.gettypenames():
- meth = getattr(self, 'post_' + typename, None)
- if meth:
- meth()
- # Do global post processing
- self.postProcess()
-
- def post_mailman(self):
- __pychecker__ = 'no-classattr'
-
- # Post-process the qrunner specification
- qrunners = self.mailman.qrunners = {}
- for qrname, qrclass, qrcount in self.mailman.queue:
- qrunners[qrname] = qrclass, qrcount
-
- def post_logs(self):
- self.logs.loglevels = dict(self.logs.log)
-
- def post_domains(self):
- # Post-process the virtual domain configuration
- bydomain = self.domains.bydomain = {}
- bywebhost = self.domains.bywebhost = {}
- bymailhost = self.domains.bymailhost = {}
- for domain, mailhost, webhost in self.domains.domain:
- bydomain[domain] = mailhost, webhost
- bywebhost[webhost] = domain
- bymailhost[mailhost] = domain
-
- def post_databases(self):
- from mailman.dbmgr import dbmgr
- for stype, sobj in self.databases.storage:
- db = getattr(self.databases, sobj)
- setattr(dbmgr, stype, db)
-
- def postProcess(self):
- pass
+ self._conf, ignore = ZConfig.loadConfig(schema, configfile)
+ # If running as root, set the process's primary and secondary groups,
+ # and user id
+ myuid = os.getuid()
+ targetuid = self.privileges.user.id
+ if myuid == 0:
+ os.setgid(self.privileges.group.id)
+ # Set the process's supplimental groups.
+ groups = [x[2] for x in grp.getgrall()
+ if self.privileges.user.name in x[3]]
+ os.setgroups(groups)
+ # Set the process's user.
+ os.setuid(self.privileges.user.id)
+ elif myuid <> targetuid:
+ print >> sys.stderr, 'UID mismatch. real: %s, target: %s (%s)' % (
+ myuid, self.privileges.user.id, self.privileges.user.name)
+ print >> sys.stderr, 'Permission problems may occur.'
+ # Now that we're running at the proper permission level, create dirs
+ for d in self._dirs:
+ # Make the given directory if it doesn't exist, but otherwise do
+ # no conversion of the datatype.
+ omask = os.umask(0)
+ try:
+ try:
+ os.makedirs(d, 02770)
+ except OSError, e:
+ if e.errno <> errno.EEXIST: raise
+ finally:
+ os.umask(omask)
+ # Start the loggers with a umask that results in 0660 perms.
+ omask = os.umask(006)
+ try:
+ self._conf.eventlog()
+ for log in self._conf.logs:
+ log()
+ finally:
+ os.umask(omask)
configuration = Configuration()
-
-
-
-def startup():
- # Initialize the logging subsystem
- from mailman.config import logs
- logs.startup()
-
-
-
-def shutdown():
- pass
Index: datatypes.py
===================================================================
RCS file: /cvsroot/mailman/mailman3/src/mailman/config/datatypes.py,v
retrieving revision 3.1
retrieving revision 3.2
diff -u -d -r3.1 -r3.2
--- datatypes.py 4 Apr 2004 04:21:35 -0000 3.1
+++ datatypes.py 20 Apr 2004 04:15:24 -0000 3.2
@@ -36,17 +36,53 @@
-def queue(s):
- # Convert 'runner queue class [count]' to a tuple of the same form, with
- # count converted to an integer and efaulting to 1 if not given.
- parts = s.split()
- if len(parts) == 2:
- parts.append(1)
- elif len(parts) == 3:
- parts[-1] = int(parts[-1])
- else:
- raise TypeError(s)
- return tuple(parts)
+class queue:
+ def __init__(self, s):
+ # Parse 'runner queue class [count]', with count converted to an
+ # integer and defaulting to 1 if not given.
+ parts = s.split()
+ if len(parts) == 2:
+ parts.append(1)
+ elif len(parts) == 3:
+ parts[-1] = int(parts[-1])
+ else:
+ raise TypeError(s)
+ self.qrunner, self.qclass, self.count = parts
+
+
+def qrunners(s):
+ s.qrunners = {}
+ for q in s.queue:
+ s.qrunners[q.qrunner] = q.qclass, q.count
+ return s
+
+
+
+class domain:
+ def __init__(self, s):
+ parts = s.split()
+ if len(parts) == 1:
+ self.domain, self.mailhost, self.webhost = parts * 3
+ elif len(parts) == 2:
+ self.domain = parts[0]
+ self.mailhost = parts[1]
+ self.webhost = parts[1]
+ elif len(parts) <> 3:
+ raise errors.ConfigurationError('Bad domain specification: %s' % s)
+ else:
+ self.domain, self.mailhost, self.webhost = parts
+
+
+def domains(s):
+ # Post-process the virtual domain configuration
+ s.bydomain = {}
+ s.bywebhost = {}
+ s.bymailhost = {}
+ for d in s.domain:
+ s.bydomain[d.domain] = d.mailhost, d.webhost
+ s.bywebhost[d.webhost] = d.domain
+ s.bymailhost[d.mailhost] = d.domain
+ return s
@@ -74,30 +110,34 @@
-def userid(s):
- try:
- uid = int(s)
+class username:
+ def __init__(self, s):
try:
- uname = pwd.getpwuid(uid)[0]
- except KeyError:
- uname = '<uid %s>' % uid
- except ValueError:
- uname = s
- uid = pwd.getpwnam(s)[2]
- return uid, uname
+ uid = int(s)
+ try:
+ uname = pwd.getpwuid(uid)[0]
+ except KeyError:
+ uname = '<uid %s>' % uid
+ except ValueError:
+ uname = s
+ uid = pwd.getpwnam(s)[2]
+ self.id = uid
+ self.name = uname
-def groupid(s):
- try:
- gid = int(s)
+class groupname:
+ def __init__(self, s):
try:
- gname = grp.getgrgid(gid)[0]
- except KeyError:
- gname = '<gid %s>' % gid
- except ValueError:
- gname = s
- gid = grp.getgrnam(s)[2]
- return gid, gname
+ gid = int(s)
+ try:
+ gname = grp.getgrgid(gid)[0]
+ except KeyError:
+ gname = '<gid %s>' % gid
+ except ValueError:
+ gname = s
+ gid = grp.getgrnam(s)[2]
+ self.id = gid
+ self.name = gname
@@ -112,18 +152,6 @@
-def domain(s):
- parts = s.split()
- if len(parts) == 1:
- return parts[0], parts[0], parts[0]
- if len(parts) == 2:
- return parts[0], parts[1], parts[1]
- if len(parts) <> 3:
- raise errors.ConfigurationError('Bad domain specification: %s' % s)
- return parts
-
-
-
def bdblist(s):
from mailman.berkeleydb.bdblist import BDBListDatabase
return BDBListDatabase(s.path, s.checkpoint_interval, s.cachesize)
@@ -138,14 +166,17 @@
from mailman.berkeleydb.bdbmember import BDBMemberDatabase
return BDBMemberDatabase(s.path, s.checkpoint_interval, s.cachesize)
+
def stublist(s):
from mailman.stubbackend.stubimpl import StubListStorage
return StubListStorage()
+
def stubuser(s):
from mailman.stubbackend.stubimpl import StubUserStorage
return StubUserStorage()
+
def storage(s):
parts = s.split()
if len(parts) <> 2:
@@ -153,3 +184,11 @@
if parts[0] not in ('lists', 'users', 'messages'):
raise errors.ConfigurationError('Bad storage type: %s' % parts[0])
return parts[0], parts[1]
+
+
+def databases(s):
+ from mailman.dbmgr import dbmgr
+ for stype, sobj in s.storage:
+ db = getattr(s, sobj)
+ setattr(dbmgr, stype, db)
+ return s
--- logs.py DELETED ---
_______________________________________________
Mailman-checkins mailing list
[EMAIL PROTECTED]
Unsubscribe: http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org