summaryrefslogtreecommitdiffstats
path: root/replace
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2008-09-25 01:51:49 -0400
committerSimo Sorce <idra@samba.org>2008-09-25 02:30:18 -0400
commitf698831f0ae0cd86225eb647ae4aeb813f08d3b5 (patch)
tree55689de966245292e6ae517480c668ce993caf70 /replace
parentcced59be44cbc2204314bdf77a35b41b81bf4097 (diff)
downloadsssd-f698831f0ae0cd86225eb647ae4aeb813f08d3b5.tar.gz
sssd-f698831f0ae0cd86225eb647ae4aeb813f08d3b5.tar.xz
sssd-f698831f0ae0cd86225eb647ae4aeb813f08d3b5.zip
Sync with upstream changes
Diffstat (limited to 'replace')
-rw-r--r--replace/Makefile.in20
-rw-r--r--replace/build_macros.m420
-rw-r--r--replace/configure.ac2
-rw-r--r--replace/getaddrinfo.h2
-rw-r--r--replace/getpass.c7
-rw-r--r--replace/libreplace.m49
-rw-r--r--replace/libreplace_cc.m424
-rw-r--r--replace/replace.c2
-rw-r--r--replace/snprintf.c2
-rw-r--r--replace/system/network.h2
-rw-r--r--replace/system/passwd.h2
-rw-r--r--replace/test/main.c37
12 files changed, 90 insertions, 39 deletions
diff --git a/replace/Makefile.in b/replace/Makefile.in
index 008d1830b..65f8125ef 100644
--- a/replace/Makefile.in
+++ b/replace/Makefile.in
@@ -9,8 +9,8 @@ libdir = @libdir@
VPATH = @libreplacedir@
srcdir = @srcdir@
builddir = @builddir@
-buildinstdir = @buildinstdir@
-INSTALL = @INSTALL@
+sharedbuilddir = @sharedbuilddir@
+INSTALLCMD = @INSTALL@
LIBS = @LIBS@
.PHONY: test all showflags install installcheck clean distclean realdistclean
@@ -30,14 +30,14 @@ showflags:
@echo ' LIBS = $(LIBS)'
install: all
- mkdir -p $(libdir)
- $(INSTALL) libreplace.a $(libdir)
+ ${INSTALLCMD} -d $(libdir)
+ ${INSTALLCMD} -m 644 libreplace.a $(libdir)
-build-install: all
- mkdir -p $(buildinstdir)/include
- $(INSTALL) replace.h $(buildinstdir)/include
- mkdir -p $(buildinstdir)/lib
- $(INSTALL) libreplace.a $(buildinstdir)/lib
+shared-build: all
+ ${INSTALLCMD} -d $(sharedbuilddir)/include
+ ${INSTALLCMD} -m 644 replace.h $(sharedbuilddir)/include
+ ${INSTALLCMD} -d $(sharedbuilddir)/lib
+ ${INSTALLCMD} -m 644 libreplace.a $(sharedbuilddir)/lib
libreplace.a: $(OBJS)
ar -rcsv $@ $(OBJS)
@@ -47,7 +47,7 @@ test: all
installcheck: install test
-TEST_OBJS = test/testsuite.o test/os2_delete.o test/strptime.o test/getifaddrs.o
+TEST_OBJS = test/main.o test/testsuite.o test/os2_delete.o test/strptime.o test/getifaddrs.o
testsuite: libreplace.a $(TEST_OBJS)
$(CC) -o testsuite $(TEST_OBJS) -L. -lreplace $(LDFLAGS) $(LIBS)
diff --git a/replace/build_macros.m4 b/replace/build_macros.m4
index bc3ec729d..c036668cd 100644
--- a/replace/build_macros.m4
+++ b/replace/build_macros.m4
@@ -1,14 +1,14 @@
-AC_DEFUN(BUILD_WITH_BUILD_INST_DIR,
- [ AC_ARG_WITH([build-install-dir],
- [AC_HELP_STRING([--with-build-install-dir=DIR],
- [temporary build directory where libraries are installed [$srcdir/buildinst]])])
+AC_DEFUN(BUILD_WITH_SHARED_BUILD_DIR,
+ [ AC_ARG_WITH([shared-build-dir],
+ [AC_HELP_STRING([--with-shared-build-dir=DIR],
+ [temporary build directory where libraries are installed [$srcdir/sharedbuild]])])
- buildinstdir="$srcdir/buildinst"
- if test x"$with_build_install_dir" != x; then
- buildinstdir=$with_build_install_dir
- CFLAGS="$CFLAGS -I$with_build_install_dir/include"
- LDFLAGS="$LDFLAGS -L$with_build_install_dir/lib"
+ sharedbuilddir="$srcdir/sharedbuild"
+ if test x"$with_shared_build_dir" != x; then
+ sharedbuilddir=$with_shared_build_dir
+ CFLAGS="$CFLAGS -I$with_shared_build_dir/include"
+ LDFLAGS="$LDFLAGS -L$with_shared_build_dir/lib"
fi
- AC_SUBST(buildinstdir)
+ AC_SUBST(sharedbuilddir)
])
diff --git a/replace/configure.ac b/replace/configure.ac
index 20a7582b5..0361825a0 100644
--- a/replace/configure.ac
+++ b/replace/configure.ac
@@ -23,7 +23,7 @@ if test "$ac_cv_prog_gcc" = yes; then
fi
m4_include(build_macros.m4)
-BUILD_WITH_BUILD_INST_DIR
+BUILD_WITH_SHARED_BUILD_DIR
LIBS="${LIBREPLACE_NETWORK_LIBS}"
AC_SUBST(LIBS)
diff --git a/replace/getaddrinfo.h b/replace/getaddrinfo.h
index dddd699b6..cf040da2d 100644
--- a/replace/getaddrinfo.h
+++ b/replace/getaddrinfo.h
@@ -75,7 +75,9 @@ in lib/replace we use rep_xxx()
#undef getnameinfo
#endif
#define getnameinfo rep_getnameinfo
+#ifndef HAVE_GETNAMEINFO
#define HAVE_GETNAMEINFO
+#endif
extern int rep_getaddrinfo(const char *node, const char *service,
const struct addrinfo * hints, struct addrinfo ** res);
diff --git a/replace/getpass.c b/replace/getpass.c
index 73333b902..0be618fc9 100644
--- a/replace/getpass.c
+++ b/replace/getpass.c
@@ -187,10 +187,6 @@ char *rep_getpass(const char *prompt)
in_fd = fileno(in);
if (fgets(buf, bufsize, in) == NULL) {
buf[0] = 0;
- if (in && in != stdin) {
- fclose(in);
- }
- return buf;
}
}
nread = strlen(buf);
@@ -201,8 +197,9 @@ char *rep_getpass(const char *prompt)
/* Restore echoing. */
if (echo_off) {
- if (gotintr && in_fd == -1)
+ if (gotintr && in_fd == -1) {
in = fopen ("/dev/tty", "w+");
+ }
if (in != NULL)
tcsetattr (fileno (in), TCSANOW, &t);
}
diff --git a/replace/libreplace.m4 b/replace/libreplace.m4
index 71fa04167..e563acfd7 100644
--- a/replace/libreplace.m4
+++ b/replace/libreplace.m4
@@ -5,7 +5,7 @@ echo "LIBREPLACE_LOCATION_CHECKS: START"
dnl find the libreplace sources. This is meant to work both for
dnl libreplace standalone builds, and builds of packages using libreplace
libreplacedir=""
-libreplacepaths="$srcdir $srcdir/lib/replace $srcdir/libreplace $srcdir/../libreplace $srcdir/../replace"
+libreplacepaths="$srcdir $srcdir/lib/replace $srcdir/libreplace $srcdir/../libreplace $srcdir/../replace $srcdir/../lib/replace $srcdir/../../../lib/replace"
for d in $libreplacepaths; do
if test -f "$d/replace.c"; then
libreplacedir="$d"
@@ -34,13 +34,18 @@ echo "LIBREPLACE_BROKEN_CHECKS: START"
dnl find the libreplace sources. This is meant to work both for
dnl libreplace standalone builds, and builds of packages using libreplace
libreplacedir=""
-for d in "$srcdir" "$srcdir/lib/replace" "$srcdir/libreplace" "$srcdir/../libreplace" "$srcdir/../replace"; do
+libreplacepaths="$srcdir $srcdir/lib/replace $srcdir/libreplace $srcdir/../libreplace $srcdir/../replace $srcdir/../lib/replace $srcdir/../../../lib/replace"
+for d in $libreplacepaths; do
if test -f "$d/replace.c"; then
libreplacedir="$d"
AC_SUBST(libreplacedir)
break;
fi
done
+if test x"$libreplacedir" = "x"; then
+ AC_MSG_ERROR([cannot find libreplace in $libreplacepaths])
+fi
+
LIBREPLACEOBJ="replace.o"
AC_SUBST(LIBREPLACEOBJ)
diff --git a/replace/libreplace_cc.m4 b/replace/libreplace_cc.m4
index 0ce0958a9..30c63f2f0 100644
--- a/replace/libreplace_cc.m4
+++ b/replace/libreplace_cc.m4
@@ -109,25 +109,34 @@ AC_CHECK_HEADERS([standards.h])
# Solaris needs HAVE_LONG_LONG defined
AC_CHECK_TYPES(long long)
+AC_CHECK_SIZEOF(int)
+AC_CHECK_SIZEOF(char)
+AC_CHECK_SIZEOF(short)
+AC_CHECK_SIZEOF(long)
+AC_CHECK_SIZEOF(long long)
+
AC_CHECK_TYPE(uint_t, unsigned int)
AC_CHECK_TYPE(int8_t, char)
AC_CHECK_TYPE(uint8_t, unsigned char)
AC_CHECK_TYPE(int16_t, short)
AC_CHECK_TYPE(uint16_t, unsigned short)
+
+if test $ac_cv_sizeof_int -eq 4 ; then
+AC_CHECK_TYPE(int32_t, int)
+AC_CHECK_TYPE(uint32_t, unsigned int)
+elif test $ac_cv_size_long -eq 4 ; then
AC_CHECK_TYPE(int32_t, long)
AC_CHECK_TYPE(uint32_t, unsigned long)
+else
+AC_MSG_ERROR([LIBREPLACE no 32-bit type found])
+fi
+
AC_CHECK_TYPE(int64_t, long long)
AC_CHECK_TYPE(uint64_t, unsigned long long)
AC_CHECK_TYPE(size_t, unsigned int)
AC_CHECK_TYPE(ssize_t, int)
-AC_CHECK_SIZEOF(int)
-AC_CHECK_SIZEOF(char)
-AC_CHECK_SIZEOF(short)
-AC_CHECK_SIZEOF(long)
-AC_CHECK_SIZEOF(long long)
-
AC_CHECK_SIZEOF(off_t)
AC_CHECK_SIZEOF(size_t)
AC_CHECK_SIZEOF(ssize_t)
@@ -158,7 +167,8 @@ AC_CACHE_CHECK([for immediate structures],libreplace_cv_immediate_structures,[
FOOBAR y;
} f2[] = {
{FOO_ONE}
- };
+ };
+ static const FOOBAR f3[] = {FOO_ONE};
],
libreplace_cv_immediate_structures=yes,
libreplace_cv_immediate_structures=no,
diff --git a/replace/replace.c b/replace/replace.c
index 106c9dfe6..98d799b07 100644
--- a/replace/replace.c
+++ b/replace/replace.c
@@ -170,7 +170,7 @@ int rep_initgroups(char *name, gid_t id)
#include <grp.h>
gid_t *grouplst = NULL;
- int max_gr = 32;
+ int max_gr = NGROUPS_MAX;
int ret;
int i,j;
struct group *g;
diff --git a/replace/snprintf.c b/replace/snprintf.c
index a174dcffe..c54d721ce 100644
--- a/replace/snprintf.c
+++ b/replace/snprintf.c
@@ -526,7 +526,7 @@ static int dopr(char *buffer, size_t maxlen, const char *format, va_list args_in
}
}
- /* retieve the format arguments */
+ /* retrieve the format arguments */
for (pnum = 0; pnum < max_pos; pnum++) {
int i;
diff --git a/replace/system/network.h b/replace/system/network.h
index 077892a54..473d79b5f 100644
--- a/replace/system/network.h
+++ b/replace/system/network.h
@@ -326,7 +326,7 @@ struct addrinfo {
#ifndef SOCKET_WRAPPER_NOT_REPLACE
#define SOCKET_WRAPPER_REPLACE
#endif
-#include "lib/socket_wrapper/socket_wrapper.h"
+#include "../socket_wrapper/socket_wrapper.h"
#endif
#endif
diff --git a/replace/system/passwd.h b/replace/system/passwd.h
index cad3197cc..9d7de34bc 100644
--- a/replace/system/passwd.h
+++ b/replace/system/passwd.h
@@ -104,7 +104,7 @@ char *rep_getpass(const char *prompt);
#ifndef NSS_WRAPPER_NOT_REPLACE
#define NSS_WRAPPER_REPLACE
#endif
-#include "lib/nss_wrapper/nss_wrapper.h"
+#include "../nss_wrapper/nss_wrapper.h"
#endif
#endif
diff --git a/replace/test/main.c b/replace/test/main.c
new file mode 100644
index 000000000..9bd12840a
--- /dev/null
+++ b/replace/test/main.c
@@ -0,0 +1,37 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ libreplace tests
+
+ Copyright (C) Jelmer Vernooij 2006
+
+ ** NOTE! The following LGPL license applies to the talloc
+ ** library. This does NOT imply that all of Samba is released
+ ** under the LGPL
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 3 of the License, or (at your option) any later version.
+
+ This library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "replace.h"
+
+struct torture_context;
+bool torture_local_replace(struct torture_context *ctx);
+
+int main(void)
+{
+ bool ret = torture_local_replace(NULL);
+ if (ret)
+ return 0;
+ return -1;
+}