Removed old logrotate file Fixed socket leak (#394431) Fixed dumping

useless info to log (#389581)
This commit is contained in:
Zdenek Prikryl 2007-11-23 13:56:05 +00:00
parent ff642ebd49
commit 26b0fd697c
5 changed files with 152 additions and 41 deletions

View File

@ -1,6 +1,14 @@
--- acpid-1.0.6.orig/acpid.c 2007-09-24 18:49:02.000000000 -0400
+++ acpid-1.0.6/acpid.c 2007-09-24 18:52:44.000000000 -0400
@@ -397,7 +397,7 @@ open_log(void)
--- acpid-1.0.6/acpid.c.fd 2007-11-23 14:12:36.000000000 +0100
+++ acpid-1.0.6/acpid.c 2007-11-23 14:13:03.000000000 +0100
@@ -246,6 +246,7 @@ main(int argc, char **argv)
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);
@@ -397,7 +398,7 @@ open_log(void)
int log_opts;
/* open /dev/null */
@ -9,9 +17,8 @@
if (nullfd < 0) {
fprintf(stderr, "%s: can't open %s: %s\n", progname,
"/dev/null", strerror(errno));
diff -urp acpid-1.0.6.orig/event.c acpid-1.0.6/event.c
--- acpid-1.0.6.orig/event.c 2007-09-24 18:49:02.000000000 -0400
+++ acpid-1.0.6/event.c 2007-09-24 18:55:10.000000000 -0400
--- acpid-1.0.6/event.c.fd 2007-05-25 06:26:09.000000000 +0200
+++ acpid-1.0.6/event.c 2007-11-23 14:12:36.000000000 +0100
@@ -318,6 +318,7 @@ parse_file(const char *file)
file);
}
@ -29,4 +36,3 @@ diff -urp acpid-1.0.6.orig/event.c acpid-1.0.6/event.c
if (*p == '%') {
p++;
if (*p == 'e') {

111
acpid-1.0.6-log.patch Normal file
View File

@ -0,0 +1,111 @@
--- acpid-1.0.6/acpid.c.log 2007-10-11 17:56:11.000000000 +0200
+++ acpid-1.0.6/acpid.c 2007-10-12 10:50:36.000000000 +0200
@@ -158,7 +158,7 @@ main(int argc, char **argv)
if (open_log() < 0) {
exit(EXIT_FAILURE);
}
- acpid_log(LOG_INFO, "starting up\n");
+ acpid_log(LOG_NOTICE, "starting up\n");
/* trap key signals */
signal(SIGHUP, reload_conf);
@@ -205,11 +205,15 @@ main(int argc, char **argv)
/* read and handle an event */
event = read_line(event_fd);
if (event) {
- acpid_log(LOG_INFO,
- "received event \"%s\"\n", event);
+ if(acpid_debug) {
+ acpid_log(LOG_INFO,
+ "received event \"%s\"\n", event);
+ }
acpid_handle_event(event);
- acpid_log(LOG_INFO,
- "completed event \"%s\"\n", event);
+ if (acpid_debug) {
+ acpid_log(LOG_INFO,
+ "completed event \"%s\"\n", event);
+ }
} else if (errno == EPIPE) {
acpid_log(LOG_WARNING,
"events file connection closed\n");
--- acpid-1.0.6/event.c.log 2007-10-11 17:56:11.000000000 +0200
+++ acpid-1.0.6/event.c 2007-10-12 10:50:48.000000000 +0200
@@ -154,8 +154,10 @@ acpid_read_conf(const char *confdir)
closedir(dir);
unlock_rules();
- acpid_log(LOG_INFO, "%d rule%s loaded\n",
- nrules, (nrules == 1)?"":"s");
+ if (acpid_debug) {
+ acpid_log(LOG_INFO, "%d rule%s loaded\n",
+ nrules, (nrules == 1)?"":"s");
+ }
return 0;
}
@@ -341,9 +343,11 @@ acpid_add_client(int clifd, const char *
nrules++;
}
- acpid_log(LOG_INFO, "%d client rule%s loaded\n",
- nrules, (nrules == 1)?"":"s");
-
+ if (acpid_debug) {
+ acpid_log(LOG_INFO, "%d client rule%s loaded\n",
+ nrules, (nrules == 1)?"":"s");
+ }
+
return 0;
}
@@ -565,8 +569,9 @@ do_cmd_rule(struct rule *rule, const cha
case 0: /* child */
/* parse the commandline, doing any substitutions needed */
action = parse_cmd(rule->action.cmd, event);
- acpid_log(LOG_INFO, "executing action \"%s\"\n", action);
-
+ if (acpid_debug) {
+ acpid_log(LOG_INFO, "executing action \"%s\"\n", action);
+ }
/* reset signals */
signal(SIGHUP, SIG_DFL);
signal(SIGTERM, SIG_DFL);
@@ -588,14 +593,20 @@ do_cmd_rule(struct rule *rule, const cha
if (acpid_debug)
fprintf(stdout, "END HANDLER MESSAGES\n");
if (WIFEXITED(status)) {
- acpid_log(LOG_INFO, "action exited with status %d\n",
- WEXITSTATUS(status));
+ if (acpid_debug) {
+ acpid_log(LOG_INFO, "action exited with status %d\n",
+ WEXITSTATUS(status));
+ }
} else if (WIFSIGNALED(status)) {
- acpid_log(LOG_INFO, "action exited on signal %d\n",
- WTERMSIG(status));
+ if (acpid_debug) {
+ acpid_log(LOG_INFO, "action exited on signal %d\n",
+ WTERMSIG(status));
+ }
} else {
- acpid_log(LOG_INFO, "action exited with status %d\n",
- status);
+ if (acpid_debug) {
+ acpid_log(LOG_INFO, "action exited with status %d\n",
+ status);
+ }
}
return 0;
@@ -607,7 +618,9 @@ do_client_rule(struct rule *rule, const
int r;
int client = rule->action.fd;
- acpid_log(LOG_INFO, "notifying client %s\n", rule->origin);
+ if (acpid_debug) {
+ acpid_log(LOG_INFO, "notifying client %s\n", rule->origin);
+ }
r = safe_write(client, event, strlen(event));
if (r < 0 && errno == EPIPE) {

View File

@ -21,15 +21,6 @@
# Source function library.
. /etc/rc.d/init.d/functions
# Check that we're a priviledged user
[ `id -u` = 0 ] || exit 1
# Check if acpid is executable
test -x /usr/sbin/acpid || exit 1
# Check for kernel support
[ -f /proc/acpi/event ] || exit 1
RETVAL=0
#
@ -37,10 +28,19 @@ RETVAL=0
#
start() {
# Check that we're a privileged user
[ `id -u` = 0 ] || exit 4
# Check if acpid is executable
test -x /usr/sbin/acpid || exit 5
# Check for kernel support
[ -f /proc/acpi/event ] || exit 1
# Check if it is already running
if [ ! -f /var/lock/subsys/acpid ]; then
echo -n $"Starting acpi daemon: "
daemon /usr/sbin/acpid $@
daemon /usr/sbin/acpid
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/acpid
echo
@ -60,7 +60,7 @@ stop() {
restart() {
stop
start $@
start
}
reload() {
@ -72,7 +72,7 @@ reload() {
case "$1" in
start)
start $2
start
;;
stop)
stop
@ -85,11 +85,11 @@ force-reload)
RETVAL=3
;;
restart)
restart $2
restart
;;
condrestart)
if [ -f /var/lock/subsys/acpid ]; then
restart $2
restart
fi
;;
status)

View File

@ -1,8 +0,0 @@
/var/log/acpid {
missingok
notifempty
size=64k
postrotate
/etc/init.d/acpid condrestart >/dev/null || :
endscript
}

View File

@ -1,17 +1,17 @@
Summary: ACPI Event Daemon
Name: acpid
Version: 1.0.6
Release: 3%{?dist}
Release: 4%{?dist}
License: GPL
Group: System Environment/Daemons
Source: http://prdownloads.sourceforge.net/acpid/acpid-%{version}.tar.gz
Source1: acpid.logrotate
Source2: acpid.init
Source3: acpid.video.conf
Source4: acpid.power.conf
Source1: acpid.init
Source2: acpid.video.conf
Source3: acpid.power.conf
Patch1: acpid-1.0.6-makefile.patch
Patch2: acpid-1.0.6-return.patch
Patch3: acpid-1.0.6-fd.patch
Patch4: acpid-1.0.6-log.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
ExclusiveArch: ia64 x86_64 %{ix86}
URL: http://acpid.sourceforge.net/
@ -29,6 +29,7 @@ acpid is a daemon that dispatches ACPI events to user-space programs.
%patch1 -p1 -b .makefile
%patch2 -p1 -b .return
%patch3 -p1 -b .fd
%patch4 -p1 -b .log
%build
make %{?_smp_mflags}
@ -42,14 +43,11 @@ make install INSTPREFIX=$RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/acpi/events
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/acpi/actions
chmod 755 $RPM_BUILD_ROOT%{_sysconfdir}/acpi/events
install -m 644 %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}/acpi/events/video.conf
install -m 644 %{SOURCE4} $RPM_BUILD_ROOT%{_sysconfdir}/acpi/events/power.conf
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d
install -m 644 %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/acpid
install -m 644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/acpi/events/video.conf
install -m 644 %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}/acpi/events/power.conf
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d
install -m 755 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d/acpid
install -m 755 %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d/acpid
%clean
@ -64,7 +62,6 @@ rm -rf $RPM_BUILD_ROOT
%dir %{_sysconfdir}/acpi/actions
%config(noreplace) %attr(0644,root,root) %{_sysconfdir}/acpi/events/video.conf
%config(noreplace) %attr(0644,root,root) %{_sysconfdir}/acpi/events/power.conf
%config(noreplace) %{_sysconfdir}/logrotate.d/acpid
%{_bindir}/acpi_listen
%{_sbindir}/acpid
%attr(0755,root,root) %{_sysconfdir}/rc.d/init.d/acpid
@ -87,6 +84,11 @@ if [ "$1" -ge "1" ]; then
fi
%changelog
* Fri Nov 23 2007 Zdenek Prikryl <zprikryl@redhat.com> - 1.0.6-4.fc9
- Removed old logrotate file
- Fixed socket leak (#394431)
- Fixed dumping useless info to log (#389581)
* Thu Oct 23 2007 Zdenek Prikryl <zprikryl@redhat.com> - 1.0.6-3.fc9
- Silent initscript
- Resolves: #345611