From dc39232ded510bdafe6456c046aeb8b92342152e Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 9 Oct 2017 11:47:23 +0100 Subject: [PATCH] Do not build journal integration on older Linux platforms We need to add more checks for journal_sendv(), as we depend on the presence of mkostemp() and O_CLOEXEC, which may not be available on older Linux platforms, like RHEL 5. https://bugzilla.gnome.org/show_bug.cgi?id=788705 --- glib/gmessages.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/glib/gmessages.c b/glib/gmessages.c index 4b9e8366e..12542a3b5 100644 --- a/glib/gmessages.c +++ b/glib/gmessages.c @@ -2276,7 +2276,12 @@ g_log_writer_format_fields (GLogLevelFlags log_level, return g_string_free (gstring, FALSE); } -#if defined(__linux__) && !defined(__BIONIC__) +/* Enable support for the journal if we're on a recent enough Linux */ +#if defined(__linux__) && !defined(__BIONIC__) && defined(HAVE_MKOSTEMP) && defined(O_CLOEXEC) +#define ENABLE_JOURNAL_SENDV +#endif + +#ifdef ENABLE_JOURNAL_SENDV static int journal_sendv (struct iovec *iov, gsize iovlen) @@ -2360,7 +2365,7 @@ retry2: return -1; } -#endif +#endif /* ENABLE_JOURNAL_SENDV */ /** * g_log_writer_journald: @@ -2390,7 +2395,7 @@ g_log_writer_journald (GLogLevelFlags log_level, gsize n_fields, gpointer user_data) { -#if defined(__linux__) && !defined(__BIONIC__) +#ifdef ENABLE_JOURNAL_SENDV const char equals = '='; const char newline = '\n'; gsize i, k; @@ -2470,7 +2475,7 @@ g_log_writer_journald (GLogLevelFlags log_level, return retval == 0 ? G_LOG_WRITER_HANDLED : G_LOG_WRITER_UNHANDLED; #else return G_LOG_WRITER_UNHANDLED; -#endif +#endif /* ENABLE_JOURNAL_SENDV */ } /**