#6408 Avoid controller scanning within 'routes'

v1.0.0
closed
sf-1 (616)
General
2015-08-20
2013-06-25
No

The core routing setup uses 'routes' which is set up to use directory scanning to find controllers. This can error out, as seen below, if there is permission issue. This directory scanning isn't necessary, since we use object dispatch for all the routing.

Traceback (most recent call last):
  File "/etc/httpd/conf.d/allura.wsgi", line 35, in <module>
    wsgipreload.preload(application, urls=urls)
  File "/var/local/env-allura/lib/python2.7/site-packages/wsgipreload-1.2-py2.7.egg/wsgipreload.py", line 36, in preload
    request(app, url, extra_environ)
  File "/var/local/env-allura/lib/python2.7/site-packages/wsgipreload-1.2-py2.7.egg/wsgipreload.py", line 25, in request
    a = app(environ, start_response)
  File "/var/local/env-allura/lib/python2.7/site-packages/Pylons-1.0-py2.7.egg/pylons/middleware.py", line 163, in __call__
    self.app, new_environ, catch_exc_info=True)
  File "/var/local/env-allura/lib/python2.7/site-packages/Pylons-1.0-py2.7.egg/pylons/util.py", line 51, in call_wsgi_application
    output.extend(app_iter)
  File "/var/local/env-allura/lib/python2.7/site-packages/Paste-1.7.5.1-py2.7.egg/paste/registry.py", line 409, in streaming_iter
    for item in self.application(environ, start_response):
  File "/var/local/env-allura/lib/python2.7/site-packages/Ming-0.3.6dev_20130620-py2.7.egg/ming/odm/middleware.py", line 16, in __call__
    result = self.app(environ, start_response)
  File "/var/local/allura/Allura/allura/lib/custom_middleware.py", line 58, in __call__
    return self.app(environ, start_response)
  File "/var/local/env-allura/lib/python2.7/site-packages/EasyWidgets-0.2dev_20130603-py2.7.egg/ew/middleware.py", line 65, in __call__
    result = self.app(environ, start_response)
  File "/var/local/allura/Allura/allura/lib/custom_middleware.py", line 171, in __call__
    return resp(environ, start_response)
  File "/var/local/allura/Allura/allura/config/middleware.py", line 193, in AlluraGlobalsMiddleware
    return app(environ, start_response)
  File "/var/local/allura/Allura/allura/lib/custom_middleware.py", line 139, in __call__
    return self._app(environ, session_start_response)
  File "/var/local/env-allura/lib/python2.7/site-packages/TimerMiddleware-0.4.2-py2.7.egg/timermiddleware/__init__.py", line 172, in __call__
    resp = req.get_response(self.app)
  File "/var/local/env-allura/lib/python2.7/site-packages/WebOb-1.0.8-py2.7.egg/webob/request.py", line 1053, in get_response
    application, catch_exc_info=False)
  File "/var/local/env-allura/lib/python2.7/site-packages/WebOb-1.0.8-py2.7.egg/webob/request.py", line 1022, in call_application
    app_iter = application(self.environ, start_response)
  File "/var/local/allura/Allura/allura/lib/custom_middleware.py", line 95, in __call__
    self.app, environ, catch_exc_info=True)
  File "/var/local/env-allura/lib/python2.7/site-packages/Pylons-1.0-py2.7.egg/pylons/util.py", line 48, in call_wsgi_application
    app_iter = application(environ, start_response)
  File "/var/local/env-allura/lib/python2.7/site-packages/Beaker-1.5.4-py2.7.egg/beaker/middleware.py", line 152, in __call__
    return self.wrap_app(environ, session_start_response)
  File "/var/local/env-allura/lib/python2.7/site-packages/Routes-1.12.3-py2.7.egg/routes/middleware.py", line 80, in __call__
    config.environ = environ
  File "/var/local/env-allura/lib/python2.7/site-packages/Routes-1.12.3-py2.7.egg/routes/__init__.py", line 22, in __setattr__
    self.load_wsgi_environ(value)
  File "/var/local/env-allura/lib/python2.7/site-packages/Routes-1.12.3-py2.7.egg/routes/__init__.py", line 51, in load_wsgi_environ
    result = mapper.routematch(path)
  File "/var/local/env-allura/lib/python2.7/site-packages/Routes-1.12.3-py2.7.egg/routes/mapper.py", line 690, in routematch
    result = self._match(url, environ)
  File "/var/local/env-allura/lib/python2.7/site-packages/Routes-1.12.3-py2.7.egg/routes/mapper.py", line 609, in _match
    self.create_regs()
  File "/var/local/env-allura/lib/python2.7/site-packages/Routes-1.12.3-py2.7.egg/routes/mapper.py", line 560, in create_regs
    self._create_regs(*args, **kwargs)
  File "/var/local/env-allura/lib/python2.7/site-packages/Routes-1.12.3-py2.7.egg/routes/mapper.py", line 568, in _create_regs
    clist = self.controller_scan(self.directory)
  File "/var/local/env-allura/lib/python2.7/site-packages/Routes-1.12.3-py2.7.egg/routes/util.py", line 502, in controller_scan
    controllers = find_controllers(directory)
  File "/var/local/env-allura/lib/python2.7/site-packages/Routes-1.12.3-py2.7.egg/routes/util.py", line 497, in find_controllers
    prefix=prefix+fname+'/'))
  File "/var/local/env-allura/lib/python2.7/site-packages/Routes-1.12.3-py2.7.egg/routes/util.py", line 490, in find_controllers
    for fname in os.listdir(dirname):
Permission denied: '/var/local/allura/Allura/allura/controllers/.~tmp~'

Discussion

  • Dave Brondsema

    Dave Brondsema - 2013-06-25
    • status: in-progress --> code-review
     
  • Dave Brondsema

    Dave Brondsema - 2013-06-25

    allura:db/6408

    To test:

    mkdir Allura/allura/controllers/tmp
    chown root:root !$
    chmod 700 !$
    /etc/init.d/httpd restart
    

    That'll fail on master, should work fine on this branch

     
  • Dave Brondsema

    Dave Brondsema - 2013-06-26

    and sfpy:db/6408

     
    • QA: Tim Van Steenburgh
     
    • status: code-review --> closed
     

Log in to post a comment.