summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 05e92c0)
raw | patch | inline | side by side (parent: 05e92c0)
author | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Fri, 12 Oct 2001 02:20:32 +0000 (02:20 +0000) | ||
committer | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Fri, 12 Oct 2001 02:20:32 +0000 (02:20 +0000) |
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@298 57a73879-2fb5-44c3-a270-3262357dd7e2
roundup-server | patch | blob | history |
diff --git a/roundup-server b/roundup-server
index 3c6c9e53fd66a94768824f45eeeb941795c07ac6..8fb6a55771ad5b1e1af2969aa1025b242b5c8764 100755 (executable)
--- a/roundup-server
+++ b/roundup-server
Based on CGIHTTPServer in the Python library.
-$Id: roundup-server,v 1.13 2001-10-05 02:23:24 richard Exp $
+$Id: roundup-server,v 1.14 2001-10-12 02:20:32 richard Exp $
"""
import sys
'bar': '/tmp/bar',
}
+ROUNDUP_USER = None
+
+
# Where to log debugging information to. Use an instance of DevNull if you
# don't want to log anywhere.
# TODO: actually use this stuff
class RoundupRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
ROUNDUP_INSTANCE_HOMES = ROUNDUP_INSTANCE_HOMES
+ ROUNDUP_USER = ROUNDUP_USER
def send_head(self):
"""Version of send_head that support CGI scripts"""
# TODO: actually do the HEAD ...
decoded_query = query.replace('+', ' ')
- # if root, setuid to nobody
- # TODO why isn't this done much earlier? - say, in main()?
- if not os.getuid():
- nobody = nobody_uid()
- os.setuid(nobody)
-
# reload all modules
# TODO check for file timestamp changes and dependencies
#reload(date)
do_POST = run_cgi
-nobody = None
+user = None
def nobody_uid():
"""Internal routine to get nobody's uid"""
- global nobody
- if nobody:
- return nobody
- try:
- import pwd
- except ImportError:
- return -1
- try:
- nobody = pwd.getpwnam('nobody')[2]
- except KeyError:
- nobody = 1 + max(map(lambda x: x[2], pwd.getpwall()))
- return nobody
+ global user
+ if user:
+ return user
def usage(message=''):
if message: message = 'Error: %s\n'%message
port = 8080
try:
# handle the command-line args
- optlist, args = getopt.getopt(sys.argv[1:], 'n:p:')
+ optlist, args = getopt.getopt(sys.argv[1:], 'n:p:u:')
+ user = ROUNDUP_USER
for (opt, arg) in optlist:
if opt == '-n': hostname = arg
elif opt == '-p': port = int(arg)
+ elif opt == '-u': user = arg
elif opt == '-h': usage()
+ # if root, setuid to the running user
+ if not os.getuid() and user is not None:
+ try:
+ import pwd
+ except ImportError:
+ raise ValueError, "Can't change users - no pwd module"
+ try:
+ uid = pwd.getpwnam(user)[2]
+ except KeyError:
+ raise ValueError, "User %s doesn't exist"%user
+ os.setuid(uid)
+ elif os.getuid() and user is not None:
+ print 'WARNING: ignoring "-u" argument, not root'
+
+ # People can remove this check if they're really determined
+ if not os.getuid() and user is None:
+ raise ValueError, "Can't run as root!"
+
# handle instance specs
if args:
d = {}
for arg in args:
- name, home = string.split(arg, '=')
+ try:
+ name, home = string.split(arg, '=')
+ except ValueError:
+ raise ValueError, "Instances must be name=home"
d[name] = home
RoundupRequestHandler.ROUNDUP_INSTANCE_HOMES = d
except:
#
# $Log: not supported by cvs2svn $
+# Revision 1.13 2001/10/05 02:23:24 richard
+# . roundup-admin create now prompts for property info if none is supplied
+# on the command-line.
+# . hyperdb Class getprops() method may now return only the mutable
+# properties.
+# . Login now uses cookies, which makes it a whole lot more flexible. We can
+# now support anonymous user access (read-only, unless there's an
+# "anonymous" user, in which case write access is permitted). Login
+# handling has been moved into cgi_client.Client.main()
+# . The "extended" schema is now the default in roundup init.
+# . The schemas have had their page headings modified to cope with the new
+# login handling. Existing installations should copy the interfaces.py
+# file from the roundup lib directory to their instance home.
+# . Incorrectly had a Bizar Software copyright on the cgitb.py module from
+# Ping - has been removed.
+# . Fixed a whole bunch of places in the CGI interface where we should have
+# been returning Not Found instead of throwing an exception.
+# . Fixed a deviation from the spec: trying to modify the 'id' property of
+# an item now throws an exception.
+#
# Revision 1.12 2001/09/29 13:27:00 richard
# CGI interfaces now spit up a top-level index of all the instances they can
# serve.