You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mod_python-dev@quetz.apache.org by "Kevin Quick (JIRA)" <ji...@apache.org> on 2005/07/14 01:45:09 UTC

[jira] Created: (MODPYTHON-63) Handle wildcard in Directory to sys.path transfer

Handle wildcard in Directory to sys.path transfer
-------------------------------------------------

         Key: MODPYTHON-63
         URL: http://issues.apache.org/jira/browse/MODPYTHON-63
     Project: mod_python
        Type: Improvement
    Versions: 3.1.3    
 Environment: gentoo Linux 2.4.20-gentoo-r8 apache-2.0.54-r8 mod_python-3.1.3-r1
    Reporter: Kevin Quick
    Priority: Minor


Below is a patch that does two things:

1) On module import failures, logfile contains additional information showing
   system paths as well as module name.

2) Support of Python*Handler found in a wildcard-based directory.  For example,

<IfModule mod_python.c> 
    <Directory /home/*/public_html/python> 
        AddHandler mod_python .py 
        PythonHandler helloworld 
        PythonDebug on 
    </Directory> 
</IfModule> 

which mirrors a corresponding perl setting and would allow the user to
place a mod_python handler in their $HOME/public_html/python directory.

In the current code, the wildcard is not translated, the sys.path update
will be invalid, and the user's module will not be accessible.  The attached
patch provides a fix for this.

N.B. There are obvious security issues in using this type of configuration,
but this is very useful for dev environments, and security would implemented
via explicit alternatives anyhow.

Index: apache.py
===================================================================
RCS file: /home/cvspublic/httpd-python/lib/python/mod_python/apache.py,v
retrieving revision 1.83
diff -r1.83 apache.py
33a34,40
> def add_handler_path(hpath):
>     import glob
>     if hpath:
>         for D in glob.glob(hpath):
>             if os.path.isdir(D) and D not in sys.path:
>                 sys.path.insert(0, D)
> 
170,171c177
<                 if filter.dir and (filter.dir not in sys.path):
<                     sys.path[:0] = [filter.dir]
---
>                 add_handler_path(filter.dir)
280,282c286
<                     dir = hlist.directory
<                     if dir and (dir not in sys.path):
<                         sys.path[:0] = [dir]
---
>                     add_handler_path(hlist.directory)
454c458,462
<             f, p, d = imp.find_module(parts[i], path)
---
>             try:
>                 f, p, d = imp.find_module(parts[i], path)
>             except:
>                 _apache.log_error("mod_python: import error for module %s with path: %s and sys.path: %s"%(parts[i],path,sys.path))
>                 raise


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


[jira] Updated: (MODPYTHON-63) Handle wildcard in Directory to sys.path transfer

Posted by "Nicolas Lehuen (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/MODPYTHON-63?page=all ]

Nicolas Lehuen updated MODPYTHON-63:
------------------------------------

    Component: core

> Handle wildcard in Directory to sys.path transfer
> -------------------------------------------------
>
>          Key: MODPYTHON-63
>          URL: http://issues.apache.org/jira/browse/MODPYTHON-63
>      Project: mod_python
>         Type: Improvement
>   Components: core
>     Versions: 3.1.3
>  Environment: gentoo Linux 2.4.20-gentoo-r8 apache-2.0.54-r8 mod_python-3.1.3-r1
>     Reporter: Kevin Quick
>     Priority: Minor

>
> Below is a patch that does two things:
> 1) On module import failures, logfile contains additional information showing
>    system paths as well as module name.
> 2) Support of Python*Handler found in a wildcard-based directory.  For example,
> <IfModule mod_python.c> 
>     <Directory /home/*/public_html/python> 
>         AddHandler mod_python .py 
>         PythonHandler helloworld 
>         PythonDebug on 
>     </Directory> 
> </IfModule> 
> which mirrors a corresponding perl setting and would allow the user to
> place a mod_python handler in their $HOME/public_html/python directory.
> In the current code, the wildcard is not translated, the sys.path update
> will be invalid, and the user's module will not be accessible.  The attached
> patch provides a fix for this.
> N.B. There are obvious security issues in using this type of configuration,
> but this is very useful for dev environments, and security would implemented
> via explicit alternatives anyhow.
> Index: apache.py
> ===================================================================
> RCS file: /home/cvspublic/httpd-python/lib/python/mod_python/apache.py,v
> retrieving revision 1.83
> diff -r1.83 apache.py
> 33a34,40
> > def add_handler_path(hpath):
> >     import glob
> >     if hpath:
> >         for D in glob.glob(hpath):
> >             if os.path.isdir(D) and D not in sys.path:
> >                 sys.path.insert(0, D)
> > 
> 170,171c177
> <                 if filter.dir and (filter.dir not in sys.path):
> <                     sys.path[:0] = [filter.dir]
> ---
> >                 add_handler_path(filter.dir)
> 280,282c286
> <                     dir = hlist.directory
> <                     if dir and (dir not in sys.path):
> <                         sys.path[:0] = [dir]
> ---
> >                     add_handler_path(hlist.directory)
> 454c458,462
> <             f, p, d = imp.find_module(parts[i], path)
> ---
> >             try:
> >                 f, p, d = imp.find_module(parts[i], path)
> >             except:
> >                 _apache.log_error("mod_python: import error for module %s with path: %s and sys.path: %s"%(parts[i],path,sys.path))
> >                 raise

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


