Skip to content

Commit 00060cc

Browse files
author
Richard Jones
committed
merge from HEAD
1 parent bb7f679 commit 00060cc

File tree

4 files changed

+105
-65
lines changed

4 files changed

+105
-65
lines changed

CHANGES.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,17 @@ Fixed:
1010
(see doc/upgrading.txt for how to fix in your trackers)
1111
- after logout, always display tracker home page
1212
- web forms don't create new items if no item properties are set from UI
13-
- item creation failed if multilink fields had invalid entries (sf bug 1177602)
13+
- item creation failed if multilink fields had invalid entries (sf bug
14+
1177602)
1415
- fix bdist_rpm (sf bug 1164328)
16+
- fix checking of "Email Access" for Anonymous email registration (sf bug
17+
1177057)
18+
- disable "Email Access" for Anonymous by default to stop spam regsitering
19+
users on public trackers
20+
- send errors in the web interface to a logfile by default. Use the
21+
"debug" multiprocess mode (roundup-server) or the DEBUG_TO_CLIENT var
22+
(roundup.cgi) to have the errors appear in your browser
23+
- fix setgid typo (sf bug 1171346)
1524

1625

1726
2005-03-03 0.8.2

cgi-bin/roundup.cgi

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1717
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1818
#
19-
# $Id: roundup.cgi,v 1.40 2004-07-27 00:57:17 richard Exp $
19+
# $Id: roundup.cgi,v 1.40.2.1 2005-04-13 06:11:14 richard Exp $
2020

2121
# python version check
2222
from roundup import version_check
2323
from roundup.i18n import _
24-
import sys
24+
import sys, time
2525

2626
#
2727
## Configuration
@@ -42,8 +42,9 @@ import sys
4242
# ROUNDUP_LOG is the name of the logfile; if it's empty or does not exist,
4343
# logging is turned off (unless you changed the default below).
4444

45-
# ROUNDUP_DEBUG is a debug level, currently only 0 (OFF) and 1 (ON) are
46-
# used in the code. Higher numbers means more debugging output.
45+
# DEBUG_TO_CLIENT specifies whether debugging goes to the HTTP server (via
46+
# stderr) or to the web client (via cgitb).
47+
DEBUG_TO_CLIENT = False
4748

