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 | |||
@@ -93,16 +93,19 @@ config: | |||
93 | fi | 93 | fi |
94 | @mv .config.tmp .config | 94 | @mv .config.tmp .config |
95 | 95 | ||
96 | listarchive: | 96 | define build_cgi_rule = |
97 | @if [ -z "$(MAILMANSRC)" ]; then \ | 97 | $(1):; @if [ -z "$(MAILMANSRC)" ]; then \ |
98 | echo >&2 "Please set MAILMANSRC to point to the mailman-2.x tree"; \ | 98 | echo >&2 "Please set MAILMANSRC to point to the mailman-2.x tree"; \ |
99 | exit 1; \ | 99 | exit 1; \ |
100 | elif ! test -w $(MAILMANSRC)/src; then \ | 100 | elif ! test -w $(MAILMANSRC)/src; then \ |
101 | echo >&2 "$(MAILMANSRC)/src must be writable"; \ | 101 | echo >&2 "$(MAILMANSRC)/src must be writable"; \ |
102 | exit 1; \ | 102 | exit 1; \ |
103 | else \ | 103 | else \ |
104 | make -C $(MAILMANSRC)/src CGI_PROGS=listarchive listarchive; \ | 104 | make -C $(MAILMANSRC)/src CGI_PROGS=$(1) $(1); \ |
105 | fi | 105 | fi |
106 | endef | ||
107 | |||
108 | $(foreach tgt,listarchive findmail,$(eval $(call build_cgi_rule,$(tgt)))) | ||
106 | 109 | ||
107 | define geninstall | 110 | define geninstall |
108 | install-$(1):; | 111 | install-$(1):; |
@@ -126,9 +129,10 @@ TARGETS=\ | |||
126 | 129 | ||
127 | $(foreach tgt,$(TARGETS),$(eval $(call geninstall,$(tgt)))) | 130 | $(foreach tgt,$(TARGETS),$(eval $(call geninstall,$(tgt)))) |
128 | 131 | ||
129 | install-cgi: listarchive | 132 | install-cgi: listarchive findmail |
130 | install -d $(DESTDIR)$(CGIDIR) | 133 | install -d $(DESTDIR)$(CGIDIR) |
131 | install -o root -g mailman -m 2755 $(MAILMANSRC)/src/listarchive $(DESTDIR)$(CGIDIR) | 134 | install -o root -g mailman -m 2755 $(MAILMANSRC)/src/listarchive $(DESTDIR)$(CGIDIR) |
135 | install -o root -g mailman -m 2755 $(MAILMANSRC)/src/findmail $(DESTDIR)$(CGIDIR) | ||
132 | 136 | ||
133 | install: install-cgi $(foreach tgt,$(TARGETS), install-$(tgt)) | 137 | install: install-cgi $(foreach tgt,$(TARGETS), install-$(tgt)) |
134 | 138 | ||
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 @@ | |||
1 | import os | ||
2 | import sys | ||
3 | import cgi | ||
4 | import mimetypes | ||
5 | import time | ||
6 | import glob | ||
7 | import stat | ||
8 | |||
9 | from Mailman import mm_cfg | ||
10 | from Mailman import Utils | ||
11 | from Mailman import MailList | ||
12 | from Mailman import Errors | ||
13 | from Mailman import i18n | ||
14 | from Mailman.htmlformat import * | ||
15 | from Mailman.Logging.Syslog import syslog | ||
16 | |||
17 | # Set up i18n. Until we know which list is being requested, we use the | ||
18 | # server's default. | ||
19 | _ = i18n._ | ||
20 | i18n.set_language(mm_cfg.DEFAULT_SERVER_LANGUAGE) | ||
21 | |||
22 | script_name = 'findmail' | ||
23 | |||
24 | def main(): | ||
25 | env = os.environ | ||
26 | doc = Document() | ||
27 | doc.set_language(mm_cfg.DEFAULT_SERVER_LANGUAGE) | ||
28 | |||
29 | form = cgi.FieldStorage() | ||
30 | listname = form.getvalue('idxname','') | ||
31 | |||
32 | if listname: | ||
33 | try: | ||
34 | mlist = MailList.MailList(listname, lock=0) | ||
35 | except Errors.MMListError, e: | ||
36 | # Avoid cross-site scripting attacks | ||
37 | safelistname = Utils.websafe(listname) | ||
38 | msg = _('No such list <em>%(safelistname)s</em>') | ||
39 | doc.SetTitle(_("Archive Error - %(msg)s")) | ||
40 | doc.AddItem(Header(2, msg)) | ||
41 | print doc.Format() | ||
42 | syslog('error', 'No such list "%s": %s\n', listname, e) | ||
43 | return | ||
44 | |||
45 | if mlist.archive_private: | ||
46 | username = form.getvalue('username', '') | ||
47 | password = form.getvalue('password', '') | ||
48 | message = '' | ||
49 | if not mlist.WebAuthenticate((mm_cfg.AuthUser, | ||
50 | mm_cfg.AuthListModerator, | ||
51 | mm_cfg.AuthListAdmin, | ||
52 | mm_cfg.AuthSiteAdmin), | ||
53 | password, username): | ||
54 | if form.has_key('submit'): | ||
55 | # This is a re-authorization attempt | ||
56 | message = Bold(FontSize('+1', _('Authorization failed.'))).Format() | ||
57 | # Output the password form | ||
58 | charset = Utils.GetCharSet(mlist.preferred_language) | ||
59 | print 'Content-type: text/html; charset=' + charset + '\n\n' | ||
60 | # Put the original full path in the authorization form, but | ||
61 | # avoid trailing slash if we're not adding parts. | ||
62 | # We add it below. | ||
63 | action = mlist.GetScriptURL(script_name, absolute=1) + \ | ||
64 | '?' + os.getenv('QUERY_STRING') | ||
65 | # Escape web input parameter to avoid cross-site scripting. | ||
66 | print Utils.maketext('private.html', | ||
67 | {'action' : Utils.websafe(action), | ||
68 | 'realname': mlist.real_name, | ||
69 | 'message' : message, | ||
70 | }, mlist=mlist) | ||
71 | return | ||
72 | |||
73 | finder = os.getenv('MAIL_FINDER_CGI') | ||
74 | 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(): | |||
196 | return | 196 | return |
197 | 197 | ||
198 | loc = script_name + '/' + listname + '/' + plist[n] + '/' | 198 | loc = script_name + '/' + listname + '/' + plist[n] + '/' |
199 | print "Location: %s%s\n" % (mm_cfg.DEFAULT_HOST_NAME or mm_cfg.DEFAULT_EMAIL_HOST, loc) | 199 | print "Location: http://mail.gnu.org.ua%s\n" % loc |
200 | return | 200 | return |
201 | 201 | ||
202 | 202 | ||