summaryrefslogtreecommitdiff
path: root/Mailman/MTA
diff options
context:
space:
mode:
authorbwarsaw2002-08-23 20:32:05 +0000
committerbwarsaw2002-08-23 20:32:05 +0000
commit8aab93956d6b4df29b636653f3f25b0c5e11a340 (patch)
tree04e2e1e45e79d02efba4b64843f96299954d0614 /Mailman/MTA
parentb95b0781e6a494350bb3c7f0e5277910f0e807dc (diff)
downloadmailman-8aab93956d6b4df29b636653f3f25b0c5e11a340.tar.gz
mailman-8aab93956d6b4df29b636653f3f25b0c5e11a340.tar.zst
mailman-8aab93956d6b4df29b636653f3f25b0c5e11a340.zip
Patch set for SF bug #596565. Use symbolic user/group names instead
of numeric ids. Initial idea and patch by Todd Vierling, fleshed out by Barry. Specific changes here: checkperms(): Use MAILMAN_USER instead of MAILMAN_UID and getpwnam() and getgrnam() where appropriate.
Diffstat (limited to 'Mailman/MTA')
-rw-r--r--Mailman/MTA/Postfix.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/Mailman/MTA/Postfix.py b/Mailman/MTA/Postfix.py
index bf50cdf87..24c1c7e58 100644
--- a/Mailman/MTA/Postfix.py
+++ b/Mailman/MTA/Postfix.py
@@ -4,14 +4,14 @@
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
+# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
"""Creation/deletion hooks for the Postfix MTA.
@@ -21,6 +21,7 @@ import os
import time
import errno
import pwd
+import grp
from stat import *
from Mailman import mm_cfg
@@ -209,7 +210,7 @@ def _do_create(mlist, textfile, func):
# Now double check the virtual plain text file
if func is _addvirtual:
_check_for_virtual_loopaddr(mlist, textfile)
-
+
def create(mlist, cgi=0, nolock=0):
# Acquire the global list database lock
@@ -275,7 +276,7 @@ def _do_remove(mlist, textfile, virtualp):
infp.close()
outfp.close()
os.rename(textfile+'.tmp', textfile)
-
+
def remove(mlist, cgi=0):
# Acquire the global list database lock
@@ -325,16 +326,19 @@ def checkperms(state):
continue
if state.VERBOSE:
print _('checking ownership of %(dbfile)s')
- ownerok = stat[ST_UID] == mm_cfg.MAILMAN_UID
+ user = mm_cfg.MAILMAN_USER
+ ownerok = stat[ST_UID] == pwd.getpwnam(user)[2]
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)')
+ print _('%(dbfile)s owned by %(owner)s (must be owned by %(user)s')
state.ERRORS += 1
if state.FIX:
print _('(fixing)')
- os.chown(dbfile, mm_cfg.MAILMAN_UID, mm_cfg.MAILMAN_GID)
+ uid = pwd.getpwnam(user)[2]
+ gid = grp.getgrnam(mm_cfg.MAILMAN_GROUP)[2]
+ os.chown(dbfile, uid, gid)
else:
print