diff options
| author | bwarsaw | 2002-03-01 03:22:26 +0000 |
|---|---|---|
| committer | bwarsaw | 2002-03-01 03:22:26 +0000 |
| commit | ec853c67da09434f4fd56e9bac8b7065bb1fa03c (patch) | |
| tree | 32f27ef37c3e9d107ad311c81951c500bd41f12e | |
| parent | dd19ab8c2c701b6c49e1d87f827596ba17826a06 (diff) | |
| download | mailman-ec853c67da09434f4fd56e9bac8b7065bb1fa03c.tar.gz mailman-ec853c67da09434f4fd56e9bac8b7065bb1fa03c.tar.zst mailman-ec853c67da09434f4fd56e9bac8b7065bb1fa03c.zip | |
| -rw-r--r-- | Mailman/MTA/Postfix.py | 76 |
1 files changed, 43 insertions, 33 deletions
diff --git a/Mailman/MTA/Postfix.py b/Mailman/MTA/Postfix.py index 69021da91..6cd180b3c 100644 --- a/Mailman/MTA/Postfix.py +++ b/Mailman/MTA/Postfix.py @@ -277,37 +277,47 @@ def remove(mlist, cgi=0): def checkperms(state): targetmode = S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP - if state.VERBOSE: - print _('checking permissions on %(DBFILE)s') - try: - stat = os.stat(DBFILE) - except OSError, e: - if e.errno <> errno.ENOENT: raise - return - if (stat[ST_MODE] & targetmode) <> targetmode: - state.ERRORS += 1 - octmode = oct(stat[ST_MODE]) - print _('%(DBFILE)s permissions must be 066x (got %(octmode)s)'), - if state.FIX: - print _('(fixing)') - os.chmod(DBFILE, stat[ST_MODE] | targetmode) - else: - print - # Make sure the aliases.db is owned by root. We don't need to check the - # group ownership of the file, since check_perms checks this itself. - if state.VERBOSE: - print _('checking ownership of %(DBFILE)s') - rootuid = pwd.getpwnam('mailman')[2] - ownerok = stat[ST_UID] == rootuid - if not ownerok: + for file in ALIASFILE, VIRTFILE: + if state.VERBOSE: + print _('checking permissions on %(file)s') + stat = None try: - owner = pwd.getpwuid(stat[ST_UID])[0] - except KeyError: - owner = 'uid %d' % stat[ST_UID] - print _('%(DBFILE)s owned by %(owner)s (must be owned by mailman)') - state.ERRORS += 1 - if state.FIX: - print _('(fixing)') - os.chown(DBFILE, rootuid, mm_cfg.MAILMAN_GID) - else: - print + stat = os.stat(file) + except OSError, e: + if e.errno <> errno.ENOENT: + raise + if stat and (stat[ST_MODE] & targetmode) <> targetmode: + state.ERRORS += 1 + octmode = oct(stat[ST_MODE]) + print _('%(file)s permissions must be 066x (got %(octmode)s)'), + if state.FIX: + print _('(fixing)') + os.chmod(file, stat[ST_MODE] | targetmode) + else: + print + # Make sure the corresponding .db files are owned by the Mailman user. + # We don't need to check the group ownership of the file, since + # check_perms checks this itself. + dbfile = file + '.db' + stat = None + try: + stat = os.stat(dbfile) + except OSError, e: + if e.errno <> errno.ENOENT: + raise + continue + if state.VERBOSE: + print _('checking ownership of %(dbfile)s') + ownerok = stat[ST_UID] == mm_cfg.MAILMAN_UID + if not ownerok: + try: + owner = pwd.getpwuid(stat[ST_UID])[0] + except KeyError: + owner = 'uid %d' % stat[ST_UID] + print _('%(dbfile)s owned by %(owner)s (must be owned by Mailman)') + state.ERRORS += 1 + if state.FIX: + print _('(fixing)') + os.chown(dbfile, mm_cfg.MAILMAN_UID, mm_cfg.MAILMAN_GID) + else: + print |
