summaryrefslogtreecommitdiff
path: root/bin/genaliases
diff options
context:
space:
mode:
authorbwarsaw2001-11-21 18:50:35 +0000
committerbwarsaw2001-11-21 18:50:35 +0000
commit08d5844545385a3c40ff0413389fcbcdfac1a31a (patch)
tree12117a11ff8608c8f9c1cc1fa43d6ad34873cf9a /bin/genaliases
parent2f01013a13cf2a237728b4835c372c3c9cda2fe7 (diff)
downloadmailman-08d5844545385a3c40ff0413389fcbcdfac1a31a.tar.gz
mailman-08d5844545385a3c40ff0413389fcbcdfac1a31a.tar.zst
mailman-08d5844545385a3c40ff0413389fcbcdfac1a31a.zip
Better support for Berkeley DB link problems (I hope). The problem is
if Python and Postfix have incompatible versions of BerkeleyDB, genaliases either will fail or will break Postfix. :( Because Robin Dunn's PyBSDDB3 should be compatible with the widest range of existing BDB libs, we try to import and use it first. Failing that, fallback to the standard bsddb module. In either case, we really don't need the dbhash module, which knows nothing about bsddb3.
Diffstat (limited to 'bin/genaliases')
-rw-r--r--bin/genaliases27
1 files changed, 21 insertions, 6 deletions
diff --git a/bin/genaliases b/bin/genaliases
index 3bf86cfb2..7fb1b73ce 100644
--- a/bin/genaliases
+++ b/bin/genaliases
@@ -31,9 +31,19 @@ Options:
import sys
import os
import getopt
-import dbhash
import fcntl
+# The issue here is that we must be using a Berkeley DB version in Python
+# that's compatible with the version that Postfix uses. First, we'll try
+# Robin Dunn's PyBSDDB3 module if its available, since that should be
+# backwards compatible with the widest range of existing libraries.
+# Otherwise,we'll fall back to whatever's available in Python. Then about the
+# best we can do is just report any errors that come up.
+try:
+ import bsddb3 as bsddb
+except ImportError:
+ import bsddb
+
import paths # path hacking
from Mailman import Utils
from Mailman import MailList
@@ -63,9 +73,9 @@ def main():
if args:
usage(1)
- # Open the text file and dbhash files, truncating any data already there.
- # We need to acquire a lock so nobody tries to update the files while
- # we're doing it.
+ # Open the text file and Berkeley DB files, truncating any data already
+ # there. We need to acquire a lock so nobody tries to update the files
+ # while we're doing it.
lock = Postfix.makelock()
lock.lock()
lockfp = None
@@ -78,7 +88,7 @@ def main():
# why we do the locking this way.
lockfp = open(Postfix.DBFILE, 'w')
fcntl.flock(lockfp.fileno(), fcntl.LOCK_EX)
- db = dbhash.open(Postfix.DBFILE, 'n')
+ db = bsddb.hashopen(Postfix.DBFILE, 'n')
fp = open(Postfix.TEXTFILE, 'w')
for listname in Utils.list_names():
mlist = MailList.MailList(listname, lock=0)
@@ -95,4 +105,9 @@ def main():
if __name__ == '__main__':
- main()
+ try:
+ main()
+ except bsddb.error, (code, msg):
+ if code <> 22: raise
+ print >> sys.stderr, _(
+ "Python and Postfix have incompatible Berkeley DB libraries!")