Updated: (MODPYTHON-50) Session use outside of <Directory> directive.
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > Apache Server configuration support > Apache Mod-Python > Updated: (MODPYTHON-50) Session use outside of <Directory> directive.




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Updated: (MODPYTHON-50) Session use outside of <Directory> directive.  
Nicolas Lehuen (JIRA)


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-30-05 12:45 PM

[ http://issues.apache.org/jira/brows...N-50?page=3Dall ]

Nicolas Lehuen updated MODPYTHON-50:
------------------------------------

Description:=20
MODPYTHON-31 was previously closed with outcome of "Won't Fix".
The orginal problem as described in the report was actually not connected
to the Python traceback which was supplied, but the Python traceback
still identified a problem which shold be fixed. Have logged this separate
report to cover this issue.

The issue again came up recently on the mailing list as:

http://www.modpython.org/pipermail/...ril/XXXXX3.html

Specifically, if PythonHandler is specified outside of any <Directory>
directive and sessions are used, you can get the error:

Mod_python error: "PythonHandler mod_python.psp"=20

Traceback (most recent call last):=20

File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line 299, i=
n=20
HandlerDispatch=20
result =3D object(req)=20

File "/usr/lib/python2.3/site-packages/mod_python/psp.py", line 297, in=
=20
handler=20
p.run()=20

File "/usr/lib/python2.3/site-packages/mod_python/psp.py", line 191, in r=
un=20
session =3D Session.Session(req)=20

File "/usr/lib/python2.3/site-packages/mod_python/Session.py", line 389, =
in=20
Session=20
timeout=3Dtimeout, lock=3Dlock)=20

File "/usr/lib/python2.3/site-packages/mod_python/Session.py", line 294, =
in=20
__init__=20
timeout=3Dtimeout, lock=3Dlock)=20

File "/usr/lib/python2.3/site-packages/mod_python/Session.py", line 132, =
in=20
__init__=20
Cookie.add_cookie(self._req, self.make_cookie())=20

File "/usr/lib/python2.3/site-packages/mod_python/Session.py", line 160, =
in=20
make_cookie=20
c.path =3D dirpath[len(docroot):]=20

TypeError: unsubscriptable object=20

This is ultimately caused by code in BaseSession.make_cookie() which reads:

def make_cookie(self):

if self._secret:
c =3D Cookie.SignedCookie(COOKIE_NAME, self._sid,
secret=3Dself._secret)
else:
c =3D Cookie.Cookie(COOKIE_NAME, self._sid)

config =3D self._req.get_options()
if config.has_key("ApplicationPath"):
c.path =3D config["ApplicationPath"]
else:
docroot =3D self._req.document_root()
# the path where *Handler directive was specified
dirpath =3D self._req.hlist.directory=20
c.path =3D dirpath[len(docroot):]

# Sometimes there is no path, e.g. when Location
# is used. When Alias or UserDir are used, then
# the path wouldn't match the URI. In those cases
# just default to '/'
if not c.path or not self._req.uri.startswith(c.path):
c.path =3D '/'

return c

What happens when PythonHandler is defined outside of a <Directory>
directive is that req.hlist.directory is None, thus indexing into dirpath
fails.

A workaround is to set ApplicationPath option, but true fix would be
to write code something like:

# the path where *Handler directive was specified
dirpath =3D self._req.hlist.directory=20
if dirpath:
docroot =3D self._req.document_root()
c.path =3D dirpath[len(docroot):]
else:
c.path =3D'/'

# Sometimes there is no path, e.g. when Location
# is used. When Alias or UserDir are used, then
# the path wouldn't match the URI. In those cases
# just default to '/'
if not c.path or not self._req.uri.startswith(c.path):
c.path =3D '/'

This would eliminate the problem altogether and avoid user having to
use workaround of setting ApplicationPath option.

was:
MODPYTHON-31 was previously closed with outcome of "Won't Fix".
The orginal problem as described in the report was actually not connected
to the Python traceback which was supplied, but the Python traceback
still identified a problem which shold be fixed. Have logged this separate
report to cover this issue.

The issue again came up recently on the mailing list as:

http://www.modpython.org/pipermail/...ril/XXXXX3.html

Specifically, if PythonHandler is specified outside of any <Directory>
directive and sessions are used, you can get the error:

Mod_python error: "PythonHandler mod_python.psp"=20

Traceback (most recent call last):=20

=A0=A0File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line 29=
9, in=20
HandlerDispatch=20
=A0=A0=A0=A0result =3D object(req)=20

=A0=A0File "/usr/lib/python2.3/site-packages/mod_python/psp.py", line 297, =
in=20
handler=20
=A0=A0=A0=A0p.run()=20

=A0=A0File "/usr/lib/python2.3/site-packages/mod_python/psp.py", line 191, =
in run=20
=A0=A0=A0=A0session =3D Session.Session(req)=20

=A0=A0File "/usr/lib/python2.3/site-packages/mod_python/Session.py", line 3=
89, in=20
Session=20
=A0=A0=A0=A0timeout=3Dtimeout, lock=3Dlock)=20

=A0=A0File "/usr/lib/python2.3/site-packages/mod_python/Session.py", line 2=
94, in=20
__init__=20
=A0=A0=A0=A0timeout=3Dtimeout, lock=3Dlock)=20

=A0=A0File "/usr/lib/python2.3/site-packages/mod_python/Session.py", line 1=
32, in=20
__init__=20
=A0=A0=A0=A0Cookie.add_cookie(self._req, self.make_cookie())=20

=A0=A0File "/usr/lib/python2.3/site-packages/mod_python/Session.py", line 1=
60, in=20
make_cookie=20
=A0=A0=A0=A0c.path =3D dirpath[len(docroot):]=20

TypeError: unsubscriptable object=20

