File bug-694243_cluster-glue_symbol-conflict.patch of Package cluster-glue
# HG changeset patch
# Parent ef8ad188f372c6393847a1287af02f79e11717ec
Medium: stonith: load libplumb symbols manually (thanks to lge) (bnc#694243)
diff -r ef8ad188f372 -r 43e0d1d58866 lib/stonith/Makefile.am
--- a/lib/stonith/Makefile.am Thu Dec 13 17:38:22 2012 +0100
+++ b/lib/stonith/Makefile.am Thu Dec 13 17:43:11 2012 +0100
@@ -33,9 +33,7 @@ endif
stonith_SOURCES = main.c
-stonith_LDADD = libstonith.la $(top_builddir)/lib/pils/libpils.la $(GLIBLIB) \
- $(top_builddir)/lib/clplumbing/libplumb.la \
- $(top_builddir)/lib/clplumbing/libplumbgpl.la
+stonith_LDADD = libstonith.la $(top_builddir)/lib/pils/libpils.la $(GLIBLIB)
stonith_LDFLAGS = @LIBADD_DL@ @LIBLTDL@ -export-dynamic @DLOPEN_FORCE_FLAGS@ @LIBADD_INTL@
meatclient_SOURCES = meatclient.c
diff -r ef8ad188f372 -r 43e0d1d58866 lib/stonith/main.c
--- a/lib/stonith/main.c Thu Dec 13 17:38:22 2012 +0100
+++ b/lib/stonith/main.c Thu Dec 13 17:43:11 2012 +0100
@@ -26,9 +26,9 @@
#include <unistd.h>
#include <string.h>
#include <syslog.h>
+#include <dlfcn.h>
#include <stonith/stonith.h>
#include <pils/plugin.h>
-#include <clplumbing/cl_log.h>
#include <glib.h>
#include <libxml/entities.h>
@@ -43,6 +43,7 @@ static int debug = 0;
#define LOG_TERMINAL 0
#define LOG_CLLOG 1
static int log_destination = LOG_TERMINAL;
+static void (*logfun)(int, const char *, ...) G_GNUC_PRINTF(2,3);
static const char META_TEMPLATE[] =
"<?xml version=\"1.0\"?>\n"
@@ -73,9 +74,11 @@ void print_stonith_meta(Stonith * stonit
void print_types(void);
void print_confignames(Stonith *s);
+const char *prio2str(int priority);
void log_buf(int severity, char *buf);
void log_msg(int severity, const char * fmt, ...)G_GNUC_PRINTF(2,3);
void trans_log(int priority, const char * fmt, ...)G_GNUC_PRINTF(2,3);
+void setup_cl_log(void);
static int pil_loglevel_to_syslog_severity[] = {
/* Indices: <none>=0, PIL_FATAL=1, PIL_CRIT=2, PIL_WARN=3,
@@ -297,6 +300,7 @@ print_stonith_meta(Stonith * stonith_obj
}
#define MAXNVARG 50
+#define MAXLINE (512*10)
void
print_types()
@@ -331,6 +335,27 @@ print_confignames(Stonith *s)
printf("\n");
}
+const char *
+prio2str(int priority)
+{
+ static const char *log_prio[8] = {
+ "EMERG",
+ "ALERT",
+ "CRIT",
+ "ERROR",
+ "WARN",
+ "notice",
+ "info",
+ "debug"
+ };
+ int logpri;
+
+ logpri = LOG_PRI(priority);
+
+ return (logpri < 0 || logpri >= DIMOF(log_prio)) ?
+ "(undef)" : log_prio[logpri];
+}
+
void
log_buf(int severity, char *buf)
{
@@ -339,7 +364,11 @@ log_buf(int severity, char *buf)
if (log_destination == LOG_TERMINAL) {
fprintf(stderr, "%s: %s\n", prio2str(severity),buf);
} else {
- cl_log(severity, "%s", buf);
+ if (logfun) {
+ (*logfun)(severity, "%s", buf);
+ } else {
+ syslog(severity, "%s", buf);
+ }
}
}
@@ -370,6 +399,40 @@ trans_log(int priority, const char * fmt
log_buf(severity, buf);
}
+/*
+ * due to possible symbol conflict with other system libraries
+ * (in particular HMAC, MD5, and base64*) we just pick the
+ * symbols we need here
+ */
+
+void
+setup_cl_log(void)
+{
+ void *ldhandle;
+ void (*set_entity)(const char *);
+ void (*enable_stderr)(int);
+ void (*set_facility)(int);
+ void (*inherit_logging_environment)(int);
+
+ ldhandle = dlopen("libplumb.so", RTLD_LAZY);
+ if (!ldhandle) {
+ return;
+ }
+
+ *(void **) (&set_entity) = dlsym(ldhandle, "cl_log_set_entity");
+ *(void **) (&enable_stderr) = dlsym(ldhandle, "cl_log_enable_stderr");
+ *(void **) (&set_facility) = dlsym(ldhandle, "cl_log_set_facility");
+ *(void **) (&inherit_logging_environment) = dlsym(ldhandle, "cl_inherit_logging_environment");
+ *(void **) (&logfun) = dlsym(ldhandle, "cl_log");
+
+ (*set_entity)("stonith");
+ (*enable_stderr)(debug?TRUE:FALSE);
+ (*set_facility)(HA_LOG_FACILITY);
+
+ /* Use logd if it's enabled by heartbeat */
+ (*inherit_logging_environment)(0);
+}
+
int
main(int argc, char** argv)
{
@@ -491,12 +554,7 @@ main(int argc, char** argv)
/* if we're invoked by stonithd, log through cl_log */
if (!isatty(fileno(stdin))) {
log_destination = LOG_CLLOG;
- cl_log_set_entity("stonith");
- cl_log_enable_stderr(debug?TRUE:FALSE);
- cl_log_set_facility(HA_LOG_FACILITY);
-
- /* Use logd if it's enabled by heartbeat */
- cl_inherit_logging_environment(0);
+ setup_cl_log();
}
if (help && !errors) {