Updated to version 1.0.8 power.sh works with ConsoleKit >= 0.3.0 (#470752)

Fixed conditions in power.sh, which look for power-managers (#470752)
    Added check to init script
This commit is contained in:
Zdenek Prikryl 2008-11-11 14:36:30 +00:00
parent d149db560e
commit d650c89476
10 changed files with 65 additions and 190 deletions

View File

@ -1,2 +1 @@
acpid-1.0.6.tar.gz
acpid.power.sh
acpid-1.0.8.tar.gz

View File

@ -1,38 +0,0 @@
--- 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 */
- 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));
--- 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);
}
free_rule(r);
+ fclose(fp);
return NULL;
}
fclose(fp);
@@ -667,7 +668,7 @@ parse_cmd(const char *cmd, const char *e
i = 0;
memset(buf, 0, sizeof(buf));
- while (i < (sizeof(buf)-1)) {
+ while ((size_t)i < (sizeof(buf)-1)) {
if (*p == '%') {
p++;
if (*p == 'e') {

View File

@ -1,111 +0,0 @@
--- 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

@ -1,14 +0,0 @@
--- acpid-1.0.6/Makefile.makefile 2007-06-30 21:15:45.000000000 +0200
+++ acpid-1.0.6/Makefile 2008-02-13 18:05:37.000000000 +0100
@@ -21,8 +21,9 @@ acpi_listen_OBJS = $(acpi_listen_SRCS:.c
MAN8 = acpid.8 acpi_listen.8
MAN8GZ = $(MAN8:.8=.8.gz)
-CFLAGS = -Wall -Werror -g $(DEFS)
-DEFS = -DVERSION="\"$(VERSION)\""
+CFLAGS = -Wall -Werror -g $(DEFS) $(RPM_OPT_FLAGS) -fPIE
+LDFLAGS = -pie -Wl,-z,relro
+DEFS = -DVERSION="\"$(VERSION)\"" -D_GNU_SOURCE
all: $(PROGS)

View File

@ -1,13 +0,0 @@
--- acpid-1.0.6/acpid.c.return 2007-05-25 06:19:23.000000000 +0200
+++ acpid-1.0.6/acpid.c 2007-08-07 10:30:35.000000000 +0200
@@ -387,9 +387,7 @@ daemonize(void)
umask(0);
/* get outta the way */
- chdir("/");
-
- return 0;
+ return chdir("/");
}
static int

View File

@ -0,0 +1,13 @@
diff -up acpid-1.0.8/Makefile.makefile acpid-1.0.8/Makefile
--- acpid-1.0.8/Makefile.makefile 2008-10-29 04:48:52.000000000 +0100
+++ acpid-1.0.8/Makefile 2008-11-11 15:19:21.000000000 +0100
@@ -23,7 +23,8 @@ all_SRCS = $(acpid_SRCS) $(acpi_listen_S
MAN8 = acpid.8 acpi_listen.8
MAN8GZ = $(MAN8:.8=.8.gz)
-CFLAGS = -W -Wall -Werror -Wundef -Wshadow -D_GNU_SOURCE -O2 -g $(DEFS)
+CFLAGS = -W -Wall -Werror -Wundef -Wshadow -D_GNU_SOURCE -O2 -g $(DEFS) $(RPM_OPT_FLAGS) -fPIE
+LDFLAGS = -pie -Wl,-z,relro
DEFS = -DVERSION="\"$(VERSION)\""
all: $(PROGS)

View File

@ -27,12 +27,17 @@ RETVAL=0
# See how we were called.
#
start() {
check() {
# Check that we're a privileged user
[ `id -u` = 0 ] || exit 4
# Check if acpid is executable
test -x /usr/sbin/acpid || exit 5
}
start() {
check
# Check for kernel support
[ -f /proc/acpi/event ] || exit 1
@ -49,6 +54,9 @@ start() {
}
stop() {
check
echo -n $"Stopping acpi daemon: "
killproc /usr/sbin/acpid
RETVAL=$?
@ -64,6 +72,9 @@ restart() {
}
reload() {
check
trap "" SIGHUP
action $"Reloading acpi daemon:" killall -HUP acpid
RETVAL=$?

29
acpid.power.sh Normal file
View File

@ -0,0 +1,29 @@
#!/bin/sh
PATH=/sbin:/bin:/usr/bin
# Get the ID of the first active X11 session:
uid_session=$(
ck-list-sessions | \
awk '
/^Session[0-9]+:$/ { uid = active = x11 = "" ; next }
{ gsub(/'\''/, "", $3) }
$1 == "unix-user" { uid = $3 }
$1 == "active" { active = $3 }
$1 == "x11-display" { x11 = $3 }
active == "TRUE" && x11 != "" {
print uid
exit
}')
# Check that there is a power manager, otherwise shut down.
[ "$uid_session" ] &&
ps axo uid,cmd | \
awk '
$1 == '$uid_session' &&
($2 ~ /gnome-power-manager/ || $2 ~ /kpowersave/) \
{ found = 1; exit }
END { exit !found }
' ||
shutdown -h now

View File

@ -1,7 +1,7 @@
Summary: ACPI Event Daemon
Name: acpid
Version: 1.0.6
Release: 8%{?dist}
Version: 1.0.8
Release: 1%{?dist}
License: GPLv2+
Group: System Environment/Daemons
Source: http://prdownloads.sourceforge.net/acpid/acpid-%{version}.tar.gz
@ -9,10 +9,7 @@ Source1: acpid.init
Source2: acpid.video.conf
Source3: acpid.power.conf
Source4: acpid.power.sh
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
Patch1: acpid-1.0.8-makefile.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
ExclusiveArch: ia64 x86_64 %{ix86}
URL: http://acpid.sourceforge.net/
@ -28,9 +25,6 @@ acpid is a daemon that dispatches ACPI events to user-space programs.
%prep
%setup -q
%patch1 -p1 -b .makefile
%patch2 -p1 -b .return
%patch3 -p1 -b .fd
%patch4 -p1 -b .log
%build
make %{?_smp_mflags}
@ -87,6 +81,12 @@ if [ "$1" -ge "1" ]; then
fi
%changelog
* Tue Nov 11 2008 Zdenek Prikryl <zprikryl@redhat.com> - 1.0.8-1
- Updated to version 1.0.8
- power.sh works with ConsoleKit >= 0.3.0 (#470752)
- Fixed conditions in power.sh, which look for power-managers (#470752)
- Added check to init script
* Mon Jul 14 2008 Tom "spot" Callaway <tcallawa@redhat.com> - 1.0.6-8
- fix license tag

View File

@ -1,2 +1 @@
5c9b705700df51d232be223b6ab6414d acpid-1.0.6.tar.gz
581b7998a78b140ca58c428338c734ed acpid.power.sh
1d9c52fe2c0b51f8463f357c2a3d3ddb acpid-1.0.8.tar.gz