r11086 - in libprelude/trunk: m4 src src/include

[email protected]
Newsgroups gmane.comp.security.ids.prelude.cvs
Message-ID <[email protected]>
Author: yoann
Date: 2008-11-12 10:36:53 +0100 (Wed, 12 Nov 2008)
New Revision: 11086

Modified:
   libprelude/trunk/m4/libprelude.m4
   libprelude/trunk/src/include/prelude-plugin.h
   libprelude/trunk/src/prelude-plugin.c
Log:
Workaround libtool/libltdl 1.5 -> 2.x ABI compatibility issues. This
introduce two fixes:

- Fix a crash when an application use a different libtool version than the
  libltdl version used to compile libprelude. In order to prevent this
  problem, we automatically rewrite symbol table provided by libtool 1.5
  application, and make it compatible with libltdl 2.2 (we will now ship
  libtool/ltdl 2.2 as the default with libprelude).

- Automatic handling of symbol renaming between libtool 1.5 -> 2.x,
  which solve application linking problem.

This fix #294.


Modified: libprelude/trunk/m4/libprelude.m4
===================================================================
--- libprelude/trunk/m4/libprelude.m4	2008-11-12 09:36:48 UTC (rev 11085)
+++ libprelude/trunk/m4/libprelude.m4	2008-11-12 09:36:53 UTC (rev 11086)
@@ -179,6 +179,11 @@
   AC_SUBST(LIBPRELUDE_LIBS)
   AC_SUBST(LIBPRELUDE_PREFIX)
   AC_SUBST(LIBPRELUDE_CONFIG_PREFIX)
+
+  m4_ifdef([LT_INIT],
+           [AC_DEFINE([PRELUDE_APPLICATION_USE_LIBTOOL2], [], [Define whether application use libtool >= 2.0])],
+           [])
+
 ])
 
 dnl *-*wedit:notab*-*  Please keep this as the last line.

Modified: libprelude/trunk/src/include/prelude-plugin.h
===================================================================
--- libprelude/trunk/src/include/prelude-plugin.h	2008-11-12 09:36:48 UTC (rev 11085)
+++ libprelude/trunk/src/include/prelude-plugin.h	2008-11-12 09:36:53 UTC (rev 11086)
@@ -6,7 +6,7 @@
 * This file is part of the Prelude library.
 *
 * 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 
+* it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
@@ -24,6 +24,9 @@
 #ifndef _LIBPRELUDE_PLUGIN_H
 #define _LIBPRELUDE_PLUGIN_H
 
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
 
 #include "prelude-list.h"
 #include "prelude-option.h"
@@ -45,7 +48,7 @@
         char *name;                          \
         void (*destroy)(prelude_plugin_instance_t *pi, prelude_string_t *err)
 
-         
+
 typedef struct {
         PRELUDE_PLUGIN_GENERIC;
 } prelude_plugin_generic_t;
@@ -56,9 +59,13 @@
  * Hack for plugin preloading,
  * without having the end program depend on ltdl.
  */
+#ifdef PRELUDE_APPLICATION_USE_LIBTOOL2
+# define lt_preloaded_symbols lt__PROGRAM__LTX_preloaded_symbols
+#endif
+
 extern const void *lt_preloaded_symbols[];
 
-#define PRELUDE_PLUGIN_SET_PRELOADED_SYMBOLS()                     \
+#define PRELUDE_PLUGIN_SET_PRELOADED_SYMBOLS()         \
         prelude_plugin_set_preloaded_symbols(lt_preloaded_symbols)
 
 
@@ -159,7 +166,7 @@
 
 /*
  * Call this if you want to use this plugin.
- */ 
+ */
 int prelude_plugin_instance_add(prelude_plugin_instance_t *pi, prelude_list_t *h);
 
 void prelude_plugin_instance_del(prelude_plugin_instance_t *pi);
@@ -198,7 +205,7 @@
         (((type *)prelude_plugin_instance_get_plugin(pi))->member(__VA_ARGS__))
 
 #ifdef __cplusplus
- } 
+ }
 #endif
 
 #endif /* _LIBPRELUDE_PLUGIN_H */

Modified: libprelude/trunk/src/prelude-plugin.c
===================================================================
--- libprelude/trunk/src/prelude-plugin.c	2008-11-12 09:36:48 UTC (rev 11085)
+++ libprelude/trunk/src/prelude-plugin.c	2008-11-12 09:36:53 UTC (rev 11086)
@@ -419,7 +419,7 @@
 
         handle = lt_dlopenext(filename);
         if ( ! handle ) {
-                prelude_log(PRELUDE_LOG_WARN, "%s.\n", lt_dlerror());
+                prelude_log(PRELUDE_LOG_WARN, "%s: %s.\n", filename, lt_dlerror());
                 return -1;
         }
 
@@ -449,7 +449,7 @@
 
         plugin_init = lt_dlsym(handle, buggy_libtool ? libtool_is_buggy(pname, symbol, buf, sizeof(buf)) : symbol);
         if ( ! plugin_init ) {
-                prelude_log(PRELUDE_LOG_WARN, "plugin initialization failed: '%s'.\n", lt_dlerror());
+                prelude_log(PRELUDE_LOG_WARN, "%s: plugin initialization failed: '%s'.\n", pname, lt_dlerror());
                 lt_dlclose(handle);
                 return -1;
         }
@@ -845,7 +845,34 @@
 
 void prelude_plugin_set_preloaded_symbols(void *symlist)
 {
-        lt_dlpreload_default(symlist);
+        size_t len;
+        lt_dlsymlist *s = symlist;
+        static lt_dlsymlist rpl_sym[25] = {
+                { "@PROGNAME@", NULL },
+                { NULL, NULL         }
+        };
+
+        if ( s[0].name == NULL || strcmp(s[0].name, "@PROGNAME@") != 0 ) {
+                /*
+                 * Check size of the input symlist.
+                 */
+                for ( len = 0; s[len].name != NULL; len++ );
+
+                if ( len + 1 >= sizeof(rpl_sym) / sizeof(*rpl_sym) ) {
+                        prelude_log(PRELUDE_LOG_CRIT, "replacement symlist is not large enough (%lu entry).\n", len);
+                        len = (sizeof(rpl_sym) / sizeof(*rpl_sym)) - 2;
+                }
+
+                /*
+                 * Copy as many symbols as possible, and set the last entry to NULL.
+                 */
+                memcpy(&rpl_sym[1], s, len * sizeof(*rpl_sym));
+                rpl_sym[len + 1].name = NULL;
+
+                s = rpl_sym;
+        }
+
+        lt_dlpreload_default(s);
 }
 
 

_______________________________________________
Prelude-cvslog site list
[email protected]
http://lists.prelude-ids.org/mailman/listinfo/prelude-cvslog
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.