[jira] Work started: (MODPYTHON-63) Handle wildcard in Directory to sys.path transfer

Posted by "Graham Dumpleton (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/MODPYTHON-63?page=all ]
     
Work on MODPYTHON-63 started by Graham Dumpleton

> Handle wildcard in Directory to sys.path transfer
> -------------------------------------------------
>
>          Key: MODPYTHON-63
>          URL: http://issues.apache.org/jira/browse/MODPYTHON-63
>      Project: mod_python
>         Type: Improvement

>   Components: core
>     Versions: 3.1.3
>  Environment: gentoo Linux 2.4.20-gentoo-r8 apache-2.0.54-r8 mod_python-3.1.3-r1
>     Reporter: Kevin Quick
>     Assignee: Graham Dumpleton
>     Priority: Minor

>
> Below is a patch that does two things:
> 1) On module import failures, logfile contains additional information showing
>    system paths as well as module name.
> 2) Support of Python*Handler found in a wildcard-based directory.  For example,
> <IfModule mod_python.c> 
>     <Directory /home/*/public_html/python> 
>         AddHandler mod_python .py 
>         PythonHandler helloworld 
>         PythonDebug on 
>     </Directory> 
> </IfModule> 
> which mirrors a corresponding perl setting and would allow the user to
> place a mod_python handler in their $HOME/public_html/python directory.
> In the current code, the wildcard is not translated, the sys.path update
> will be invalid, and the user's module will not be accessible.  The attached
> patch provides a fix for this.
> N.B. There are obvious security issues in using this type of configuration,
> but this is very useful for dev environments, and security would implemented
> via explicit alternatives anyhow.
> Index: apache.py
> ===================================================================
> RCS file: /home/cvspublic/httpd-python/lib/python/mod_python/apache.py,v
> retrieving revision 1.83
> diff -r1.83 apache.py
> 33a34,40
> > def add_handler_path(hpath):
> >     import glob
> >     if hpath:
> >         for D in glob.glob(hpath):
> >             if os.path.isdir(D) and D not in sys.path:
> >                 sys.path.insert(0, D)
> > 
> 170,171c177
> <                 if filter.dir and (filter.dir not in sys.path):
> <                     sys.path[:0] = [filter.dir]
> ---
> >                 add_handler_path(filter.dir)
> 280,282c286
> <                     dir = hlist.directory
> <                     if dir and (dir not in sys.path):
> <                         sys.path[:0] = [dir]
> ---
> >                     add_handler_path(hlist.directory)
> 454c458,462
> <             f, p, d = imp.find_module(parts[i], path)
> ---
> >             try:
> >                 f, p, d = imp.find_module(parts[i], path)
> >             except:
> >                 _apache.log_error("mod_python: import error for module %s with path: %s and sys.path: %s"%(parts[i],path,sys.path))
> >                 raise

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


[jira] Closed: (MODPYTHON-63) Handle wildcard in Directory to sys.path transfer

Posted by "Graham Dumpleton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MODPYTHON-63?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Graham Dumpleton closed MODPYTHON-63.
-------------------------------------


> Handle wildcard in Directory to sys.path transfer
> -------------------------------------------------
>
>                 Key: MODPYTHON-63
>                 URL: https://issues.apache.org/jira/browse/MODPYTHON-63
>             Project: mod_python
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 3.1.3
>         Environment: gentoo Linux 2.4.20-gentoo-r8 apache-2.0.54-r8 mod_python-3.1.3-r1
>            Reporter: Kevin Quick
>         Assigned To: Graham Dumpleton
>            Priority: Minor
>             Fix For: 3.3
>
>
> Below is a patch that does two things:
> 1) On module import failures, logfile contains additional information showing
>    system paths as well as module name.
> 2) Support of Python*Handler found in a wildcard-based directory.  For example,
> <IfModule mod_python.c> 
>     <Directory /home/*/public_html/python> 
>         AddHandler mod_python .py 
>         PythonHandler helloworld 
>         PythonDebug on 
>     </Directory> 
> </IfModule> 
> which mirrors a corresponding perl setting and would allow the user to
> place a mod_python handler in their $HOME/public_html/python directory.
> In the current code, the wildcard is not translated, the sys.path update
> will be invalid, and the user's module will not be accessible.  The attached
> patch provides a fix for this.
> N.B. There are obvious security issues in using this type of configuration,
> but this is very useful for dev environments, and security would implemented
> via explicit alternatives anyhow.
> Index: apache.py
> ===================================================================
> RCS file: /home/cvspublic/httpd-python/lib/python/mod_python/apache.py,v
> retrieving revision 1.83
> diff -r1.83 apache.py
> 33a34,40
> > def add_handler_path(hpath):
> >     import glob
> >     if hpath:
> >         for D in glob.glob(hpath):
> >             if os.path.isdir(D) and D not in sys.path:
> >                 sys.path.insert(0, D)
> > 
> 170,171c177
> <                 if filter.dir and (filter.dir not in sys.path):
> <                     sys.path[:0] = [filter.dir]
> ---
> >                 add_handler_path(filter.dir)
> 280,282c286
> <                     dir = hlist.directory
> <                     if dir and (dir not in sys.path):
> <                         sys.path[:0] = [dir]
> ---
> >                     add_handler_path(hlist.directory)
> 454c458,462
> <             f, p, d = imp.find_module(parts[i], path)
> ---
> >             try:
> >                 f, p, d = imp.find_module(parts[i], path)
> >             except:
> >                 _apache.log_error("mod_python: import error for module %s with path: %s and sys.path: %s"%(parts[i],path,sys.path))
> >                 raise

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (MODPYTHON-63) Handle wildcard in Directory to sys.path transfer

