[GRASS-dev] G_tempfile() proposed changes [relevant to creating a new location]

Glynn Clements glynn at gclements.plus.com
Sun Jan 7 05:34:42 EST 2007


Paul Kelly wrote:

>   * Write a new G_tempfile() that puts a tempfile in the directory pointed 
> to by the TEMP environment variable if it exists (this will be somewhere 
> writeable by the user on Windows) or P_tmpdir otherwise (/tmp on Unix or 
> root of current drive on Windows).

Unix uses $TMPDIR rather than $TEMP. I'd suggest that G_tempfile()
should use $TMPDIR in preference to /tmp, to eliminate potential
security issues related to the use of world-writable directories,
although this isn't necessary if a private subdirectory is used.

> The reason I haven't applied the changes yet is that I'm slightly worried 
> about what the effect might be of the sudden change. In particular, that 
> tempfiles created by the current G_tempfile (i.e. in the current mapset) 
> get cleaned up at the end of the session and after the change they won't. 
> Should we just change it and fix things on a case-by-case basis? (Either 
> change them to create the tempfile in the mapset, or force them to delete 
> it?) A bit of a dilemma.

I would suggest using a private subdirectory of /tmp ($TEMP, $TMPDIR),
linked to a particular session (i.e. use $GIS_LOCK in the directory
name) so that we can clean it up safely.

Was there a reason for not using the /tmp/grass-<user>-$GIS_LOCK
directory (where the monitor sockets are stored)?

I do feel that we should figure out a solution which allows for
cleaning up (i.e. not using a directory which is shared with temporary
files created by programs other than GRASS) before changing anything.

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




More information about the grass-dev mailing list