4849
# This indicates where the Roundup tracker lives
4950
TRACKER_HOMES = {
@@ -211,7 +212,16 @@ except SystemExit:
211212
except:
212213
sys.stdout, sys.stderr = out, err
213214
out.write('Content-Type: text/html\n\n')
214-
cgitb.handler()
215+
if DEBUG_TO_CLIENT:
216+
cgitb.handler()
217+
else:
218+
out.write(cgitb.breaker())
219+
ts = time.ctime()
220+
out.write('''<p>%s: An error occurred. Please check
221+
the server log for more infomation.</p>'''%ts)
222+
print >> sys.stderr, 'EXCEPTION AT', ts
223+
traceback.print_exc(0, sys.stderr)
224+
215225
sys.stdout.flush()
216226
sys.stdout, sys.stderr = out, err
217227
LOG.close()

doc/customizing.txt

Lines changed: 54 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Customising Roundup
33
===================
44

5-
:Version: $Revision: 1.161.2.12 $
5+
:Version: $Revision: 1.161.2.13 $
66

77
.. This document borrows from the ZopeBook section on ZPT. The original is at:
88
http://www.zope.org/Documentation/Books/ZopeBook/current/ZPT.stx
@@ -18,7 +18,7 @@ Before you get too far, it's probably worth having a quick read of the Roundup
1818

1919
Customisation of Roundup can take one of six forms:
2020

21-
1. `tracker configuration`_ file changes
21+
1. `tracker configuration`_ changes
2222
2. database, or `tracker schema`_ changes
2323
3. "definition" class `database content`_ changes
2424
4. behavioural changes, through detectors_
@@ -58,6 +58,12 @@ Tracker Configuration
5858
The ``config.ini`` located in your tracker home contains the basic
5959
configuration for the web and e-mail components of roundup's interfaces.
6060

61+
Changes to the data captured by your tracker is controlled by the `tracker
62+
schema`_. Some configuration is also performed using permissions - see the
63+
`security / access controls`_ section. For example, to allow users to
64+
automatically register through the email interface, you must grant the
65+
"Anonymous" Role the "Email Access" Permission.
66+
6167
The following is taken from the `Python Library Reference`__ (May 20, 2004)
6268
section "ConfigParser -- Configuration file parser":
6369

@@ -79,11 +85,6 @@ section "ConfigParser -- Configuration file parser":
7985

8086
__ http://docs.python.org/lib/module-ConfigParser.html
8187

82-
Configuration variables may be referred to in lower or upper case. In code,
83-
variables not in the "main" section are referred to using their section and
84-
name, so "domain" in the section "mail" becomes MAIL_DOMAIN. The
85-
configuration variables available are:
86-
8788
Section **main**
8889
database -- ``db``
8990
Database directory path. The path may be either absolute or relative
@@ -282,6 +283,11 @@ Section **nosy**
282283
You may generate a new default config file using the ``roundup-admin
283284
genconfig`` command.
284285

286+
Configuration variables may be referred to in lower or upper case. In code,
287+
variables not in the "main" section are referred to using their section and
288+
name, so "domain" in the section "mail" becomes MAIL_DOMAIN. The
289+
configuration variables available are:
290+
285291

286292
Tracker Schema
287293
==============
@@ -740,22 +746,28 @@ A set of Permissions is built into the security module by default:
740746
- Edit (everything)
741747
- View (everything)
742748

743-
Every Class you define in your tracker's schema also gets an Create, Edit
744-
and View Permission of its own.
745-
746-
The default interfaces define:
747-
748-
- Web Registration
749-
- Web Access
750-
- Web Roles
751-
- Email Registration
752-
- Email Access
749+
These are assigned to the "Admin" Role by default, and allow a user to do
750+
anything. Every Class you define in your `tracker schema`_ also gets an
751+
Create, Edit and View Permission of its own. The web and email interfaces
752+
also define:
753+
754+
*Email Access*
755+
If defined, the user may use the email interface. Used by default to deny
756+
Anonymous users access to the email interface. When granted to the
757+
Anonymous user, they will be automatically registered by the email
758+
interface (see also the ``new_email_user_roles`` configuration option).
759+
*Web Access*
760+
If defined, the user may use the web interface. All users are able to see
761+
the login form, regardless of this setting (thus enabling logging in).
762+
*Web Roles*
763+
Controls user access to editing the "roles" property of the "user" class.
764+
TODO: deprecate in favour of a property-based control.
753765

754766
These are hooked into the default Roles:
755767

756768
- Admin (Create, Edit, View and everything; Web Roles)
757769
- User (Web Access; Email Access)
758-
- Anonymous (Web Registration; Email Registration)
770+
- Anonymous (Web Access)
759771

760772
And finally, the "admin" user gets the "Admin" Role, and the "anonymous"
761773
user gets "Anonymous" assigned when the tracker is installed.
@@ -765,10 +777,11 @@ For the "User" Role, the "classic" tracker defines:
765777
- Create, Edit and View issue, file, msg, query, keyword
766778
- View priority, status
767779
- View user
768-
- Edit their own record
780+
- Edit their own user record
769781

770782
And the "Anonymous" Role is defined as:
771783

784+
- Web interface access
772785
- Create user (for registration)
773786
- View issue, file, msg, query, keyword, priority, status
774787

@@ -784,37 +797,31 @@ Put together, these settings appear in the tracker's ``schema.py`` file::
784797
# REGULAR USERS
785798
#
786799
# Give the regular users access to the web and email interface
787-
p = db.security.getPermission('Web Access')
788-
db.security.addPermissionToRole('User', p)
789-
p = db.security.getPermission('Email Access')
790-
db.security.addPermissionToRole('User', p)
800+
db.security.addPermissionToRole('User', 'Web Access')
801+
db.security.addPermissionToRole('User', 'Email Access')
791802

792803
# Assign the access and edit Permissions for issue, file and message
793804
# to regular users now
794805
for cl in 'issue', 'file', 'msg', 'query', 'keyword':
795-
p = db.security.getPermission('View', cl)
796-
db.security.addPermissionToRole('User', p)
797-
p = db.security.getPermission('Edit', cl)
798-
db.security.addPermissionToRole('User', p)
799-
p = db.security.getPermission('Create', cl)
800-
db.security.addPermissionToRole('User', p)
806+
db.security.addPermissionToRole('User', 'View', cl)
807+
db.security.addPermissionToRole('User', 'Edit', cl)
808+
db.security.addPermissionToRole('User', 'Create', cl)
801809
for cl in 'priority', 'status':
802-
p = db.security.getPermission('View', cl)
803-
db.security.addPermissionToRole('User', p)
810+
db.security.addPermissionToRole('User', 'View', cl)
804811

805812
# May users view other user information? Comment these lines out
806813
# if you don't want them to
807-
p = db.security.getPermission('View', 'user')
808-
db.security.addPermissionToRole('User', p)
814+
db.security.addPermissionToRole('User', 'View', 'user')
809815

810-
# Users should be able to edit their own details. Note that this
811-
# permission is limited to only the situation where the Viewed or
812-
# Edited item is their own.
816+
# Users should be able to edit their own details -- this permission
817+
# is limited to only the situation where the Viewed or Edited item
818+
# is their own.
813819
def own_record(db, userid, itemid):
814820
'''Determine whether the userid matches the item being accessed.'''
815821
return userid == itemid
816822
p = db.security.addPermission(name='View', klass='user', check=own_record,
817823
description="User is allowed to view their own user details")
824+
db.security.addPermissionToRole('User', p)
818825
p = db.security.addPermission(name='Edit', klass='user', check=own_record,
819826
description="User is allowed to edit their own user details")
820827
db.security.addPermissionToRole('User', p)
@@ -825,35 +832,31 @@ Put together, these settings appear in the tracker's ``schema.py`` file::
825832
# Let anonymous users access the web interface. Note that almost all
826833
# trackers will need this Permission. The only situation where it's not
827834
# required is in a tracker that uses an HTTP Basic Authenticated front-end.
828-
p = db.security.getPermission('Web Access')
829-
db.security.addPermissionToRole('Anonymous', p)
835+
db.security.addPermissionToRole('Anonymous', 'Web Access')
830836

831837
# Let anonymous users access the email interface (note that this implies
832838
# that they will be registered automatically, hence they will need the
833839
# "Create" user Permission below)
834-
p = db.security.getPermission('Email Access')
835-
db.security.addPermissionToRole('Anonymous', p)
840+
# This is disabled by default to stop spam from auto-registering users on
841+
# public trackers.
842+
#db.security.addPermissionToRole('Anonymous', 'Email Access')
836843

837844
# Assign the appropriate permissions to the anonymous user's Anonymous
838845
# Role. Choices here are:
839846
# - Allow anonymous users to register
840-
p = db.security.getPermission('Create', 'user')
841-
db.security.addPermissionToRole('Anonymous', p)
847+
db.security.addPermissionToRole('Anonymous', 'Create', 'user')
842848

843849
# Allow anonymous users access to view issues (and the related, linked
844850
# information)
845851
for cl in 'issue', 'file', 'msg', 'keyword', 'priority', 'status':
846-
p = db.security.getPermission('View', cl)
847-
db.security.addPermissionToRole('Anonymous', p)
852+
db.security.addPermissionToRole('Anonymous', 'View', cl)
848853

849854
# [OPTIONAL]
850855
# Allow anonymous users access to create or edit "issue" items (and the
851856
# related file and message items)
852857
#for cl in 'issue', 'file', 'msg':
853-
# p = db.security.getPermission('Create', cl)
854-
# db.security.addPermissionToRole('Anonymous', p)
855-
# p = db.security.getPermission('Edit', cl)
856-
# db.security.addPermissionToRole('Anonymous', p)
858+
# db.security.addPermissionToRole('Anonymous', 'Create', cl)
859+
# db.security.addPermissionToRole('Anonymous', 'Edit', cl)
857860

858861

859862
Automatic Permission Checks
@@ -887,6 +890,9 @@ New users are assigned the Roles defined in the config file as:
887890
- NEW_WEB_USER_ROLES
888891
- NEW_EMAIL_USER_ROLES
889892

893+
The `users may only edit their issues`_ example shows customisation of
894+
these parameters.
895+
890896

891897
Changing Access Controls
892898
------------------------

roundup/scripts/roundup_server.py

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717

1818
"""Command-line script that runs a server over roundup.cgi.client.
1919
20-
$Id: roundup_server.py,v 1.74.2.3 2005-02-19 10:14:16 a1s Exp $
20+
$Id: roundup_server.py,v 1.74.2.4 2005-04-13 06:11:15 richard Exp $
2121
"""
2222
__docformat__ = 'restructuredtext'
2323

24-
import errno, cgi, getopt, os, socket, sys, traceback, urllib
24+
import errno, cgi, getopt, os, socket, sys, traceback, urllib, time
2525
import ConfigParser, BaseHTTPServer, SocketServer, StringIO
2626

2727
# python version check
@@ -70,6 +70,7 @@ class RoundupRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
7070
TRACKER_HOMES = {}
7171
TRACKERS = None
7272
LOG_IPADDRESS = 1
73+
DEBUG_MODE = False
7374

7475
def get_tracker(self, name):
7576
"""Return a tracker instance for given tracker name"""
@@ -116,16 +117,26 @@ def run_cgi(self):
116117
self.send_response(400)
117118
self.send_header('Content-Type', 'text/html')
118119
self.end_headers()
119-
try:
120-
reload(cgitb)
120+
if self.DEBUG_MODE:
121+
try:
122+
reload(cgitb)
123+
self.wfile.write(cgitb.breaker())
124+
self.wfile.write(cgitb.html())
125+
except:
126+
s = StringIO.StringIO()
127+
traceback.print_exc(None, s)
128+
self.wfile.write("<pre>")
129+
self.wfile.write(cgi.escape(s.getvalue()))
130+
self.wfile.write("</pre>\n")
131+
else:
132+
# user feedback
121133
self.wfile.write(cgitb.breaker())
122-
self.wfile.write(cgitb.html())
123-
except:
124-
s = StringIO.StringIO()
125-
traceback.print_exc(None, s)
126-
self.wfile.write("<pre>")
127-
self.wfile.write(cgi.escape(s.getvalue()))
128-
self.wfile.write("</pre>\n")
134+
ts = time.ctime()
135+
self.wfile.write('''<p>%s: An error occurred. Please check
136+
the server log for more infomation.</p>'''%ts)
137+
# out to the logfile
138+
print 'EXCEPTION AT', ts
139+
traceback.print_exc()
129140
sys.stdin = save_stdin
130141

131142
do_GET = do_POST = do_HEAD = run_cgi
@@ -405,18 +416,22 @@ def get_server(self):
405416
"""Return HTTP server object to run"""
406417
# we don't want the cgi module interpreting the command-line args ;)
407418
sys.argv = sys.argv[:1]
419+
408420
# preload all trackers unless we are in "debug" mode
409421
tracker_homes = self.trackers()
410422
if self["MULTIPROCESS"] == "debug":
411423
trackers = None
412424
else:
413425
trackers = dict([(name, roundup.instance.open(home, optimize=1))
414426
for (name, home) in tracker_homes])
427+
415428
# build customized request handler class
416429
class RequestHandler(RoundupRequestHandler):
417430
LOG_IPADDRESS = not self["LOG_HOSTNAMES"]
418431
TRACKER_HOMES = dict(tracker_homes)
419432
TRACKERS = trackers
433+
DEBUG_MODE = self["MULTIPROCESS"] == "debug"
434+
420435
# obtain request server class
421436
if self["MULTIPROCESS"] not in MULTIPROCESS_TYPES:
422437
print _("Multiprocess mode \"%s\" is not available, "

0 commit comments

Comments
 (0)