Christoph Biedl wrote...
+noinst_LTLIBRARIES = libpreload.la
+libpreload_la_SOURCES = \
- getnameinfo-preload.c
+libpreload_la_LDFLAGS = \
- -module -export-dynamic -avoid-version -shared
This should create a libpreload.so but does not.
Wild guessing: noinst_LTLIBRARIES never creates .so files. Using lib_LTLIBRARIES instead does the trick but triggers installation of both .so and .la files. Hackaround: Use "install-exec-hook". The patch attached works as expected, but: Appearently you'd have to run autoreconf, and if that one is to new, if will break since a feature has been removed that is used by ngircd (bug#181).
Christoph
--- a/src/testsuite/Makefile.am +++ b/src/testsuite/Makefile.am @@ -24,11 +24,24 @@ start-server1 stop-server1 ngircd-test1.conf \ start-server2 stop-server2 ngircd-test2.conf
+lib_LTLIBRARIES = libpreload.la + +libpreload_la_SOURCES = \ + getnameinfo-preload.c + +libpreload_la_LDFLAGS = \ + -module -export-dynamic -avoid-version -shared + +install-exec-hook: + rm $(DESTDIR)/$(libdir)/libpreload.so* \ + $(DESTDIR)/$(libdir)/libpreload.la + all:
clean-local: rm -rf logs tests *-test ngircd-test*.log procs.tmp tests-skipped.lst \ - T-ngircd1 ngircd-test1.motd T-ngircd2 ngircd-test2.motd + T-ngircd1 ngircd-test1.motd T-ngircd2 ngircd-test2.motd \ + getnameinfo-preload.o getnameinfo-preload.lo libpreload.la .libs/
maintainer-clean-local: rm -f Makefile Makefile.in Makefile.am --- a/src/testsuite/start-server.sh +++ b/src/testsuite/start-server.sh @@ -40,6 +40,13 @@ export MALLOC_CHECK_
# starting up test-server ... +if [ "$(uname)" = 'Linux' ] ; then + if [ "$LD_PRELOAD" ] ; then + export LD_PRELOAD="$PWD/.libs/libpreload.so $LD_PRELOAD" +else + export LD_PRELOAD="$PWD/.libs/libpreload.so" + fi +fi ./T-ngircd${id} -n -f ${srcdir}/ngircd-test${id}.conf $* \
ngircd-test${id}.log 2>&1 &
sleep 1 --- /dev/null +++ b/src/testsuite/getnameinfo-preload.c @@ -0,0 +1,55 @@ + +#define _GNU_SOURCE + +#include <arpa/inet.h> +#include <dlfcn.h> +#include <netdb.h> +#include <string.h> +#include <sys/socket.h> + +#include <stdio.h> + +int getnameinfo ( + const struct sockaddr *sa, + socklen_t salen, + char *host, + socklen_t hostlen, + char *serv, + socklen_t servlen, + unsigned int flags +) +{ + int (*real_getnameinfo) ( + const struct sockaddr *, + socklen_t, + char *, + socklen_t, + char *, + socklen_t, + unsigned int + ); + static struct sockaddr_in localhost; + if (localhost.sin_family == 0) { + localhost.sin_family = AF_INET; + inet_pton(AF_INET, "127.0.0.1", &(localhost.sin_addr)); + } + + if (!(real_getnameinfo = dlsym (RTLD_NEXT, "getnameinfo"))) + return -1; + + if ( + flags == NI_NAMEREQD && + sa->sa_family == AF_INET && + memcmp ( + &((struct sockaddr_in *) sa)->sin_addr, + &localhost.sin_addr, + sizeof (localhost.sin_addr) + ) == 0 + ) { + /* shortcut to "localhost" */ + strncpy (host, "localhost", hostlen); + return 0; + } + /* forward */ + return (real_getnameinfo (sa, salen, host, hostlen, serv, servlen, flags)); +} --- a/configure.ac +++ b/configure.ac @@ -64,6 +64,7 @@
AC_PROG_AWK AC_PROG_INSTALL +AC_PROG_LIBTOOL AC_PROG_LN_S AC_PROG_MAKE_SET AC_PROG_MKDIR_P