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:
parent
c73f4e11e4
commit
b3d2512ed4
@ -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)
|
||||
|
@ -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>])
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user