summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bin/genaliases10
1 files changed, 9 insertions, 1 deletions
diff --git a/bin/genaliases b/bin/genaliases
index 951c3eabc..b71a74d1b 100644
--- a/bin/genaliases
+++ b/bin/genaliases
@@ -31,6 +31,7 @@ Options:
import sys
import getopt
import dbhash
+import fcntl
import paths # path hacking
from Mailman import Utils
@@ -66,9 +67,13 @@ def main():
# we're doing it.
lock = Postfix.makelock()
lock.lock()
+ lockfp = None
try:
# Overwrite the current file contents, since we're going to be adding
- # all new entries.
+ # all new entries. See the discussion in Mailman/MTA/Postfix.py for
+ # why we do the locking this way.
+ lockfp = open(Postfix.DBFILE)
+ fcntl.flock(lockfp.fileno(), fcntl.LOCK_EX)
db = dbhash.open(Postfix.DBFILE, 'n')
fp = open(Postfix.TEXTFILE, 'w')
for listname in Utils.list_names():
@@ -77,6 +82,9 @@ def main():
db.sync()
fp.close()
finally:
+ if lockfp:
+ fcntl.flock(lockfp.fileno(), fcntl.LOCK_UN)
+ lockfp.close()
lock.unlock(unconditionally=1)