~joostvb/mailman/2.1-pgp-smime

« back to all changes in this revision

Viewing changes to scripts/driver

  • Committer: Mark Sapiro
  • Date: 2009-01-10 20:44:55 UTC
  • mto: (414.15.6 stable-sc)
  • mto: This revision was merged to the branch mainline in revision 524.
  • Revision ID: mark@msapiro.net-20090110204455-vxj8lu3ulirg9mt9
- Fixed the admin Membership List Find member function so the 'letter'
  links to a chunked result would still be limited to the Find member
  search. SF patch #1532081.

- Changed scripts/driver to return a 405 status for non GET, POST, HEAD
  methods. SF patch #1578756.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# -*- python -*-
2
2
 
3
 
# Copyright (C) 1998-2004 by the Free Software Foundation, Inc.
 
3
# Copyright (C) 1998-2009 by the Free Software Foundation, Inc.
4
4
#
5
5
# This program is free software; you can redistribute it and/or
6
6
# modify it under the terms of the GNU General Public License
14
14
#
15
15
# You should have received a copy of the GNU General Public License
16
16
# along with this program; if not, write to the Free Software
17
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
 
18
# USA.
18
19
 
19
20
# This better succeed.  If this fails, Python is royally screwed so we might
20
21
# as well let the Web server give us a fatal and obtrusive error.
 
22
import os
21
23
import sys
22
24
 
23
25
# From here on we are as bulletproof as possible!
51
53
#   no way to catch that.  Mailman's install procedure should make this highly
52
54
#   unlikely.
53
55
#
54
 
# - The sys module could be royally screwed, probably we couldn't import it.
55
 
#   This would indicate a serious problem with the Python installation, so
56
 
#   it's also highly unlikely to occur.
 
56
# - The os or sys modules could be royally screwed, probably we couldn't
 
57
#   import one or both of them.  This would indicate a serious problem with
 
58
#   the Python installation, so it's also highly unlikely to occur.
 
59
 
57
60
 
58
61
 
59
62
def run_main():
98
101
            try:
99
102
                sys.stderr = logger
100
103
                sys.stdout = tempstdout
101
 
                main()
 
104
                # Check for a valid request method.
 
105
                request_method = os.environ.get('REQUEST_METHOD')
 
106
                if not request_method.lower() in ['get', 'post', 'head']:
 
107
                    print 'Status: 405 Method not allowed'
 
108
                    print 'Content-type: text/plain'
 
109
                    print
 
110
                    print '%s method is not allowed' % request_method
 
111
                else:
 
112
                    main()
102
113
                sys.__stdout__.write(tempstdout.getvalue())
103
114
            finally:
104
115
                sys.stderr = sys.__stderr__