krb5 commit: Avoid libdl dependencies in bundled libverto

Greg Hudson ghudson at MIT.EDU
Tue Sep 4 01:32:00 EDT 2012


https://github.com/krb5/krb5/commit/c91cda209a1e2467bbb5fbb5a3116757d38ef374
commit c91cda209a1e2467bbb5fbb5a3116757d38ef374
Author: Greg Hudson <ghudson at mit.edu>
Date:   Sun Jul 8 18:04:56 2012 -0400

    Avoid libdl dependencies in bundled libverto
    
    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)

 src/config/pre.in                   |    5 +-
 src/configure.in                    |    7 +-
 src/lib/apputils/deps               |    2 +-
 src/lib/apputils/net-server.c       |    9 -
 src/util/Makefile.in                |    2 +-
 src/util/depfix.pl                  |    1 -
 src/util/k5ev/Makefile.in           |   52 -
 src/util/k5ev/README                |   31 -
 src/util/k5ev/Symbols.ev            |   73 -
 src/util/k5ev/deps                  |    7 -
 src/util/k5ev/ev.c                  | 3913 -----------------------------------
 src/util/k5ev/ev.h                  |  829 --------
 src/util/k5ev/ev_poll.c             |  148 --
 src/util/k5ev/ev_select.c           |  310 ---
 src/util/k5ev/ev_vars.h             |  203 --
 src/util/k5ev/ev_win32.c            |  153 --
 src/util/k5ev/ev_wrap.h             |  196 --
 src/util/k5ev/libverto-k5ev.exports |    3 -
 src/util/k5ev/verto-k5ev.c          |  215 --
 src/util/k5ev/verto-k5ev.h          |   33 -
 src/util/k5ev/verto-libev.c         |  199 --
 src/util/verto/Makefile.in          |   22 +-
 src/util/verto/README               |   40 +-
 src/util/verto/Symbols.ev           |   73 +
 src/util/verto/deps                 |    4 +
 src/util/verto/ev.c                 | 3913 +++++++++++++++++++++++++++++++++++
 src/util/verto/ev.h                 |  829 ++++++++
 src/util/verto/ev_poll.c            |  148 ++
 src/util/verto/ev_select.c          |  310 +++
 src/util/verto/ev_vars.h            |  203 ++
 src/util/verto/ev_win32.c           |  153 ++
 src/util/verto/ev_wrap.h            |  196 ++
 src/util/verto/module.c             |  179 +--
 src/util/verto/verto-k5ev.c         |  212 ++
 src/util/verto/verto-libev.c        |  199 ++
 35 files changed, 6300 insertions(+), 6572 deletions(-)

diff --git a/src/config/pre.in b/src/config/pre.in
index e5a087c..1ba26d8 100644
--- a/src/config/pre.in
+++ b/src/config/pre.in
@@ -369,9 +369,6 @@ VERTO_VERSION	= @VERTO_VERSION@
 VERTO_DEPS	= $(VERTO_DEPS- at VERTO_VERSION@)
 VERTO_DEPS-sys	=
 VERTO_DEPS-k5	= $(BUILDTOP)/include/verto.h
-VERTO_K5EV_DEPS	= $(VERTO_K5EV_DEPS- at VERTO_VERSION@)
-VERTO_K5EV_DEPS-sys =
-VERTO_K5EV_DEPS-k5 = $(BUILDTOP)/include/verto-k5ev.h
 
 # LIBS gets substituted in... e.g. -lnsl -lsocket
 
@@ -389,7 +386,7 @@ KDB5_LIB	= -lkdb5 $(KDB5_PLUGIN_LIBS)
 
 VERTO_DEPLIB	= $(VERTO_DEPLIB- at 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@
 
diff --git a/src/configure.in b/src/configure.in
index 9e9c94f..7154f68 100644
--- a/src/configure.in
+++ b/src/configure.in
@@ -1219,7 +1219,7 @@ 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
@@ -1227,7 +1227,7 @@ if test "x$with_system_verto" != xno; then
     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])
