mirror of
https://github.com/samba-team/samba.git
synced 2025-03-08 04:58:40 +03:00
Use dup2() replacement from libreplace.
This commit is contained in:
parent
df766a303a
commit
5a56c0adf2
@ -64,6 +64,7 @@ getifaddrs
|
||||
freeifaddrs
|
||||
utime
|
||||
utimes
|
||||
dup2
|
||||
|
||||
Types:
|
||||
bool
|
||||
|
@ -107,7 +107,7 @@ AC_CHECK_HEADERS(stropts.h)
|
||||
AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror)
|
||||
AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename)
|
||||
AC_CHECK_FUNCS(waitpid strlcpy strlcat initgroups memmove strdup)
|
||||
AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp)
|
||||
AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp dup2)
|
||||
AC_CHECK_FUNCS(isatty)
|
||||
AC_HAVE_DECL(setresuid, [#include <unistd.h>])
|
||||
AC_HAVE_DECL(setresgid, [#include <unistd.h>])
|
||||
|
@ -614,3 +614,12 @@ int rep_utimes(const char *filename, const struct timeval tv[2])
|
||||
return utime(filename, &u);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_DUP2
|
||||
int rep_dup2(int oldfd, int newfd)
|
||||
{
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -358,6 +358,11 @@ struct tm;
|
||||
char *rep_strptime(const char *buf, const char *format, struct tm *tm);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_DUP2
|
||||
#define dup2 rep_dup2
|
||||
int rep_dup2(int oldfd, int newfd);
|
||||
#endif
|
||||
|
||||
/* Load header file for dynamic linking stuff */
|
||||
#ifdef HAVE_DLFCN_H
|
||||
#include <dlfcn.h>
|
||||
|
@ -1054,7 +1054,6 @@ void *sys_dlopen(const char *name, int flags);
|
||||
void *sys_dlsym(void *handle, const char *symbol);
|
||||
int sys_dlclose (void *handle);
|
||||
const char *sys_dlerror(void);
|
||||
int sys_dup2(int oldfd, int newfd) ;
|
||||
ssize_t sys_getxattr (const char *path, const char *name, void *value, size_t size);
|
||||
ssize_t sys_lgetxattr (const char *path, const char *name, void *value, size_t size);
|
||||
ssize_t sys_fgetxattr (int filedes, const char *name, void *value, size_t size);
|
||||
|
@ -680,8 +680,8 @@ bool reopen_logs( void )
|
||||
force_check_log_size();
|
||||
(void)umask(oldumask);
|
||||
|
||||
/* Take over stderr to catch ouput into logs */
|
||||
if (dbf && sys_dup2(x_fileno(dbf), 2) == -1) {
|
||||
/* Take over stderr to catch output into logs */
|
||||
if (dbf && dup2(x_fileno(dbf), 2) == -1) {
|
||||
close_low_fds(True); /* Close stderr too, if dup2 can't point it
|
||||
at the logfile */
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ static int smbrun_internal(const char *cmd, int *outfd, bool sanitize)
|
||||
/* point our stdout at the file we want output to go into */
|
||||
if (outfd) {
|
||||
close(1);
|
||||
if (sys_dup2(*outfd,1) != 1) {
|
||||
if (dup2(*outfd,1) != 1) {
|
||||
DEBUG(2,("Failed to create stdout file descriptor\n"));
|
||||
close(*outfd);
|
||||
exit(80);
|
||||
@ -305,7 +305,7 @@ int smbrunsecret(const char *cmd, const char *secret)
|
||||
|
||||
close(ifd[1]);
|
||||
close(0);
|
||||
if (sys_dup2(ifd[0], 0) != 0) {
|
||||
if (dup2(ifd[0], 0) != 0) {
|
||||
DEBUG(2,("Failed to create stdin file descriptor\n"));
|
||||
close(ifd[0]);
|
||||
exit(80);
|
||||
|
@ -1343,16 +1343,6 @@ const char *sys_dlerror(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
int sys_dup2(int oldfd, int newfd)
|
||||
{
|
||||
#if defined(HAVE_DUP2)
|
||||
return dup2(oldfd, newfd);
|
||||
#else
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
Wrapper for Admin Logs.
|
||||
****************************************************************************/
|
||||
|
@ -184,17 +184,17 @@ static int dochild(int master, const char *slavedev, const struct passwd *pass,
|
||||
|
||||
/* Make slave stdin/out/err of child. */
|
||||
|
||||
if (sys_dup2(slave, STDIN_FILENO) != STDIN_FILENO)
|
||||
if (dup2(slave, STDIN_FILENO) != STDIN_FILENO)
|
||||
{
|
||||
DEBUG(3, ("Could not re-direct stdin\n"));
|
||||
return (False);
|
||||
}
|
||||
if (sys_dup2(slave, STDOUT_FILENO) != STDOUT_FILENO)
|
||||
if (dup2(slave, STDOUT_FILENO) != STDOUT_FILENO)
|
||||
{
|
||||
DEBUG(3, ("Could not re-direct stdout\n"));
|
||||
return (False);
|
||||
}
|
||||
if (sys_dup2(slave, STDERR_FILENO) != STDERR_FILENO)
|
||||
if (dup2(slave, STDERR_FILENO) != STDERR_FILENO)
|
||||
{
|
||||
DEBUG(3, ("Could not re-direct stderr\n"));
|
||||
return (False);
|
||||
|
Loading…
x
Reference in New Issue
Block a user