mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-15 04:32:24 +00:00
Use mkstemp() and handle /usr/lib64 in imake.c
tmpnam() usage replaced with mkstemp(). Find a suitable tmp directory checking the TMPDIR environment variable first, then the P_tmpdir macro and finally /tmp directly. On 64-bit Linux platforms, check to see if libc.so exists in /usr/lib64. If found, use it over /usr/lib/libc.so.
This commit is contained in:
parent
6d46aca1b1
commit
16c57ad669
1 changed files with 29 additions and 6 deletions
|
@ -950,6 +950,9 @@ static const char libc_c[]=
|
||||||
"}\n"
|
"}\n"
|
||||||
;
|
;
|
||||||
|
|
||||||
|
#define libc32path "/usr/lib/libc.so"
|
||||||
|
#define libc64path "/usr/lib64/libc.so"
|
||||||
|
|
||||||
static void
|
static void
|
||||||
get_libc_version(FILE *inFile)
|
get_libc_version(FILE *inFile)
|
||||||
{
|
{
|
||||||
|
@ -973,13 +976,13 @@ get_libc_version(FILE *inFile)
|
||||||
|
|
||||||
if (!strcmp(u.sysname, "Linux") &&
|
if (!strcmp(u.sysname, "Linux") &&
|
||||||
(!strcmp(u.machine, "x86_64"))) {
|
(!strcmp(u.machine, "x86_64"))) {
|
||||||
if (!lstat ("/usr/lib64/libc.so", &sb) && S_ISREG(sb.st_mode)) {
|
if (!lstat (libc64path, &sb) && S_ISREG(sb.st_mode)) {
|
||||||
libcso = strdup("/usr/lib64/libc.so");
|
libcso = libc64path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (libcso == NULL) {
|
if (libcso == NULL) {
|
||||||
libcso = strdup("/usr/lib/libc.so");
|
libcso = libc32path;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lstat (libcso, &sb) == 0) {
|
if (lstat (libcso, &sb) == 0) {
|
||||||
|
@ -1000,13 +1003,35 @@ get_libc_version(FILE *inFile)
|
||||||
* /usr/lib/libc.so is NOT a symlink -- this is libc 6.x / glibc 2.x
|
* /usr/lib/libc.so is NOT a symlink -- this is libc 6.x / glibc 2.x
|
||||||
* now we have to figure this out the hard way.
|
* now we have to figure this out the hard way.
|
||||||
*/
|
*/
|
||||||
char *aout = tmpnam (NULL);
|
char aout[PATH_MAX];
|
||||||
|
int fd = -1;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
const char *format = "%s -o %s -x c -";
|
const char *format = "%s -o %s -x c -";
|
||||||
char *cc;
|
char *cc;
|
||||||
int len;
|
int len;
|
||||||
char *command;
|
char *command;
|
||||||
|
|
||||||
|
memset(&aout, '\0', PATH_MAX);
|
||||||
|
|
||||||
|
if (!lstat(getenv("TMPDIR"), &sb) && S_ISDIR(sb.st_mode))
|
||||||
|
strcpy(aout, getenv("TMPDIR"));
|
||||||
|
#ifdef P_tmpdir /* defined by XPG and XOPEN, but don't assume we have it */
|
||||||
|
else if (!lstat(P_tmpdir, &sb) && S_ISDIR(sb.st_mode))
|
||||||
|
strcpy(aout, P_tmpdir);
|
||||||
|
#endif
|
||||||
|
else if (!lstat("/tmp", &sb) && S_ISDIR(sb.st_mode))
|
||||||
|
strcpy(aout, "/tmp");
|
||||||
|
else
|
||||||
|
abort();
|
||||||
|
|
||||||
|
strcpy(aout+strlen(aout), "/imaketmp.XXXXXX");
|
||||||
|
|
||||||
|
if ((fd = mkstemp(aout)) == -1)
|
||||||
|
abort ();
|
||||||
|
|
||||||
|
if (close(fd) == -1)
|
||||||
|
abort ();
|
||||||
|
|
||||||
cc = getenv ("CC");
|
cc = getenv ("CC");
|
||||||
if (cc == NULL)
|
if (cc == NULL)
|
||||||
cc = "gcc";
|
cc = "gcc";
|
||||||
|
@ -1034,8 +1059,6 @@ get_libc_version(FILE *inFile)
|
||||||
abort ();
|
abort ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(libcso);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in a new issue