[Lispweb] Question: problem with execute rights in clisp cgi, :MAY-EXEC ?
Pascal Bourguignon
pjb at informatimago.com
Thu Apr 20 07:56:44 CDT 2006
rso at gmx.at writes:
> Hallo,
>
> I have a unix (freebsd) specific problem, at least that is what I
> think. Here is the situation:
>
> I run a clisp cgi script in apache2 in a directory with permissions
> 777. This clisp script creates a file example.tex Then I let lisp
> execute a perl script with this function:
>
> (defun makePicFile (input texSource)
> "creates picture file with same name as html file but different
> ending, returns the name of the picture"
> (EXT:RUN-PROGRAM "./textogif" :ARGUMENTS
> (list "-png"
> (writeToFile (mkName input ".tex")
> texSource))
> :OUTPUT NIL)
> (mkName input ".png"))
>
> Now all this worked fine on a ubuntu linux system, but unfortunately
> not on the freebsd system.
>
> I changed the header of the perl script, it has all the
> permissions. If I start the perl script manually as a user
> everything works fine. It creates the file, makes the system calls
> etc. So it is not the problem of the perl script.
>
> If the perl script (started by clisp) is run by the apache user www
> it fails at the first system call: echo x | latex example.tex
> returns: Error processing Command and the perl script exits. Which I
> know from reading the httpd-error.log file.
Do you have more details on this error?
What is different in the CGI environment is the user and group, the
SUID bit which is reset by the server, and the environment variables.
(Perhaps the root directory, if a chroot jail is activated).
I'd bet for the environment variables.
Add:
(format t "<table>~%")
(dolist (var-val (ext:getenv))
(format t "<tr><td>~A</tr><td>~A</td></tr>~%" (car var-val) (cdr var-val)))
(format t "</table>~%")
to your CGI clisp script.
Check the PATH variable. Does it contain the directory where latex lies?
If not, try to use absolute pathnames in your perl script, or add the
relevant directories to the environment variable before calling the
perl script:
(setf (ext:getenv "PATH") (format nil "~A~{:~A~}" (ext:getenv "PATH")
'("/usr/bin" "/usr/local/bin" "..." )))
(ext:run-program ...)
> So I thought this is a problem of permissions.
>
> In [1] I found the keyword :MAY-EXEC specifically for unix systems. So
> I added :MAY-EXEC T to the makePicFile function above. But this gave
> me the error:
>
> *** - RUN-PROGRAM: illegal keyword/value pair :MAY-EXEC, T in argument
> list. The allowed keywords are (:ARGUMENTS :INPUT :OUTPUT
> :IF-OUTPUT-EXISTS :WAIT)
>
> So I guess this does not exist anymore or in my clisp version? (GNU
> CLISP 2.38 (2006-01-24) (built 3353839801) C-MODULS: contains
> 'syscalls' too
>
> How could I solve this problem?
See above. If this doesn't work, add more log and error handling,
either in the clisp or in the perl script.
"Error processing Command" doesn't tell much.
> How can I use the :MAY-EXEC keyword?
Well, it should be available, *BSD is UNIX(-like).
Check whether you've got :UNIX in *FEATURES*.
If not, it may be a problem in configure.
You could get the same effect forcibly using run-shell-command instead
of run-program, and inserting exec in front of the command:
> Is this the right approach?
I don't think it'll help. exec only serves to avoid one fork in the shell.
> The error might lie in my apache configuration too, but the only
> thing I found was suExec which doesn't seem to be right.
--
__Pascal Bourguignon__ http://www.informatimago.com/
The mighty hunter
Returns with gifts of plump birds,
Your foot just squashed one.
More information about the lispweb
mailing list