2008/4/5 Nikos Apostolakis <[EMAIL PROTECTED]>:
>
>
>  mabshoff <[EMAIL PROTECTED]> writes:
>
>  > On Apr 5, 7:20 am, Nikos Apostolakis <[EMAIL PROTECTED]> wrote:
>  >> Hi,
>  >>
>  >> I am trying to use sage in a cgi script and every time I try to
>  >> import the sage libraries I keep getting the following error
>  >>
>  >> -------- 8< --------
>  >> Traceback (most recent call last):
>  >>   File "/usr/local/include/sage-2.10.2/local/bin/sage-eval", line 4,
>  >>   in <module>
>  >>     from sage.all import *
>  >>   File
>  >>   
> "/usr/local/include/sage-2.10.2/local/lib/python2.5/site-packages/sage/all.py",
>  >>   line 53, in <module>
>  >>     from sage.misc.all       import *         # takes a while
>  >>   File
>  >>   
> "/usr/local/include/sage-2.10.2/local/lib/python2.5/site-packages/sage/misc/all.py",
>  >>   line 1, in <module>
>  >>     from misc import (alarm, ellipsis_range, ellipsis_iter, srange,
>  >>   xsrange, sxrange, getitem,
>  >>   File
>  >>   
> "/usr/local/include/sage-2.10.2/local/lib/python2.5/site-packages/sage/misc/misc.py",
>  >>   line 83, in <module>
>  >>     os.makedirs(DOT_SAGE)
>  >>   File "/usr/local/include/sage-2.10.2/local/lib/python2.5/os.py",
>  >>   line 172, in makedirs
>  >>     mkdir(name, mode)
>  >> OSError: [Errno 13] Permission denied: '/.sage/'
>  >> -------- >8 --------
>  >>
>  >> I guess that at some point sage tries to create a directory at "/"
>  >> and it doesn't have permisssion to.
>  >
>  > Hi Nick,
>  >
>  > Sage checks for the exitence of $HOME/.sage and if it doesn't exist
>  > creates it. In your case $HOME seems to be empty.
>  >
>
>  Ok, I see.  But shouldn't $HOME be "/var/www"?  According to
>  /etc/passwd that's the home directory of the apache user.
>
>  I don't know if the following make sense but is it possible to
>  have some kind of global .sage directory for cases like this?
>  Something like `/etc/sage/'.  Is it really necessary for a user
>  to have a `~/.sage' directory in order to run a script that uses
>  sage?
>

Yes, it is absolutely necessary.  Sage needs a directory where it
stores configuration info, temp files, etc.   However, if you set the
environment variable DOT_SAGE then the directory it is
set to will be used exactly ~/.sage would be used.   For example,

teragon:~ was$ export DOT_SAGE=/Users/was/tmp/foo
teragon:~ was$ sage
----------------------------------------------------------------------
| SAGE Version sage-2.11, Release Date: 2008-03-30                   |
| Type notebook() for the GUI, and license() for information.        |
----------------------------------------------------------------------
Setting permissions of DOT_SAGE directory so only you can read and write it.
Loading SAGE library. Current Mercurial branch is: referee
sage:
Exiting SAGE (CPU time 0m0.00s, Wall time 0m6.18s).
Exiting spawned Gap process.
teragon:~ was$ ls /Users/was/tmp/foo
db           gap          ipython      matplotlibrc temp


>
>  >> Is this a bug?  Any workarounds?
>  >
>  > It isn't a bug. To fix this we need to know more about your setup,
>  > i.e. which user the webserver runs as, which webserver you are using
>  > and so on.
>
>  I've tried this with two setups, Debian unstable with apache2 and
>  Ubuntu 7.10 with thttpd, in both cases the distribution provided
>  packages. On the Debian box apache runs as `www-data', I don't have
>  access to the Ubuntu box right now but I used the standard setup in
>  both case since my knoweldge of this stuff is minimal.  Also in both
>  machines sage has been install by the superuser at /usr/local/include.
>
>  This morning I played a bit more with this.  After creating a
>  directory "/.sage" with owner "www-data" and permissions 700 the cgi
>  scripts seem to work.  I am not sure that this is a good solution on
>  the long run though.

That's fine  Either do that or better set the DOT_SAGE variable
to a directory that www-data has write access to.

>  Are there any security (or other) issues that
>  could result from this hack?

Just out of curiosity what Sage functionality are you exporting over
the web.  Because there are a lot of security issues that could
arise from whatever you're actually doing.

william

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to