summaryrefslogtreecommitdiff
path: root/Mailman/Utils.py
diff options
context:
space:
mode:
authorbwarsaw2001-05-09 06:32:39 +0000
committerbwarsaw2001-05-09 06:32:39 +0000
commite4a3a0e44202e07665c6dc84fcaf16951372095b (patch)
treea978273f66593a6069a71df75d5c50ff6b856016 /Mailman/Utils.py
parent4050387841e1af3d090f18c47444ebc9aa531769 (diff)
downloadmailman-e4a3a0e44202e07665c6dc84fcaf16951372095b.tar.gz
mailman-e4a3a0e44202e07665c6dc84fcaf16951372095b.tar.zst
mailman-e4a3a0e44202e07665c6dc84fcaf16951372095b.zip
Diffstat (limited to 'Mailman/Utils.py')
-rw-r--r--Mailman/Utils.py62
1 files changed, 53 insertions, 9 deletions
diff --git a/Mailman/Utils.py b/Mailman/Utils.py
index 0332aee61..f72e451e5 100644
--- a/Mailman/Utils.py
+++ b/Mailman/Utils.py
@@ -52,7 +52,6 @@ def list_exists(listname):
return os.path.exists(dbfile) or os.path.exists(lastfile)
-
def list_names():
"""Return the names of all lists in default list directory."""
got = []
@@ -376,18 +375,29 @@ def GetRandomSeed():
return c
return "%c%c" % tuple(map(mkletter, (chr1, chr2)))
-def SetSiteAdminPassword(pw):
+
+
+def set_global_password(pw, siteadmin=1):
+ if siteadmin:
+ filename = mm_cfg.SITE_PW_FILE
+ else:
+ filename = mm_cfg.LISTCREATOR_PW_FILE
omask = os.umask(026) # rw-r-----
try:
- fp = open(mm_cfg.SITE_PW_FILE, 'w')
+ fp = open(filename, 'w')
fp.write(sha.new(pw).hexdigest() + '\n')
fp.close()
finally:
os.umask(omask)
+
-def CheckSiteAdminPassword(response):
+def check_global_password(response, siteadmin=1):
+ if siteadmin:
+ filename = mm_cfg.SITE_PW_FILE
+ else:
+ filename = mm_cfg.LISTCREATOR_PW_FILE
try:
- fp = open(mm_cfg.SITE_PW_FILE)
+ fp = open(filename)
challenge = fp.read()[:-1] # strip off trailing nl
fp.close()
except IOError, e:
@@ -518,10 +528,11 @@ def is_administrivia(msg):
def mkdir(dir, mode=02775):
"""Wraps os.mkdir() in a umask saving try/finally.
-Two differences from os.mkdir():
- - umask is forced to 0 during mkdir()
- - default mode is 02775
-"""
+
+ Two differences from os.mkdir():
+ - umask is forced to 0 during mkdir()
+ - default mode is 02775
+ """
ou = os.umask(0)
try:
os.mkdir(dir, mode)
@@ -529,6 +540,26 @@ Two differences from os.mkdir():
os.umask(ou)
+def rmdirhier(dir):
+ """Like `rm -r'
+
+ Completely and recursively removes a directory and all its contents,
+ unlike os.removedirs().
+ """
+ files = []
+ def ls(arg, dirname, names):
+ for name in names:
+ arg.append(os.path.join(dirname, name))
+ os.path.walk(dir, ls, files)
+ files.reverse()
+ for file in files:
+ if os.path.isdir(file):
+ os.rmdir(file)
+ else:
+ os.unlink(file)
+ os.rmdir(dir)
+
+
def GetRequestURI(fallback=None):
"""Return the full virtual path this CGI script was invoked with.
@@ -579,3 +610,16 @@ def GetLanguageDescr(lang):
def GetCharSet(lang):
return mm_cfg.LC_DESCRIPTIONS[lang][1]
+
+
+
+def get_domain():
+ host = os.environ.get('HTTP_HOST', os.environ.get('SERVER_NAME'))
+ port = os.environ.get('SERVER_PORT')
+ # Strip off the port if there is one
+ if port and host.endswith(':' + port):
+ host = host[:-len(port)-1]
+ if mm_cfg.VIRTUAL_HOST_OVERVIEW and host:
+ return host
+ else:
+ return mm_cfg.DEFAULT_HOST_NAME