[GRASS5] 5.7 - GIS manager - zoom and pan - change term to execute in d.m.tcl

Glynn Clements glynn.clements at virgin.net
Wed Oct 20 13:03:02 EDT 2004


Hamish wrote:

> > > > See if this fixes the problem. If so, I can easily make a generic
> > > > change to all the buttons as they all use this format.
> > > 
> > > No, this doesn't make a difference for me...
> > > 
> > > When I try to launch 'xterm -e d.zoom' from the GRASS command line,
> > > I have the same problem. When I launch xterm from the GRASS command
> > > line I get an xterm, but when I enter d.zoom in there, I get:
> > > 
> > > d.zoom: error while loading shared libraries: libgrass_display.so:
> > > cannot open shared object file: No such file or directory
> > 
> > This usually occurs because xterm is setuid/setgid. For security
> > reasons, the loader unsets certain environment variables (e.g. 
> > LD_LIBRARY_PATH) when running setuid/setgid programs.
> > 
> > You need to add the full path for $GISBASE/lib to /etc/ld.so.conf then
> > run ldconfig. This will allow the GRASS shared libraries to be found
> > when LD_LIBRARY_PATH is unset.
> 
> [that fixes it but isn't a real solution]

A better solution is to install a script to re-set LD_LIBRARY_PATH,
e.g.:

	#!/bin/sh
	if [ -n "$LD_LIBRARY_PATH" ] ; then
		LD_LIBRARY_PATH=$GISBASE/lib:$LD_LIBRARY_PATH
	else
		LD_LIBRARY_PATH=$GISBASE/lib
	fi
	export LD_LIBRARY_PATH
	prog="$1"
	shift
	exec "$prog" "$@"

then change the "term" function to use it, e.g.:

	proc term {cmd args} {
	    eval exec -- xterm -e $env(GISBASE)/etc/run $cmd $args &
	}

The script would have to be dynamically generated to use the correct
variable name, as is currently done for etc/Init.sh.

> mmmn.. 
> 
> $ ls -l `which xterm`
> -rwxr-sr-x  1 root utmp 259896 Sep 29 00:10 /usr/bin/X11/xterm*

This is setgid, so LD_* will be cleared.

> from the command line:
> xterm -e "ls $LD_LIBRARY_PATH/libgrass_gis* ; g.version ; read"
> 
> pops up a window with this output:
> /usr/local/src/grass/grass57/dist.i686-pc-linux-gnu/lib/libgrass_gis.so
> g.version: error while loading shared libraries: libgrass_gis.so: cannot open shared object file: No such file or directory
> 
> 
> so $LD_LIBRARY_PATH survives, ???

No. The expansion is performed by the shell from which xterm is run.
You would need to use e.g.:

	xterm -e sh -c 'ls $LD_LIBRARY_PATH/libgrass_gis* ; g.version ; read'

[Note: *single* quotes.]

> $PATH must survive, otherwise it wouldn't have found the
> $GISBASE/bin/g.version which called libgrass_gis.so ...
> 
> If it were ignoring $LD_LIBRARY_PATH I'd think it would ignore $PATH
> as well?

No. $PATH doesn't have the same security implications.

-- 
Glynn Clements <glynn.clements at virgin.net>




More information about the grass-dev mailing list