[Xapian-discuss] How to wrap omega cgi in a script

Olly Betts olly at survex.com
Wed Jun 20 23:28:26 BST 2007


On Wed, Jun 20, 2007 at 07:47:20PM +0000, - Tong - wrote:
> What is the proper way to wrap omega in a cgi shell script? The reason that
> I need to wrap it up is that sourceforge.net does not allows binary
> executable cgi programs [1].

I've not read anything about such a restriction.

> [1]
>   $ lynx -dump http://xpt.sourceforge.net/cgi-bin/omega
>                                   Forbidden
> 
>    You don't have permission to access /cgi-bin/omega on this server.

I don't get the forbidden now, and looking on the sourceforge server, I
noticed you've remove the symlink, so I suspect they've just configured
it so that CGI binaries can't be symlinks.

> Here is how I'm doing:
> 
>  /home/groups/x/xp/xpt/cgi-bin$ ls -gGl search omega
>  lrwxrwxrwx  1 22 06-20 11:59 omega -> ../lib/omega/bin/omega
>  -rwxr-xr-x  1 21 06-20 12:27 search
> 
>  $ cat search
>  #!/bin/sh
>  omega "$@"

You need to specify a path to Omega here.  It's unusual for the default
PATH to contain `.' on Unix (I've seen it on some RedHat boxes, but it's
arguably a minor security risk on shared machines).  If you put
"printenv" in a CGI shell script, you'll see it isn't here anyway.

There won't be any parameters, so the `"$@"' isn't needed.

> Everything is fine testing on commnand line[2], but when using the cgi
> shell script from the web, I got:

If I use this shell script (`exec 2>&1' redirects stderr to stdin for
the current script, and so its children):

#!/bin/sh
echo "Content-Type: text/plain"
echo
exec 2>&1
./omega
echo Exit code: $?

Then the output I get is:

./omega: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
Exit code: 127

ldd on omega from the shell should it's found, but if you stick ldd in
the script above, it isn't.  And `ls -l /usr/lib' shows it isn't there.
I guess the shell server and web server(s) both mount /home but aren't
the same machine.

I found I can make it work by copying /lib/libgcc_s.so.1 and
/usr/lib/libstdc++.so into ../lib (from cgi-bin) and then using this
script:

#!/bin/sh
LD_LIBRARY_PATH=$PWD/../lib ./omega

It might actually be cleaner to statically link omega in this case - the
above has the potential to stop working if either machine is upgraded.

> FYI, I'm the one who posted here quite a while ago asking if it is possible
> to install xapian/omega on sourceforge.net so that every hosted project
> can use it., and set force on the pilot work since. It has not been easy
> for me, but as you can see in [2], I've made it to this last step.

Yes, I remember - good to hear you're pretty close to making it work.
Hopefully the hints above can get you the rest of the way!

Cheers,
    Olly



More information about the Xapian-discuss mailing list