2017-10-09 21:06:05 +00:00
|
|
|
From e6833567cd834cbbd182c48327b7e8ce3a8fc2bc Mon Sep 17 00:00:00 2001
|
2017-10-06 15:36:34 +00:00
|
|
|
From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <jpokorny@redhat.com>
|
|
|
|
Date: Fri, 6 Oct 2017 17:17:26 +0200
|
|
|
|
Subject: [PATCH 6/6] Low: fix internal object symbol's leak & expose run-time
|
|
|
|
lib version
|
|
|
|
MIME-Version: 1.0
|
|
|
|
Content-Type: text/plain; charset=UTF-8
|
|
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
|
|
|
|
The object in question has never been published through the header file,
|
|
|
|
hence it's presumably safe to make it static as it's meant to be.
|
|
|
|
|
|
|
|
On the other hand, QB_LOG_INIT_DATA macro from qblog.h has already
|
|
|
|
started to depend on that symbol so as to locate the library handle
|
|
|
|
for libqb itself correctly. This is trivially fixed by finally exposing
|
|
|
|
library versioning info in run-time through objects identified by the
|
|
|
|
compile-time/static counterparts from qbconfig.h header file, with
|
|
|
|
lower-casing applied on originally upper-cased macro identifiers.
|
|
|
|
Better than to roll out a futile data object serving as an artificial
|
|
|
|
anchor for the above purpose, and this was a while due, afterall.
|
|
|
|
|
|
|
|
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
|
|
|
|
---
|
|
|
|
include/qb/qbconfig.h.in | 5 ++++-
|
|
|
|
include/qb/qblog.h | 10 ++++++----
|
|
|
|
include/qb/qbutil.h | 11 +++++++++++
|
|
|
|
lib/log_format.c | 2 +-
|
|
|
|
lib/util.c | 7 +++++++
|
|
|
|
tests/functional/log_client.c | 4 ++++
|
|
|
|
tests/functional/log_client.err | 2 +-
|
|
|
|
7 files changed, 34 insertions(+), 7 deletions(-)
|
|
|
|
|
|
|
|
diff --git a/include/qb/qbconfig.h.in b/include/qb/qbconfig.h.in
|
|
|
|
index c1852e1..789fff3 100644
|
|
|
|
--- a/include/qb/qbconfig.h.in
|
|
|
|
+++ b/include/qb/qbconfig.h.in
|
|
|
|
@@ -30,7 +30,10 @@
|
|
|
|
/* Enabling code using __attribute__((section)) */
|
|
|
|
#undef QB_HAVE_ATTRIBUTE_SECTION
|
|
|
|
|
|
|
|
-/* versioning info: MAJOR, MINOR, MICRO, and REST components */
|
|
|
|
+/* versioning info: MAJOR, MINOR, MICRO, and REST components;
|
|
|
|
+ note that static compile-time info is not that useful as run-time
|
|
|
|
+ querying the lower-cased symbolic constants directly from libqb
|
|
|
|
+ (see qbutil.h), but that was only introduced after v1.0.2 */
|
|
|
|
#undef QB_VER_MAJOR
|
|
|
|
#undef QB_VER_MINOR
|
|
|
|
#undef QB_VER_MICRO
|
|
|
|
diff --git a/include/qb/qblog.h b/include/qb/qblog.h
|
|
|
|
index e49c86c..7ca236d 100644
|
|
|
|
--- a/include/qb/qblog.h
|
|
|
|
+++ b/include/qb/qblog.h
|
|
|
|
@@ -279,10 +279,12 @@ extern struct qb_log_callsite QB_ATTR_SECTION_STOP[];
|
|
|
|
#define QB_NONAPI_LOG_INIT_DATA_EXTRA_
|
|
|
|
#else
|
|
|
|
#define QB_NONAPI_LOG_INIT_DATA_EXTRA_ \
|
|
|
|
- /* libqb sanity (locating libqb by it's relatively unique \
|
|
|
|
- -- and currently only such per-linkage global one -- \
|
|
|
|
- non-functional symbol, due to possible confusion otherwise) */ \
|
|
|
|
- if (dladdr(dlsym(RTLD_DEFAULT, "facilitynames"), &work_dli) \
|
|
|
|
+ /* libqb sanity (locating libqb by it's relatively unique \
|
|
|
|
+ non-functional symbol (the two are mutually exclusive, the \
|
|
|
|
+ ordinarily latter was introduced by accident, the former is \
|
|
|
|
+ intentional), due to possible confusion otherwise) */ \
|
|
|
|
+ if ((dladdr(dlsym(RTLD_DEFAULT, "qb_ver_str"), &work_dli) \
|
|
|
|
+ || dladdr(dlsym(RTLD_DEFAULT, "facilitynames"), &work_dli)) \
|
|
|
|
&& (work_handle = dlopen(work_dli.dli_fname, \
|
|
|
|
RTLD_LOCAL|RTLD_LAZY)) != NULL) { \
|
|
|
|
work_s1 = (struct qb_log_callsite *) \
|
|
|
|
diff --git a/include/qb/qbutil.h b/include/qb/qbutil.h
|
|
|
|
index bfce349..a03bdf8 100644
|
|
|
|
--- a/include/qb/qbutil.h
|
|
|
|
+++ b/include/qb/qbutil.h
|
|
|
|
@@ -289,6 +289,17 @@ uint64_t
|
|
|
|
qb_util_stopwatch_time_split_get(qb_util_stopwatch_t *sw,
|
|
|
|
uint32_t receint, uint32_t older);
|
|
|
|
|
|
|
|
+/** Major component of the library version */
|
|
|
|
+extern const uint8_t qb_ver_major;
|
|
|
|
+/** Minor component of the library version */
|
|
|
|
+extern const uint8_t qb_ver_minor;
|
|
|
|
+/** Micro component of the library version */
|
|
|
|
+extern const uint8_t qb_ver_micro;
|
|
|
|
+/** Rest (pertaining the mid-release-point) component of the library version */
|
|
|
|
+extern const char *const qb_ver_rest;
|
|
|
|
+/** Complete library versioning info as a string */
|
|
|
|
+extern const char *const qb_ver_str;
|
|
|
|
+
|
|
|
|
/* *INDENT-OFF* */
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
diff --git a/lib/log_format.c b/lib/log_format.c
|
|
|
|
index 712f447..e7e1f40 100644
|
|
|
|
--- a/lib/log_format.c
|
|
|
|
+++ b/lib/log_format.c
|
|
|
|
@@ -49,7 +49,7 @@ static struct syslog_names prioritynames[] = {
|
|
|
|
{NULL, -1}
|
|
|
|
};
|
|
|
|
|
|
|
|
-struct syslog_names facilitynames[] = {
|
|
|
|
+static struct syslog_names facilitynames[] = {
|
|
|
|
{"auth", LOG_AUTH},
|
|
|
|
#if defined(LOG_AUTHPRIV)
|
|
|
|
{"authpriv", LOG_AUTHPRIV},
|
|
|
|
diff --git a/lib/util.c b/lib/util.c
|
|
|
|
index 6181a25..4693e58 100644
|
|
|
|
--- a/lib/util.c
|
|
|
|
+++ b/lib/util.c
|
|
|
|
@@ -23,6 +23,7 @@
|
|
|
|
#include "util_int.h"
|
|
|
|
#include <pthread.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
+#include <qb/qbconfig.h>
|
|
|
|
#include <qb/qbdefs.h>
|
|
|
|
#include <qb/qbutil.h>
|
|
|
|
|
|
|
|
@@ -372,3 +373,9 @@ qb_util_stopwatch_time_split_get(qb_util_stopwatch_t *sw,
|
|
|
|
}
|
|
|
|
return (time_start - time_end) / QB_TIME_NS_IN_USEC;
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+const uint8_t qb_ver_major = QB_VER_MAJOR;
|
|
|
|
+const uint8_t qb_ver_minor = QB_VER_MINOR;
|
|
|
|
+const uint8_t qb_ver_micro = QB_VER_MICRO;
|
|
|
|
+const char *const qb_ver_rest = QB_VER_REST;
|
|
|
|
+const char *const qb_ver_str = QB_VER_STR;
|
|
|
|
diff --git a/tests/functional/log_client.c b/tests/functional/log_client.c
|
|
|
|
index aa6ebe1..3612dab 100644
|
|
|
|
--- a/tests/functional/log_client.c
|
|
|
|
+++ b/tests/functional/log_client.c
|
|
|
|
@@ -53,6 +53,10 @@ main(int32_t argc, char *argv[])
|
|
|
|
qb_log_tags_stringify_fn_set(my_tags_stringify);
|
|
|
|
qb_log_format_set(QB_LOG_STDERR, "[%5g|%p] %f:%l:%b");
|
|
|
|
|
|
|
|
+#if 0
|
|
|
|
+ printf("\n==%s==\n\n", qb_ver_str);
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
#if 0
|
|
|
|
printf("--\n");
|
|
|
|
qb_log_callsites_dump();
|
|
|
|
diff --git a/tests/functional/log_client.err b/tests/functional/log_client.err
|
|
|
|
index 0ae7665..c9c955c 100644
|
|
|
|
--- a/tests/functional/log_client.err
|
|
|
|
+++ b/tests/functional/log_client.err
|
|
|
|
@@ -1,2 +1,2 @@
|
|
|
|
-[MAIN |debug] ../log_client.c:63:hello
|
|
|
|
+[MAIN |debug] ../log_client.c:67:hello
|
|
|
|
[libqb|error] log_blackbox.c:196:qb_log_blackbox_print_from_file: No such file or directory (2)
|
|
|
|
--
|
|
|
|
2.14.2
|
|
|
|
|