1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-13 11:42:21 +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:
David Cantrell 2012-08-21 21:51:56 -04:00
parent 6d46aca1b1
commit 16c57ad669

View file

@ -950,6 +950,9 @@ static const char libc_c[]=
"}\n"
;
#define libc32path "/usr/lib/libc.so"
#define libc64path "/usr/lib64/libc.so"
static void
get_libc_version(FILE *inFile)
{
@ -973,13 +976,13 @@ get_libc_version(FILE *inFile)
if (!strcmp(u.sysname, "Linux") &&
(!strcmp(u.machine, "x86_64"))) {
if (!lstat ("/usr/lib64/libc.so", &sb) && S_ISREG(sb.st_mode)) {
libcso = strdup("/usr/lib64/libc.so");
if (!lstat (libc64path, &sb) && S_ISREG(sb.st_mode)) {
libcso = libc64path;
}
}
if (libcso == NULL) {
libcso = strdup("/usr/lib/libc.so");
libcso = libc32path;
}
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
* now we have to figure this out the hard way.
*/
char *aout = tmpnam (NULL);
char aout[PATH_MAX];
int fd = -1;
FILE *fp;
const char *format = "%s -o %s -x c -";
char *cc;
int len;
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");
if (cc == NULL)
cc = "gcc";
@ -1034,8 +1059,6 @@ get_libc_version(FILE *inFile)
abort ();
}
}
free(libcso);
}
static void