This is ultimately caused by code in BaseSession.make_cookie() which reads:

def make_cookie(self):

if self._secret:
c =3D Cookie.SignedCookie(COOKIE_NAME, self._sid,
secret=3Dself._secret)
else:
c =3D Cookie.Cookie(COOKIE_NAME, self._sid)

config =3D self._req.get_options()
if config.has_key("ApplicationPath"):
c.path =3D config["ApplicationPath"]
else:
docroot =3D self._req.document_root()
# the path where *Handler directive was specified
dirpath =3D self._req.hlist.directory=20
c.path =3D dirpath[len(docroot):]

# Sometimes there is no path, e.g. when Location
# is used. When Alias or UserDir are used, then
# the path wouldn't match the URI. In those cases
# just default to '/'
if not c.path or not self._req.uri.startswith(c.path):
c.path =3D '/'

return c

What happens when PythonHandler is defined outside of a <Directory>
directive is that req.hlist.directory is None, thus indexing into dirpath
fails.

A workaround is to set ApplicationPath option, but true fix would be
to write code something like:

# the path where *Handler directive was specified
dirpath =3D self._req.hlist.directory=20
if dirpath:
docroot =3D self._req.document_root()
c.path =3D dirpath[len(docroot):]
else:
c.path =3D'/'

# Sometimes there is no path, e.g. when Location
# is used. When Alias or UserDir are used, then
# the path wouldn't match the URI. In those cases
# just default to '/'
if not c.path or not self._req.uri.startswith(c.path):
c.path =3D '/'

This would eliminate the problem altogether and avoid user having to
use workaround of setting ApplicationPath option.

Fix Version: 3.2.0

> Session use outside of <Directory> directive.
> ---------------------------------------------
>
>          Key: MODPYTHON-50
>          URL: http://issues.apache.org/jira/browse/MODPYTHON-50
>      Project: mod_python
>         Type: Improvement
>   Components: core
>     Versions: 3.1.4
>     Reporter: Graham Dumpleton
>     Assignee: Nicolas Lehuen
>     Priority: Minor
>      Fix For: 3.2.0

>
> MODPYTHON-31 was previously closed with outcome of "Won't Fix".
> The orginal problem as described in the report was actually not connected
> to the Python traceback which was supplied, but the Python traceback
> still identified a problem which shold be fixed. Have logged this separat=
e
> report to cover this issue.
> The issue again came up recently on the mailing list as:
>   http://www.modpython.org/pipermail/...ril/XXXXX3.html
> Specifically, if PythonHandler is specified outside of any <Directory>
> directive and sessions are used, you can get the error:
> Mod_python error: "PythonHandler mod_python.psp"=20
> Traceback (most recent call last):=20
>   File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line 299,=
in=20
> HandlerDispatch=20
>     result =3D object(req)=20
>   File "/usr/lib/python2.3/site-packages/mod_python/psp.py", line 297, in=
=20
> handler=20
>     p.run()=20
>   File "/usr/lib/python2.3/site-packages/mod_python/psp.py", line 191, in=
run=20
>     session =3D Session.Session(req)=20
>   File "/usr/lib/python2.3/site-packages/mod_python/Session.py", line 389=
, in=20
> Session=20
>     timeout=3Dtimeout, lock=3Dlock)=20
>   File "/usr/lib/python2.3/site-packages/mod_python/Session.py", line 294=
, in=20
> __init__=20
>     timeout=3Dtimeout, lock=3Dlock)=20
>   File "/usr/lib/python2.3/site-packages/mod_python/Session.py", line 132=
, in=20
> __init__=20
>     Cookie.add_cookie(self._req, self.make_cookie())=20
>   File "/usr/lib/python2.3/site-packages/mod_python/Session.py", line 160=
, in=20
> make_cookie=20
>     c.path =3D dirpath[len(docroot):]=20
> TypeError: unsubscriptable object=20
> This is ultimately caused by code in BaseSession.make_cookie() which read=
s:
>     def make_cookie(self):
>         if self._secret:
>             c =3D Cookie.SignedCookie(COOKIE_NAME, self._sid,
>                                     secret=3Dself._secret)
>         else:
>             c =3D Cookie.Cookie(COOKIE_NAME, self._sid)
>         config =3D self._req.get_options()
>         if config.has_key("ApplicationPath"):
>             c.path =3D config["ApplicationPath"]
>         else:
>             docroot =3D self._req.document_root()
>             # the path where *Handler directive was specified
>             dirpath =3D self._req.hlist.directory=20
>             c.path =3D dirpath[len(docroot):]
>             # Sometimes there is no path, e.g. when Location
>             # is used. When Alias or UserDir are used, then
>             # the path wouldn't match the URI. In those cases
>             # just default to '/'
>             if not c.path or not self._req.uri.startswith(c.path):
>                 c.path =3D '/'
>         return c
> What happens when PythonHandler is defined outside of a <Directory>
> directive is that req.hlist.directory is None, thus indexing into dirpath
> fails.
> A workaround is to set ApplicationPath option, but true fix would be
> to write code something like:
>             # the path where *Handler directive was specified
>             dirpath =3D self._req.hlist.directory=20
>             if dirpath:
>                 docroot =3D self._req.document_root()
>                 c.path =3D dirpath[len(docroot):]
>             else:
>                 c.path =3D'/'
>             # Sometimes there is no path, e.g. when Location
>             # is used. When Alias or UserDir are used, then
>             # the path wouldn't match the URI. In those cases
>             # just default to '/'
>             if not c.path or not self._req.uri.startswith(c.path):
>                 c.path =3D '/'
> This would eliminate the problem altogether and avoid user having to
> use workaround of setting ApplicationPath option.

--=20
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secur...nistrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira







[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 06:38 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register