From: Otto Moerbeek Date: Mon, 12 Jun 2023 07:40:18 +0000 (+0200) Subject: rec: Escape (by prepending "PDNS") message keys that are special to systemd-journal X-Git-Tag: rec-4.10.0-alpha0~1^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=455eba699569ebbc9cd30ef41b7d04269a8942f1;p=thirdparty%2Fpdns.git rec: Escape (by prepending "PDNS") message keys that are special to systemd-journal --- diff --git a/pdns/misc.hh b/pdns/misc.hh index 8800cd7f53..5757cccc5c 100644 --- a/pdns/misc.hh +++ b/pdns/misc.hh @@ -414,17 +414,21 @@ struct CIStringCompare struct CIStringComparePOSIX { - bool operator() (const std::string& lhs, const std::string& rhs) + bool operator() (const std::string& lhs, const std::string& rhs) const { - std::string::const_iterator a,b; const std::locale &loc = std::locale("POSIX"); - a=lhs.begin();b=rhs.begin(); - while(a!=lhs.end()) { - if (b==rhs.end() || std::tolower(*b,loc) special = { + "message", + "message_id", + "priority", + "code_file", + "code_line", + "code_func", + "errno", + "invocation_id", + "user_invocation_id", + "syslog_facility", + "syslog_identifier", + "syslog_pid", + "syslog_timestamp", + "syslog_raw", + "documentation", + "tid", + "unit", + "user_unit", + "object_pid" + }; + // First map SL priority to syslog's Urgency Logger::Urgency u = entry.d_priority ? Logger::Urgency(entry.d_priority) : Logger::Info; if (u > s_logUrgency) { @@ -931,8 +954,13 @@ static void loggerSDBackend(const Logging::Entry& entry) } std::array timebuf{}; appendKeyAndVal("TIMESTAMP", toTimestampStringMilli(entry.d_timestamp, timebuf)); - for (auto const& v : entry.values) { - appendKeyAndVal(toUpper(v.first), v.second); + for (const auto& value : entry.values) { + if (value.first.at(0) == '_' || special.count(value.first) != 0) { + string key{"PDNS"}; + key.append(value.first); + appendKeyAndVal(toUpper(key), value.second); + } + appendKeyAndVal(toUpper(value.first), value.second); } // Thread id filled in by backend, since the SL code does not know about RecursorThreads // We use the Recursor thread, other threads get id 0. May need to revisit.