summaryrefslogtreecommitdiff
path: root/lib/replace
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2012-09-24 06:03:31 +1000
committerAndrew Bartlett <abartlet@samba.org>2012-09-24 03:51:07 +0200
commit0727ad73212ff3cfe7e78249504b0209e082d7c4 (patch)
tree2e0ac45ba69457a320bfe618f3d55ef8a10c10a7 /lib/replace
parentf767059911460c0944d5e9289148a0776aeb97e5 (diff)
downloadsamba-0727ad73212ff3cfe7e78249504b0209e082d7c4.tar.gz
samba-0727ad73212ff3cfe7e78249504b0209e082d7c4.tar.bz2
samba-0727ad73212ff3cfe7e78249504b0209e082d7c4.zip
lib/replace: Improve mkstemp test in autoconf and waf
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
Diffstat (limited to 'lib/replace')
-rw-r--r--lib/replace/libreplace.m421
-rw-r--r--lib/replace/wscript17
2 files changed, 34 insertions, 4 deletions
diff --git a/lib/replace/libreplace.m4 b/lib/replace/libreplace.m4
index d298b9242b..796069c8ca 100644
--- a/lib/replace/libreplace.m4
+++ b/lib/replace/libreplace.m4
@@ -212,12 +212,27 @@ AC_TRY_RUN([#include <stdlib.h>
#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);
unlink(tpl);
+ unlink(tpl2);
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,
diff --git a/lib/replace/wscript b/lib/replace/wscript
index 2f632e18a7..58053057d7 100644
--- a/lib/replace/wscript
+++ b/lib/replace/wscript
@@ -399,11 +399,26 @@ removeea setea
conf.CHECK_CODE('''
struct stat st;
char tpl[20]="/tmp/test.XXXXXX";
+ char tpl2[20]="/tmp/test.XXXXXX";
int fd = mkstemp(tpl);
- if (fd == -1) exit(1);
+ int fd2 = mkstemp(tpl2);
+ if (fd == -1) {
+ if (fd2 != -1) {
+ unlink(tpl2);
+ }
+ exit(1);
+ }
+ if (fd2 == -1) exit(1);
unlink(tpl);
+ unlink(tpl2);
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',