summaryrefslogtreecommitdiff
path: root/libgfortran/runtime
diff options
context:
space:
mode:
authorjb <jb@138bc75d-0d04-0410-961f-82ee72b054a4>2012-05-05 06:30:51 +0000
committerjb <jb@138bc75d-0d04-0410-961f-82ee72b054a4>2012-05-05 06:30:51 +0000
commita291e3b6538a0697986d1a7d22aa220829998bab (patch)
treeac63807666eaf2ebc05379c848806981ba536332 /libgfortran/runtime
parente3168f5bde2d4ceb1543c5ea0c779ee66b5f9a02 (diff)
downloadgcc-a291e3b6538a0697986d1a7d22aa220829998bab.tar.gz
Fix handling of temporary files.
2012-05-05 Janne Blomqvist <jb@gcc.gnu.org> * gfortran.texi (GFORTRAN_TMPDIR): Rename to TMPDIR, explain algorithm for choosing temp directory. 2012-05-05 Janne Blomqvist <jb@gcc.gnu.org> * config.h.in: Regenerated. * configure: Regenerated. * configure.ac: 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@187190 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/runtime')
-rw-r--r--libgfortran/runtime/environ.c18
-rw-r--r--libgfortran/runtime/main.c2
2 files changed, 16 insertions, 4 deletions
diff --git a/libgfortran/runtime/environ.c b/libgfortran/runtime/environ.c
index 7782cee044c..bcb91f44613 100644
--- a/libgfortran/runtime/environ.c
+++ b/libgfortran/runtime/environ.c
@@ -56,6 +56,19 @@ variable;
static void init_unformatted (variable *);
+
+#ifdef FALLBACK_SECURE_GETENV
+char *
+secure_getenv (const char *name)
+{
+ if ((getuid () == geteuid ()) && (getgid () == getegid ()))
+ return getenv (name);
+ else
+ return NULL;
+}
+#endif
+
+
/* print_spaces()-- Print a particular number of spaces. */
static void
@@ -285,9 +298,8 @@ static variable variable_table[] = {
"Unit number that will be preconnected to standard error\n"
"(No preconnection if negative)", 0},
- {"GFORTRAN_TMPDIR", 0, NULL, init_string, show_string,
- "Directory for scratch files. Overrides the TMP environment variable\n"
- "If TMP is not set " DEFAULT_TEMPDIR " is used.", 0},
+ {"TMPDIR", 0, NULL, init_string, show_string,
+ "Directory for scratch files.", 0},
{"GFORTRAN_UNBUFFERED_ALL", 0, &options.all_unbuffered, init_boolean,
show_boolean,
diff --git a/libgfortran/runtime/main.c b/libgfortran/runtime/main.c
index 79659e52bcd..72c32fc2e1b 100644
--- a/libgfortran/runtime/main.c
+++ b/libgfortran/runtime/main.c
@@ -163,7 +163,7 @@ find_addr2line (void)
{
#ifdef HAVE_ACCESS
#define A2L_LEN 10
- char *path = getenv ("PATH");
+ char *path = secure_getenv ("PATH");
if (!path)
return;
size_t n = strlen (path);