Posted by "Graham Dumpleton (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/MODPYTHON-63?page=comments#action_12427867 ] 
            
Graham Dumpleton commented on MODPYTHON-63:
-------------------------------------------

Committed code to complete changes such that handler directory is set correctly when handler directive is used with context of Directory or DirectoryMatch directive with a pattern. Forgot to cross reference to this report in commit message. Link to changes is:

  http://svn.apache.org/viewvc?view=rev&revision=431327


> Handle wildcard in Directory to sys.path transfer
> -------------------------------------------------
>
>                 Key: MODPYTHON-63
>                 URL: http://issues.apache.org/jira/browse/MODPYTHON-63
>             Project: mod_python
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 3.1.3
>         Environment: gentoo Linux 2.4.20-gentoo-r8 apache-2.0.54-r8 mod_python-3.1.3-r1
>            Reporter: Kevin Quick
>         Assigned To: Graham Dumpleton
>            Priority: Minor
>             Fix For: 3.3
>
>
> Below is a patch that does two things:
> 1) On module import failures, logfile contains additional information showing
>    system paths as well as module name.
> 2) Support of Python*Handler found in a wildcard-based directory.  For example,
> <IfModule mod_python.c> 
>     <Directory /home/*/public_html/python> 
>         AddHandler mod_python .py 
>         PythonHandler helloworld 
>         PythonDebug on 
>     </Directory> 
> </IfModule> 
> which mirrors a corresponding perl setting and would allow the user to
> place a mod_python handler in their $HOME/public_html/python directory.
> In the current code, the wildcard is not translated, the sys.path update
> will be invalid, and the user's module will not be accessible.  The attached
> patch provides a fix for this.
> N.B. There are obvious security issues in using this type of configuration,
> but this is very useful for dev environments, and security would implemented
> via explicit alternatives anyhow.
> Index: apache.py
> ===================================================================
> RCS file: /home/cvspublic/httpd-python/lib/python/mod_python/apache.py,v
> retrieving revision 1.83
> diff -r1.83 apache.py
> 33a34,40
> > def add_handler_path(hpath):
> >     import glob
> >     if hpath:
> >         for D in glob.glob(hpath):
> >             if os.path.isdir(D) and D not in sys.path:
> >                 sys.path.insert(0, D)
> > 
> 170,171c177
> <                 if filter.dir and (filter.dir not in sys.path):
> <                     sys.path[:0] = [filter.dir]
> ---
> >                 add_handler_path(filter.dir)
> 280,282c286
> <                     dir = hlist.directory
> <                     if dir and (dir not in sys.path):
> <                         sys.path[:0] = [dir]
> ---
> >                     add_handler_path(hlist.directory)
> 454c458,462
> <             f, p, d = imp.find_module(parts[i], path)
> ---
> >             try:
> >                 f, p, d = imp.find_module(parts[i], path)
> >             except:
> >                 _apache.log_error("mod_python: import error for module %s with path: %s and sys.path: %s"%(parts[i],path,sys.path))
> >                 raise

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

        

[jira] Commented: (MODPYTHON-63) Handle wildcard in Directory to sys.path transfer

Posted by "Graham Dumpleton (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/MODPYTHON-63?page=comments#action_12366270 ] 

Graham Dumpleton commented on MODPYTHON-63:
-------------------------------------------

In what will be the grand unified theory for the module importer, there will be no explicit modification of sys.path, so above solution isn't going to work.

The issues of wildcards in paths does need to be looked at and how they do it in mod_perl would be a good guide so still need to keep this issue open.

FWIW though, the above will be able to be done in other ways when MODPYTHON-125 is addressed. One could for example use:

<IfModule mod_python.c> 
    <Directory /home/*/public_html/python>
        PythonFixupHandler mod_userdir_dispatch
        PythonDebug on 
    </Directory> 
