Hello community,
here is the log from the commit of package acpid for openSUSE:Factory
checked in at Fri Feb 6 20:47:56 CET 2009.
--------
--- acpid/acpid.changes 2009-01-26 11:53:46.000000000 +0100
+++ acpid/acpid.changes 2009-02-04 21:46:59.000000000 +0100
@@ -1,0 +2,14 @@
+Wed Feb 4 21:10:28 CET 2009 - seife@suse.de
+
+- update to version 1.0.8:
+ - various code cleanups, enable stricter compiler warnings
+ - fix typos in man pages. (acpid.8, acpi_listen.8)
+ - stop processing ACPI events when a lockfile exists (see acpid.8)
+ - add -l (--logevents) option to enable logging of all events.
+ Due to a number of reports of log flooding (bad ACPI BIOS?), the
+ new default is to NOT log events
+ - add pidfile support and a -p (--pidfile) option to change it
+ - close client file descriptors on exec()
+ - fix a fd leak on error
+
+-------------------------------------------------------------------
calling whatdependson for head-i586
Old:
----
acpid-1.0.6.dif
acpid-1.0.6.tar.gz
New:
----
acpid-1.0.8.dif
acpid-1.0.8.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ acpid.spec ++++++
--- /var/tmp/diff_new_pack.T27621/_old 2009-02-06 20:47:22.000000000 +0100
+++ /var/tmp/diff_new_pack.T27621/_new 2009-02-06 20:47:22.000000000 +0100
@@ -1,5 +1,5 @@
#
-# spec file for package acpid (Version 1.0.6)
+# spec file for package acpid (Version 1.0.8)
#
# Copyright (c) 2009 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
@@ -20,8 +20,8 @@
Name: acpid
Url: http://acpid.sourceforge.net/
-Version: 1.0.6
-Release: 90
+Version: 1.0.8
+Release: 1
%define acpi_version 0.09
License: GPL v2 or later
Group: System/Daemons
@@ -60,7 +60,7 @@
%prep
%setup -b 0 -a 1
-%patch
+%patch -p1
%patch1
pushd acpi-%{acpi_version}
popd
@@ -129,6 +129,17 @@
%ghost %config(noreplace,missingok) %_var/log/acpid
%changelog
+* Wed Feb 04 2009 seife@suse.de
+- update to version 1.0.8:
+ - various code cleanups, enable stricter compiler warnings
+ - fix typos in man pages. (acpid.8, acpi_listen.8)
+ - stop processing ACPI events when a lockfile exists (see acpid.8)
+ - add -l (--logevents) option to enable logging of all events.
+ Due to a number of reports of log flooding (bad ACPI BIOS?), the
+ new default is to NOT log events
+ - add pidfile support and a -p (--pidfile) option to change it
+ - close client file descriptors on exec()
+ - fix a fd leak on error
* Mon Jan 26 2009 ro@suse.de
- change fillup call from "-Y" to "-y" the boot script has
been present in this package for long enough (SLES10-GA)
++++++ acpid-1.0.6.dif -> acpid-1.0.8.dif ++++++
--- acpid/acpid-1.0.6.dif 2008-10-16 14:46:39.000000000 +0200
+++ acpid/acpid-1.0.8.dif 2009-02-04 21:46:57.000000000 +0100
@@ -1,23 +1,17 @@
---- acpid.c.orig 2004-10-18 00:33:51.000000000 +0200
-+++ acpid.c 2005-08-02 19:22:04.000000000 +0200
-@@ -386,7 +386,8 @@
- umask(0);
+Index: b/Makefile
+===================================================================
+--- a/Makefile
++++ b/Makefile
+@@ -21,11 +21,11 @@ acpi_listen_OBJS = $(acpi_listen_SRCS:.c
+ all_SRCS = $(acpid_SRCS) $(acpi_listen_SRCS)
- /* get outta the way */
-- chdir("/");
-+ if(chdir("/") < 0)
-+ fprintf(stderr, "%s: chdir: %s\n", progname, strerror(errno));
-
- return 0;
- }
---- Makefile.orig 2004-10-18 00:54:28.000000000 +0200
-+++ Makefile 2005-08-02 19:22:04.000000000 +0200
-@@ -21,7 +21,7 @@
MAN8 = acpid.8 acpi_listen.8
MAN8GZ = $(MAN8:.8=.8.gz)
--CFLAGS = -Wall -Werror -g $(DEFS)
-+CFLAGS = -Wall -Werror -g $(DEFS) $(EXTRA_CFLAGS)
+-CFLAGS = -W -Wall -Werror -Wundef -Wshadow -D_GNU_SOURCE -O2 -g $(DEFS)
++CFLAGS = -W -Wall -Werror -Wundef -Wshadow -D_GNU_SOURCE -O2 -g $(DEFS) $(EXTRA_CFLAGS)
DEFS = -DVERSION="\"$(VERSION)\""
all: $(PROGS)
+
+ acpid: $(acpid_OBJS)
++++++ acpid-1.0.6.tar.gz -> acpid-1.0.8.tar.gz ++++++
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/acpid-1.0.6/acpid.8 new/acpid-1.0.8/acpid.8
--- old/acpid-1.0.6/acpid.8 2007-05-25 06:35:31.000000000 +0200
+++ new/acpid-1.0.8/acpid.8 2008-10-27 06:41:34.000000000 +0100
@@ -1,6 +1,6 @@
.TH acpid 8 ""
.\" Portions Copyright (c) 2001 Sun Microsystems
-.\" Portions Copyright (c) Tim Hockin (thockin@hockin.org.com)
+.\" Portions Copyright (c) Tim Hockin (thockin@hockin.org)
.SH NAME
acpid \- Advanced Configuration and Power Interface event daemon
.SH SYNOPSIS
@@ -8,21 +8,24 @@
.SH DESCRIPTION
\fBacpid\fP is designed to notify user-space programs of ACPI events.
-\fBacpid\fP should be started during the system boot, and will run as a
-background process, by default. It will open an events file
-(\fI/proc/acpi/event\fP by default) and attempt to read whole lines. When
-a line is received (an \fIevent\fP), \fBacpid\fP will examine a list of rules,
-and execute the rules that match the event.
+\fBacpid\fP should be started during the system boot, and will run as a
+background process, by default. It will open an events file
+(\fI/proc/acpi/event\fP by default) and attempt to read whole lines. When
+a line is received (an \fIevent\fP), \fBacpid\fP will examine a list of rules,
+and execute the rules that match the event.
+\fBacpid\fP will ignore all incoming ACPI events if a lock file exists
+(\fI/var/lock/acpid\fP by default).
.PP
\fIRules\fP are defined by simple configuration files. \fBacpid\fP
-will look in a configuration directory (\fI/etc/acpi/events\fP by default),
-and parse all files that do not begin with a period ('.'). Each file must
-define two things: an \fIevent\fP and an \fIaction\fP. Any blank lines, or
-lines where the first character is a pound sign ('#') are ignored. Extraneous
-lines are flagged as warnings, but are not fatal. Each line has three tokens:
-the key, a literal equal sign, and the value. The key can be up to 63
-characters, and is case-insensitive (but whitespace matters). The value can be
-up to 511 characters, and is case and whitespace sensitive.
+will look in a configuration directory (\fI/etc/acpi/events\fP by default),
+and parse all regular files that do not begin with a period ('.') or end
+with a tilde (~). Each file must define two things: an \fIevent\fP and an
+\fIaction\fP. Any blank lines, or lines where the first character is a
+pound sign ('#') are ignored. Extraneous lines are flagged as warnings, but
+are not fatal. Each line has three tokens: the key, a literal equal sign,
+and the value. The key can be up to 63 characters, and is case-insensitive
+(but whitespace matters). The value can be up to 511 characters, and is
+case and whitespace sensitive.
.PP
The event value is a regular expression (see regcomp(3)), against which events are matched.
.PP
@@ -31,30 +34,30 @@
include shell-special characters, and they will be preserved. The only special
characters in an action value are "%" escaped. The string "%e" will be
replaced by the literal text of the event for which the action was invoked.
-This string may contain spaces, so the commandline must take care to quote the "%e" if it wants a single token. The string "%%" will be replaced by a
-literal "%". All other "%" escapes are reserved, and will cause a rule to
+This string may contain spaces, so the commandline must take care to quote the "%e" if it wants a single token. The string "%%" will be replaced by a
+literal "%". All other "%" escapes are reserved, and will cause a rule to
not load.
.PP
This feature allows multiple rules to be defined for the same event (though no
ordering is guaranteed), as well as one rule to be defined for multiple events.
To force \fBacpid\fP to reload the rule configuration, send it a SIGHUP.
.PP
-In addition to rule files, \fBacpid\fP also accepts connections on a UNIX
-domain socket (\fI/var/run/acpid.socket\fP by default). Any application may
-connect to this socket. Once connected, \fBacpid\fP will send the text of
+In addition to rule files, \fBacpid\fP also accepts connections on a UNIX
+domain socket (\fI/var/run/acpid.socket\fP by default). Any application may
+connect to this socket. Once connected, \fBacpid\fP will send the text of
all ACPI events to the client. The client has the responsibility of filtering
-for messages about which it cares. \fBacpid\fP will not close the client
+for messages about which it cares. \fBacpid\fP will not close the client
socket except in the case of a SIGHUP or \fBacpid\fP exiting.
.PP
.B acpid
-will log all of it's activities, as well as the stdout and stderr of any
-actions to syslog.
+will log all of its activities, as well as the stdout and stderr of any
+actions, to syslog.
.PP
-All the default file and directories can be changed with commandline options.
+All the default files and directories can be changed with commandline options.
.SH OPTIONS
.TP 12
.BI \-c "\fR, \fP" \--confdir " directory"
-This option changes the directory in which \fBacpid\fP looks for rule
+This option changes the directory in which \fBacpid\fP looks for rule
configuration files. Default is \fI/etc/acpi/events\fP.
.TP 12
.BI \-d "\fR, \fP" \--debug
@@ -69,9 +72,15 @@
.BI \-f "\fR, \fP" \--foreground
This option keeps \fBacpid\fP in the foreground by not forking at startup.
.TP
+.BI \-l "\fR, \fP" \--logevents
+This option tells \fBacpid\fP to log information about all events and actions.
+.TP
+.BI \-L "\fR, \fP" \--lockfile " filename"
+This option changes the lock file used to stop event processing.
+Default is \fI/var/lock/acpid\fP.
.TP
.BI \-g "\fR, \fP" \--socketgroup " groupname"
-This option changes the group ownership of the UNIX domain socket to which
+This option changes the group ownership of the UNIX domain socket to which
\fBacpid\fP publishes events.
.TP
.BI \-m "\fR, \fP" \--socketmode " mode"
@@ -83,9 +92,14 @@
Default is \fI/var/run/acpid.socket\fP.
.TP
.BI \-S "\fR, \fP" \--nosocket " filename"
-This option tells \fBacpid\fP not to open a UNIX domain socket. This
+This option tells \fBacpid\fP not to open a UNIX domain socket. This
overrides the \fI-s\fP option, and negates all other socket options.
.TP
+.BI \-p "\fR, \fP" \--pidfile " filename"
+This option tells \fBacpid\fP to use the specified file as its pidfile. If
+the file exists, it will be removed and over-written.
+Default is \fI/var/run/acpid.pid\fP.
+.TP
.BI \-v "\fR, \fP" \--version
Print version information and exit.
.TP
@@ -101,7 +115,7 @@
action=/usr/local/sbin/power.sh "%e"
.PP
The script power.sh gets called and will see the complete event string
-as parameter $1.
+as parameter $1.
.SH DEPENDENCIES
\fBacpid\fP should work on any linux kernel released since 2003.
.SH FILES
@@ -112,6 +126,10 @@
.br
.B /var/run/acpid.socket
.br
+.B /var/run/acpid.pid
+.br
+.B /var/lock/acpid
+.br
.PD
.SH BUGS
There are no known bugs. To file bug reports, see \fBAUTHORS\fP below.
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/acpid-1.0.6/acpid.c new/acpid-1.0.8/acpid.c
--- old/acpid-1.0.6/acpid.c 2007-05-25 06:19:23.000000000 +0200
+++ new/acpid-1.0.8/acpid.c 2008-10-27 07:07:25.000000000 +0100
@@ -42,6 +42,7 @@
static void close_fds(void);
static int daemonize(void);
static int open_log(void);
+static int create_pidfile(void);
static void clean_exit(int sig);
static void reload_conf(int sig);
static char *read_line(int fd);
@@ -49,14 +50,19 @@
/* global debug level */
int acpid_debug;
+/* do we log event info? */
+int logevents;
+
static const char *progname;
-static const char *confdir = ACPI_CONFDIR;
-static const char *eventfile = ACPI_EVENTFILE;
-static const char *socketfile = ACPI_SOCKETFILE;
+static const char *confdir = ACPID_CONFDIR;
+static const char *eventfile = ACPID_EVENTFILE;
+static const char *socketfile = ACPID_SOCKETFILE;
+static const char *lockfile = ACPID_LOCKFILE;
static int nosocket;
static const char *socketgroup;
-static mode_t socketmode = ACPI_SOCKETMODE;
+static mode_t socketmode = ACPID_SOCKETMODE;
static int foreground;
+static const char *pidfile = ACPID_PIDFILE;
int
main(int argc, char **argv)
@@ -168,9 +174,18 @@
signal(SIGPIPE, SIG_IGN);
/* read in our configuration */
- acpid_read_conf(confdir);
+ if (acpid_read_conf(confdir)) {
+ exit(EXIT_FAILURE);
+ }
+
+ /* create our pidfile */
+ if (create_pidfile() < 0) {
+ exit(EXIT_FAILURE);
+ }
/* main loop */
+ acpid_log(LOG_INFO, "waiting for events: event logging is %s\n",
+ logevents ? "on" : "off");
while (1) {
struct pollfd ar[2];
int r;
@@ -193,7 +208,12 @@
/* was it an event? */
if (ar[0].revents) {
char *event;
-
+ struct stat trash;
+ int fexists;
+
+ /* check for existence of a lockfile */
+ fexists = (stat(lockfile, &trash) == 0);
+
/* this shouldn't happen */
if (!ar[0].revents & POLLIN) {
acpid_log(LOG_DEBUG,
@@ -202,21 +222,37 @@
continue;
}
- /* read and handle an event */
+ /* read an event */
event = read_line(event_fd);
+
+ /* if we're locked, don't process the event */
+ if (fexists) {
+ if (logevents) {
+ acpid_log(LOG_INFO,
+ "lockfile present, not processing "
+ "event \"%s\"\n", event);
+ }
+ continue;
+ }
+
+ /* handle the event */
if (event) {
- acpid_log(LOG_INFO,
- "received event \"%s\"\n", event);
+ if (logevents) {
+ acpid_log(LOG_INFO,
+ "received event \"%s\"\n", event);
+ }
acpid_handle_event(event);
- acpid_log(LOG_INFO,
- "completed event \"%s\"\n", event);
+ if (logevents) {
+ acpid_log(LOG_INFO,
+ "completed event \"%s\"\n", event);
+ }
} else if (errno == EPIPE) {
acpid_log(LOG_WARNING,
"events file connection closed\n");
break;
} else {
static int nerrs;
- if (++nerrs >= ACPI_MAX_ERRS) {
+ if (++nerrs >= ACPID_MAX_ERRS) {
acpid_log(LOG_ERR,
"too many errors reading "
"events file - aborting\n");
@@ -246,6 +282,7 @@
strerror(errno));
continue;
}
+ fcntl(cli_fd, F_SETFD, FD_CLOEXEC);
snprintf(buf, sizeof(buf)-1, "%d[%d:%d]",
creds.pid, creds.uid, creds.gid);
acpid_add_client(cli_fd, buf);
@@ -268,10 +305,13 @@
{"debug", 0, 0, 'd'},
{"eventfile", 1, 0, 'e'},
{"foreground", 0, 0, 'f'},
+ {"logevents", 0, 0, 'l'},
{"socketgroup", 1, 0, 'g'},
{"socketmode", 1, 0, 'm'},
{"socketfile", 1, 0, 's'},
{"nosocket", 1, 0, 'S'},
+ {"pidfile", 1, 0, 'p'},
+ {"lockfile", 1, 0, 'L'},
{"version", 0, 0, 'v'},
{"help", 0, 0, 'h'},
{NULL, 0, 0, 0},
@@ -281,10 +321,13 @@
"Increase debugging level (implies -f).",/* debug */
"Use the specified file for events.", /* eventfile */
"Run in the foreground.", /* foreground */
+ "Log all event activity.", /* logevents */
"Set the group on the socket file.", /* socketgroup */
"Set the permissions on the socket file.",/* socketmode */
"Use the specified socket file.", /* socketfile */
"Do not listen on a UNIX socket (overrides -s).",/* nosocket */
+ "Use the specified PID file.", /* pidfile */
+ "Use the specified lockfile to stop processing.", /* pidfile */
"Print version information.", /* version */
"Print this message.", /* help */
};
@@ -294,7 +337,8 @@
for (;;) {
int i;
- i = getopt_long(*argc, *argv, "c:de:fg:m:s:Svh", opts, NULL);
+ i = getopt_long(*argc, *argv,
+ "c:de:flg:m:s:Sp:L:vh", opts, NULL);
if (i == -1) {
break;
}
@@ -312,6 +356,9 @@
case 'f':
foreground = 1;
break;
+ case 'l':
+ logevents = 1;
+ break;
case 'g':
socketgroup = optarg;
break;
@@ -324,6 +371,12 @@
case 'S':
nosocket = 1;
break;
+ case 'p':
+ pidfile = optarg;
+ break;
+ case 'L':
+ lockfile = optarg;
+ break;
case 'v':
printf(PACKAGE "-" VERSION "\n");
exit(EXIT_SUCCESS);
@@ -387,7 +440,11 @@
umask(0);
/* get outta the way */
- chdir("/");
+ if (chdir("/") < 0) {
+ fprintf(stderr, "%s: chdir(\"/\"): %s\n", progname,
+ strerror(errno));
+ return -1;
+ }
return 0;
}
@@ -399,7 +456,7 @@
int log_opts;
/* open /dev/null */
- nullfd = open("/dev/null", O_RDONLY, 0640);
+ nullfd = open("/dev/null", O_RDONLY);
if (nullfd < 0) {
fprintf(stderr, "%s: can't open %s: %s\n", progname,
"/dev/null", strerror(errno));
@@ -431,23 +488,57 @@
return 0;
}
+static int
+create_pidfile(void)
+{
+ int fd;
+
+ /* JIC */
+ unlink(pidfile);
+
+ /* open the pidfile */
+ fd = open(pidfile, O_WRONLY|O_CREAT|O_EXCL, 0644);
+ if (fd >= 0) {
+ FILE *f;
+
+ /* write our pid to it */
+ f = fdopen(fd, "w");
+ if (f != NULL) {
+ fprintf(f, "%d\n", getpid());
+ fclose(f);
+ /* leave the fd open */
+ return 0;
+ }
+ close(fd);
+ }
+
+ /* something went wrong */
+ acpid_log(LOG_ERR, "can't create pidfile %s: %s\n",
+ pidfile, strerror(errno));
+ return -1;
+}
+
static void
-clean_exit(int sig)
+clean_exit(int sig __attribute__((unused)))
{
acpid_cleanup_rules(1);
acpid_log(LOG_NOTICE, "exiting\n");
+ unlink(pidfile);
exit(EXIT_SUCCESS);
}
static void
-reload_conf(int sig)
+reload_conf(int sig __attribute__((unused)))
{
acpid_log(LOG_NOTICE, "reloading configuration\n");
acpid_cleanup_rules(0);
acpid_read_conf(confdir);
}
-int
+int
+#ifdef __GNUC__
+__attribute__((format(printf, 2, 3)))
+#endif
acpid_log(int level, const char *fmt, ...)
{
va_list args;
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/acpid-1.0.6/acpid.h new/acpid-1.0.8/acpid.h
--- old/acpid-1.0.6/acpid.h 2007-05-24 08:33:33.000000000 +0200
+++ new/acpid-1.0.8/acpid.h 2008-10-27 06:52:07.000000000 +0100
@@ -30,11 +30,13 @@
#include