This file is indexed.

/usr/share/pyshared/quixote/server/scgi_server.py is in python-quixote 2.7~b2-1+b2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env python
"""A SCGI server that uses Quixote to publish dynamic content.
"""

from scgi import scgi_server

class QuixoteHandler(scgi_server.SCGIHandler):
    def __init__(self, parent_fd, create_publisher, script_name=None):
        scgi_server.SCGIHandler.__init__(self, parent_fd)
        self.publisher = create_publisher()
        self.script_name = script_name

    def handle_connection(self, conn):
        input = conn.makefile("r")
        output = conn.makefile("w")
        env = self.read_env(input)

        if self.script_name is not None:
            # mod_scgi doesn't know SCRIPT_NAME :-(
            prefix = self.script_name
            path = env['SCRIPT_NAME']
            assert path[:len(prefix)] == prefix, (
                "path %r doesn't start with script_name %r" % (path, prefix))
            env['SCRIPT_NAME'] = prefix
            env['PATH_INFO'] = path[len(prefix):] + env.get('PATH_INFO', '')

        response = self.publisher.process(input, env)
        try:
            response.write(output)
            input.close()
            output.close()
            conn.close()
        except IOError, err:
            self.publisher.log("IOError while sending response "
                               "ignored: %s" % err)


def run(create_publisher, host='localhost', port=3000, script_name=None,
        max_children=5):
    def create_handler(parent_fd):
        return QuixoteHandler(parent_fd, create_publisher, script_name)
    s = scgi_server.SCGIServer(create_handler, host=host, port=port,
                               max_children=max_children)
    s.serve()


def main():
    from optparse import OptionParser
    from quixote.util import import_object
    parser = OptionParser()
    parser.set_description(run.__doc__)
    default_host = 'localhost'
    parser.add_option(
        '--host', dest="host", default=default_host, type="string",
        help="Host interface to listen on. (default=%s)" % default_host)
    default_port = 3000
    parser.add_option(
        '--port', dest="port", default=default_port, type="int",
        help="Port to listen on. (default=%s)" % default_port)
    default_maxchild = 5
    parser.add_option(
        '--max-children', dest="maxchild", default=default_maxchild,
        type="string",
        help="Maximum number of children to spawn. (default=%s)" %
            default_maxchild)
    parser.add_option(
        '--script-name', dest="script_name", default=None, type="string",
        help="Value of SCRIPT_NAME (only needed if using mod_scgi)")
    default_factory = 'quixote.demo.create_publisher'
    parser.add_option(
        '--factory', dest="factory",
        default=default_factory,
        help="Path to factory function to create the site Publisher. "
             "(default=%s)" % default_factory)
    (options, args) = parser.parse_args()
    run(import_object(options.factory), host=options.host, port=options.port,
        script_name=options.script_name, max_children=options.maxchild)

if __name__ == '__main__':
    main()