</IfModule>

# mod_userdir_dispatch.py

from mod_python import apache

def fixuphandler(req):
  if os.splitext(req.filename)[1] == ".py":
    req.handler = "mod_python"
    user = req.notes["mod_userdir_user"]
    directory = "/home/%s/public_html/python" % user
    req.add_handler("PythonHandler","helloworld",dir)
  return apache.OK

In other words, use a fixup handler to enable mod_python for the content handler phase when extension of mapped file is .py, and also specify actual module in users home directory to be called in that situation.

Personally I wouldn't use "helloworld" in the users directory but something like "_dispatch". That way a user could put in that file:

  # _dispatch.py

  from mod_python.publisher import handler

Thus allowing them to use publisher, but where an access to URL of "_dispatch.py/handler" isn't going to cause a loop as publisher tries to call into it, ie., the underscore protects it from publisher.

At least I think that would work.

> Handle wildcard in Directory to sys.path transfer
> -------------------------------------------------
>
>          Key: MODPYTHON-63
>          URL: http://issues.apache.org/jira/browse/MODPYTHON-63
>      Project: mod_python
>         Type: Improvement
>   Components: core
>     Versions: 3.1.3
>  Environment: gentoo Linux 2.4.20-gentoo-r8 apache-2.0.54-r8 mod_python-3.1.3-r1
>     Reporter: Kevin Quick
>     Priority: Minor

