diff options
-rw-r--r-- | GNUmakefile | 12 | ||||
-rw-r--r-- | Mailman/Cgi/findmail.py | 74 | ||||
-rw-r--r-- | Mailman/Cgi/listarchive.py | 2 |
3 files changed, 83 insertions, 5 deletions
diff --git a/GNUmakefile b/GNUmakefile index 73e92b1..b5b4909 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -93,16 +93,19 @@ config: fi @mv .config.tmp .config -listarchive: - @if [ -z "$(MAILMANSRC)" ]; then \ +define build_cgi_rule = +$(1):; @if [ -z "$(MAILMANSRC)" ]; then \ echo >&2 "Please set MAILMANSRC to point to the mailman-2.x tree"; \ exit 1; \ elif ! test -w $(MAILMANSRC)/src; then \ echo >&2 "$(MAILMANSRC)/src must be writable"; \ exit 1; \ else \ - make -C $(MAILMANSRC)/src CGI_PROGS=listarchive listarchive; \ + make -C $(MAILMANSRC)/src CGI_PROGS=$(1) $(1); \ fi +endef + +$(foreach tgt,listarchive findmail,$(eval $(call build_cgi_rule,$(tgt)))) define geninstall install-$(1):; @@ -126,9 +129,10 @@ TARGETS=\ $(foreach tgt,$(TARGETS),$(eval $(call geninstall,$(tgt)))) -install-cgi: listarchive +install-cgi: listarchive findmail install -d $(DESTDIR)$(CGIDIR) install -o root -g mailman -m 2755 $(MAILMANSRC)/src/listarchive $(DESTDIR)$(CGIDIR) + install -o root -g mailman -m 2755 $(MAILMANSRC)/src/findmail $(DESTDIR)$(CGIDIR) install: install-cgi $(foreach tgt,$(TARGETS), install-$(tgt)) diff --git a/Mailman/Cgi/findmail.py b/Mailman/Cgi/findmail.py new file mode 100644 index 0000000..d5f3c25 --- /dev/null +++ b/Mailman/Cgi/findmail.py @@ -0,0 +1,74 @@ +import os +import sys +import cgi +import mimetypes +import time +import glob +import stat + +from Mailman import mm_cfg +from Mailman import Utils +from Mailman import MailList +from Mailman import Errors +from Mailman import i18n +from Mailman.htmlformat import * +from Mailman.Logging.Syslog import syslog + +# Set up i18n. Until we know which list is being requested, we use the +# server's default. +_ = i18n._ +i18n.set_language(mm_cfg.DEFAULT_SERVER_LANGUAGE) + +script_name = 'findmail' + +def main(): + env = os.environ + doc = Document() + doc.set_language(mm_cfg.DEFAULT_SERVER_LANGUAGE) + + form = cgi.FieldStorage() + listname = form.getvalue('idxname','') + + if listname: + try: + mlist = MailList.MailList(listname, lock=0) + except Errors.MMListError, e: + # Avoid cross-site scripting attacks + safelistname = Utils.websafe(listname) + msg = _('No such list <em>%(safelistname)s</em>') + doc.SetTitle(_("Archive Error - %(msg)s")) + doc.AddItem(Header(2, msg)) + print doc.Format() + syslog('error', 'No such list "%s": %s\n', listname, e) + return + + if mlist.archive_private: + username = form.getvalue('username', '') + password = form.getvalue('password', '') + message = '' + if not mlist.WebAuthenticate((mm_cfg.AuthUser, + mm_cfg.AuthListModerator, + mm_cfg.AuthListAdmin, + mm_cfg.AuthSiteAdmin), + password, username): + if form.has_key('submit'): + # This is a re-authorization attempt + message = Bold(FontSize('+1', _('Authorization failed.'))).Format() + # Output the password form + charset = Utils.GetCharSet(mlist.preferred_language) + print 'Content-type: text/html; charset=' + charset + '\n\n' + # Put the original full path in the authorization form, but + # avoid trailing slash if we're not adding parts. + # We add it below. + action = mlist.GetScriptURL(script_name, absolute=1) + \ + '?' + os.getenv('QUERY_STRING') + # Escape web input parameter to avoid cross-site scripting. + print Utils.maketext('private.html', + {'action' : Utils.websafe(action), + 'realname': mlist.real_name, + 'message' : message, + }, mlist=mlist) + return + + finder = os.getenv('MAIL_FINDER_CGI') + os.execl(finder, os.path.basename(finder)) diff --git a/Mailman/Cgi/listarchive.py b/Mailman/Cgi/listarchive.py index 873a7be..40c6fcf 100644 --- a/Mailman/Cgi/listarchive.py +++ b/Mailman/Cgi/listarchive.py @@ -196,7 +196,7 @@ def main(): return loc = script_name + '/' + listname + '/' + plist[n] + '/' - print "Location: %s%s\n" % (mm_cfg.DEFAULT_HOST_NAME or mm_cfg.DEFAULT_EMAIL_HOST, loc) + print "Location: http://mail.gnu.org.ua%s\n" % loc return |