summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rw-r--r--source4/lib/replace/README3
-rw-r--r--source4/lib/replace/config.m42
-rw-r--r--source4/lib/replace/replace.c15
-rw-r--r--source4/lib/replace/replace.h4
4 files changed, 22 insertions, 2 deletions
diff --git a/source4/lib/replace/README b/source4/lib/replace/README
index 0101b80913..271713247a 100644
--- a/source4/lib/replace/README
+++ b/source4/lib/replace/README
@@ -45,6 +45,7 @@ chroot
bzero
strerror
errno
+mkdtemp
mkstemp (a secure one!)
pread
pwrite
@@ -75,4 +76,4 @@ Prerequisites:
memset (for bzero)
syslog (for vsyslog)
setnetgrent, getnetgrent, endnetgrent (for innetgr)
-mktemp (for mkstemp)
+mktemp (for mkstemp and mkdtemp)
diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4
index 4948f91163..8b71372262 100644
--- a/source4/lib/replace/config.m4
+++ b/source4/lib/replace/config.m4
@@ -57,7 +57,7 @@ AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq)
AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror)
AC_CHECK_FUNCS(timegm setenv vsyslog setlinebuf mktime ftruncate chsize rename)
AC_CHECK_FUNCS(waitpid strnlen strlcpy strlcat innetgr initgroups memmove strdup)
-AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r)
+AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp)
AC_HAVE_DECL(setresuid, [#include <unistd.h>])
AC_HAVE_DECL(setresgid, [#include <unistd.h>])
AC_HAVE_DECL(errno, [#include <errno.h>])
diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c
index 02c3d04163..989c0947c3 100644
--- a/source4/lib/replace/replace.c
+++ b/source4/lib/replace/replace.c
@@ -506,6 +506,21 @@ int rep_mkstemp(char *template)
}
#endif
+#ifndef HAVE_MKDTEMP
+char * mkdtemp(char *template)
+{
+ char *dname;
+
+ if (dname = mktemp(template)) {
+ if (mkdir(dname, 0700) >= 0) {
+ return dname;
+ }
+ }
+
+ return NULL;
+}
+#endif
+
#ifndef HAVE_PREAD
static ssize_t pread(int __fd, void *__buf, size_t __nbytes, off_t __offset)
{
diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h
index 8beb43bfa4..e59ba43206 100644
--- a/source4/lib/replace/replace.h
+++ b/source4/lib/replace/replace.h
@@ -173,6 +173,10 @@ typedef int (*comparison_fn_t)(const void *, const void *);
int rep_mkstemp(char *temp);
#endif
+#ifndef HAVE_MKDTEMP
+char *mkdtemp(char *template);
+#endif
+
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif