OS X Rev CGI engine failure

Andre Garzia andre at andregarzia.com
Fri Sep 19 11:14:20 EDT 2008


Hello Jacque,

In MacOS X only the logged user has permission to connect to the
windowing server (layer), so when you run your script from the
terminal, it runs as the logged user, thus, revolution engine is able
to connect to the GUI layer and is pretty happy. When you run as cgi,
apache runs the cgi as user nobody (or a similar underpowered foe).
This is for security reasons as you don't want your cgi to have
administrator privileges.

There are many ways to solve that.

First Solution - or, you have the wrong engine -
Copy the engine from the Standalone.app in the Runtime folder of
3.0-gm-* Thats the correct CGI engine. I think you copied the one from
Revolution.app. I just tried the engine from 3.0-gm-3 here and it
works fine as a CGI. You need to call it with the shebang and dash ui
as you know (actually I think it was you or mark that first told me
that).

Second Solution  - or, shameless plug -
You can use the latest version of RevHTTP to run plain old cgis from
inside the IDE. Yes, you just put the .cgi files in the correct place
and it will run like a normal standard law abiding web server.
Courtesy of msgboxredirect. It's a nice way to run cgis since it
allows you to fire the debugger.

Third Solution - or, I am a unix junkie -
As I've said above, the whole problem happens because the user that
apache uses to run the cgis is not the logged user and can't access
MacOS X higher functions such as GUI access. One solution is to make
cgis run as the logged user. To do that you need to have suEXEC
enabled on your apache. By default, the bundled apache comes with it
enabled but missing the actual suEXEC file. If you have that binary
file in place, then, any cgi that runs from inside your Sites folder
in your Home folder (~/Sites) will run as your user (similar
/Users/AnotherUser/Sites cgis will run as AnotherUser).

suEXEC is built as a binary component for each apache version. I have
versions here for both powerpc and intel. It's fairly easy to build it
if you know your unix-fu. You just pick the Apache source code (the
horror! the horror!) and build it in a contained directory
(./configure --prefix=/my/sweet/folder; make; make install) then after
much cpu chunking you have the suEXEC binary in that folder you
specified, along with all the other apache files, you simply copy the
suEXEC binary from there to the correct place. You also need to
specify some suEXEC commands in the ./configure options but I can't
recall them by memory.

Why would you go with this approach? Well, running as the logged user
allows you not only to connect to the GUI but also other running apps,
so you can make a little CGI that calls osascript command to call
apple script stuff or even communicate to standalones or the
revolution IDE. This is useful in some scenarios.


I hope one of these solutions solve your problem, well, the first one
will solve for sure, I just tried here, the others are niche solutions
for specific needs!

Cheers
andre

On Fri, Sep 19, 2008 at 2:12 AM, J. Landman Gay
<jacque at hyperactivesw.com> wrote:
> I'm trying to do some CGI testing on my OS X machine locally. For ages I've
> been using an old copy of MetaCard locally but I just tried Rev (both 2.9.1
> and 3.0). I can't get the it to run.
>
> The script, permissions, etc. are correct. The Rev engine is the
> Runtime/Standalone engine from inside the the app bundle. The script's
> shebang line has the -ui flags set. If I run the cgi script from Terminal it
> works fine. But if I run it from a browser or do a "get url" from Rev's
> message box I get this server error:
>
> "could not establish the default connection to the WindowServer [date and
> stuff] Premature end of script headers: "
>
> If I change the declaration to point to the old copy of MetaCard in the cgi
> folder, the script runs fine. Anyone know why Rev is trying to load the
> window manager? And why only when called from a browser?
>
> Andre, are you there? :)
>
> --
> Jacqueline Landman Gay         |     jacque at hyperactivesw.com
> HyperActive Software           |     http://www.hyperactivesw.com
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>



-- 
http://www.andregarzia.com All We Do Is Code.



More information about the use-livecode mailing list