Group :: Development/C
RPM: imake
Main Changelog Spec Patches Sources Download Gear Bugs and FR Repocop
Patch: imake-1.0.5-alt-tmpdir.patch
Download
Download
diff -ur imake-1.0.5.old/imake.c imake-1.0.5/imake.c
--- imake-1.0.5.old/imake.c 2012-03-26 13:31:27.000000000 +0000
+++ imake-1.0.5/imake.c 2012-03-26 16:05:04.245005685 +0000
@@ -144,6 +144,10 @@
* <add any global targets like 'clean' and long dependencies>
*/
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE 1
+#endif
+
#include "config.h"
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
@@ -303,9 +307,9 @@
const char *cpp = NULL;
const char *tmpMakefile;
-const char *tmpMakefileTemplate = "/tmp/Imf.XXXXXX";
+const char *tmpMakefileTemplate = "Imf.XXXXXX";
const char *tmpImakefile;
-const char *tmpImakefileTemplate = "/tmp/IIf.XXXXXX";
+const char *tmpImakefileTemplate = "IIf.XXXXXX";
const char *make_argv[ ARGUMENTS ] = {
#ifdef WIN32
"nmake"
@@ -371,6 +375,13 @@
boolean verbose = FALSE;
boolean show = TRUE;
+static char *get_tmp_file_name (const char *pattern)
+{
+ char *name = 0;
+ asprintf (&name, "%s/%s", getenv("TMPDIR") ?: "/tmp", pattern);
+ return name;
+}
+
int
main(int argc, char *argv[])
{
@@ -402,7 +413,7 @@
#ifdef HAVE_MKSTEMP
int fd;
#endif
- char *tmpMakefileName = Strdup(tmpMakefileTemplate);
+ char *tmpMakefileName = get_tmp_file_name(tmpMakefileTemplate);
#ifndef HAVE_MKSTEMP
if (mktemp(tmpMakefileName) == NULL ||
(tmpfd = fopen(tmpMakefileName, "w+")) == NULL) {
@@ -956,23 +967,13 @@
static void
get_libc_version(FILE *inFile)
{
- char aout[4096], *tmpdir;
+ char *aout = get_tmp_file_name("imakeXXXXXX"), *tmpdir;
FILE *fp;
const char *format = "%s -o %s -x c -";
char *cc;
int len;
char *command;
- /* If $TMPDIR is defined and has an acceptable length,
- * use that as tmp dir, else use /tmp. That fixes
- * problems with /tmp mounted "noexec".
- */
- if((tmpdir = getenv("TMPDIR")) != NULL && strlen(tmpdir) < (4096-13))
- strcpy(aout, tmpdir);
- else
- strcpy(aout, "/tmp");
- strcat(aout, "/imakeXXXXXX");
-
/* Pre-create temp file safely */
{
/* Linux + ELF has mkstemp() */
@@ -1782,7 +1783,7 @@
#ifdef HAVE_MKSTEMP
int fd;
#endif
- char *tmpImakefileName = Strdup(tmpImakefileTemplate);
+ char *tmpImakefileName = get_tmp_file_name(tmpImakefileTemplate);
#ifndef HAVE_MKSTEMP
if (mktemp(tmpImakefileName) == NULL ||
(outFile = fopen(tmpImakefileName, "w+")) == NULL) {