Skip to content

Commit

Permalink
Avoid libdl dependencies in bundled libverto
Browse files Browse the repository at this point in the history
The upstream libverto depends on dynamic loading and in particular on
dladdr(), which is not universal.  To avoid this dependency, stub out
support for module loading (by replacing module.c) and instead
integrate the k5ev module directly into the bundled verto library.

This change removes the need to link, include, and invoke libverto
differently depending on whether we're using the bundled library; we
can always just link with -lverto and call verto_default().

bigredbutton: whitespace
ticket: 7351 (new)
  • Loading branch information
greghudson committed Sep 4, 2012
1 parent 6b60871 commit c91cda2
Show file tree
Hide file tree
Showing 25 changed files with 68 additions and 340 deletions.
5 changes: 1 addition & 4 deletions src/config/pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,6 @@ VERTO_VERSION = @VERTO_VERSION@
VERTO_DEPS = $(VERTO_DEPS-@VERTO_VERSION@)
VERTO_DEPS-sys =
VERTO_DEPS-k5 = $(BUILDTOP)/include/verto.h
VERTO_K5EV_DEPS = $(VERTO_K5EV_DEPS-@VERTO_VERSION@)
VERTO_K5EV_DEPS-sys =
VERTO_K5EV_DEPS-k5 = $(BUILDTOP)/include/verto-k5ev.h

# LIBS gets substituted in... e.g. -lnsl -lsocket

Expand All @@ -389,7 +386,7 @@ KDB5_LIB = -lkdb5 $(KDB5_PLUGIN_LIBS)

VERTO_DEPLIB = $(VERTO_DEPLIB-@VERTO_VERSION@)
VERTO_DEPLIB-sys = # empty
VERTO_DEPLIB-k5 = $(TOPLIBD)/libverto-k5ev$(DEPLIBEXT) $(TOPLIBD)/libverto$(DEPLIBEXT)
VERTO_DEPLIB-k5 = $(TOPLIBD)/libverto$(DEPLIBEXT)
VERTO_CFLAGS = @VERTO_CFLAGS@
VERTO_LIBS = @VERTO_LIBS@

