This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch, libfortran] Fix handling of temporary files


the attached patch implements some fixes for handling STATUS="SCRATCH" files.

- Currently, we check GFORTRAN_TMPDIR, TMP, and TEMP environment
variables, but not the POSIX and GNU standard TMPDIR. As specifying a
temporary directory depending on the compiler used to create an
application doesn't make much sense, the patch just uses the standard
TMPDIR (on Windows TMP and TEMP are used, and on MingW/Cygwin those
variables are still checked)

- The patch tries to create a temporary file in the first possible
directory, and tries the next directory in the list if the current one
fails, and so on. Document this search logic.

- Use the macro P_tmpdir which is available on many systems.

- If the program is privileged, we shouldn't trust path style
environment variables. The patch fixes this for TMPDIR and also for
the logic figuring out where addr2line is.

Regtested on x86_64-unknown-linux-gnu, Ok for trunk?

gcc/fortran ChangeLog:

2012-04-19  Janne Blomqvist  <>

	* gfortran.texi (GFORTRAN_TMPDIR): Rename to TMPDIR, explain
	algorithm for choosing temp directory.

libgfortran ChangeLog:

2012-04-19  Janne Blomqvist  <>

	* Regenerated.
	* configure: Regenerated.
	* Add checks for getegid and __secure_getenv.
	* io/unix.c (P_tmpdir): Fallback definition for macro.
	(tempfile_open): New function.
	(tempfile): Use secure_getenv, call tempfile_open to try each
	directory in turn.
	* libgfortran.h (DEFAULT_TMPDIR): Remove macro.
	(secure_getenv): New macro/prototype.
	* runtime/environ.c (secure_getenv): New function.
	(variable_table): Rename GFORTRAN_TMPDIR to TMPDIR.
	* runtime/main.c (find_addr2line): Use secure_getenv.

Janne Blomqvist

Attachment: tmpdir.diff
Description: Binary data

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]