@@ -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])
@@ -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
 
diff --git a/src/lib/apputils/deps b/src/lib/apputils/deps
index 586e1ef..a41563e 100644
--- a/src/lib/apputils/deps
+++ b/src/lib/apputils/deps
@@ -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 \
diff --git a/src/lib/apputils/net-server.c b/src/lib/apputils/net-server.c
index 0fd08ec..1f8a8f9 100644
--- a/src/lib/apputils/net-server.c
+++ b/src/lib/apputils/net-server.c
@@ -58,10 +58,6 @@
 
 #include "fake-addrinfo.h"
 #include "net-server.h"
-#ifdef INTERNAL_VERTO
-#include "verto-k5ev.h"
-#endif
-
 #include <signal.h>
 
 /* XXX */
@@ -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
diff --git a/src/util/Makefile.in b/src/util/Makefile.in
index f45bc70..f2f6b75 100644
--- a/src/util/Makefile.in
+++ b/src/util/Makefile.in
@@ -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:
 
diff --git a/src/util/depfix.pl b/src/util/depfix.pl
index 4fc3789..f648da8 100644
--- a/src/util/depfix.pl
+++ b/src/util/depfix.pl
@@ -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.
diff --git a/src/util/k5ev/Makefile.in b/src/util/k5ev/Makefile.in
deleted file mode 100644
index b80a60d..0000000
--- a/src/util/k5ev/Makefile.in
+++ /dev/null
@@ -1,52 +0,0 @@
-mydir=util$(S)k5ev
-BUILDTOP=$(REL)..$(S)..
-RELDIR=../util/k5ev
-DEFS=
-
-SED = sed
-
-LIBBASE=verto-k5ev
-LIBMAJOR=0
-LIBMINOR=0
-
-LOCALINCLUDES=-I. -I$(srcdir)/../verto
-
-# Turn off extra warnings since we're not going to clean up libev's code.
-WARN_CFLAGS=
-
-STLIBOBJS=verto-k5ev.o
-LIBOBJS=$(OUTPRE)verto-k5ev.$(OBJEXT)
-SRCS=verto-k5ev.c
-
-STOBJLISTS=OBJS.ST
-SHLIB_EXPLIBS= $(LIBS) -lverto -lm      # libm needed for ceil() currently.
-SHLIB_DIRS=-L$(TOPLIBD)
-SHLIB_RDIRS=$(KRB5_LIBDIR)
-
-VERTO_K5EV_HDR=$(BUILDTOP)$(S)include$(S)verto-k5ev.h
-
-all-unix:: all-liblinks includes
-
-install-unix:: install-libs
-
-clean-unix:: clean-liblinks clean-libs clean-libobjs
-	$(RM) $(VERTO_K5EV_HDR)
-
-includes:: $(VERTO_K5EV_HDR)
-depend:: $(VERTO_K5EV_HDR)
-
-$(VERTO_K5EV_HDR): $(srcdir)/verto-k5ev.h
-	$(RM) $@
-	$(CP) $(srcdir)/verto-k5ev.h $@
-
-rename.h: $(srcdir)/Symbols.ev
-	$(RM) $@
-	$(SED) -e 's/.*/#define & k5&/' < $(srcdir)/Symbols.ev > $@
-
-clean::
-	$(RM) rename.h
-
-depend:: rename.h
-
- at lib_frag@
- at libobj_frag@
diff --git a/src/util/k5ev/README b/src/util/k5ev/README
deleted file mode 100644
index 7a14f13..0000000
--- a/src/util/k5ev/README
+++ /dev/null
@@ -1,31 +0,0 @@
-This directory builds a private libverto module using 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-ev.c.
-
-The libev upstream project page is at:
-
-  http://software.schmorp.de/pkg/libev.html
diff --git a/src/util/k5ev/deps b/src/util/k5ev/deps
deleted file mode 100644
index 5fd8552..0000000
--- a/src/util/k5ev/deps
+++ /dev/null
@@ -1,7 +0,0 @@
-# 
-# Generated makefile dependencies follow.
-#
-verto-k5ev.so verto-k5ev.po $(OUTPRE)verto-k5ev.$(OBJEXT): \
-  $(BUILDTOP)/include/autoconf.h $(VERTO_DEPS) $(srcdir)/../verto/verto-module.h \
-  ev.c ev.h ev_poll.c ev_select.c ev_vars.h ev_wrap.h \
-  rename.h verto-k5ev.c verto-k5ev.h
diff --git a/src/util/k5ev/libverto-k5ev.exports b/src/util/k5ev/libverto-k5ev.exports
deleted file mode 100644
index 7907fbe..0000000
--- a/src/util/k5ev/libverto-k5ev.exports
+++ /dev/null
@@ -1,3 +0,0 @@
-verto_default_k5ev
-verto_module_table_k5ev
-verto_new_k5ev
diff --git a/src/util/k5ev/verto-k5ev.h b/src/util/k5ev/verto-k5ev.h
deleted file mode 100644
index 0b1ad19..0000000
--- a/src/util/k5ev/verto-k5ev.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2011 Red Hat, Inc.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifndef VERTO_K5EV_H_
-#define VERTO_K5EV_H_
-
-#include <verto.h>
-
-verto_ctx *verto_new_k5ev(void);
-verto_ctx *verto_default_k5ev(void);
-
-#endif /* VERTO_K5EV_H_ */
diff --git a/src/util/verto/Makefile.in b/src/util/verto/Makefile.in
index f7206c8..ff1bd1a 100644
--- a/src/util/verto/Makefile.in
+++ b/src/util/verto/Makefile.in
@@ -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) $@
diff --git a/src/util/verto/README b/src/util/verto/README
index 8e47610..6de645f 100644
--- a/src/util/verto/README
+++ b/src/util/verto/README
@@ -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
diff --git a/src/util/k5ev/Symbols.ev b/src/util/verto/Symbols.ev
similarity index 100%
rename from src/util/k5ev/Symbols.ev
rename to src/util/verto/Symbols.ev
diff --git a/src/util/verto/deps b/src/util/verto/deps
index dad2f3a..3424d30 100644
--- a/src/util/verto/deps
+++ b/src/util/verto/deps
@@ -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
diff --git a/src/util/k5ev/ev.c b/src/util/verto/ev.c
similarity index 100%
rename from src/util/k5ev/ev.c
rename to src/util/verto/ev.c
diff --git a/src/util/k5ev/ev.h b/src/util/verto/ev.h
similarity index 100%
rename from src/util/k5ev/ev.h
rename to src/util/verto/ev.h
diff --git a/src/util/k5ev/ev_poll.c b/src/util/verto/ev_poll.c
similarity index 100%
rename from src/util/k5ev/ev_poll.c
rename to src/util/verto/ev_poll.c
diff --git a/src/util/k5ev/ev_select.c b/src/util/verto/ev_select.c
similarity index 100%
rename from src/util/k5ev/ev_select.c
rename to src/util/verto/ev_select.c
diff --git a/src/util/k5ev/ev_vars.h b/src/util/verto/ev_vars.h
similarity index 100%
rename from src/util/k5ev/ev_vars.h
rename to src/util/verto/ev_vars.h
diff --git a/src/util/k5ev/ev_win32.c b/src/util/verto/ev_win32.c
similarity index 100%
rename from src/util/k5ev/ev_win32.c
rename to src/util/verto/ev_win32.c
diff --git a/src/util/k5ev/ev_wrap.h b/src/util/verto/ev_wrap.h
similarity index 100%
rename from src/util/k5ev/ev_wrap.h
rename to src/util/verto/ev_wrap.h
diff --git a/src/util/verto/module.c b/src/util/verto/module.c
index d5977cb..68dc709 100644
--- a/src/util/verto/module.c
+++ b/src/util/verto/module.c
@@ -22,138 +22,25 @@
  * SOFTWARE.
  */
 
