[Maxima] plot2d in Lisp CGI (was: plot2d output "")
milan at eskimo.com
Fri Sep 21 20:29:04 CDT 2007
* Yigal Asnis <yigalasnis at yahoo.com> [2007-09-20 02:48:13 -0700]:
"> Apache run on my machine as "www-data" user, so I think may be a
solution will be to save maxima image as this user, but I don't know
right now how to do it."
This is both interesting and puzzling. Here is a way to make a new
Maxima image running Clisp as "www-data" user.
1) su /* i.e., become a root */
2) chsh -s /bin/bash www-data /* the default shell for www-data is
probably /bin/false. This will
change it to /bin/bash
3) su www-data /* become the www-data user */
4) cd /tmp or whatever directory you want to use ...
5) prepare new maxima image, plus whetever other work you might need
to do while www-data user. When done,
6) exit /* now you should be root again */
8) chsh -s /bin/false www-data /* restore the original www-data
HTH. I could not test this since I am unable to reproduce your
#$plot2d .... Namely, I can do "clisp -M maxima.mem" but then I am
like in a regular Maxima session, so I don't know how you get to that
> As I wrote, #$plot2d(...)$ (not part of script, just that command from clisp) from root terminal worked, but from my "yigal" user terminal I got "permission denied" error.
> All other maxima's command (except plot2d) worked from both terminals, as well as direct execution of "gnuplot", so there is something special with plot2d.
> I tryed plot2d to screen and to file (to directory that "yigal" can write in), with format "gnuplot" and "gnuplot-pipes" - the result is same error.
> I thought, may be the problem is in maxima image, so I saved new maxima image, this time from clisp runned by "yigal" user and not by root as I did before. Now I can do plot2d from user terminal and CGI script runned from user terminal works too!
> Apache run on my machine as "www-data" user, so I think may be a solution will be to save maxima image as this user, but I don't know right now how to do it.
> Anyway, I think, there is something to fix with plot2d function.
> Milan Lukic <milan at eskimo.com> wrote: I would try to play with umask, and if that does not help, then
> try a Debian user group, say http://lists.debian.org/debian-apache
> I was making a tighter security on a linux machine last year and one
> of consequences was that I only could run Maxima as root. The fix was
> simple, but I can't remember now what did the trick. Sorry for not
> being of more help.
> * Yigal Asnis <yigalasnis at yahoo.com> [2007-09-19 00:08:20 -0700]:
> > The error in Apache log is "UNIX error 13 (EACCES): Permission denied".
> > I tryed to run the script from a console:
> > If I log in as root, there is no problem - plot is created.
> > If I log in as non-root (my regulary user "yigal") I get the same error as in Apache log above.
> > I checked the permissions of gnuplot - it can be executed by everyone.
> > I tryed to create output file in directory that everyone can write in : [gnuplot_out_file "/tmp/outfile.ps"], but still have the same error.
> > Finally, I runned
> > clisp -M -maxima.mem
> > from my non-root-user terminal (usually I use root terminal) and tryed
> > #$plot2d (sin(x), [x,-1,1], [gnuplot_term, ps], [gnuplot_out_file "/tmp/outfile.ps"])$
> > and still have the same error!
> > What else can be wrong with permissions?
> > Andrej Vodopivec wrote: On 9/18/07, Rupert Swarbrick wrote:
> > > On Mon, 17 Sep 2007 13:17:21 -0700 (PDT)
> > > Yigal Asnis wrote:
> > >
> > > > It turns out that return value of plot2d ("") wasn't
> > > > problem. I suppressed it by (progn #$plot2d(...)$
> > > > (princ "something I need to print")) but CGI program
> > > > still stuck.
> > > > If I execute the CGI file from terminal, it works -
> > > > plot2d generates plot file and all other output work
> > > > as expected.
> > > > But if I point to CGI file with browser, the plot file
> > > > isn't generated and all commands after plot2d aren't
> > > > executed.
> > > > I think the problem is calling external function
> > > > (gnuplot) from CGI.
> > > > I use Apache with mod_cgi on Debian.
> > > >
> > > > Yigal Asnis
> > >
> > > Are you on *nix?
> > >
> > > I don't know much at all about cgi programming in general or with
> > > gnuplot in particular, but maybe there's a problem because gnuplot is
> > > an X11 program?
> > >
> > > In particular, try running some random X11 program (gnuplot,xeyes ?)
> > > from a console (Ctrl-Alt-F1) on Linux and you'll get a 5 sec. or so
> > > wait followed by an error message complaining that it was unable to
> > > communicate with the X server (because the DISPLAY variable was not set
> > > and it doesn't know who to ask).
> > >
> > > Running from Apache as a CGI script, your program might have a similar
> > > problem. Have you tried running your CGI script via a proper console? I
> > > think that would show whether this is the problem.
> > gnuplot does not require X to be running. The following produces a ps
> > file even from console (you need to set the plot_format to gnuplot,
> > the default gnuplot_pipes does not work for me).
> > plot2d(sin(x), [x,-5,5], [plot_format, gnuplot], [gnuplot_term, ps]);
> > HTH,
More information about the Maxima