1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-13 13:18:06 +03:00

r16556: Add mkdtemp to libreplace. This is apparantly available on Linux

and BSD systems, but it's not everywhere.
This commit is contained in:
James Peach 2006-06-27 05:49:09 +00:00 committed by Gerald (Jerry) Carter
parent c73f4e11e4
commit b3d2512ed4
4 changed files with 22 additions and 2 deletions

View File

@ -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)

View File

@ -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>])

View File

@ -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)
{

View File

@ -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