summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortwouters2001-07-24 11:56:56 +0000
committertwouters2001-07-24 11:56:56 +0000
commit2d7e83aaeb0bc43702b81d1a63d45c7657be000c (patch)
tree051d6c16ade1b1e39cec53683c0016a1496048ca
parent6580803e77476772353d94ca9f62b9992a374139 (diff)
downloadmailman-2d7e83aaeb0bc43702b81d1a63d45c7657be000c.tar.gz
mailman-2d7e83aaeb0bc43702b81d1a63d45c7657be000c.tar.zst
mailman-2d7e83aaeb0bc43702b81d1a63d45c7657be000c.zip
check_privs(): new function that drops root privileges (if we have them) and
complains if we aren't running as the right user, gets called from main(). Should we check for the availability of os.(g|s)et(u|g)id ?
-rw-r--r--bin/mailmanctl12
1 files changed, 12 insertions, 0 deletions
diff --git a/bin/mailmanctl b/bin/mailmanctl
index 73312415e..e305e9b6c 100644
--- a/bin/mailmanctl
+++ b/bin/mailmanctl
@@ -104,6 +104,17 @@ def kill_subrunners(sig):
os.unlink(mm_cfg.PIDFILE)
+def check_privs():
+ # Should we check for the availability of these functions ?
+ if os.getuid() == 0:
+ os.setgid(mm_cfg.MAILMAN_GID)
+ os.setuid(mm_cfg.MAILMAN_UID)
+ if os.getuid() <> mm_cfg.MAILMAN_UID:
+ print >> sys.stderr, _("This program should only be run as root "
+ "or as the Mailman user.")
+ sys.exit(1)
+
+
def main():
try:
opts, args = getopt.getopt(sys.argv[1:], 'hn',
@@ -128,6 +139,7 @@ def main():
if command not in ('start', 'stop', 'restart'):
usage(1, _('Bad command: %(command)s'))
+ check_privs()
# Handle the commands
if command == 'stop':
# Sent the master qrunner process a SIGINT, which is equivalent to