-#ifdef WIN32
-#include <windows.h>
-#define dlltype HMODULE
-static char *
-dllerror(void) {
-    char *amsg;
-    LPTSTR msg;
+/* Stub implementation of module loading for MIT krb5 bundled libverto. */
 
-    FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER
-                      | FORMAT_MESSAGE_FROM_SYSTEM
-                      | FORMAT_MESSAGE_IGNORE_INSERTS,
-                  NULL, GetLastError(),
-                  MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
-                  (LPTSTR) &msg, 0, NULL);
-    amsg = strdup((const char*) msg);
-    LocalFree(msg);
-    return amsg;
-}
-#elif defined(aix)
-#include "sys/ldr.h"
-
-struct Dl_info {
-  const char* dli_fname;
-};
-
-static int
-dladdr(void* s, Dl_info* i)
-{
-    static const size_t bufSize = 4096;
-    G__FastAllocString buf(bufSize);
-    char* pldi = buf;
-    int r;
-
-    r = loadquery(L_GETINFO, pldi, bufSize);
-    if (r == -1) {
-        i->dli_fname = NULL;
-        return 0;
-    }
-
-    for (ld_info* ldi = (ld_info*) buf;
-         ldi->ldinfo_next;
-         ldi += ldi->ldinfo_next) {
-        char* textBegin = (char*) ldi->ldinfo_textorg;
-        if (textBegin < s) {
-            char* textEnd = textBegin + ldi->ldinfo_textsize;
-            if (textEnd > s) {
-                i->dli_fname = ldi->ldinfo_filename;
-                return 1;
-            }
-        }
-    }
-
-    // First is main(), skip.
-    ld_info* ldi = (ld_info*) pldi;
-    while (ldi->ldinfo_next) {
-        pldi += ldi->ldinfo_next;
-        ldi = (ld_info*) pldi;
-
-    }
-
-    i->dli_fname = NULL;
-    return 0;
-}
-#else
-#define _GNU_SOURCE
-#include <stdlib.h>
 #include <string.h>
