summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
authorJames Peach <jpeach@samba.org>2006-06-27 05:49:09 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:09:34 -0500
commitff2041c955e9152bd286ab6ea534b8445caab574 (patch)
tree7169ccd956bdae0d8965761b772aaba7b78f7524 /source4/lib
parent1db2f0d3a19913a460bec9eb516b4d96e9a3e595 (diff)
downloadsamba-ff2041c955e9152bd286ab6ea534b8445caab574.tar.gz
samba-ff2041c955e9152bd286ab6ea534b8445caab574.tar.bz2
samba-ff2041c955e9152bd286ab6ea534b8445caab574.zip
r16556: Add mkdtemp to libreplace. This is apparantly available on Linux
and BSD systems, but it's not everywhere. (This used to be commit b3d2512ed4fc8c378607bcc2dc241a1f77ab7197)
Diffstat (limited to 'source4/lib')
-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