On the Sernet-solaris8 host, this test passed in the autoconf build,
then failed in the recursive waf build. This newer test should probe
the behaviour more closely, by checking we get two distinct, secure
files.
Andrew Bartlett
#include <unistd.h>
main() {
struct stat st;
#include <unistd.h>
main() {
struct stat st;
- char tpl[20]="/tmp/test.XXXXXX";
- int fd = mkstemp(tpl);
- if (fd == -1) exit(1);
+ char tpl[20]="/tmp/test.XXXXXX";
+ char tpl2[20]="/tmp/test.XXXXXX";
+ int fd = mkstemp(tpl);
+ int fd2 = mkstemp(tpl2);
+ if (fd == -1) {
+ if (fd2 != -1) {
+ unlink(tpl2);
+ }
+ exit(1);
+ }
+ if (fd2 == -1) exit(1);
if (fstat(fd, &st) != 0) exit(1);
if ((st.st_mode & 0777) != 0600) exit(1);
if (fstat(fd, &st) != 0) exit(1);
if ((st.st_mode & 0777) != 0600) exit(1);
+ if (strcmp(tpl, "/tmp/test.XXXXXX") == 0) {
+ exit(1);
+ }
+ if (strcmp(tpl, tpl2) == 0) {
+ exit(1);
+ }
exit(0);
}],
libreplace_cv_HAVE_SECURE_MKSTEMP=yes,
exit(0);
}],
libreplace_cv_HAVE_SECURE_MKSTEMP=yes,
conf.CHECK_CODE('''
struct stat st;
char tpl[20]="/tmp/test.XXXXXX";
conf.CHECK_CODE('''
struct stat st;
char tpl[20]="/tmp/test.XXXXXX";
+ char tpl2[20]="/tmp/test.XXXXXX";
+ int fd2 = mkstemp(tpl2);
+ if (fd == -1) {
+ if (fd2 != -1) {
+ unlink(tpl2);
+ }
+ exit(1);
+ }
+ if (fd2 == -1) exit(1);
if (fstat(fd, &st) != 0) exit(1);
if ((st.st_mode & 0777) != 0600) exit(1);
if (fstat(fd, &st) != 0) exit(1);
if ((st.st_mode & 0777) != 0600) exit(1);
+ if (strcmp(tpl, "/tmp/test.XXXXXX") == 0) {
+ exit(1);
+ }
+ if (strcmp(tpl, tpl2) == 0) {
+ exit(1);
+ }
exit(0);
''',
define='HAVE_SECURE_MKSTEMP',
exit(0);
''',
define='HAVE_SECURE_MKSTEMP',