-#include <dlfcn.h>
-#define dlltype void *
-#define dllerror() strdup(dlerror())
-#endif
 
 int
 module_symbol_is_present(const char *modname, const char *symbname)
 {
-#ifdef WIN32
-    return (GetProcAddress(GetModuleHandle(modname), symbname) != NULL ||
-            GetProcAddress(GetModuleHandle(NULL), symbname) != NULL);
-#else  /* WIN32 */
-    void* mod = dlopen(NULL, RTLD_LAZY | RTLD_LOCAL);
-    if (mod) {
-        void* sym = dlsym(mod, symbname);
-        dlclose(mod);
-        return sym != NULL;
-    }
-#endif /* WIN32 */
     return 0;
 }
 
 int
 module_get_filename_for_symbol(void *addr, char **filename)
 {
-#ifdef WIN32
-    MEMORY_BASIC_INFORMATION info;
-    HMODULE mod;
-    char tmp[MAX_PATH];
-
-    if (!VirtualQuery(addr, &info, sizeof(info)))
-        return 0;
-    mod = (HMODULE) info.AllocationBase;
-
-    if (!GetModuleFileNameA(mod, tmp, MAX_PATH))
-        return 0;
-#else
-    const char *tmp;
-    Dl_info dlinfo;
-
-    if (!dladdr(addr, &dlinfo))
-        return 0;
-    tmp = dlinfo.dli_fname;
-#endif
-
-    if (filename) {
-        *filename = strdup(tmp);
-        if (!*filename)
-            return 0;
-    }
-
-    return 1;
+    return 0;
 }
 
 void
 module_close(void *dll)
 {
-    if (!dll)
-        return;
-
-#ifdef WIN32
-    FreeLibrary((dlltype) dll);
-#else  /* WIN32 */
-    dlclose((dlltype) dll);
-#endif /* WIN32 */
 }
 
 char *
