[GRASS-dev] running d.mon outside grass shell with php & granting rights problem

Dear list,

when running d.mon out of a php script, I see

d.mon start=PNG:
/usr/local/grass-6.1.cvs/driver/PNG: error while loading shared libraries: libgrass_driver.so: cannot open shared object file: No such file or directory

Inside the grass shell, it works fine. The environment variables for PATH and GRASS_LD_LIBRARY_PATH are pointing at the right locations (from my point of view; the requested files ar there and accessible). I nicked the php code from Markus' grass.itc.it/spearfish example.

Second thing:
I can't get outside-shell-access to a mapset even when calling in advance g.access with grant for both user and group. When chowning the entire location directory to user www-data, it works, but then there is no longer access from the grass shell.

Now I'm stuck and confused. r.out.png works with the chowned directory. Did I mix something up with the environment variables?

/Stefan

full php result in working order is:

system("env"):
GRASS_GNUPLOT=gnuplot -persist
GRASS_PAGER=more
GISRC=/gd/.grassrc6_php
GRASS_WISH=wish
USER=www-data
MONITOR=PNG
GRASS_PNG_COMPRESSION=1
GRASS_TRUECOLOR=TRUE
GISBASE=/usr/local/grass-6.1.cvs PATH=/usr/lib:/usr/local/grass-6.1.cvs/lib:/usr/local/grass-6.1.cvs/driver:/ usr/local/grass-6.1.cvs/bin:/usr/local/grass-6.1.cvs/scripts:/usr/local/bin: /usr/local/sbin:/sbin:/usr/sbin:/bin:/usr/bin:/usr/bin/X11 TCLTKGRASSBASE=/usr/local/grass-6.1.cvs/etc
_=/usr/bin/env PWD=/home/grassdata
GIS_LOCK=$$
GISRCRC=/gd/.grassrc6_php
LANG=C
GRASS_VERSION=6.1.cvs
HOME=/tmp SHLVL=2 LANGUAGE=de_DE:de:en_GB:en
GRASS_HTML_BROWSER=mozilla GRASS_LD_LIBRARY_PATH=/usr/lib:/usr/local/grass-6.1.cvs/lib:/usr/local/grass -6.1.cvs/driver GRASS_PERL=/usr/bin/perl
GRASS_PNGFILE=/gd/bild.png
GRASS_WIDTH=900
GRASS_GUI=tcltk
GRASS_TCLSH=tclsh g.gisenv:
GISDBASE='/gd';
GRASS_GUI='tcltk';
MAPSET='etopo5';
LOCATION_NAME='www';

systen("d.mon start=PNG"):
/usr/local/grass-6.1.cvs/driver/PNG: error while loading shared libraries: libgrass_driver.so: cannot open shared object file: No such file or directory

system("d.rast"):
No graphics monitor has been selected for output.

("r.out.png input=etopo5 output=bild2.png") :
rows = 180, cols = 360 Converting raw... 0% 6% 12% 18% 24% 30% 36% 42% 48% 54% 60% 66% 72% 78% 84% 90% 96% Done.

// note: image is correct dumped to file.

Paulick Consult wrote:

when running d.mon out of a php script, I see

d.mon start=PNG:
/usr/local/grass-6.1.cvs/driver/PNG: error while loading shared libraries:
libgrass_driver.so: cannot open shared object file: No such file or
directory

Inside the grass shell, it works fine. The environment variables for PATH
and GRASS_LD_LIBRARY_PATH are pointing at the right locations (from my point
of view; the requested files ar there and accessible). I nicked the php code
from Markus' grass.itc.it/spearfish example.

You need to set LD_LIBRARY_PATH. GRASS_LD_LIBRARY_PATH is merely a
saved copy so that the value can be restored if LD_LIBRARY_PATH is
reset due to running a setuid/setgid executable (e.g. xterm).
LD_LIBRARY_PATH is what the Linux loader actually uses to locate
shared libraries.

Second thing:
I can't get outside-shell-access to a mapset even when calling in advance
g.access with grant for both user and group. When chowning the entire
location directory to user www-data, it works, but then there is no longer
access from the grass shell.

You can't select a mapset as the current mapset unless you actually
own it. Having write permission isn't sufficient.

This check is implemented in G__mapset_permissions() and
G__mapset_permissions2() in lib/gis/mapset_msc.c. You will have to
modify those functions to disable the check if you want to be able to
modify mapsets which you don't own.

If your web application only reads the data, you can create a single
mapset directory owned by the account under which the PHP script runs,
then either use g.mapsets or explicit map@mapset references to access
maps in other mapsets.

--
Glynn Clements <glynn@gclements.plus.com>