>
> Below is a patch that does two things:
> 1) On module import failures, logfile contains additional information showing
>    system paths as well as module name.
> 2) Support of Python*Handler found in a wildcard-based directory.  For example,
> <IfModule mod_python.c> 
>     <Directory /home/*/public_html/python> 
>         AddHandler mod_python .py 
>         PythonHandler helloworld 
>         PythonDebug on 
>     </Directory> 
> </IfModule> 
> which mirrors a corresponding perl setting and would allow the user to
> place a mod_python handler in their $HOME/public_html/python directory.
> In the current code, the wildcard is not translated, the sys.path update
> will be invalid, and the user's module will not be accessible.  The attached
> patch provides a fix for this.
> N.B. There are obvious security issues in using this type of configuration,
> but this is very useful for dev environments, and security would implemented
> via explicit alternatives anyhow.
> Index: apache.py
> ===================================================================
> RCS file: /home/cvspublic/httpd-python/lib/python/mod_python/apache.py,v
> retrieving revision 1.83
> diff -r1.83 apache.py
> 33a34,40
> > def add_handler_path(hpath):
> >     import glob
> >     if hpath:
> >         for D in glob.glob(hpath):
> >             if os.path.isdir(D) and D not in sys.path:
> >                 sys.path.insert(0, D)
> > 
> 170,171c177
> <                 if filter.dir and (filter.dir not in sys.path):
> <                     sys.path[:0] = [filter.dir]
> ---
> >                 add_handler_path(filter.dir)
> 280,282c286
> <                     dir = hlist.directory
> <                     if dir and (dir not in sys.path):
> <                         sys.path[:0] = [dir]
> ---
> >                     add_handler_path(hlist.directory)
> 454c458,462
> <             f, p, d = imp.find_module(parts[i], path)
> ---
> >             try:
> >                 f, p, d = imp.find_module(parts[i], path)
> >             except:
> >                 _apache.log_error("mod_python: import error for module %s with path: %s and sys.path: %s"%(parts[i],path,sys.path))
> >                 raise

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


[jira] Work started: (MODPYTHON-63) Handle wildcard in Directory to sys.path transfer

Posted by "Graham Dumpleton (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/MODPYTHON-63?page=all ]

Work on MODPYTHON-63 started by Graham Dumpleton.

> Handle wildcard in Directory to sys.path transfer
> -------------------------------------------------
>
>                 Key: MODPYTHON-63
>                 URL: http://issues.apache.org/jira/browse/MODPYTHON-63
>             Project: mod_python
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 3.1.3
>         Environment: gentoo Linux 2.4.20-gentoo-r8 apache-2.0.54-r8 mod_python-3.1.3-r1
>            Reporter: Kevin Quick
>         Assigned To: Graham Dumpleton
>            Priority: Minor
>
> Below is a patch that does two things:
> 1) On module import failures, logfile contains additional information showing
>    system paths as well as module name.
> 2) Support of Python*Handler found in a wildcard-based directory.  For example,
> <IfModule mod_python.c> 
>     <Directory /home/*/public_html/python> 
>         AddHandler mod_python .py 
>         PythonHandler helloworld 
>         PythonDebug on 
>     </Directory> 
> </IfModule> 
> which mirrors a corresponding perl setting and would allow the user to
> place a mod_python handler in their $HOME/public_html/python directory.
> In the current code, the wildcard is not translated, the sys.path update
> will be invalid, and the user's module will not be accessible.  The attached
> patch provides a fix for this.
> N.B. There are obvious security issues in using this type of configuration,
> but this is very useful for dev environments, and security would implemented
> via explicit alternatives anyhow.
> Index: apache.py
> ===================================================================
> RCS file: /home/cvspublic/httpd-python/lib/python/mod_python/apache.py,v
> retrieving revision 1.83
> diff -r1.83 apache.py
> 33a34,40
> > def add_handler_path(hpath):
> >     import glob
> >     if hpath:
> >         for D in glob.glob(hpath):
> >             if os.path.isdir(D) and D not in sys.path:
> >                 sys.path.insert(0, D)
> > 
> 170,171c177
> <                 if filter.dir and (filter.dir not in sys.path):
> <                     sys.path[:0] = [filter.dir]
> ---
> >                 add_handler_path(filter.dir)
> 280,282c286
> <                     dir = hlist.directory
> <                     if dir and (dir not in sys.path):
> <                         sys.path[:0] = [dir]
> ---
> >                     add_handler_path(hlist.directory)
> 454c458,462
> <             f, p, d = imp.find_module(parts[i], path)
> ---
> >             try:
> >                 f, p, d = imp.find_module(parts[i], path)
> >             except:
> >                 _apache.log_error("mod_python: import error for module %s with path: %s and sys.path: %s"%(parts[i],path,sys.path))
> >                 raise

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

        

