On Jun 21, 9:09 pm, Yarin <[email protected]> wrote:
> Roger that Yarko- I will do as you say.  Big thanks to you and Massimo
> too for sticking with me today- It was my first time on this board,
> and my first week with web2py, and I've been nothing but impressed
> with what I've seen- Awesome framework, great support

Welcome, Yarin! -   glad we could be of some little help.   (and
thanks for the kind words :-)).

- Yarko

>
> On Jun 21, 9:52 pm, Yarko Tymciurak <[email protected]>
> wrote:
>
>
>
> > I think this problem is the wrong one for you to focus on - when you
> > configure your web2py instance to run
> > as something other than root (_never_ run a web server as root:  IF
> > you get the slightest injection, it will have abiliity to have full
> > control, do _anything_ to your system!)
>
> > Configure proper user for your web2py instance, and set a proper home
> > directory, and this will not be a problem - that is what you need to
> > focus on next I think
>
> > Regards,
> > - Yarko
>
> > On Jun 21, 3:37 pm, Yarin <[email protected]> wrote:
>
> > > > You should
> > > > be able to add this to options_std.py;  I think you should be able,
> > > > alternatively, to do this
> > > > in your parameters*.py file
> > > > (seehttp://www.web2py.com/book/default/section/4/1?search=environ).
>
> > > > that is, put these lines in either:
>
> > > > import os
> > > > os.environ[PYTHON_EGG_CACHE]=....
>
> > > I tried this in both files but no luck- It fails the same as if the
> > > variable was never assigned,
> > > both through apache and on the command line.
>
> > > > >   [Errno 13] Permission denied: '/.python-eggs'
>
> > > > Note:  This is root directory (!) ---  probably the "home" directory
> > > > for the user in question
>
> > > I'm very green with respect to securing servers, though I know I
> > > shouldn't be runnning things from root.  Apache runs as its own user,
> > > but I'm assuming I then have to set up another user distinct from
> > > root?  (I know this is beyond the scope of this forum- maybe you could
> > > point me to some good resources?)
>
> > > On Jun 21, 3:33 pm, Yarko Tymciurak <[email protected]>
> > > wrote:
>
> > > > On Jun 21, 2:01 pm, Yarin <[email protected]> wrote:
>
> > > > > Got it!
> > > > > Stripped the try-catch and let the import fail...
>
> > > > > TICKET:
> > > > > ExtractionError: Can't extract file(s) to egg cache
>
> > > > > The following error occurred while trying to extract file(s) to the
> > > > > Python egg
> > > > > cache:
>
> > > > >   [Errno 13] Permission denied: '/.python-eggs'
>
> > > > Note:  This is root directory (!) ---  probably the "home" directory
> > > > for the user in question
>
> > > > > The Python egg cache directory is currently set to:
>
> > > > >   /.python-eggs
>
> > > > > Perhaps your account does not have write access to this directory?
> > > > > You can
> > > > > change the cache directory by setting the PYTHON_EGG_CACHE environment
> > > > > variable to point to an accessible directory.
>
> > > > Yes - what you want to do; google on PYTHON_EGG_CACHE and wsgi, for
> > > > example.
> > > > This is a place where python can (if needed) _temporarily_ extract
> > > > eggs.
>
> > > > > END TICKET
>
> > > > > Solution:
>
> > > > > $ mkdir /var/www/web2py/python-eggs
> > > > > $ sudo chown -R apache:apache python-eggs
>
> > > > It doesn't matter so much you owns this, as long as it's writable and
> > > > readable by your process.
> > > > It could just as logically be in /tmp directory (that way it would
> > > > clean up at system reboot too...)
>
> > > > > Then in web2py/gluon/tools.py:
>
> > > > >    3285         try:
>
> > > > > (Inserted)
> > > > > import os
> > > > > os.environ['PYTHON_EGG_CACHE'] = '/var/www/web2py/python-eggs'
>
> > > > >    3286             import pyamf
> > > > >    3287             import pyamf.remoting.gateway
> > > > >    3288         except:
> > > > >    3289             return "pyamf not installed or not in Python
>
> > > > > and it works!
>
> > > > > So my final questions to you is can you think of a more elegant,
> > > > > permanent way of setting this up?  Is it bad practice to repeatedly
> > > > > set environment vars in multi-threaded code?
>
> > > > You probably want to do this at web2py start, for web2py.   You should
> > > > be able to add this to options_std.py;  I think you should be able,
> > > > alternatively, to do this
> > > > in your parameters*.py file
> > > > (seehttp://www.web2py.com/book/default/section/4/1?search=environ).
>
> > > > that is, put these lines in either:
>
> > > > import os
> > > > os.environ[PYTHON_EGG_CACHE]=....
>
> > > > - Yarko
>
> > > > >  And it's probably not
> > > > > wise to assign ownership of the eggs cache to the apache user, as I
> > > > > assume it may be used for other things.  Thoughts?
>
> > > > > On Jun 21, 2:29 pm, Yarko Tymciurak <[email protected]>
> > > > > wrote:
>
> > > > > > On Jun 21, 12:18 pm, Yarin <[email protected]> wrote:
>
> > > > > > > @Yarko
>
> > > > > > > > Try to compare these two:
> > > > > > > > $ python -c 'import sys; print sys.path'
> > > > > > > > and, from your web2py directory:
> > > > > > > > $ python web2py.py -S welcome
> > > > > > > > >>> import sys;  print sys.path
> > > > > > > > Compare the two to see what's missing;
>
> > > > > > > Results, in order:
>
> > > > > > > [
> > > > > > > '',
> > > > > > > '/usr/lib/python2.5/site-packages/PyAMF-0.5.1-py2.5-linux-i686.egg',
> > > > > > > '/usr/lib/python25.zip',
> > > > > > > '/usr/lib/python2.5',
> > > > > > > '/usr/lib/python2.5/plat-linux2',
> > > > > > > '/usr/lib/python2.5/lib-tk',
> > > > > > > '/usr/lib/python2.5/lib-dynload',
> > > > > > > '/usr/lib/python2.5/site-packages',
> > > > > > > '/usr/lib/python2.5/site-packages/gtk-2.0'
> > > > > > > ]
>
> > > > > > > [
> > > > > > > '/var/www/web2py',
> > > > > > > '/usr/lib/python2.5/site-packages/PyAMF-0.5.1-py2.5-linux-i686.egg',
> > > > > > > '/usr/lib/python25.zip',
> > > > > > > '/usr/lib/python2.5',
> > > > > > > '/usr/lib/python2.5/plat-linux2',
> > > > > > > '/usr/lib/python2.5/lib-tk',
> > > > > > > '/usr/lib/python2.5/lib-dynload',
> > > > > > > '/usr/lib/python2.5/site-packages',
> > > > > > > '/usr/lib/python2.5/site-packages/gtk-2.0',
> > > > > > > '../gluon',
> > > > > > > '/var/www/web2py/site-packages'
> > > > > > > ]
>
> > > > > > > I don't see a problem here- do you?
>
> > > > > > No - I do not see this showing the problem - your pyamf installation
> > > > > > appears to be ok.
>
> > > > > > You can do what Massimo suggested to get more detailed info.
>
> > > > > > Also - fedora has a secure kernel which ...  I might suspect some
> > > > > > things because of that.
> > > > > > You might start by looking at the owner/group of your pyamf egg, and
> > > > > > comparing what / who web2py is running (the simple test would be to
> > > > > > run web2py as yourself - you've seen the path is the same;  see if
> > > > > > your imports work from the web2py shell when you are running as
> > > > > > "you" (instead of through apache, as some other process user/group).
>
> > > > > > If the web2py command line import works, then you may have an issue
> > > > > > with the user/group that web2py is running as under apache - or
> > > > > > perhaps even fedora protecting what anything running from apache can
> > > > > > access.
>
> > > > > > After you have tried the import runing from your shell as you (if it
> > > > > > works) you could try as sudo -u www-data (or whatever the web2py
> > > > > > process is running under);  this will help you sort out if it is a
> > > > > > user related constraint, or an apache process constraint that fedora
> > > > > > is putting on you.
>
> > > > > > You may also try what Massimo suggested;
>
> > > > > > Let us know your progress.
>
> > > > > > - Yarko
> > > > > > Also, run
>
> > > > > > > I've even run
>
> > > > > > > $ chmod -R 777 /usr/lib/python2.5/site-packages/PyAMF-0.5.1-py2.5-
> > > > > > > linux-i686.egg
>
> > > > > > > to ensure it's not a permissions issue, but I'm getting the same
> > > > > > > result...
>
> > > > > > > On Jun 21, 12:45 pm, Yarko Tymciurak <[email protected]>
> > > > > > > wrote:
>
> > > > > > > > On Jun 21, 10:57 am, Yarin <[email protected]> wrote:
>
> > > > > > > > > @mdipierro - Do you mean do I have multiple versions of 
> > > > > > > > > Python on my
> > > > > > > > > system?
>
> > > > > > > > > $ ls usr/bin/ shows ->
> > > > > > > > > ...
> > > > > > > > > -rwxr-xr-x 1 root root         82 Jul 10  2008 pydoc
> > > > > > > > > -rwxr-xr-x 1 root root       3572 Jul 10  2008 python
> > > > > > > > > lrwxrwxrwx 1 root root         16 Nov 27  2009 python-config 
> > > > > > > > > ->
> > > > > > > > > python2.5-config
> > > > > > > > > lrwxrwxrwx 1 root root          6 Nov 27  2009 python2 -> 
> > > > > > > > > python
> > > > > > > > > -rwxr-xr-x 1 root root       3572 Jul 10  2008 python2.5
> > > > > > > > > -rwxr-xr-x 1 root root       1418 Jul 10  2008 
> > > > > > > > > python2.5-config
>
> > > > > > > > > but all of these refer to version Python2.5.1
>
> > > > > > > > > Moreover, I know that that error is thrown from 
> > > > > > > > > web2py/gluon.tools.py
> > > > > > > > >    3285         try:
> > > > > > > > >    3286             import pyamf
> > > > > > > > >    3287             import pyamf.remoting.gateway
> > > > > > > > >    3288         except:
> > > > > > > > >    3289             return "pyamf not installed or not in 
> > > > > > > > > Python
> > > > > > > > > sys.path"
>
> > > > > > > > > but when I run from the command line...
>
> > > > > > > > > $ python
>
> > > > > > > > > >>>> import pyamf
> > > > > > > > > >>>> import pyamf.remoting.gateway
>
> > > > > > > > Try to compare these two:
>
> > > > > > > > $ python -c 'import sys; print sys.path'
>
> > > > > > > > and, from your web2py directory:
>
> > > > > > > > $ python web2py.py -S welcome
>
> > > > > > > > >>> import sys;  print sys.path
>
> > > > > > > > Compare the two to see what's missing;
>
> > > > > > > > You can also find where your pyamf was installed -
>
> > > > > > > > If you are not seeing it somewhere like /usr/lib/python2.5/site-
> > > > > > > > packages (use your sys.path as a guide to the correct path), 
> > > > > > > > then it
>
> ...
>
> read more »

Reply via email to