@@ -161,69 +48,9 @@ module_load(const char *filename, const char *symbname,
             int (*shouldload)(void *symb, void *misc, char **err), void *misc,
             void **dll, void **symb)
 {
-    dlltype intdll = NULL;
-    void *  intsym = NULL;
-    char *  interr = NULL;
-
     if (dll)
         *dll = NULL;
     if (symb)
         *symb = NULL;
-
-    /* Open the module library */
-#ifdef WIN32
-    /* NOTE: DONT_RESOLVE_DLL_REFERENCES is evil. Don't use this in your own
-     * code. However, our design pattern avoids all the issues surrounding a
-     * more general use of this evil flag. */
-    intdll = LoadLibraryEx(filename, NULL, DONT_RESOLVE_DLL_REFERENCES);
-#else  /* WIN32 */
-    intdll = dlopen(filename, RTLD_LAZY | RTLD_LOCAL);
-#endif /* WIN32 */
-    if (!intdll)
-        return dllerror();
-
-    /* Get the module symbol */
-#ifdef WIN32
-    intsym = (void *) GetProcAddress(intdll, symbname);
-#else /* WIN32 */
-    intsym = dlsym(intdll, symbname);
-#endif /* WIN32 */
-    if (!intsym) {
-        module_close(intdll);
-        return dllerror();
-    }
-
-    /* Figure out whether or not to load this module */
-    if (!shouldload(intsym, misc, &interr)) {
-        module_close(intdll);
-        return interr;
-    }
-
-    /* Re-open the module */
-    module_close(intdll);
-#ifdef WIN32
-    intdll = LoadLibrary(filename);
-#else  /* WIN32 */
-    intdll = dlopen(filename, RTLD_NOW | RTLD_LOCAL);
-#endif /* WIN32 */
-    if (!intdll) {
-        return dllerror();
-    }
-
-    /* Get the symbol again */
-#ifdef WIN32
-    intsym = (void *) GetProcAddress(intdll, symbname);
-#else /* WIN32 */
-    intsym = dlsym(intdll, symbname);
-#endif /* WIN32 */
-    if (!intsym) {
-        module_close(intdll);
-        return dllerror();
-    }
-
-    if (dll)
-        *dll = intdll;
-    if (symb)
-        *symb = intsym;
-    return NULL;
+    return strdup("module loading disabled");
 }
diff --git a/src/util/k5ev/verto-k5ev.c b/src/util/verto/verto-k5ev.c
similarity index 97%
rename from src/util/k5ev/verto-k5ev.c
rename to src/util/verto/verto-k5ev.c
index 35c94d6..f75e8aa 100644
--- a/src/util/k5ev/verto-k5ev.c
+++ b/src/util/verto/verto-k5ev.c
@@ -32,7 +32,7 @@
 #include <string.h>
 #include <errno.h>
 
-#include "verto-k5ev.h"
+#include <verto.h>
 #include <verto-module.h>
 #include "rename.h"
 #include "autoconf.h"
@@ -201,15 +201,12 @@ k5ev_ctx_del(verto_mod_ctx *ctx, const verto_ev *ev, verto_mod_ev *evpriv)
     free(evpriv);
 }
 
+verto_ctx *verto_new_k5ev(void);
+verto_ctx *verto_default_k5ev(void);
+
 VERTO_MODULE(k5ev, NULL,
              VERTO_EV_TYPE_IO |
              VERTO_EV_TYPE_TIMEOUT |
              VERTO_EV_TYPE_IDLE |
              VERTO_EV_TYPE_SIGNAL |
              VERTO_EV_TYPE_CHILD);
-
-verto_ctx *
-verto_convert_k5ev(struct ev_loop* loop)
-{
-    return verto_convert(k5ev, 0, loop);
-}
diff --git a/src/util/k5ev/verto-libev.c b/src/util/verto/verto-libev.c
similarity index 100%
rename from src/util/k5ev/verto-libev.c
rename to src/util/verto/verto-libev.c


More information about the cvs-krb5 mailing list