[jira] Work stopped: (MODPYTHON-63) Handle wildcard in Directory to sys.path transfer

Posted by "Graham Dumpleton (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/MODPYTHON-63?page=all ]

Work on MODPYTHON-63 stopped by Graham Dumpleton

> Handle wildcard in Directory to sys.path transfer
> -------------------------------------------------
>
>          Key: MODPYTHON-63
>          URL: http://issues.apache.org/jira/browse/MODPYTHON-63
>      Project: mod_python
>         Type: Improvement

>   Components: core
>     Versions: 3.1.3
>  Environment: gentoo Linux 2.4.20-gentoo-r8 apache-2.0.54-r8 mod_python-3.1.3-r1
>     Reporter: Kevin Quick
>     Assignee: Graham Dumpleton
>     Priority: Minor

>
> Below is a patch that does two things:
> 1) On module import failures, logfile contains additional information showing
>    system paths as well as module name.
> 2) Support of Python*Handler found in a wildcard-based directory.  For example,
> <IfModule mod_python.c> 
>     <Directory /home/*/public_html/python> 
>         AddHandler mod_python .py 
>         PythonHandler helloworld 
>         PythonDebug on 
>     </Directory> 
> </IfModule> 
> which mirrors a corresponding perl setting and would allow the user to
> place a mod_python handler in their $HOME/public_html/python directory.
> In the current code, the wildcard is not translated, the sys.path update
> will be invalid, and the user's module will not be accessible.  The attached
> patch provides a fix for this.
> N.B. There are obvious security issues in using this type of configuration,
> but this is very useful for dev environments, and security would implemented
> via explicit alternatives anyhow.
> Index: apache.py
> ===================================================================
> RCS file: /home/cvspublic/httpd-python/lib/python/mod_python/apache.py,v
> retrieving revision 1.83
> diff -r1.83 apache.py
> 33a34,40
> > def add_handler_path(hpath):
> >     import glob
> >     if hpath:
> >         for D in glob.glob(hpath):
> >             if os.path.isdir(D) and D not in sys.path:
> >                 sys.path.insert(0, D)
> > 
> 170,171c177
> <                 if filter.dir and (filter.dir not in sys.path):
> <                     sys.path[:0] = [filter.dir]
> ---
> >                 add_handler_path(filter.dir)
> 280,282c286
> <                     dir = hlist.directory
> <                     if dir and (dir not in sys.path):
> <                         sys.path[:0] = [dir]
> ---
> >                     add_handler_path(hlist.directory)
> 454c458,462
> <             f, p, d = imp.find_module(parts[i], path)
> ---
> >             try:
> >                 f, p, d = imp.find_module(parts[i], path)
> >             except:
> >                 _apache.log_error("mod_python: import error for module %s with path: %s and sys.path: %s"%(parts[i],path,sys.path))
> >                 raise

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


[jira] Updated: (MODPYTHON-63) Handle wildcard in Directory to sys.path transfer

Posted by "Graham Dumpleton (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/MODPYTHON-63?page=all ]

Graham Dumpleton updated MODPYTHON-63:
--------------------------------------

    Fix Version/s: 3.3

> Handle wildcard in Directory to sys.path transfer
> -------------------------------------------------
>
>                 Key: MODPYTHON-63
>                 URL: http://issues.apache.org/jira/browse/MODPYTHON-63
>             Project: mod_python
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 3.1.3
>         Environment: gentoo Linux 2.4.20-gentoo-r8 apache-2.0.54-r8 mod_python-3.1.3-r1
>            Reporter: Kevin Quick
>         Assigned To: Graham Dumpleton
>            Priority: Minor
>             Fix For: 3.3
>
>
> Below is a patch that does two things:
> 1) On module import failures, logfile contains additional information showing
>    system paths as well as module name.
> 2) Support of Python*Handler found in a wildcard-based directory.  For example,
> <IfModule mod_python.c> 
>     <Directory /home/*/public_html/python> 
>         AddHandler mod_python .py 
>         PythonHandler helloworld 
>         PythonDebug on 
>     </Directory> 
> </IfModule> 
> which mirrors a corresponding perl setting and would allow the user to
> place a mod_python handler in their $HOME/public_html/python directory.
> In the current code, the wildcard is not translated, the sys.path update
> will be invalid, and the user's module will not be accessible.  The attached
> patch provides a fix for this.
> N.B. There are obvious security issues in using this type of configuration,
> but this is very useful for dev environments, and security would implemented
> via explicit alternatives anyhow.
> Index: apache.py
> ===================================================================
> RCS file: /home/cvspublic/httpd-python/lib/python/mod_python/apache.py,v
> retrieving revision 1.83
> diff -r1.83 apache.py
> 33a34,40
> > def add_handler_path(hpath):
> >     import glob
> >     if hpath:
> >         for D in glob.glob(hpath):
> >             if os.path.isdir(D) and D not in sys.path:
> >                 sys.path.insert(0, D)
> > 
> 170,171c177
> <                 if filter.dir and (filter.dir not in sys.path):
> <                     sys.path[:0] = [filter.dir]
> ---
> >                 add_handler_path(filter.dir)
> 280,282c286
> <                     dir = hlist.directory
> <                     if dir and (dir not in sys.path):
> <                         sys.path[:0] = [dir]
> ---
> >                     add_handler_path(hlist.directory)
> 454c458,462
> <             f, p, d = imp.find_module(parts[i], path)
> ---
> >             try:
> >                 f, p, d = imp.find_module(parts[i], path)
> >             except:
> >                 _apache.log_error("mod_python: import error for module %s with path: %s and sys.path: %s"%(parts[i],path,sys.path))
> >                 raise

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

        

