summaryrefslogtreecommitdiff
path: root/source3/lib/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/lib/util.c')
-rw-r--r--source3/lib/util.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c
index cd1395aba7..42a9617077 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -1742,6 +1742,20 @@ char *smbd_mktemp(char *template)
return p;
}
+/*****************************************************************
+possibly replace mkstemp if it is broken
+*****************************************************************/
+int smb_mkstemp(char *template)
+{
+#if HAVE_SECURE_MKSTEMP
+ return mkstemp(template);
+#else
+ /* have a reasonable go at emulating it. Hope that
+ the system mktemp() isn't completly hopeless */
+ if (!mktemp(template)) return -1;
+ return open(template, O_CREAT|O_EXCL|O_RDWR, 0600);
+#endif
+}
/*****************************************************************
like strdup but for memory