diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2019-07-05 17:37:17 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2019-07-05 17:37:17 +0300 |
commit | 4647af06b0d1911a96d84c5e58c4ea5122d86532 (patch) | |
tree | 49036176196db8ff19ab2ec7a57603851c5e3b5d | |
parent | b3901df95ed4e0bba64522f7859b50de92d8db68 (diff) | |
download | mailman-4647af06b0d1911a96d84c5e58c4ea5122d86532.tar.gz mailman-4647af06b0d1911a96d84c5e58c4ea5122d86532.tar.bz2 |
Build findmail
-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 @@ -90,22 +90,25 @@ config: echo >&2 "PREFIX must be supplied"; \ rm .config.tmp; \ exit 1; \ 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):; install -d $$(DESTDIR)$$($(shell echo $(1) | tr '[:lower:]' '[:upper:]')DIR) tar -C $(1) -cf - . | tar -C $$(DESTDIR)$$($(shell echo $(1) | tr '[:lower:]' '[:upper:]')DIR) -xpf - endef @@ -123,15 +126,16 @@ TARGETS=\ bin\ man\ htdocs $(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)) clean: @rm -f $(MAILMANSRC)/src/listarchive 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 @@ -193,13 +193,13 @@ def main(): 'script' : script_name }, mlist = mlist) print Utils.maketext('list/footer.html', {}) 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 realname = mlist.real_name i18n.set_language(mlist.preferred_language) |