Expand Down
7 changes: 3 additions & 4 deletions src/configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -1219,15 +1219,15 @@ AC_ARG_WITH([system-verto],
[AC_HELP_STRING([--with-system-verto], [always use system verto library])],
[], [with_system_verto=default])
VERTO_CFLAGS=
VERTO_LIBS="-lverto-k5ev -lverto"
VERTO_LIBS="-lverto"
VERTO_VERSION=k5
if test "x$with_system_verto" != xno; then
if verto_cflags=`pkg-config --cflags libverto 2>&1`; then
VERTO_CFLAGS=$verto_cflags
VERTO_LIBS=`pkg-config --libs libverto`
VERTO_VERSION=sys
else
AC_CHECK_LIB([verto], [verto_run], [VERTO_VERSION=sys; VERTO_LIBS=-lverto],
AC_CHECK_LIB([verto], [verto_run], [VERTO_VERSION=sys],
[if test "x$with_system_verto" = xyes; then
AC_MSG_ERROR([cannot detect system libverto])
fi])
Expand All @@ -1237,7 +1237,6 @@ if test "x$VERTO_VERSION" = xsys; then
AC_MSG_NOTICE([Using system libverto])
else
AC_MSG_RESULT([Using built-in libverto])
AC_DEFINE([INTERNAL_VERTO],[1],[Define if using bundled libverto])
fi
AC_SUBST([VERTO_CFLAGS])
AC_SUBST([VERTO_LIBS])
Expand Down Expand Up @@ -1295,7 +1294,7 @@ AC_CONFIG_FILES(krb5-config, [chmod +x krb5-config])
V5_AC_OUTPUT_MAKEFILE(.

util util/support util/profile util/profile/testmod util/send-pr
util/verto util/k5ev
util/verto

lib lib/kdb

Expand Down
2 changes: 1 addition & 1 deletion src/lib/apputils/deps
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ net-server.so net-server.po $(OUTPRE)net-server.$(OBJEXT): \
$(BUILDTOP)/include/autoconf.h $(BUILDTOP)/include/gssapi/gssapi.h \
$(BUILDTOP)/include/gssrpc/types.h $(BUILDTOP)/include/krb5/krb5.h \
$(BUILDTOP)/include/osconf.h $(BUILDTOP)/include/profile.h \
$(COM_ERR_DEPS) $(VERTO_DEPS) $(VERTO_K5EV_DEPS) $(top_srcdir)/include/adm_proto.h \
$(COM_ERR_DEPS) $(VERTO_DEPS) $(top_srcdir)/include/adm_proto.h \
$(top_srcdir)/include/fake-addrinfo.h $(top_srcdir)/include/foreachaddr.h \
$(top_srcdir)/include/gssrpc/auth.h $(top_srcdir)/include/gssrpc/auth_gss.h \
$(top_srcdir)/include/gssrpc/auth_unix.h $(top_srcdir)/include/gssrpc/clnt.h \
Expand Down
9 changes: 0 additions & 9 deletions src/lib/apputils/net-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@

#include "fake-addrinfo.h"
#include "net-server.h"
#ifdef INTERNAL_VERTO
#include "verto-k5ev.h"
#endif

#include <signal.h>

/* XXX */
Expand Down Expand Up @@ -269,12 +265,7 @@ loop_init(verto_ev_type types)
types |= VERTO_EV_TYPE_IO;
types |= VERTO_EV_TYPE_SIGNAL;
types |= VERTO_EV_TYPE_TIMEOUT;

#ifdef INTERNAL_VERTO
return verto_default_k5ev();
#else
return verto_default(NULL, types);
#endif
}

static void
Expand Down
2 changes: 1 addition & 1 deletion src/util/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ MAYBE_ET_sys =
MAYBE_ET_intlsys =
MAYBE_SS_sys =
MAYBE_VERTO_sys =
MAYBE_VERTO_k5 = verto k5ev
MAYBE_VERTO_k5 = verto

all-recurse:

Expand Down
1 change: 0 additions & 1 deletion src/util/depfix.pl
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ sub do_subs_2 {
s;\$\(BUILDTOP\)/include/com_err.h ;\$(COM_ERR_DEPS) ;g;
s;\$\(BUILDTOP\)/include/ss/ss.h \$\(BUILDTOP\)/include/ss/ss_err.h ;\$(SS_DEPS) ;g;
s;\$\(BUILDTOP\)/include/db-config.h \$\(BUILDTOP\)/include/db.h ;\$(DB_DEPS) ;g;
s;\$\(BUILDTOP\)/include/verto-k5ev.h ;\$(VERTO_K5EV_DEPS) ;g;
s;\$\(BUILDTOP\)/include/verto.h ;\$(VERTO_DEPS) ;g;
if ($thisdir eq "util/gss-kernel-lib") {
# Here com_err.h is used from the current directory.
Expand Down
52 changes: 0 additions & 52 deletions src/util/k5ev/Makefile.in

This file was deleted.

31 changes: 0 additions & 31 deletions src/util/k5ev/README

This file was deleted.

7 changes: 0 additions & 7 deletions src/util/k5ev/deps

This file was deleted.

3 changes: 0 additions & 3 deletions src/util/k5ev/libverto-k5ev.exports

This file was deleted.

33 changes: 0 additions & 33 deletions src/util/k5ev/verto-k5ev.h

This file was deleted.

22 changes: 14 additions & 8 deletions src/util/verto/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,38 @@ LIBBASE=verto
LIBMAJOR=0
LIBMINOR=0

LOCALINCLUDES=-I$(srcdir)
DEFINES=-DDEFAULT_LIBRARY=\"k5ev\"
LOCALINCLUDES=-I$(srcdir) -I.
DEFINES=-DDEFAULT_LIBRARY=\"k5ev\" -DBUILTIN_MODULE=k5ev

# Turn off extra warnings since we're not going to clean up libverto's code.
WARN_CFLAGS=

STLIBOBJS=verto.o module.o
LIBOBJS=$(OUTPRE)verto.$(OBJEXT) $(OUTPRE)module.$(OBJEXT)
SRCS=verto.c module.c
STLIBOBJS=verto.o module.o verto-k5ev.o
LIBOBJS=$(OUTPRE)verto.$(OBJEXT) \
$(OUTPRE)module.$(OBJEXT) \
$(OUTPRE)verto-k5ev.$(OBJEXT)
SRCS=verto.c module.c verto-k5ev.c

STOBJLISTS=OBJS.ST
SHLIB_EXPLIBS= $(DL_LIB) $(LIBS)
SHLIB_EXPLIBS= $(LIBS) -lm # libm needed for ceil() currently.
SHLIB_DIRS=
SHLIB_RDIRS=$(KRB5_LIBDIR)

VERTO_HDR=$(BUILDTOP)$(S)include$(S)verto.h

rename.h: $(srcdir)/Symbols.ev
$(RM) $@
$(SED) -e 's/.*/#define & k5&/' < $(srcdir)/Symbols.ev > $@

all-unix:: all-liblinks includes

install-unix:: install-libs

clean-unix:: clean-liblinks clean-libs clean-libobjs
$(RM) $(VERTO_HDR)
$(RM) $(VERTO_HDR) rename.h

includes:: $(VERTO_HDR)
depend:: $(VERTO_HDR)
depend:: $(VERTO_HDR) rename.h

$(VERTO_HDR): $(srcdir)/verto.h
$(RM) $@
Expand Down
40 changes: 37 additions & 3 deletions src/util/verto/README
Original file line number Diff line number Diff line change
@@ -1,6 +1,40 @@
This directory builds a verto library with only a private back-end
module, for use when the system has no installed verto library.
This directory builds a verto library with only a private built-in
module, for use when the system has no installed verto library. The
bundled verto cannot dynamically load modules. From the upstream
libverto, we take only verto.c and verto-libev.c, and we only build
the former; the latter is stored here for comparison purposes. We use
a stub implementation of module.c to disable dynamic loading support.

The libverto upstream project page is at:
This private module uses an embedded libev with renamed symbols (so we
don't leak libev symbols into the namespace on platforms where we
can't control the export list). libev has built-in support for this
kind of embedding, so we don't have to modify the libev sources.
Following libev's documentation, the following files have been copied
from the ev sources:

ev.h
ev_vars.h
ev_wrap.h
ev.c
ev_select.c
ev_poll.c
ev_win32.c
Symbols.ev

(Symbols.ev wasn't included in the 4.04 tar file due to an oversight,
so it is taken from the appropriate tag in libev's source repository.)

To rename the exported symbols, we create rename.h from Symbols.ev.
We also use Symbols.ev to construct the library export list.
(Renaming libev's symbols would be unnecessary if libev's embedding
had support for making its API symbols static, but it currently does
not.) The source file verto-k5ev.c wraps ev.c with appropriate
embedding defines, and then defines the libverto module functions
using the slightly modified contents of libverto's verto-libev.c. The
resulting module table is embedded into verto.c using the
BUILTIN_MODULE define.

The libverto and libev upstream project pages are at:

https://fedorahosted.org/libverto/
http://software.schmorp.de/pkg/libev.html
File renamed without changes.
4 changes: 4 additions & 0 deletions src/util/verto/deps
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@
verto.so verto.po $(OUTPRE)verto.$(OBJEXT): $(VERTO_DEPS) \
module.h verto-module.h verto.c
module.so module.po $(OUTPRE)module.$(OBJEXT): module.c
verto-k5ev.so verto-k5ev.po $(OUTPRE)verto-k5ev.$(OBJEXT): \
$(BUILDTOP)/include/autoconf.h $(VERTO_DEPS) ev.c ev.h \
ev_poll.c ev_select.c ev_vars.h ev_wrap.h rename.h \
verto-k5ev.c verto-module.h
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit c91cda2

Please sign in to comment.