acpid/acpid-1.0.4-use-syslog.diff

64 lines
1.3 KiB
Diff

Make acpid use syslog instead of its own logfile-writing mechanism.
From: Stefan Seyfried <seife@suse.de>
diff -ruN acpid-1.0.4~/acpid.c acpid-1.0.4/acpid.c
--- acpid-1.0.4~/acpid.c 2005-10-12 21:14:07.000000000 +0200
+++ acpid-1.0.4/acpid.c 2005-10-12 22:09:58.000000000 +0200
@@ -32,6 +32,7 @@
#include <time.h>
#include <sys/poll.h>
#include <grp.h>
+#include <sys/syslog.h>
#include "acpid.h"
#include "ud_socket.h"
@@ -405,13 +406,17 @@
"/dev/null", strerror(errno));
return -1;
}
+#ifdef USE_SYSLOG
+ openlog("[acpid]", LOG_CONS, LOG_DAEMON);
+ logfd = nullfd;
+#else
logfd = open(logfile, O_WRONLY|O_CREAT|O_APPEND);
if (logfd < 0) {
fprintf(stderr, "%s: can't open %s: %s\n", progname,
logfile, strerror(errno));
return -1;
}
-
+#endif
if (dup2(nullfd, STDIN_FILENO) != STDIN_FILENO) {
fprintf(stderr, "%s: dup2: %s\n", progname, strerror(errno));
return -1;
@@ -447,6 +452,20 @@
acpid_read_conf(confdir);
}
+#ifdef USE_SYSLOG
+int
+acpid_log(const char *fmt, ...)
+{
+ va_list args;
+
+ va_start(args, fmt);
+ vsyslog(LOG_INFO, fmt, args);
+ va_end(args);
+
+ return 0;
+}
+
+#else
int
acpid_log(const char *fmt, ...)
{
@@ -465,6 +484,7 @@
return 0;
}
+#endif
/*
* This depends on fixes in linux ACPI after 2.4.8