Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormain() <main@ehvag.eu.org>2014-07-18 14:08:20 +0400
committerMikkel Krautz <mikkel@krautz.dk>2014-07-18 14:09:06 +0400
commit30023c5b361fa17f59e38b1689e76a28a7e49dc7 (patch)
treea153dd850570580540d8de774dc6535efc7975e9
parentdc3b78c9147fe7da57ec7de58cf952d4ae281b4e (diff)
Support logging to syslog in Murmur
Simply set the logfile path to "syslog" and Murmur will log to syslog. This should be stable, it has approximately 4 user-months of testing.
-rw-r--r--src/murmur/UnixMurmur.cpp4
-rw-r--r--src/murmur/UnixMurmur.h2
-rw-r--r--src/murmur/main.cpp38
-rw-r--r--src/murmur/murmur_pch.h1
4 files changed, 44 insertions, 1 deletions
diff --git a/src/murmur/UnixMurmur.cpp b/src/murmur/UnixMurmur.cpp
index 799f0cce8..a42b26813 100644
--- a/src/murmur/UnixMurmur.cpp
+++ b/src/murmur/UnixMurmur.cpp
@@ -182,7 +182,9 @@ void UnixMurmur::handleSigHup() {
ssize_t len = ::read(iHupFd[1], &tmp, sizeof(tmp));
Q_UNUSED(len);
- if (! qfLog) {
+ if (logToSyslog) {
+ qWarning("Caught SIGHUP, but logging to syslog");
+ } else if (! qfLog) {
qWarning("Caught SIGHUP, but logfile not in use");
} else if (! qfLog->isOpen()) {
qWarning("Caught SIGHUP, but logfile not in use -- interpreting as hint to quit");
diff --git a/src/murmur/UnixMurmur.h b/src/murmur/UnixMurmur.h
index 6d685d797..6fde13bac 100644
--- a/src/murmur/UnixMurmur.h
+++ b/src/murmur/UnixMurmur.h
@@ -66,6 +66,8 @@ class UnixMurmur : public QObject {
void handleSigHup();
void handleSigTerm();
public:
+ bool logToSyslog;
+
void setuid();
void initialcap();
void finalcap();
diff --git a/src/murmur/main.cpp b/src/murmur/main.cpp
index e33053d65..37c03a9a0 100644
--- a/src/murmur/main.cpp
+++ b/src/murmur/main.cpp
@@ -54,6 +54,10 @@ static bool detach = true;
static bool detach = false;
#endif
+#ifdef Q_OS_UNIX
+static UnixMurmur *unixMurmur = NULL;
+#endif
+
Meta *meta = NULL;
static LogEmitter le;
@@ -61,6 +65,29 @@ static LogEmitter le;
static QStringList qlErrors;
static void murmurMessageOutputQString(QtMsgType type, const QString &msg) {
+#ifdef Q_OS_UNIX
+ if (unixMurmur->logToSyslog) {
+ int level;
+ switch (type) {
+ case QtDebugMsg:
+ level = LOG_DEBUG;
+ break;
+ case QtWarningMsg:
+ level = LOG_WARNING;
+ break;
+ case QtCriticalMsg:
+ level = LOG_CRIT;
+ break;
+ case QtFatalMsg:
+ default:
+ level = LOG_ALERT;
+ break;
+ }
+ syslog(level, qPrintable(msg));
+ return;
+ }
+#endif
+
char c;
switch (type) {
case QtDebugMsg:
@@ -175,6 +202,7 @@ int main(int argc, char **argv) {
#endif
QCoreApplication a(argc, argv);
UnixMurmur unixhandler;
+ unixMurmur = &unixhandler;
unixhandler.initialcap();
#endif
a.setApplicationName("Murmur");
@@ -310,7 +338,12 @@ int main(int argc, char **argv) {
// need to open log file early so log dir can be root owned:
// http://article.gmane.org/gmane.comp.security.oss.general/4404
+#ifdef Q_OS_UNIX
+ unixhandler.logToSyslog = Meta::mp.qsLogfile == "syslog";
+ if (detach && ! Meta::mp.qsLogfile.isEmpty() && !unixhandler.logToSyslog) {
+#else
if (detach && ! Meta::mp.qsLogfile.isEmpty()) {
+#endif
qfLog = new QFile(Meta::mp.qsLogfile);
if (! qfLog->open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)) {
delete qfLog;
@@ -330,6 +363,11 @@ int main(int argc, char **argv) {
}
#endif
}
+#ifdef Q_OS_UNIX
+ } else if (detach && unixhandler.logToSyslog) {
+ openlog("murmurd", LOG_PID, LOG_DAEMON);
+ syslog(LOG_DEBUG, "murmurd syslog adapter up and running");
+#endif
} else {
detach = false;
}
diff --git a/src/murmur/murmur_pch.h b/src/murmur/murmur_pch.h
index d15fc1b50..c721af45f 100644
--- a/src/murmur/murmur_pch.h
+++ b/src/murmur/murmur_pch.h
@@ -58,6 +58,7 @@ extern "C" {
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/resource.h>
+#include <syslog.h>
#ifdef Q_OS_LINUX
#include <linux/types.h> // needed to work around evil magic stuff in capability.h
#include <sys/capability.h>