summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-09-23 00:38:22 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:38:45 -0500
commitf3b412fbd6dd94d64eb6a63d88baef2816891c29 (patch)
tree61b6086157d30cf1dd64c8cc720638cd484c78d1 /source4
parent92d74c340843f52aaced18dcc243965387fcaedb (diff)
downloadsamba-f3b412fbd6dd94d64eb6a63d88baef2816891c29.tar.gz
samba-f3b412fbd6dd94d64eb6a63d88baef2816891c29.tar.bz2
samba-f3b412fbd6dd94d64eb6a63d88baef2816891c29.zip
r10438: Move portability functions to lib/replace/; replace now simply ensures
that a given set of (working) POSIX functions are available (without prefixes to their names, etc). See lib/replace/README for a list. Functions that behave different from their POSIX specification (such as sys_select, sys_read, etc) have kept the sys_ prefix. (This used to be commit 29919a71059b29fa27a49b1f5b84bb8881de65fc)
Diffstat (limited to 'source4')
-rw-r--r--source4/SConstruct3
-rw-r--r--source4/build/m4/rewrite.m4100
-rw-r--r--source4/client/client.c6
-rw-r--r--source4/dynconfig.c31
-rw-r--r--source4/heimdal_build/glue.c2
-rw-r--r--source4/include/includes.h13
-rw-r--r--source4/lib/com/tables.c4
-rw-r--r--source4/lib/replace/README54
-rw-r--r--source4/lib/replace/SConscript2
-rw-r--r--source4/lib/replace/config.m484
-rw-r--r--source4/lib/replace/config.mk4
-rw-r--r--source4/lib/replace/dlfcn.c71
-rw-r--r--source4/lib/replace/replace.c73
-rw-r--r--source4/lib/replace/replace.h22
-rw-r--r--source4/lib/signal.c2
-rw-r--r--source4/lib/system.c71
-rw-r--r--source4/lib/time.c34
-rw-r--r--source4/lib/util.c20
-rw-r--r--source4/libcli/resolve/host.c2
-rw-r--r--source4/librpc/ndr/ndr_basic.c2
-rw-r--r--source4/torture/torture.c2
-rw-r--r--source4/winbind/wb_samba3_protocol.c2
22 files changed, 341 insertions, 263 deletions
diff --git a/source4/SConstruct b/source4/SConstruct
index e791f97d7c..8376479fe1 100644
--- a/source4/SConstruct
+++ b/source4/SConstruct
@@ -9,8 +9,6 @@
import cPickle, string, os
-# We don't care about NFS builds...
-
opts = Options(None, ARGUMENTS)
opts.AddOptions(
BoolOption('developer','enable developer flags', False),
@@ -26,6 +24,7 @@ hostenv = Environment(
CPPDEFINES={'_SAMBA_BUILD_': None},
)
+# We don't care about NFS builds...
hostenv.SetOption('max_drift', 1)
if hostenv['developer']:
diff --git a/source4/build/m4/rewrite.m4 b/source4/build/m4/rewrite.m4
index d8ba0104ab..8d72d852f4 100644
--- a/source4/build/m4/rewrite.m4
+++ b/source4/build/m4/rewrite.m4
@@ -53,19 +53,14 @@ AC_HEADER_DIRENT
AC_HEADER_TIME
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(sys/select.h fcntl.h sys/fcntl.h sys/time.h)
-AC_CHECK_HEADERS(utime.h grp.h sys/id.h limits.h memory.h)
-AC_CHECK_HEADERS(compat.h math.h)
+AC_CHECK_HEADERS(utime.h grp.h sys/id.h limits.h memory.h compat.h math.h)
AC_CHECK_HEADERS(sys/param.h ctype.h sys/wait.h sys/resource.h sys/ioctl.h sys/ipc.h sys/mode.h)
AC_CHECK_HEADERS(sys/mman.h sys/filio.h sys/priv.h sys/shm.h string.h strings.h stdlib.h)
AC_CHECK_HEADERS(sys/vfs.h sys/fs/s5param.h sys/filsys.h termios.h termio.h)
AC_CHECK_HEADERS(fnmatch.h pwd.h sys/termio.h sys/time.h sys/statfs.h sys/statvfs.h stdarg.h)
-AC_CHECK_HEADERS(security/pam_modules.h security/_pam_macros.h dlfcn.h)
-AC_CHECK_HEADERS(sys/syslog.h syslog.h)
-AC_CHECK_HEADERS(stdint.h inttypes.h locale.h)
-AC_CHECK_HEADERS(shadow.h)
+AC_CHECK_HEADERS(stdint.h inttypes.h locale.h shadow.h)
AC_CHECK_HEADERS(nss.h nss_common.h ns_api.h sys/security.h security/pam_appl.h)
-AC_CHECK_HEADERS(sys/capability.h syscall.h sys/syscall.h)
-AC_CHECK_HEADERS(sys/acl.h)
+AC_CHECK_HEADERS(sys/capability.h sys/acl.h)
AC_CHECK_HEADERS(sys/mount.h, , , [AC_INCLUDES_DEFAULT
#ifdef HAVE_SYS_PARAM_H
@@ -89,12 +84,6 @@ AC_CHECK_TYPES(intptr_t)
AC_CHECK_TYPES(long long)
-############################################
-# we need dlopen/dlclose/dlsym/dlerror for PAM, the password database plugins and the plugin loading code
-AC_SEARCH_LIBS_EXT(dlopen, [dl], DL_LIBS)
-SMB_EXT_LIB(DL,[${DL_LIBS}],[${DL_CFLAGS}],[${DL_CPPFLAGS}],[${DL_LDFLAGS}])
-# dlopen/dlclose/dlsym/dlerror will be checked again later and defines will be set then
-
AC_CACHE_CHECK([for sig_atomic_t type],samba_cv_sig_atomic_t, [
AC_TRY_COMPILE([
#include <sys/types.h>
@@ -108,29 +97,12 @@ if test x"$samba_cv_sig_atomic_t" = x"yes"; then
AC_DEFINE(HAVE_SIG_ATOMIC_T_TYPE,1,[Whether we have the atomic_t variable type])
fi
-# stupid headers have the functions but no declaration. grrrr.
-AC_HAVE_DECL(errno, [#include <errno.h>])
-AC_HAVE_DECL(setresuid, [#include <unistd.h>])
-AC_HAVE_DECL(setresgid, [#include <unistd.h>])
-AC_HAVE_DECL(asprintf, [#include <stdio.h>])
-AC_HAVE_DECL(vasprintf, [#include <stdio.h>])
-AC_HAVE_DECL(vsnprintf, [#include <stdio.h>])
-AC_HAVE_DECL(snprintf, [#include <stdio.h>])
-
AC_FUNC_MEMCMP
-AC_CHECK_FUNCS(dlopen dlsym dlerror waitpid getcwd strdup strndup strnlen strerror chroot)
-AC_CHECK_FUNCS(bzero memset strlcpy strlcat)
-AC_CHECK_FUNCS(memmove vsnprintf snprintf asprintf vasprintf setsid pipe crypt16 getauthuid)
-AC_CHECK_FUNCS(strftime sigprocmask sigblock sigaction innetgr setnetgrent getnetgrent endnetgrent)
-AC_CHECK_FUNCS(initgroups)
-AC_CHECK_FUNCS(setgroups sysconf mktime rename ftruncate chsize)
-AC_CHECK_FUNCS(getpwanam setlinebuf)
-AC_CHECK_FUNCS(srandom random srand rand setenv usleep)
-AC_CHECK_FUNCS(syslog vsyslog timegm backtrace)
-AC_CHECK_FUNCS(setbuffer)
-
-AC_CHECK_FUNCS(pread pwrite)
+AC_CHECK_FUNCS(setsid pipe crypt16 getauthuid)
+AC_CHECK_FUNCS(strftime sigprocmask sigblock sigaction)
+AC_CHECK_FUNCS(setgroups sysconf getpwanam srandom random srand rand usleep)
+AC_CHECK_FUNCS(backtrace setbuffer pread pwrite)
# Assume non-shared by default and override below
BLDSHARED="false"
@@ -358,39 +330,6 @@ if test x"$samba_cv_HAVE___VA_COPY" = x"yes"; then
fi
fi
-AC_CACHE_CHECK([for C99 vsnprintf],samba_cv_HAVE_C99_VSNPRINTF,[
-AC_TRY_RUN([
-#include <sys/types.h>
-#include <stdarg.h>
-void foo(const char *format, ...) {
- va_list ap;
- int len;
- char buf[20];
- long long l = 1234567890;
- l *= 100;
-
- va_start(ap, format);
- len = vsnprintf(buf, 0, format, ap);
- va_end(ap);
- if (len != 5) exit(1);
-
- va_start(ap, format);
- len = vsnprintf(0, 0, format, ap);
- va_end(ap);
- if (len != 5) exit(1);
-
- if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
-
- if (snprintf(buf, 20, "%lld", l) != 12 || strcmp(buf, "123456789000") != 0) exit(1);
-
- exit(0);
-}
-main() { foo("hello"); }
-],
-samba_cv_HAVE_C99_VSNPRINTF=yes,samba_cv_HAVE_C99_VSNPRINTF=no,samba_cv_HAVE_C99_VSNPRINTF=cross)])
-if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
- AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Whether there is a C99 compliant vsnprintf])
-fi
AC_CACHE_CHECK([for utimbuf],samba_cv_HAVE_UTIMBUF,[
AC_TRY_COMPILE([#include <sys/types.h>
@@ -499,28 +438,6 @@ if test x"$samba_cv_HAVE_BROKEN_GETGROUPS" = x"yes"; then
AC_DEFINE(HAVE_BROKEN_GETGROUPS,1,[Whether getgroups is broken])
fi
-AC_CACHE_CHECK([for secure mkstemp],samba_cv_HAVE_SECURE_MKSTEMP,[
-AC_TRY_RUN([#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-main() {
- struct stat st;
- char tpl[20]="/tmp/test.XXXXXX";
- int fd = mkstemp(tpl);
- if (fd == -1) exit(1);
- unlink(tpl);
- if (fstat(fd, &st) != 0) exit(1);
- if ((st.st_mode & 0777) != 0600) exit(1);
- exit(0);
-}],
-samba_cv_HAVE_SECURE_MKSTEMP=yes,
-samba_cv_HAVE_SECURE_MKSTEMP=no,
-samba_cv_HAVE_SECURE_MKSTEMP=cross)])
-if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
- AC_DEFINE(HAVE_SECURE_MKSTEMP,1,[Whether mkstemp is secure])
-fi
-
AC_CACHE_CHECK([for sysconf(_SC_NGROUPS_MAX)],samba_cv_SYSCONF_SC_NGROUPS_MAX,[
AC_TRY_RUN([#include <unistd.h>
main() { exit(sysconf(_SC_NGROUPS_MAX) == -1 ? 1 : 0); }],
@@ -581,9 +498,6 @@ fi
;;
esac
-AC_SUBST(SMBD_EXTRA_OBJS)
-AC_SUBST(SMBD_EXTRA_LIBS)
-
###############################################
# test for where we get crypt() from
AC_CHECK_LIB_EXT(crypt, CRYPT_LIBS, crypt)
diff --git a/source4/client/client.c b/source4/client/client.c
index b6b95a4ebd..1e41924321 100644
--- a/source4/client/client.c
+++ b/source4/client/client.c
@@ -960,7 +960,7 @@ static int cmd_more(const char **cmd_ptr)
fstrcat(rname,"\\");
slprintf(lname,sizeof(lname)-1, "%s/smbmore.XXXXXX",tmpdir());
- fd = smb_mkstemp(lname);
+ fd = mkstemp(lname);
if (fd == -1) {
d_printf("failed to create temporary file for more\n");
return 1;
@@ -2601,11 +2601,11 @@ static int cmd_printmode(const char **cmd_ptr)
static int cmd_lcd(const char **cmd_ptr)
{
fstring buf;
- pstring d;
+ char d[PATH_MAX];
if (next_token(cmd_ptr,buf,NULL,sizeof(buf)))
chdir(buf);
- DEBUG(2,("the local directory is now %s\n",sys_getwd(d)));
+ DEBUG(2,("the local directory is now %s\n",getcwd(d, PATH_MAX)));
return 0;
}
diff --git a/source4/dynconfig.c b/source4/dynconfig.c
index 20567dcafc..caf75762d5 100644
--- a/source4/dynconfig.c
+++ b/source4/dynconfig.c
@@ -18,9 +18,6 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#include "includes.h"
-#include "pstring.h"
-
/**
* @file dynconfig.c
*
@@ -41,25 +38,28 @@
* table? There's kind of a chicken-and-egg situation there...
**/
-const char *dyn_SBINDIR = SBINDIR,
- *dyn_BINDIR = BINDIR;
+/** Directory with super-user binaries */
+const char *dyn_SBINDIR = SBINDIR;
+
+/** Directory with generic binaries */
+const char *dyn_BINDIR = BINDIR;
-const char *dyn_CONFIGFILE = CONFIGFILE; /**< Location of smb.conf file. **/
+/**< Location of smb.conf file. **/
+const char *dyn_CONFIGFILE = CONFIGFILE;
/** Log file directory. **/
-const char *dyn_LOGFILEBASE = LOGFILEBASE;
+const char *dyn_LOGFILEBASE = LOGFILEBASE;
+/** Directory for local RPC (ncalrpc: transport) */
const char *dyn_NCALRPCDIR = NCALRPCDIR;
/** Statically configured LanMan hosts. **/
-const char *dyn_LMHOSTSFILE = LMHOSTSFILE;
+const char *dyn_LMHOSTSFILE = LMHOSTSFILE;
-/**
- * @brief Samba library directory.
- *
- * @sa lib_path() to get the path to a file inside the LIBDIR.
- **/
+/** Samba library directory. */
const char *dyn_LIBDIR = LIBDIR;
+
+/** Shared library extension */
const char *dyn_SHLIBEXT = SHLIBEXT;
/**
@@ -68,7 +68,12 @@ const char *dyn_SHLIBEXT = SHLIBEXT;
* Not writable, but used to set a default in the parameter table.
**/
const char *dyn_LOCKDIR = LOCKDIR;
+
+/** pid file directory */
const char *dyn_PIDDIR = PIDDIR;
+/** Private data directory; holds ldb files and the like */
const char *dyn_PRIVATE_DIR = PRIVATE_DIR;
+
+/** SWAT data file (images, etc) directory */
const char *dyn_SWATDIR = SWATDIR;
diff --git a/source4/heimdal_build/glue.c b/source4/heimdal_build/glue.c
index 07c58b7789..819a395ca8 100644
--- a/source4/heimdal_build/glue.c
+++ b/source4/heimdal_build/glue.c
@@ -43,7 +43,7 @@ krb5_error_code KRB5_LIB_FUNCTION krb5_get_all_client_addrs(krb5_context context
if (res->val[i].address.data == NULL) {
return ENOMEM;
}
- ((struct in_addr *)res->val[i].address.data)->s_addr = sys_inet_addr(ip);
+ ((struct in_addr *)res->val[i].address.data)->s_addr = inet_addr(ip);
}
return 0;
diff --git a/source4/include/includes.h b/source4/include/includes.h
index 94b88d37b2..3636dec58d 100644
--- a/source4/include/includes.h
+++ b/source4/include/includes.h
@@ -76,10 +76,6 @@
#include <windows.h>
#endif
-#if defined(_MSC_VER) || defined(__MINGW32__)
-#include "lib/replace/win32/replace.h"
-#endif
-
/* we support ADS if we want it and have krb5 and ldap libs */
#if defined(WITH_ADS) && defined(HAVE_KRB5) && defined(HAVE_LDAP)
#define HAVE_ADS
@@ -106,15 +102,6 @@ struct ipv4_addr {
uint32_t addr;
};
-#ifndef HAVE_STRERROR
-extern char *sys_errlist[];
-#define strerror(i) sys_errlist[i]
-#endif
-
-#ifndef HAVE_ERRNO_DECL
-extern int errno;
-#endif
-
#include "lib/replace/replace.h"
diff --git a/source4/lib/com/tables.c b/source4/lib/com/tables.c
index cf63e7e9a2..39bd6a6bd7 100644
--- a/source4/lib/com/tables.c
+++ b/source4/lib/com/tables.c
@@ -58,13 +58,13 @@ static struct IUnknown *get_com_class_so(TALLOC_CTX *mem_ctx, const struct GUID
mod_name = talloc_asprintf(mem_ctx, "%s.so", clsid_str);
talloc_free(clsid_str);
- mod = sys_dlopen(mod_name, 0);
+ mod = dlopen(mod_name, 0);
if (!mod) {
return NULL;
}
- f = sys_dlsym(mod, "get_class_object");
+ f = dlsym(mod, "get_class_object");
if (!f) {
return NULL;
diff --git a/source4/lib/replace/README b/source4/lib/replace/README
new file mode 100644
index 0000000000..74b5397949
--- /dev/null
+++ b/source4/lib/replace/README
@@ -0,0 +1,54 @@
+This subsystem ensures that we can always use a certain core set of
+functions and types, that are either provided by the OS or by replacement
+functions / definitions in this subsystem. The aim is to try to stick
+to POSIX functions in here as much as possible. Convenience functions
+that are available on no platform at all belong in different subsystems
+(such as LIBUTIL).
+
+The following functions are guarenteed:
+
+ftruncate
+strlcpy
+strlcat
+mktime
+rename
+innetgr
+initgroups
+memmove
+strdup
+inet_ntoa
+setlinebuf
+vsyslog
+timegm
+setenv
+strtoull
+strtoll
+strndup
+strnlen
+waitpid
+seteuid
+setegid
+asprintf
+snprintf
+vasprintf
+vsnprintf
+opendir
+readdir
+telldir
+seekdir
+closedir
+dlopen
+dlclose
+dlsym
+dlerror
+chroot
+bzero
+strerror
+errno
+mkstemp (a secure one!)
+
+Prerequisites:
+memset (for bzero)
+syslog (for vsyslog)
+setnetgrent, getnetgrent, endnetgrent (for innetgr)
+mktemp (for mkstemp)
diff --git a/source4/lib/replace/SConscript b/source4/lib/replace/SConscript
index 84088db162..982120e1bf 100644
--- a/source4/lib/replace/SConscript
+++ b/source4/lib/replace/SConscript
@@ -9,4 +9,4 @@ if hostenv['configure']:
conf.Finish()
hostenv.StaticLibrary('repdir', ['repdir/repdir.c'])
-hostenv.StaticLibrary('replace', ['replace.c', 'snprintf.c'])
+hostenv.StaticLibrary('replace', ['replace.c', 'snprintf.c','dlfcn.c'])
diff --git a/source4/lib/replace/config.m4 b/source4/lib/replace/config.m4
index 4dfeb5647a..88e3be5e94 100644
--- a/source4/lib/replace/config.m4
+++ b/source4/lib/replace/config.m4
@@ -15,5 +15,87 @@ if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then
AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced])
fi
+dnl Provided by replace.c:
+AC_CHECK_HEADERS(sys/syslog.h syslog.h)
AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq)
-AC_CHECK_FUNCS(seteuid setresuid setegid setresgid)
+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_HAVE_DECL(setresuid, [#include <unistd.h>])
+AC_HAVE_DECL(setresgid, [#include <unistd.h>])
+AC_HAVE_DECL(errno, [#include <errno.h>])
+
+AC_CACHE_CHECK([for secure mkstemp],samba_cv_HAVE_SECURE_MKSTEMP,[
+AC_TRY_RUN([#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+main() {
+ struct stat st;
+ char tpl[20]="/tmp/test.XXXXXX";
+ int fd = mkstemp(tpl);
+ if (fd == -1) exit(1);
+ unlink(tpl);
+ if (fstat(fd, &st) != 0) exit(1);
+ if ((st.st_mode & 0777) != 0600) exit(1);
+ exit(0);
+}],
+samba_cv_HAVE_SECURE_MKSTEMP=yes,
+samba_cv_HAVE_SECURE_MKSTEMP=no,
+samba_cv_HAVE_SECURE_MKSTEMP=cross)])
+if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
+ AC_DEFINE(HAVE_SECURE_MKSTEMP,1,[Whether mkstemp is secure])
+fi
+
+dnl Provided by snprintf.c:
+AC_HAVE_DECL(asprintf, [#include <stdio.h>])
+AC_HAVE_DECL(vasprintf, [#include <stdio.h>])
+AC_HAVE_DECL(vsnprintf, [#include <stdio.h>])
+AC_HAVE_DECL(snprintf, [#include <stdio.h>])
+AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf)
+
+AC_CACHE_CHECK([for C99 vsnprintf],samba_cv_HAVE_C99_VSNPRINTF,[
+AC_TRY_RUN([
+#include <sys/types.h>
+#include <stdarg.h>
+void foo(const char *format, ...) {
+ va_list ap;
+ int len;
+ char buf[20];
+ long long l = 1234567890;
+ l *= 100;
+
+ va_start(ap, format);
+ len = vsnprintf(buf, 0, format, ap);
+ va_end(ap);
+ if (len != 5) exit(1);
+
+ va_start(ap, format);
+ len = vsnprintf(0, 0, format, ap);
+ va_end(ap);
+ if (len != 5) exit(1);
+
+ if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
+
+ if (snprintf(buf, 20, "%lld", l) != 12 || strcmp(buf, "123456789000") != 0) exit(1);
+
+ exit(0);
+}
+main() { foo("hello"); }
+],
+samba_cv_HAVE_C99_VSNPRINTF=yes,samba_cv_HAVE_C99_VSNPRINTF=no,samba_cv_HAVE_C99_VSNPRINTF=cross)])
+if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
+ AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Whether there is a C99 compliant vsnprintf])
+fi
+
+dnl Provided by dlfcn.c:
+AC_SEARCH_LIBS_EXT(dlopen, [dl], DL_LIBS)
+SMB_EXT_LIB(DL,[${DL_LIBS}],[${DL_CFLAGS}],[${DL_CPPFLAGS}],[${DL_LDFLAGS}])
+SAVE_LIBS="$LIBS"
+LIBS="$LIBS $DL_LIBS"
+AC_CHECK_HEADERS(dlfcn.h)
+AC_CHECK_FUNCS(dlopen dlsym dlerror dlclose)
+LIBS="$SAVE_LIBS"
+
+AC_CHECK_FUNCS([syslog memset setnetgrent getnetgrent endnetgrent],,
+ [AC_MSG_ERROR([Need syslog and memset])])
diff --git a/source4/lib/replace/config.mk b/source4/lib/replace/config.mk
index 16952ea32d..2658f0e96a 100644
--- a/source4/lib/replace/config.mk
+++ b/source4/lib/replace/config.mk
@@ -13,7 +13,9 @@ NOPROTO = YES
[SUBSYSTEM::LIBREPLACE]
INIT_OBJ_FILES = lib/replace/replace.o
ADD_OBJ_FILES = \
- lib/replace/snprintf.o
+ lib/replace/snprintf.o \
+ lib/replace/dlfcn.o
+NOPROTO = YES
REQUIRED_SUBSYSTEMS = REPLACE_READDIR
# End SUBSYSTEM LIBREPLACE
##############################
diff --git a/source4/lib/replace/dlfcn.c b/source4/lib/replace/dlfcn.c
new file mode 100644
index 0000000000..7a9e7230de
--- /dev/null
+++ b/source4/lib/replace/dlfcn.c
@@ -0,0 +1,71 @@
+/*
+ Unix SMB/CIFS implementation.
+ Samba system utilities
+ Copyright (C) Andrew Tridgell 1992-1998
+ Copyright (C) Jeremy Allison 1998-2002
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+/*
+ Unix SMB/CIFS implementation.
+ Samba system utilities
+ Copyright (C) Andrew Tridgell 1992-1998
+ Copyright (C) Jeremy Allison 1998-2002
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+
+#ifndef HAVE_DLOPEN
+void *dlopen(const char *name, int flags)
+{
+ return NULL;
+}
+#endif
+
+#ifndef HAVE_DLSYM
+void *dlsym(void *handle, const char *symbol)
+{
+ return NULL;
+}
+#endif
+
+#ifndef HAVE_DLERROR
+const char *dlerror(void)
+{
+ return "dynamic loading of objects not supported on this platform";
+}
+#endif
+
+#ifndef HAVE_DLCLOSE
+int dlclose(void *handle)
+{
+ return 0;
+}
+#endif
diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c
index ef8e053257..aa79f23fd0 100644
--- a/source4/lib/replace/replace.c
+++ b/source4/lib/replace/replace.c
@@ -361,39 +361,6 @@ duplicate a string
#endif /* HAVE_SYSLOG */
#endif /* HAVE_VSYSLOG */
-/*******************************************************************
-yield the difference between *A and *B, in seconds, ignoring leap seconds
-********************************************************************/
-static int tm_diff(struct tm *a, struct tm *b)
-{
- int ay = a->tm_year + (1900 - 1);
- int by = b->tm_year + (1900 - 1);
- int intervening_leap_days =
- (ay/4 - by/4) - (ay/100 - by/100) + (ay/400 - by/400);
- int years = ay - by;
- int days = 365*years + intervening_leap_days + (a->tm_yday - b->tm_yday);
- int hours = 24*days + (a->tm_hour - b->tm_hour);
- int minutes = 60*hours + (a->tm_min - b->tm_min);
- int seconds = 60*minutes + (a->tm_sec - b->tm_sec);
-
- return seconds;
-}
-
-/*******************************************************************
- return the UTC offset in seconds west of UTC, or 0 if it cannot be determined
- ******************************************************************/
-int get_time_zone(time_t t)
-{
- struct tm *tm = gmtime(&t);
- struct tm tm_utc;
- if (!tm)
- return 0;
- tm_utc = *tm;
- tm = localtime(&t);
- if (!tm)
- return 0;
- return tm_diff(&tm_utc,tm);
-}
#ifndef HAVE_TIMEGM
/*
@@ -496,14 +463,12 @@ int get_time_zone(time_t t)
}
#endif
-int sys_waitpid(pid_t pid,int *status,int options)
+#ifndef HAVE_WAITPID
+int waitpid(pid_t pid,int *status,int options)
{
-#ifdef HAVE_WAITPID
- return waitpid(pid,status,options);
-#else /* USE_WAITPID */
return wait4(pid, status, options, NULL);
-#endif /* USE_WAITPID */
}
+#endif
#ifndef HAVE_SETEUID
int seteuid(uid_t euid)
@@ -526,3 +491,35 @@ int sys_waitpid(pid_t pid,int *status,int options)
#endif
}
#endif
+
+/*******************************************************************
+os/2 also doesn't have chroot
+********************************************************************/
+#ifndef HAVE_CHROOT
+int chroot(const char *dname)
+{
+ static int done;
+ if (!done) {
+ DEBUG(1,("WARNING: no chroot!\n"));
+ done=1;
+ }
+ errno = ENOSYS;
+ return -1;
+}
+#endif
+
+/*****************************************************************
+ Possibly replace mkstemp if it is broken.
+*****************************************************************/
+
+#ifndef HAVE_SECURE_MKSTEMP
+int rep_mkstemp(char *template)
+{
+ /* have a reasonable go at emulating it. Hope that
+ the system mktemp() isn't completly hopeless */
+ char *p = mktemp(template);
+ if (!p)
+ return -1;
+ return open(p, O_CREAT|O_EXCL|O_RDWR, 0600);
+}
+#endif
diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h
index f85c8de634..f906e7a2f5 100644
--- a/source4/lib/replace/replace.h
+++ b/source4/lib/replace/replace.h
@@ -23,6 +23,10 @@
#ifndef _replace_h
#define _replace_h
+#if defined(_MSC_VER) || defined(__MINGW32__)
+#include "lib/replace/win32/replace.h"
+#endif
+
#ifdef __COMPAR_FN_T
#define QSORT_CAST (__compar_fn_t)
#endif
@@ -31,6 +35,15 @@
#define QSORT_CAST (int (*)(const void *, const void *))
#endif
+#ifndef HAVE_STRERROR
+extern char *sys_errlist[];
+#define strerror(i) sys_errlist[i]
+#endif
+
+#ifndef HAVE_ERRNO_DECL
+extern int errno;
+#endif
+
#ifndef HAVE_STRDUP
char *strdup(const char *s);
#endif
@@ -136,4 +149,13 @@ typedef unsigned char u_int8_t;
#define HAVE_SOCKLEN_T 1
#endif
+#ifdef HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#ifndef HAVE_SECURE_MKSTEMP
+#define mkstemp(path) rep_mkstemp(path)
+int rep_mkstemp(char *temp);
+#endif
+
#endif
diff --git a/source4/lib/signal.c b/source4/lib/signal.c
index 66d3e1f76e..6c0bb4007a 100644
--- a/source4/lib/signal.c
+++ b/source4/lib/signal.c
@@ -28,7 +28,7 @@
static void sig_cld(int signum)
{
- while (sys_waitpid((pid_t)-1,(int *)NULL, WNOHANG) > 0)
+ while (waitpid((pid_t)-1,(int *)NULL, WNOHANG) > 0)
;
/*
diff --git a/source4/lib/system.c b/source4/lib/system.c
index eb3799c7ca..629b2b07ff 100644
--- a/source4/lib/system.c
+++ b/source4/lib/system.c
@@ -23,7 +23,6 @@
#include "system/network.h"
#include "system/wait.h"
#include "system/filesys.h"
-#include "pstring.h"
/*
The idea is that this file will eventually have wrappers around all
@@ -78,20 +77,6 @@ int sys_usleep(long usecs)
/*******************************************************************
- System wrapper for getwd
-********************************************************************/
-char *sys_getwd(char *s)
-{
- char *wd;
-#ifdef HAVE_GETCWD
- wd = (char *)getcwd(s, sizeof (pstring));
-#else
- wd = (char *)getwd(s);
-#endif
- return wd;
-}
-
-/*******************************************************************
A read wrapper that will deal with EINTR.
********************************************************************/
@@ -121,24 +106,6 @@ ssize_t sys_write(int fd, const void *buf, size_t count)
-/*******************************************************************
-os/2 also doesn't have chroot
-********************************************************************/
-int sys_chroot(const char *dname)
-{
-#ifndef HAVE_CHROOT
- static int done;
- if (!done) {
- DEBUG(1,("WARNING: no chroot!\n"));
- done=1;
- }
- errno = ENOSYS;
- return -1;
-#else
- return(chroot(dname));
-#endif
-}
-
/**************************************************************************
A wrapper for gethostbyname() that tries avoids looking up hostnames
in the root domain, which can cause dial-on-demand links to come up for no
@@ -181,39 +148,6 @@ struct hostent *sys_gethostbyname(const char *name)
#endif /* REDUCE_ROOT_DNS_LOOKUPS */
}
-
-
-/**************************************************************************
- Wrappers for dlopen, dlsym, dlclose.
-****************************************************************************/
-
-void *sys_dlopen(const char *name, int flags)
-{
-#if defined(HAVE_DLOPEN)
- return dlopen(name, flags);
-#else
- return NULL;
-#endif
-}
-
-void *sys_dlsym(void *handle, const char *symbol)
-{
-#if defined(HAVE_DLSYM)
- return dlsym(handle, symbol);
-#else
- return NULL;
-#endif
-}
-
-const char *sys_dlerror(void)
-{
-#if defined(HAVE_DLERROR)
- return dlerror();
-#else
- return NULL;
-#endif
-}
-
const char *sys_inet_ntoa(struct ipv4_addr in)
{
struct in_addr in2;
@@ -221,11 +155,6 @@ const char *sys_inet_ntoa(struct ipv4_addr in)
return inet_ntoa(in2);
}
-uint32_t sys_inet_addr(const char *s)
-{
- return inet_addr(s);
-}
-
struct ipv4_addr sys_inet_makeaddr(int net, int host)
{
struct in_addr in;
diff --git a/source4/lib/time.c b/source4/lib/time.c
index 61e92b8c00..5de9046c8d 100644
--- a/source4/lib/time.c
+++ b/source4/lib/time.c
@@ -594,3 +594,37 @@ NTTIME timeval_to_nttime(const struct timeval *tv)
return 10*(tv->tv_usec +
((TIME_FIXUP_CONSTANT + (uint64_t)tv->tv_sec) * 1000000));
}
+
+/*******************************************************************
+yield the difference between *A and *B, in seconds, ignoring leap seconds
+********************************************************************/
+static int tm_diff(struct tm *a, struct tm *b)
+{
+ int ay = a->tm_year + (1900 - 1);
+ int by = b->tm_year + (1900 - 1);
+ int intervening_leap_days =
+ (ay/4 - by/4) - (ay/100 - by/100) + (ay/400 - by/400);
+ int years = ay - by;
+ int days = 365*years + intervening_leap_days + (a->tm_yday - b->tm_yday);
+ int hours = 24*days + (a->tm_hour - b->tm_hour);
+ int minutes = 60*hours + (a->tm_min - b->tm_min);
+ int seconds = 60*minutes + (a->tm_sec - b->tm_sec);
+
+ return seconds;
+}
+
+/*******************************************************************
+ return the UTC offset in seconds west of UTC, or 0 if it cannot be determined
+ ******************************************************************/
+int get_time_zone(time_t t)
+{
+ struct tm *tm = gmtime(&t);
+ struct tm tm_utc;
+ if (!tm)
+ return 0;
+ tm_utc = *tm;
+ tm = localtime(&t);
+ if (!tm)
+ return 0;
+ return tm_diff(&tm_utc,tm);
+}
diff --git a/source4/lib/util.c b/source4/lib/util.c
index a1d6f85eb9..0733103e93 100644
--- a/source4/lib/util.c
+++ b/source4/lib/util.c
@@ -347,7 +347,7 @@ uint32_t interpret_addr(const char *str)
/* if it's in the form of an IP address then get the lib to interpret it */
if (is_ipaddress(str)) {
- res = sys_inet_addr(str);
+ res = inet_addr(str);
} else {
/* otherwise assume it's a network name of some sort and use
sys_gethostbyname */
@@ -519,24 +519,6 @@ void dump_data(int level, const uint8_t *buf,int len)
}
/*****************************************************************
- Possibly replace mkstemp if it is broken.
-*****************************************************************/
-
-int smb_mkstemp(char *template)
-{
-#if HAVE_SECURE_MKSTEMP
- return mkstemp(template);
-#else
- /* have a reasonable go at emulating it. Hope that
- the system mktemp() isn't completly hopeless */
- char *p = mktemp(template);
- if (!p)
- return -1;
- return open(p, O_CREAT|O_EXCL|O_RDWR, 0600);
-#endif
-}
-
-/*****************************************************************
malloc that aborts with smb_panic on fail or zero size.
*****************************************************************/
diff --git a/source4/libcli/resolve/host.c b/source4/libcli/resolve/host.c
index 9f48f83ba4..a5edfcbc8a 100644
--- a/source4/libcli/resolve/host.c
+++ b/source4/libcli/resolve/host.c
@@ -105,7 +105,7 @@ static void pipe_handler(struct event_context *ev, struct fd_event *fde,
/* enusre the address looks good */
address[ret] = 0;
if (strcmp(address, "0.0.0.0") == 0 ||
- sys_inet_addr(address) == INADDR_NONE) {
+ inet_addr(address) == INADDR_NONE) {
goto failed;
}
diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c
index e559ea8ff6..b3740c5e01 100644
--- a/source4/librpc/ndr/ndr_basic.c
+++ b/source4/librpc/ndr/ndr_basic.c
@@ -571,7 +571,7 @@ NTSTATUS ndr_push_ipv4address(struct ndr_push *ndr, int ndr_flags, const char *a
{
uint32_t addr;
if (!is_ipaddress(address)) return NT_STATUS_INVALID_PARAMETER_MIX;
- addr = sys_inet_addr(address);
+ addr = inet_addr(address);
NDR_CHECK(ndr_push_uint32(ndr, ndr_flags, htonl(addr)));
return NT_STATUS_OK;
}
diff --git a/source4/torture/torture.c b/source4/torture/torture.c
index e60f1caf78..b4aefb8780 100644
--- a/source4/torture/torture.c
+++ b/source4/torture/torture.c
@@ -2168,7 +2168,7 @@ double torture_create_procs(BOOL (*fn)(struct smbcli_state *, int), BOOL *result
for (i=0;i<torture_nprocs;i++) {
int ret;
- while ((ret=sys_waitpid(0, &status, 0)) == -1 && errno == EINTR) /* noop */ ;
+ while ((ret=waitpid(0, &status, 0)) == -1 && errno == EINTR) /* noop */ ;
if (ret == -1 || WEXITSTATUS(status) != 0) {
*result = False;
}
diff --git a/source4/winbind/wb_samba3_protocol.c b/source4/winbind/wb_samba3_protocol.c
index bff39ab482..a5ad66ae16 100644
--- a/source4/winbind/wb_samba3_protocol.c
+++ b/source4/winbind/wb_samba3_protocol.c
@@ -50,7 +50,7 @@ NTSTATUS wbsrv_samba3_pull_request(DATA_BLOB blob, TALLOC_CTX *mem_ctx, struct w
s3_call = talloc_zero(call, struct wbsrv_samba3_call);
NT_STATUS_HAVE_NO_MEMORY(s3_call);
- s3call->call = call;
+ s3_call->call = call;
/* the packet layout is the same as the in memory layout of the request, so just copy it */
memcpy(&s3_call->request, blob.data, sizeof(s3_call->request));