[jira] Assigned: (MODPYTHON-63) Handle wildcard in Directory to sys.path transfer

Posted by "Graham Dumpleton (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/MODPYTHON-63?page=all ]

Graham Dumpleton reassigned MODPYTHON-63:
-----------------------------------------

    Assign To: Graham Dumpleton

> Handle wildcard in Directory to sys.path transfer
> -------------------------------------------------
>
>          Key: MODPYTHON-63
>          URL: http://issues.apache.org/jira/browse/MODPYTHON-63
>      Project: mod_python
>         Type: Improvement

>   Components: core
>     Versions: 3.1.3
>  Environment: gentoo Linux 2.4.20-gentoo-r8 apache-2.0.54-r8 mod_python-3.1.3-r1
>     Reporter: Kevin Quick
>     Assignee: Graham Dumpleton
>     Priority: Minor

>
> Below is a patch that does two things:
> 1) On module import failures, logfile contains additional information showing
>    system paths as well as module name.
> 2) Support of Python*Handler found in a wildcard-based directory.  For example,
> <IfModule mod_python.c> 
>     <Directory /home/*/public_html/python> 
>         AddHandler mod_python .py 
>         PythonHandler helloworld 
>         PythonDebug on 
>     </Directory> 
> </IfModule> 
> which mirrors a corresponding perl setting and would allow the user to
> place a mod_python handler in their $HOME/public_html/python directory.
> In the current code, the wildcard is not translated, the sys.path update
> will be invalid, and the user's module will not be accessible.  The attached
> patch provides a fix for this.
> N.B. There are obvious security issues in using this type of configuration,
> but this is very useful for dev environments, and security would implemented
> via explicit alternatives anyhow.
> Index: apache.py
> ===================================================================
> RCS file: /home/cvspublic/httpd-python/lib/python/mod_python/apache.py,v
> retrieving revision 1.83
> diff -r1.83 apache.py
> 33a34,40
> > def add_handler_path(hpath):
> >     import glob
> >     if hpath:
> >         for D in glob.glob(hpath):
> >             if os.path.isdir(D) and D not in sys.path:
> >                 sys.path.insert(0, D)
> > 
> 170,171c177
> <                 if filter.dir and (filter.dir not in sys.path):
> <                     sys.path[:0] = [filter.dir]
> ---
> >                 add_handler_path(filter.dir)
> 280,282c286
> <                     dir = hlist.directory
> <                     if dir and (dir not in sys.path):
> <                         sys.path[:0] = [dir]
> ---
> >                     add_handler_path(hlist.directory)
> 454c458,462
> <             f, p, d = imp.find_module(parts[i], path)
> ---
> >             try:
> >                 f, p, d = imp.find_module(parts[i], path)
> >             except:
> >                 _apache.log_error("mod_python: import error for module %s with path: %s and sys.path: %s"%(parts[i],path,sys.path))
> >                 raise

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


[jira] Resolved: (MODPYTHON-63) Handle wildcard in Directory to sys.path transfer

Posted by "Graham Dumpleton (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/MODPYTHON-63?page=all ]

Graham Dumpleton resolved MODPYTHON-63.
---------------------------------------

    Resolution: Fixed

> Handle wildcard in Directory to sys.path transfer
> -------------------------------------------------
>
>                 Key: MODPYTHON-63
>                 URL: http://issues.apache.org/jira/browse/MODPYTHON-63
>             Project: mod_python
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 3.1.3
>         Environment: gentoo Linux 2.4.20-gentoo-r8 apache-2.0.54-r8 mod_python-3.1.3-r1
>            Reporter: Kevin Quick
>         Assigned To: Graham Dumpleton
>            Priority: Minor
>             Fix For: 3.3
>
>
> Below is a patch that does two things:
> 1) On module import failures, logfile contains additional information showing
>    system paths as well as module name.
> 2) Support of Python*Handler found in a wildcard-based directory.  For example,
> <IfModule mod_python.c> 
>     <Directory /home/*/public_html/python> 
>         AddHandler mod_python .py 
>         PythonHandler helloworld 
>         PythonDebug on 
>     </Directory> 
> </IfModule> 
> which mirrors a corresponding perl setting and would allow the user to
> place a mod_python handler in their $HOME/public_html/python directory.
> In the current code, the wildcard is not translated, the sys.path update
> will be invalid, and the user's module will not be accessible.  The attached
> patch provides a fix for this.
> N.B. There are obvious security issues in using this type of configuration,
> but this is very useful for dev environments, and security would implemented
> via explicit alternatives anyhow.
> Index: apache.py
> ===================================================================
> RCS file: /home/cvspublic/httpd-python/lib/python/mod_python/apache.py,v
> retrieving revision 1.83
> diff -r1.83 apache.py
> 33a34,40
> > def add_handler_path(hpath):
> >     import glob
> >     if hpath:
> >         for D in glob.glob(hpath):
> >             if os.path.isdir(D) and D not in sys.path:
> >                 sys.path.insert(0, D)
> > 
> 170,171c177
> <                 if filter.dir and (filter.dir not in sys.path):
> <                     sys.path[:0] = [filter.dir]
> ---
> >                 add_handler_path(filter.dir)
> 280,282c286
> <                     dir = hlist.directory
> <                     if dir and (dir not in sys.path):
> <                         sys.path[:0] = [dir]
> ---
> >                     add_handler_path(hlist.directory)
> 454c458,462
> <             f, p, d = imp.find_module(parts[i], path)
> ---
> >             try:
> >                 f, p, d = imp.find_module(parts[i], path)
> >             except:
> >                 _apache.log_error("mod_python: import error for module %s with path: %s and sys.path: %s"%(parts[i],path,sys.path))
> >                 raise

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