summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGergely Nagy <algernon@balabit.hu>2012-03-22 18:37:45 +0100
committerGergely Nagy <algernon@balabit.hu>2012-03-22 18:37:45 +0100
commitb83d05ccfc8e015d440687b071c81a47d6d2ce19 (patch)
treec2e2617a7925dc050b9cfd5b6ca7563d49e2a302
parentfc2623e8c27ea5c79772bf907d597b46f0b317a7 (diff)
downloadlibumberlog-b83d05ccfc8e015d440687b071c81a47d6d2ce19.tar.gz
libumberlog-b83d05ccfc8e015d440687b071c81a47d6d2ce19.tar.xz
libumberlog-b83d05ccfc8e015d440687b071c81a47d6d2ce19.zip
Implement wrappers for __syslog_chk, when appropriate.
When compiled with __USE_FORTIFY_LEVEL, software using <syslog.h> will use the __syslog_chk function instead of syslog(), so we need to wrap that too. To do this properly, the library will wrap __syslog_chk when built with fortification, and use that from both the syslog() and the __syslog_chk() overrides. If built without, it will use the standard syslog() function. Signed-off-by: Gergely Nagy <algernon@balabit.hu>
-rw-r--r--lib/cee-syslog.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/cee-syslog.c b/lib/cee-syslog.c
index 2cb5447..b9d648d 100644
--- a/lib/cee-syslog.c
+++ b/lib/cee-syslog.c
@@ -42,7 +42,13 @@
#include "cee-syslog.h"
+
+#if __USE_FORTIFY_LEVEL > 0
+static void (*old_syslog_chk) ();
+#else
static void (*old_syslog) ();
+#endif
+
static void (*old_openlog) ();
static int (*old_setlogmask) ();
@@ -64,7 +70,11 @@ static __thread struct
static void
cee_init (void)
{
+#if __USE_FORTIFY_LEVEL > 0
+ old_syslog_chk = dlsym (RTLD_NEXT, "__syslog_chk");
+#else
old_syslog = dlsym (RTLD_NEXT, "syslog");
+#endif
old_openlog = dlsym (RTLD_NEXT, "openlog");
old_setlogmask = dlsym (RTLD_NEXT, "setlogmask");
}
@@ -297,7 +307,12 @@ _cee_vsyslog (int format_version, int priority,
jo = _cee_vformat (json_object_new_object (), format_version,
priority, msg_format, ap);
+#if __USE_FORTIFY_LEVEL > 0
+ old_syslog_chk (priority, __USE_FORTIFY_LEVEL - 1, "@cee:%s",
+ json_object_to_json_string (jo));
+#else
old_syslog (priority, "@cee:%s", json_object_to_json_string (jo));
+#endif
json_object_put (jo);
}
@@ -331,6 +346,24 @@ cee_setlogmask (int mask)
return old_setlogmask (mask);
}
+#if __USE_FORTIFY_LEVEL > 0
+void
+__syslog_chk (int __pri, int __flag, __const char *__fmt, ...)
+{
+ va_list ap;
+
+ va_start (ap, __fmt);
+ cee_legacy_vsyslog (__pri, __fmt, ap);
+ va_end (ap);
+}
+
+void
+__vsyslog_chk (int __pri, int __flag, __const char *__fmt, va_list ap)
+{
+ cee_legacy_vsyslog (__pri, __fmt, ap);
+}
+#endif
+
void openlog (const char *ident, int option, int facility)
__attribute__((alias ("cee_openlog")));