aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2019-07-05 17:37:17 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2019-07-05 17:37:17 +0300
commit4647af06b0d1911a96d84c5e58c4ea5122d86532 (patch)
tree49036176196db8ff19ab2ec7a57603851c5e3b5d
parentb3901df95ed4e0bba64522f7859b50de92d8db68 (diff)
downloadmailman-4647af06b0d1911a96d84c5e58c4ea5122d86532.tar.gz
mailman-4647af06b0d1911a96d84c5e58c4ea5122d86532.tar.bz2
Build findmail
-rw-r--r--GNUmakefile12
-rw-r--r--Mailman/Cgi/findmail.py74
-rw-r--r--Mailman/Cgi/listarchive.py2
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
96listarchive: 96define 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
106endef
107
108$(foreach tgt,listarchive findmail,$(eval $(call build_cgi_rule,$(tgt))))
106 109
107define geninstall 110define geninstall
108install-$(1):; 111install-$(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
129install-cgi: listarchive 132install-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
133install: install-cgi $(foreach tgt,$(TARGETS), install-$(tgt)) 137install: 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 @@
1import os
2import sys
3import cgi
4import mimetypes
5import time
6import glob
7import stat
8
9from Mailman import mm_cfg
10from Mailman import Utils
11from Mailman import MailList
12from Mailman import Errors
13from Mailman import i18n
14from Mailman.htmlformat import *
15from 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._
20i18n.set_language(mm_cfg.DEFAULT_SERVER_LANGUAGE)
21
22script_name = 'findmail'
23
24def 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

Return to:

Send suggestions and report system problems to the System administrator.