diff options
-rw-r--r-- | lib/replace/README | 1 | ||||
-rw-r--r-- | lib/replace/libreplace.m4 | 2 | ||||
-rw-r--r-- | lib/replace/replace.c | 8 | ||||
-rw-r--r-- | lib/replace/replace.h | 5 | ||||
-rw-r--r-- | lib/util/config.mk | 2 | ||||
-rw-r--r-- | source3/include/proto.h | 1 | ||||
-rw-r--r-- | source3/lib/debug.c | 4 | ||||
-rw-r--r-- | source3/lib/smbrun.c | 4 | ||||
-rw-r--r-- | source3/lib/system.c | 10 | ||||
-rw-r--r-- | source3/smbd/chgpasswd.c | 6 | ||||
-rw-r--r-- | source4/headermap.txt | 6 |
11 files changed, 30 insertions, 19 deletions
diff --git a/lib/replace/README b/lib/replace/README index c1cb2d0270..26383bc89a 100644 --- a/lib/replace/README +++ b/lib/replace/README @@ -66,6 +66,7 @@ getifaddrs freeifaddrs utime utimes +dup2 link readlink symlink diff --git a/lib/replace/libreplace.m4 b/lib/replace/libreplace.m4 index c67fa66f5c..30d7017d0f 100644 --- a/lib/replace/libreplace.m4 +++ b/lib/replace/libreplace.m4 @@ -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 chown lchown link readlink symlink realpath) AC_HAVE_DECL(setresuid, [#include <unistd.h>]) AC_HAVE_DECL(setresgid, [#include <unistd.h>]) diff --git a/lib/replace/replace.c b/lib/replace/replace.c index 0683f556eb..78c688d50c 100644 --- a/lib/replace/replace.c +++ b/lib/replace/replace.c @@ -616,6 +616,14 @@ int rep_utimes(const char *filename, const struct timeval tv[2]) } #endif +#ifndef HAVE_DUP2 +int rep_dup2(int oldfd, int newfd) +{ + errno = ENOSYS; + return -1; +} +#endif + #ifndef HAVE_CHOWN /** chown isn't used much but OS/2 doesn't have it diff --git a/lib/replace/replace.h b/lib/replace/replace.h index d717d6391c..8483d934d8 100644 --- a/lib/replace/replace.h +++ b/lib/replace/replace.h @@ -393,6 +393,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> diff --git a/lib/util/config.mk b/lib/util/config.mk index 61e193b0c4..22f22b5771 100644 --- a/lib/util/config.mk +++ b/lib/util/config.mk @@ -34,10 +34,12 @@ PUBLIC_HEADERS += $(addprefix $(libutilsrcdir)/, util.h \ byteorder.h \ data_blob.h \ debug.h \ + memory.h \ mutex.h \ safe_string.h \ time.h \ util_ldb.h \ + talloc_stack.h \ xfile.h) [SUBSYSTEM::ASN1_UTIL] diff --git a/source3/include/proto.h b/source3/include/proto.h index 8495d1e78d..9d7d76e539 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -1020,7 +1020,6 @@ pid_t sys_fork(void); pid_t sys_getpid(void); int sys_popen(const char *command); int sys_pclose(int fd); -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); diff --git a/source3/lib/debug.c b/source3/lib/debug.c index be2707b595..986dff48d7 100644 --- a/source3/lib/debug.c +++ b/source3/lib/debug.c @@ -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 */ } diff --git a/source3/lib/smbrun.c b/source3/lib/smbrun.c index 515fcd75c2..31990713b8 100644 --- a/source3/lib/smbrun.c +++ b/source3/lib/smbrun.c @@ -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); diff --git a/source3/lib/system.c b/source3/lib/system.c index 90dbdafa92..86c4ef2097 100644 --- a/source3/lib/system.c +++ b/source3/lib/system.c @@ -1190,16 +1190,6 @@ int sys_pclose(int fd) return wstatus; } -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. ****************************************************************************/ diff --git a/source3/smbd/chgpasswd.c b/source3/smbd/chgpasswd.c index 64a4311256..e6d2bbf59f 100644 --- a/source3/smbd/chgpasswd.c +++ b/source3/smbd/chgpasswd.c @@ -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); diff --git a/source4/headermap.txt b/source4/headermap.txt index 4574a66a7b..78b9200143 100644 --- a/source4/headermap.txt +++ b/source4/headermap.txt @@ -6,6 +6,8 @@ ../lib/util/attr.h: util/attr.h ../lib/util/byteorder.h: util/byteorder.h ../lib/util/safe_string.h: util/safe_string.h +../lib/util/memory.h: util/memory.h +../lib/util/talloc_stack.h: util/talloc_stack.h ../lib/util/xfile.h: util/xfile.h lib/tdr/tdr.h: tdr.h librpc/rpc/dcerpc.h: dcerpc.h @@ -13,10 +15,14 @@ lib/ldb/include/ldb.h: ldb.h lib/ldb/include/ldb_errors.h: ldb_errors.h auth/gensec/gensec.h: gensec.h ../librpc/ndr/libndr.h: ndr.h +librpc/ndr/libndr.h: ndr.h lib/registry/registry.h: registry.h ../libcli/util/werror.h: core/werror.h ../libcli/util/doserr.h: core/doserr.h ../libcli/util/ntstatus.h: core/ntstatus.h +libcli/util/werror.h: core/werror.h +libcli/util/doserr.h: core/doserr.h +libcli/util/ntstatus.h: core/ntstatus.h libcli/cldap/cldap.h: cldap.h librpc/gen_ndr/dcerpc.h: gen_ndr/dcerpc.h librpc/gen_ndr/netlogon.h: gen_ndr/netlogon.h |