--- acpid-1.0.8.orig/debian/acpid.postinst +++ acpid-1.0.8/debian/acpid.postinst @@ -0,0 +1,36 @@ +#!/bin/sh + +set -e + +# Remove old init.d links +if dpkg --compare-versions "$2" lt-nl "1.0.6-16"; then + rm -f /etc/rc[06].d/K??acpid +fi + +if dpkg --compare-versions "$2" lt "1.0.6-6"; then + rm -f /etc/rc1.d/K20acpid /etc/rc[2-5].d/S20acpid +fi + +HAL_NEEDS_RESTARTING=no +case "$1" in + configure|reconfigure) + # check whether the hal init script is present and hal seems running; we + # need to stop hal to grab /proc/acpi/event; when hal starts again, it will + # simply ignore this interface as long as acpid is installed; see + # Launchpad #63450 + if [ -x /etc/init.d/hal ] && [ -f /var/run/hal/hald.pid ]; then + HAL_NEEDS_RESTARTING=yes + invoke-rc.d hal stop + fi + ;; +esac + +#DEBHELPER# + +case "$1" in + configure|reconfigure) + if [ -x /etc/init.d/hal ] && [ "$HAL_NEEDS_RESTARTING" = "yes" ]; then + invoke-rc.d hal start + fi + ;; +esac --- acpid-1.0.8.orig/debian/changelog +++ acpid-1.0.8/debian/changelog @@ -0,0 +1,972 @@ +acpid (1.0.8-6) unstable; urgency=low + + * Start acpid even if /proc/acpi/event doesn't exist, closes: #516079 + * Recommend acpi-support-base so a script handling power button pressing is + installed. + * If the power button script had been changed, not only rename it but also + keep a changed events file to not lose functionality, closes: #516083 + + -- Michael Meskes Thu, 19 Feb 2009 10:03:40 +0100 + +acpid (1.0.8-5) unstable; urgency=low + + * Reverted redirection patch, it broke debug mode. + + -- Michael Meskes Thu, 19 Feb 2009 09:44:59 +0100 + +acpid (1.0.8-4) unstable; urgency=low + + * Added patch to correctly redirect stdin/stdout/stderr to /dev/null. + * Added patch by Ted Felix adding netlink support to + acpid, closes: #462467, #515773 + + -- Michael Meskes Wed, 18 Feb 2009 12:05:51 +0100 + +acpid (1.0.8-3) unstable; urgency=low + + * Only conditionally restart hal on purge, closes: #515650 + * Remove the remaining scriptlets in /etc/acpi. All files are still available + and installed as examples under /usr/share/doc/acpid/examples but not under + /etc/acpi anymore. + * Fixed GPL version information in copyright file. + + -- Michael Meskes Tue, 17 Feb 2009 11:10:42 +0100 + +acpid (1.0.8-2) unstable; urgency=low + + [ Loic Minier ] + * Add git-buildpackage config debian/gbp.conf. + + [ Michael Meskes ] + * Added patch by Harald Braumann to correctly open + /dev/null, closes: #483805 + * Removed old syslog patch as upstream has the same/similar functionality + nowadays, closes: #496574 + * Made powerbtn.sh script fall back to shutdown if dbus fails, closes: #492756 + * Restart hal in case of acpid removal, closes: #505663 + + -- Michael Meskes Wed, 11 Feb 2009 16:53:06 +0100 + +acpid (1.0.8-1) unstable; urgency=low + + [ Loic Minier ] + * Comment out OPTIONS in the acpid defaults file as -c /etc/acpi/events is + the default anyway; this paves the way to a future removal of this file. + * Test for /proc/acpi/event instead of /proc/acpi in init script; + see Debian #440870. + * Document rationale for hal restart in postinst. + + [ Michael Meskes ] + * New upstream version. + * Moved our patches to debian/patches and added support for quilt. + + -- Michael Meskes Wed, 12 Nov 2008 14:29:15 +0100 + +acpid (1.0.6-16) unstable; urgency=low + + [ Loic Minier ] + * Reword hints in /etc/default/acpid; suggested by Julien Blache. + * Drop bogus space in modules.dep causing modules without dependencies to + not be loaded for MODULES="all". + * Check for read permissions on the defaults file before attempting to + source it. + * Don't load any module (MODULES default to empty string) when the default + file doesn't exist or doesn't specify MODULES. + * Ignore the result of load_modules. + * Unset MODPROBE_OPTIONS to work around a bug in initramfs which leaks this + env var Launchpad #291619 and a bug in modprobe --all --quiet which + doesn't load all modules and exits with non-zero exit status + Debian.org #504088; thanks Derrick Karpo and Julien Blache; + closes: #502704. + + [ Michael Meskes ] + * Make sure there is no link created in runlevel 0 and 6 to stop acpid. + * Remove old links in runlevel 0 and 6, closes: #502613. + * Comment out MODULES setting in default file, so no module is loaded per + default. + + -- Loic Minier Sun, 02 Nov 2008 10:28:14 +0100 + +acpid (1.0.6-15) unstable; urgency=low + + [ Michael Meskes ] + * Fixed check for /proc/modules to not throw an error + closes: #502881, #502704 + + [ Loic Minier ] + * Fix above fix. :-P + + -- Michael Meskes Tue, 21 Oct 2008 12:55:00 +0200 + +acpid (1.0.6-14) unstable; urgency=low + + [ Loic Minier ] + * Merge support for the "status" action in the acpid init script from the + Ubuntu package; depend on lsb-base >= 3.2-14. + * Don't stop acpid in runlevels 0 and 6; from Ubuntu, closes:#495544 + * Fix support for Ubuntu kernels, stop guessing distro but always try to use + the ubuntu/acpi module dir if present; this allows using Ubuntu kernels on + Ubuntu, removes references to Ubuntu from a number of places, and makes + the script simpler to maintain and more efficient; also matches the + current Ubuntu script. + * Cleanup rules; drop DH_VERBOSE. + * Wrap build-deps and deps in control to get cleaner diffs. + * Add myself to uploaders. + * Drop obsolete information from README.Debian. + * Cleanup the awful init script. + - Drop support for *.o kernel module files; .ko is used since 2.5 kernels. + - Greatly simplify computing the list of available acpi modules by parsing + modules.dep(5) instead of running find and sh multiple times. + - Rename debian/acpid.init.d to debian/acpid.init to match debhelper's + documented name (debhelper does pick up .init.d as well, but this is + undocumented); this also avoid confusing vim which believe it's a D + file. + - Don't disable printk when loading ACPI modules; this is not only + fragile, broken, and intrusive, it's also out of the realm of acpid to + do. This snippet: + [ "$VERBOSE" = "no" ] && echo "0 0 0 0" > /proc/sys/kernel/printk + can be moved to a more sensible place if it makes sense during boot, but + I doubt anybody wants that. + - Fix support for kernels without dynamic module loading; closes: #500659. + * Use Vcs-* instead of XS-Vcs-* and fix URLs to point at the new git repos; + closes: #501305. + * Remove obsolete conffile /etc/logrotate.d/acpid in preinst; thanks to + James Westby and Ubuntu; LP: #263888. It's interesting to note that this + caused the new acpid to die once per week when logrotation kicked in. + Closes: #487815, #491058, #495686 + * Pass -s to dh_* commands in binary-arch. + * Resume shipping /etc/acpi/powerbtn.sh and /etc/acpi/events/powerbtn in + acpid. They are also installed in the examples for people who symlink to + the examples. Please note that powerbtn.sh disables itself when it + detects a running power management daemon such as gnome-power-manager or + kpowersave. + * Add -D_GNU_SOURCE in Makefile's CFLAGS to fix build with newer libc6 (such + as 2.8+20080809-1 in experimental or 2.8~20080505-0ubuntu7in Ubuntu + intrepid) in making "struct ucred" available; see + http://sourceware.org/bugzilla/show_bug.cgi?id=6545. + + [ Michael Meskes ] + * Fixed path to hal pidfile, closes: #440870 + + -- Loic Minier Mon, 13 Oct 2008 19:12:28 +0200 + +acpid (1.0.6-13) unstable; urgency=low + + * Check for distribution during build time, closes: #499825, #500003 + + -- Michael Meskes Wed, 24 Sep 2008 12:26:45 +0200 + +acpid (1.0.6-12) unstable; urgency=low + + * Check for Ubuntu/Debian in apt sources list instead of /etc/issue, + closes: #499825, #499854 + + -- Michael Meskes Tue, 23 Sep 2008 10:38:38 +0200 + +acpid (1.0.6-11) unstable; urgency=low + + * Changed maintainer to Debian Acpi Team. + * Do not call lsb-release on startup, closes: #491388 + + -- Michael Meskes Wed, 27 Aug 2008 13:49:56 +0200 + +acpid (1.0.6-10) unstable; urgency=low + + * Removed Ubuntu version information. + * Back to only including some modules on default. Using all modules creates + strange error messages and even backtraces on some machines. ALL option + remains listed but commented out, closes: #484354 + * Add video to list of modules, closes: #459237 + * Made package lintian clean. + * In Debian do not load Ubuntu modules from Ubuntu directory. I do not see + any package providing this directory. + * Do only install powerbutton scripts as example, + closes: #481903, #484306, #253423 + * Fixed watch file. + * Clarified specification of acpid options, closes: #486788 + * Bumped Standards-Version to 3.8.0 + + -- Michael Meskes Fri, 20 Jun 2008 14:21:14 +0200 + +acpid (1.0.6-9) unstable; urgency=low + + * Don't depend on sysv-rc; closes: #481912 + + -- Anibal Monsalve Salazar Fri, 23 May 2008 13:50:49 +1000 + +acpid (1.0.6-8) unstable; urgency=low + + * Update watch file + + -- Anibal Monsalve Salazar Mon, 19 May 2008 19:31:31 +1000 + +acpid (1.0.6-7) unstable; urgency=low + + * Fix dash syntax error in acpid.init.d; closes: #481824 + + -- Anibal Monsalve Salazar Mon, 19 May 2008 11:54:32 +1000 + +acpid (1.0.6-6) unstable; urgency=low + + * New maintainer; closes: #481580 + * Merge Ubuntu changes + - Use MODULES="all"; closes: #449076 + - Disable printk; closes: #449078 + - Loading modules from the ubuntu directory; closes: #449080 + * Limit syslog messages to >= NOTICE to avoid spamming unless in debug mode; + patch by Loic Minier; closes: #447200 + * Include "--oknodo" in init script start action; + patch by Daniel Hahler; closes: #475785 + * Don't fail during installation; closes: #447339 + * Don't delete conffiles in /etc; closes: #444666 + * Provide power button support; closes: #444676 + * Fix typo in acpid.8; closes: #444065 + * Fix "restart/start fails"; closes: #481327, #479517 + * Fix "tar error messages on upgrade"; closes: #447099, #451220 + * Fix "init script start/stop priorities not updated on upgrades"; + closes: #462185 + * Fix the following lintian issues: + W: acpid source: debian-rules-ignores-make-clean-error line 18 + + -- Anibal Monsalve Salazar Sat, 17 May 2008 09:54:17 +1000 + +acpid (1.0.6-5.1) unstable; urgency=low + + * Non-maintainer upload. + * Correct dependency information provided in init.d script (Closes: #459493). + + -- Petter Reinholdtsen Tue, 4 Mar 2008 13:53:46 +0100 + +acpid (1.0.6-5) unstable; urgency=low + + * New mantainer. (Closes: #455197) + * debian/control: + - Bump Standards-Version: 3.7.3. + - Build-depends debhelper >=5. + - Added Homepage header. + * debian/watch, added. + + -- Jose Carlos Medeiros Tue, 15 Jan 2008 18:02:33 -0200 + +acpid (1.0.6-4) unstable; urgency=medium + + * Add lost directory /etc/acpi/events to package again. (Closes: #444667) + * Improve the last NEWS.Debian entry to be more explicit. + + -- Torsten Werner Tue, 09 Oct 2007 07:44:46 +0200 + +acpid (1.0.6-3) unstable; urgency=low + + * Stop and start hal in postinst. (Closes: #352512, #380520, #440870) + * Start acpid earlier when booting. (Closes: #320094) + * Fix call to 'dpkg --compare-versions' in postinst. + + -- Torsten Werner Mon, 24 Sep 2007 07:41:16 +0200 + +acpid (1.0.6-2) unstable; urgency=low + + * Remove old logs and logrotate conffile. + (Closes: #178894, #360170, #443385) + * Add debian/NEWS with an explanation of the change. + * Revert any changes to acpid.c corresponding to the old log mechanism. + (Closes: #388048) + * Remove the old powerbtn scripts and provide them as examples. + (Closes: #285779, #354445, #386026, #400409, #401414, #417306, #422463, #425291, #427938) + * Add option -P to shutdown in powerbtn.sh. (Closes: #365972) + + -- Torsten Werner Sun, 23 Sep 2007 16:15:42 +0200 + +acpid (1.0.6-1) unstable; urgency=low + + * New upstream release (Closes: #442383) + * Change Maintainer field to myself as requested by the former maintainer. + * Add XS-Vcs-* headers. + * Install upstream's Changelog file. + + -- Torsten Werner Tue, 18 Sep 2007 16:48:54 +0200 + +acpid (1.0.4-7.1) unstable; urgency=low + + * Non-maintainer upload. + * Fixed typo in init script (Closes: #413729). + + -- Nico Golde Thu, 29 Mar 2007 23:22:37 +0200 + +acpid (1.0.4-7) unstable; urgency=low + + * Fixed typo in manual page (Closes: #404680) + * Updated README (Closes: #360167) + * Include lsb compliant logging (Closes: #384687) + * Fixed logrotate/cron error if acpid is not running (Closes: #388038) + * Removed powerbutton scripts - these are contained in other packages + (Closes: #354445, #285779) + * Added lsb compliant init script styles (Closes: #383591) + + -- Cajus Pollmeier Mon, 5 Mar 2007 09:33:07 +0100 + +acpid (1.0.4-6) unstable; urgency=low + + * Fixed powerptn.sh to respect shutdown changes (Closes: #365972) + + -- Cajus Pollmeier Thu, 4 May 2006 08:47:06 +0200 + +acpid (1.0.4-5ubuntu9) hardy; urgency=low + + [ Daniel Hahler ] + * debian/acpid.postinst: Stop and start hal, if present. + This allows acpid to take /proc/acpi/event and hal will ignore this kernel + interface, when acpid is installed. (LP: #63450) + * debian/acpid.init.d: Add "--oknodo" to the start-stop-daemon call in + "start". The action must not fail, if acpid is already running. + + [ Michael Vogt ] + * debian/acpid.postinst: do not restart hal on dapper upgrades + (hal may hang forever because of a incompatible dbus) + * only restart if hal is actually running + + -- Michael Vogt Wed, 16 Apr 2008 16:12:12 +0200 + +acpid (1.0.4-5ubuntu8) gutsy; urgency=low + + * Fix the broken Maintainer lines in debian/control. + + -- Adam Conrad Wed, 15 Aug 2007 23:47:42 +1000 + +acpid (1.0.4-5ubuntu7) gutsy; urgency=low + + * Build package for lpia. + * Set Ubuntu maintainer address. + + -- Matthias Klose Fri, 10 Aug 2007 21:43:04 +0000 + +acpid (1.0.4-5ubuntu6) feisty; urgency=low + + * Load drivers from ubuntu directory as well as kernel acpi directory + + -- Matthew Garrett Sat, 10 Mar 2007 15:04:34 +0000 + +acpid (1.0.4-5ubuntu5) feisty; urgency=low + + * KubuntuFeistyLaptop spec: change debian/powerbtn.sh for KDE sessions: + * single KDE session: issue KDE logout dialog for user to decide + * multiple KDE sessions: send shutdown request to all KDE sessions + (this is the same behaviour as before) + + -- Luka Renko Thu, 8 Feb 2007 10:28:09 +0100 + +acpid (1.0.4-5ubuntu4) edgy; urgency=low + + * Call modprobe with -b to allow user blacklisting. Ubuntu: #49017 + + -- Scott James Remnant Thu, 14 Sep 2006 15:13:52 +0100 + +acpid (1.0.4-5ubuntu3) edgy; urgency=low + + * Add forgotten versioned-dependency on sysv-rc to get new update-rc.d + behaviour. Go me. + + -- Scott James Remnant Fri, 21 Jul 2006 01:22:57 +0100 + +acpid (1.0.4-5ubuntu2) edgy; urgency=low + + * Remove stop links from rc0 and rc6 + + -- Scott James Remnant Thu, 20 Jul 2006 23:14:18 +0100 + +acpid (1.0.4-5ubuntu1) edgy; urgency=low + + * Merge from debian unstable, remaining changes: + - Lock file and groups, + - LSB init script, + - init script level change, + - load all modules by default, + - Power button handling changes. + + -- Scott James Remnant Tue, 11 Jul 2006 17:50:13 +0100 + +acpid (1.0.4-5) unstable; urgency=low + + * Fixed problem with logrotate and Xorg where the /proc/acpi/events gets + locked by Xorg. + + -- Cajus Pollmeier Sun, 15 Jan 2006 22:23:05 +0100 + +acpid (1.0.4-4) unstable; urgency=low + + Changes by Michael Biebl: + * Adapted scripts in /etc/acpi/ to let powersaved process the acpi event if + it is running. + * Updated standards version to 3.6.2. + * Cleaned up debian/rules, make use of dh_* tools. Created the necessary + acpid.* files. + * Cleaned up debian/*, removed unused and unnecessary files. + * Fixed package to make lintian/linda happy. + + Changes by Cajus Pollmeier: + * Removed debconf integration (Closes: #336725, #336726, #333759, #331512) + * Fixed typo in acpi_listen manpage (Closes: #342743) + + -- Cajus Pollmeier Sat, 14 Jan 2006 11:52:33 +0100 + +acpid (1.0.4-3) unstable; urgency=low + + * Added russian debconf translations (Closes: #324084) + * Added portuguese debconf translations (Closes: #329872) + * Included alternative dependency to debconf-2.0 + + -- Cajus Pollmeier Thu, 29 Sep 2005 11:08:25 +0200 + +acpid (1.0.4-2) unstable; urgency=low + + * Added logrotate control file (Closes: #306235) + * Added vietnamese debconf translations (Closes: #307598) + * Added basque debconf translations (Closes: #296865) + * Added italian debconf translations (Closes: #288224) + * Fixed amd64 specific type problem (Closes: #315070) + * Re-fixed amd64 specific type problem (Closes: #285063) + * Fixed copyright file by adding one missing original + author (Closes: #290053) + + -- Cajus Pollmeier Sat, 9 Jul 2005 12:39:49 +0200 + +acpid (1.0.4-1ubuntu11) dapper; urgency=low + + * Fix /etc/acpi/powerbtn.sh so that it doesn't bork if 'pidof' returns + multiple results. This stops the machine displaying the logout + dialogue and then immediately shutting down anyway. + (Closes: Ubuntu #46319) + + -- Paul Sladen Sat, 27 May 2006 15:54:53 +0100 + +acpid (1.0.4-1ubuntu10) dapper; urgency=low + + * Add support to set the group of the log file when acpid starts. + By default this will set it to the adm group. + + -- Daniel Silverstone Wed, 15 Feb 2006 14:04:49 +0000 + +acpid (1.0.4-1ubuntu9) dapper; urgency=low + + * Check for gnome-power-manager rather than PowerManager. The name changed + between dapper and breezy and without this, we would unconditionally shut + the system down on a powerbutton event. + * Also check for kded/klaptopdaemon and kpowersave for KDE options on the + same policy management. + * Closes: malone #31407 + + -- Daniel Silverstone Wed, 15 Feb 2006 11:41:20 +0000 + +acpid (1.0.4-1ubuntu8) breezy; urgency=low + + * Shorten and simplify init script messages + + -- Matt Zimmerman Thu, 15 Sep 2005 11:30:54 -0700 + +acpid (1.0.4-1ubuntu7) breezy; urgency=low + + * If power-manager is running, don't trigger the power button event + ourselves + + -- Matthew Garrett Tue, 30 Aug 2005 18:33:22 +0100 + +acpid (1.0.4-1ubuntu6) breezy; urgency=low + + * Start acpid before dbus is started - hal needs acpid to be running + already + + -- Matthew Garrett Tue, 30 Aug 2005 17:10:48 +0100 + +acpid (1.0.4-1ubuntu5) breezy; urgency=low + + * Interact with the new locking model in acpi-support + * Fix gcc-4.0 compile error + + -- Matthew Garrett Mon, 22 Aug 2005 22:12:52 +0100 + +acpid (1.0.4-1ubuntu4) hoary; urgency=low + + * Turn off kernel printks if we're not verbose during module loading + + -- Thom May Wed, 2 Mar 2005 17:45:36 +0000 + +acpid (1.0.4-1ubuntu3) hoary; urgency=low + + * Check for the presence of a lockfile, and don't process events if it's + there (Ubuntu: #6026) + + -- Thom May Tue, 1 Feb 2005 12:27:44 +0000 + +acpid (1.0.4-1ubuntu2) hoary; urgency=low + + * Use the new -Q argument to modprobe, add depend on the correct + module-init-tools + * Default back to trying to autoload everything (Ubuntu #4077) + + -- Thom May Fri, 14 Jan 2005 13:48:24 +0000 + +acpid (1.0.4-1ubuntu1) hoary; urgency=low + + * Resynchronise with Debian, resolved minor merging conflict. + + -- Martin Pitt Thu, 11 Nov 2004 10:38:26 +0100 + +acpid (1.0.4-1) unstable; urgency=low + + * New upstream release + * I'm dropping support for older, acpi broken kernels now. Time to + clean up. + + -- Cajus Pollmeier Mon, 1 Nov 2004 11:49:33 +0100 + +acpid (1.0.3-21ubuntu1) hoary; urgency=low + + * Resynchronise with Debian. + + -- Scott James Remnant Wed, 27 Oct 2004 12:05:00 +0100 + +acpid (1.0.3-21) unstable; urgency=low + + * Fixed dcop problem for shutdown (Closes:#274339) + + -- Cajus Pollmeier Fri, 1 Oct 2004 11:10:24 +0200 + +acpid (1.0.3-20) unstable; urgency=high + + * Added detection for non files in run-parts code (Closes:#268203) + + -- Cajus Pollmeier Mon, 30 Aug 2004 19:51:41 +0200 + +acpid (1.0.3-19ubuntu12) warty; urgency=low + + * Disable loading the platform specific acpi modules. (Warty #1451) + + -- Thom May Wed, 6 Oct 2004 14:18:58 +0100 + +acpid (1.0.3-19ubuntu11) warty; urgency=low + + * use xargs -r so we don't fail in the case of no acpi modules (Warty #1466) + + -- Thom May Mon, 20 Sep 2004 12:36:52 +0100 + +acpid (1.0.3-19ubuntu10) warty; urgency=low + + * Added versioned depend on lsb-base + + -- Nathaniel McCallum Fri, 3 Sep 2004 14:45:49 -0400 + +acpid (1.0.3-19ubuntu9) warty; urgency=low + + * log_warning_msg for failed modules, don't bomb out tho. (Warty 983, 991) + + -- Thom May Fri, 3 Sep 2004 17:08:34 +0100 + +acpid (1.0.3-19ubuntu8) warty; urgency=low + + * If a module is already loaded, log_success_msg rather than log_warning_msg + + -- Matt Zimmerman Thu, 2 Sep 2004 16:06:16 -0700 + +acpid (1.0.3-19ubuntu7) warty; urgency=low + + * debian/init: pretty initscript + + -- Nathaniel McCallum Thu, 2 Sep 2004 15:06:13 -0400 + +acpid (1.0.3-19ubuntu6) warty; urgency=low + + * install initrd script + + -- Thom May Fri, 27 Aug 2004 17:14:00 +0100 + +acpid (1.0.3-19ubuntu5) warty; urgency=low + + * Revert -4, since that causes the acpid socket to be reaped + + -- Thom May Tue, 24 Aug 2004 10:34:05 +0100 + +acpid (1.0.3-19ubuntu4) warty; urgency=low + + * Ensure acpid starts as early as possible, so we don't melt Scott's laptop + + -- Thom May Thu, 19 Aug 2004 14:04:55 +0100 + +acpid (1.0.3-19ubuntu3) warty; urgency=low + + * Load all modules + + -- Thom May Wed, 18 Aug 2004 14:11:45 +0100 + +acpid (1.0.3-19ubuntu2) warty; urgency=low + + * Get rid of FTBFS errors. + + -- LaMont Jones Sat, 31 Jul 2004 04:49:10 +0000 + +acpid (1.0.3-19ubuntu1) warty; urgency=low + + * Disable superfluous debconf note when acpi support is not present + (Warty Bug#289) + + -- Matt Zimmerman Tue, 27 Jul 2004 13:26:05 -0700 + +acpid (1.0.3-19) unstable; urgency=low + + * Update dutch translations (Closes:#250719) + * Added turkish translations (Closes:#252933) + + -- Cajus Pollmeier Fri, 28 May 2004 19:41:16 +0200 + +acpid (1.0.3-18) unstable; urgency=low + + * Fixed manpage to contain hint to runparts stylish naming convention + in /etc/acpid/events (Closes:#250066) + + -- Cajus Pollmeier Sat, 22 May 2004 10:33:13 +0200 + +acpid (1.0.3-17) unstable; urgency=low + + * Added amd64 to list of supported architectures (Closes:#249055) + + -- Cajus Pollmeier Fri, 14 May 2004 21:22:53 +0200 + +acpid (1.0.3-16) unstable; urgency=low + + * Added czech po-debconf translation (Closes:#247377) + * Modified init scripts start-stop daemon call to retry stopping + acpid after two seconds (Closes:#247130) + * Modified init script to check for ACPI presence in kernel + _before_ doing any actions (Closes:#247490) + + -- Cajus Pollmeier Fri, 7 May 2004 22:27:40 +0200 + +acpid (1.0.3-15) unstable; urgency=low + + * Fixed powerbutton script which did a shutdown when a + KDE user was logged in. Now it skips the shutdown, + because kdm will do it for us. + + -- Cajus Pollmeier Fri, 23 Apr 2004 18:06:16 +0200 + +acpid (1.0.3-14) unstable; urgency=low + + * Fixed postrm script to clean some lost config files. (Closes: #242273) + + -- Cajus Pollmeier Thu, 8 Apr 2004 11:04:05 +0200 + +acpid (1.0.3-13) unstable; urgency=low + + * Removed support for configuring list of modules with debconf. I can't + spend hours in fullfilling all wishes currently. Don't think anyone really + needs this feature - and if: This is more an issue for a tool that detects + hardware than one for the daemon itself. Implicitly closes: #241367. + * Updated init script to skip loading of modules that are not present in + system, but are configured in defaults file. + + -- Cajus Pollmeier Thu, 1 Apr 2004 06:56:27 +0200 + +acpid (1.0.3-12) unstable; urgency=low + + * Fixed possible problem in config script when installing for the + first time (Closes:#241012) + + -- Cajus Pollmeier Tue, 30 Mar 2004 13:06:01 +0200 + +acpid (1.0.3-11) unstable; urgency=low + + * Included danish translations (Closes:#240044) + + -- Cajus Pollmeier Thu, 25 Mar 2004 19:52:46 +0100 + +acpid (1.0.3-10) unstable; urgency=low + + * Avoided overwriting of manual changes in defaults file (Closes:#239635) + * Replaced init call by normal shutdown with more informative + message (Closes:#239583) + * Included upstream changelog (Closes:#235530) + + -- Cajus Pollmeier Tue, 23 Mar 2004 21:33:31 +0100 + +acpid (1.0.3-9) unstable; urgency=low + + * Made acpid close all used filehandles (Closes:#239350) + + -- Cajus Pollmeier Mon, 22 Mar 2004 14:56:57 +0100 + +acpid (1.0.3-8) unstable; urgency=low + + * Fixed clean target of debian/rules to call dh_clean (Closes:#239239) + + -- Cajus Pollmeier Mon, 22 Mar 2004 11:14:36 +0100 + +acpid (1.0.3-7) unstable; urgency=low + + * Added dutch po-debconf translation (Closes:#237816) + * Added greek po-debconf translation (Closes:#237847) + + -- Cajus Pollmeier Sun, 21 Mar 2004 11:40:48 +0100 + +acpid (1.0.3-6) unstable; urgency=low + + * Modified start script to have the 2.6 module loading + style (Closes:#236703) + + -- Cajus Pollmeier Fri, 12 Mar 2004 16:34:42 +0100 + +acpid (1.0.3-5) unstable; urgency=low + + * Changed description to a coffee cooking variant (Closes:#237199) + + -- Cajus Pollmeier Wed, 10 Mar 2004 20:51:52 +0100 + +acpid (1.0.3-4) unstable; urgency=low + + * Fixed typo in template, that made it in again. (Closes:#236005) + * Included French translations, thanks to Clement Stenac. (Closes:#236375) + + -- Cajus Pollmeier Thu, 4 Mar 2004 07:55:24 +0100 + +acpid (1.0.3-3) unstable; urgency=low + + * Included Japanese translations, thanks to Hideki Yamane. (Closes:#235320) + * Included Brazilian Portuguese translations, thanks to + Andre Luis Lopes (Closes:#235462) + * Workaround for non working postinst configure installed. (Closes:#234270) + + -- Cajus Pollmeier Sun, 29 Feb 2004 11:26:06 +0100 + +acpid (1.0.3-2) unstable; urgency=low + + * Added a sleep between stop and start in the init-scripts restart + condition. This should fix the logrotate problem. (Closes:#234283) + + -- Cajus Pollmeier Wed, 25 Feb 2004 13:15:53 +0100 + +acpid (1.0.3-1) unstable; urgency=high + + * New upstream release + + -- Cajus Pollmeier Wed, 25 Feb 2004 10:08:34 +0100 + +acpid (1.0.2-12) unstable; urgency=low + + * Added missing true condition in postinstall script (Closes: #234274) + + -- Cajus Pollmeier Mon, 23 Feb 2004 10:08:19 +0100 + +acpid (1.0.2-11) unstable; urgency=high + + * Switched to invoke-rc.d in prerm script. (Closes: #234161) + * Removed a - for some users - confusing message from debconf + templates. (Closes: #234179) + + -- Cajus Pollmeier Sun, 22 Feb 2004 10:29:11 +0100 + +acpid (1.0.2-10) unstable; urgency=low + + * Fix typo in events file - powerbtn/powerbtn.sh (Closes:#233248) + * Doing workaround in rules to remove setgid bits. Can't upload new + orig.tar.gz. (Closes: #233628) + * Changed the standard 'all' into a list of most common modules + + -- Cajus Pollmeier Tue, 17 Feb 2004 20:28:42 +0100 + +acpid (1.0.2-9) unstable; urgency=high + + * Yes, yes. I commented out this line, because I've acpi in + built into my kernel. Enabled it again. (Closes: #232400) + * Fixed some lintian related issues. + + -- Cajus Pollmeier Sun, 15 Feb 2004 09:23:31 +0100 + +acpid (1.0.2-8) unstable; urgency=low + + * Finetuning in init script for automatic module loading (Closes: #232400) + * Added debconf script to help user, made 'load all modules' the + default. + * Unmasked signals so that processes started from acpid can receive + TERM signals. (Closes: #206525) + * Added changes from CVS. New upstream release is comming soon. + + -- Cajus Pollmeier Thu, 12 Feb 2004 18:58:29 +0100 + +acpid (1.0.2-7) unstable; urgency=low + + * Renamed acpid socket. gnome-applet seems to have a compiled + in default for /var/run/acpid.socket. (Closes: #217932) + + -- Cajus Pollmeier Fri, 31 Oct 2003 21:15:17 +0100 + +acpid (1.0.2-6) unstable; urgency=low + + * Fixed module loader in init script. Credits go to Tim Wright. + + -- Cajus Pollmeier Wed, 22 Oct 2003 20:48:17 +0200 + +acpid (1.0.2-5) unstable; urgency=low + + * Ok. Removing socket support was no good idea. Obviously there + are some programms that depend on it. Notice, that the socket + is on a non standard location currently. (Closes: #207926) + + -- Cajus Pollmeier Thu, 9 Oct 2003 07:10:51 +0200 + +acpid (1.0.2-4) unstable; urgency=low + + * Removed socket support for Debian. I currently don't see any use + in it. + * Changed postrm to clean only config files (Closes: #202858) + * Added acpid to logrotate.d (Closes: #200705) + + -- Cajus Pollmeier Fri, 5 Sep 2003 16:51:43 +0200 + +acpid (1.0.2-3) unstable; urgency=low + + * Make --purge remove /etc/acpi directory (Closes: #197981) + + -- Cajus Pollmeier Thu, 19 Jun 2003 08:43:48 +0200 + +acpid (1.0.2-2) unstable; urgency=low + + * Fixed module loading for kernel 2.5. Modules now have .ko as extension + so that the former .o method wouldn't work (Closes: #193709) + + -- Cajus Pollmeier Sun, 18 May 2003 12:06:04 +0200 + +acpid (1.0.2-1) unstable; urgency=low + + * New upstream release + + -- Cajus Pollmeier Wed, 14 May 2003 07:39:25 +0200 + +acpid (1.0.1-8) unstable; urgency=low + + * Fixed automatic module loading script regex (Closes: #192711) + + -- Cajus Pollmeier Sat, 10 May 2003 10:27:14 +0200 + +acpid (1.0.1-7) unstable; urgency=low + + * Changed poweroff script to be dcop aware (Closes: #187493) + * Made title line in control file to make it more meaningly (Closes: #181774) + + -- Cajus Pollmeier Fri, 4 Apr 2003 19:56:34 +0200 + +acpid (1.0.1-6) unstable; urgency=low + + * load modules even when acpi.o is not compiled in kernel (Closes: #173173) + * updated standards-version + + -- Cajus Pollmeier Mon, 30 Dec 2002 13:58:26 +0100 + +acpid (1.0.1-5) unstable; urgency=low + + * added modules autoloading in startup script, see /etc/default/acpid (Closes: #173173) + + -- Cajus Pollmeier Sun, 29 Dec 2002 19:51:32 +0100 + +acpid (1.0.1-4) unstable; urgency=high + + * removed double freed pointer in event.c (Closes: #153288) + + -- Cajus Pollmeier Tue, 20 Aug 2002 08:05:31 +0100 + +acpid (1.0.1-3) unstable; urgency=high + + * forgot do close ia64 bug (Closes: #141101) + * made run-parts stylish /etc/acpi/events (Closes: #141350) + * renamed samples to examples and added joeys examples (Closes: #141351) + + -- Cajus Pollmeier Sat, 6 Apr 2002 10:21:15 +0100 + +acpid (1.0.1-2) unstable; urgency=high + + * Added ia64 for build + + -- Cajus Pollmeier Fri, 5 Apr 2002 08:34:01 +0100 + +acpid (1.0.1-1) unstable; urgency=high + + * new upstream release + * Fixed event handling to fit the new specs - again + + -- Cajus Pollmeier Sat, 9 Mar 2002 12:10:51 +0100 + +acpid (1.0.0-4) unstable; urgency=high + + * Changed priority to optional (Closes: #135578) + * Fixed event handling to fit the new specs + + -- Cajus Pollmeier Sat, 9 Mar 2002 12:10:51 +0100 + +acpid (1.0.0-3) unstable; urgency=high + + * Removed incompatibility message + * Closed bugs that should have been fixed with 1.0.0-2 (Closes: #130934, #127451) + * Fixed event handling with kernels patched with acpi-devel code + * Added reload option to the initscript (Closes: #129425) + + -- Cajus Pollmeier Fri, 1 Mar 2002 15:13:06 +0100 + +acpid (1.0.0-2) unstable; urgency=low + + * Fixed logfile not beeing truncated + * Changed line width of short description to less than 60 characters + * Close bugs not related to this upstream release (Closes: #67465, #108796, #63956, #109559, #110698, #107047) + + -- Cajus Pollmeier Thu, 1 Nov 2001 13:30:16 +0100 + +acpid (1.0.0-1) unstable; urgency=low + + * New upstream release + * Fixed read_line to work with unpatched 2.4.x kernels. + + -- Cajus Pollmeier Mon, 10 Aug 2001 12:12:41 +0200 + +acpid (0.2001051000-1) unstable; urgency=low + + * New upstream release (Closes: #97277, #104266) + * New maintainer + * 'acpictl' is no longer in the acpid package. (Closes: #79498) + * 'acpid' doesn't need build-depends anymore (Closes: #105751) + + -- Robert van der Meulen Mon, 25 Jun 2001 16:01:12 +0200 + +acpid (0.2000071100-1) unstable; urgency=low + + * New upstream release + + -- Wichert Akkerman Wed, 12 Jul 2000 20:57:07 -0400 + +acpid (0.2000052200-1) unstable; urgency=low + + * New upstream release + + -- Wichert Akkerman Tue, 23 May 2000 13:41:51 +0200 + +acpid (0.2000042500-1) unstable; urgency=low + + * New upstream release + * Fix a typo in the init-script + * upstream changed the buildsystem again, updated debian/rules accordingly + * Stop via executable, not pid-file (which doesn't exist) + + -- Wichert Akkerman Mon, 1 May 2000 23:00:46 +0200 + +acpid (0.20000317-2) unstable; urgency=low + + * Create /usr/doc compatibility symlinks + + -- Wichert Akkerman Fri, 7 Apr 2000 14:26:31 +0200 + +acpid (0.20000317-1) experimental; urgency=low + + * New snapshot + + -- Wichert Akkerman Mon, 3 Apr 2000 00:50:17 +0200 + +acpid (0.20000316-1) experimental; urgency=low + + * Initial release + + -- Wichert Akkerman Thu, 16 Mar 2000 12:24:51 +0100 + --- acpid-1.0.8.orig/debian/powerbtn.sh +++ acpid-1.0.8/debian/powerbtn.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# /etc/acpi/powerbtn.sh +# Initiates a shutdown when the power putton has been +# pressed. + +# Skip if we just in the middle of resuming. +test -f /var/lock/acpisleep && exit 0 + +# If gnome-power-manager, kpowersave or klaptopdaemon are running, let +# them handle policy This is effectively the same as 'acpi-support's +# '/usr/share/acpi-support/policy-funcs' file. + +if pidof gnome-power-manager kpowersave > /dev/null || + (pidof dcopserver > /dev/null && test -x /usr/bin/dcop && /usr/bin/dcop kded kded loadedModules | grep -q klaptopdaemon) ; then + exit +fi + +# Otherwise, if KDE is found, try to ask it to logout. +# If KDE is not found, just shutdown now. +if ps -Af | grep -q '[k]desktop' && pidof dcopserver > /dev/null && test -x /usr/bin/dcop ; then + KDESES=`pidof dcopserver | wc -w` + if [ $KDESES -eq 1 ] ; then + # single KDE session -> ask user + /usr/bin/dcop --all-sessions --all-users ksmserver ksmserver logout 1 2 0 && exit 0 + else + # more than one KDE session - just send shutdown signal to all of them + /usr/bin/dcop --all-sessions --all-users ksmserver ksmserver logout 0 2 0 && exit 0 + fi +fi + +# If all else failed, just initiate a plain shutdown. +/sbin/shutdown -h now "Power button pressed" --- acpid-1.0.8.orig/debian/acpid.postrm +++ acpid-1.0.8/debian/acpid.postrm @@ -0,0 +1,16 @@ +#!/bin/sh + +set -e + +if [ "$1" = purge ]; then + rm -f /var/backups/acpid-cruft.tar.gz + + # We restart hal on install and upgrades because acpid needs + # /proc/acpi/event and hal might hold it (see postinst). On removal we + # should restart hal to allow it to grab the file again. + if [ -x /etc/init.d/hal ]; then + invoke-rc.d hal restart + fi +fi + +#DEBHELPER# --- acpid-1.0.8.orig/debian/acpid.dirs +++ acpid-1.0.8/debian/acpid.dirs @@ -0,0 +1 @@ +/etc/acpi/events --- acpid-1.0.8.orig/debian/rules +++ acpid-1.0.8/debian/rules @@ -0,0 +1,48 @@ +#!/usr/bin/make -f + +include /usr/share/quilt/quilt.make + +build: patch build-stamp +build-stamp: + dh_testdir + chmod g-s -R * + $(MAKE) + $(MAKE) man + touch $@ + +clean: unpatch + dh_testdir + dh_testroot + rm -f build-stamp + [ ! -f Makefile ] || $(MAKE) clean + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean + dh_installdirs + +binary: binary-arch binary-indep + +binary-indep: + +binary-arch: build install + dh_testdir + dh_testroot + dh_installchangelogs -s Changelog + dh_installdocs -s + dh_installinit -s -- start 12 2 3 4 5 . stop 88 1 . + dh_install -s + dh_installman -s + dh_link -s + dh_strip -s + dh_compress -s + dh_fixperms -s + dh_installdeb -s + dh_shlibdeps -s + dh_gencontrol -s + dh_md5sums -s + dh_builddeb -s + +.PHONY: build clean binary-indep binary-arch binary install --- acpid-1.0.8.orig/debian/acpid.default +++ acpid-1.0.8/debian/acpid.default @@ -0,0 +1,11 @@ +# Options to pass to acpid +# +# OPTIONS are appended to the acpid command-line +#OPTIONS="" + +# Modules to load before starting acpid +# +# MODULES is a space seperated list of modules to load, or "all" to load all +# acpi drivers, or commented out to load no module +#MODULES="battery ac processor button fan thermal video" +#MODULES="all" --- acpid-1.0.8.orig/debian/acpid.install +++ acpid-1.0.8/debian/acpid.install @@ -0,0 +1,8 @@ +debian/powerbtn usr/share/doc/acpid/examples/ +debian/powerbtn.sh usr/share/doc/acpid/examples/ +debian/examples/default usr/share/doc/acpid/examples/ +debian/examples/default.sh usr/share/doc/acpid/examples/ +debian/examples/ac usr/share/doc/acpid/examples/ +debian/examples/ac.sh usr/share/doc/acpid/examples/ +acpi_listen usr/bin +acpid usr/sbin --- acpid-1.0.8.orig/debian/compat +++ acpid-1.0.8/debian/compat @@ -0,0 +1 @@ +5 --- acpid-1.0.8.orig/debian/acpid.manpages +++ acpid-1.0.8/debian/acpid.manpages @@ -0,0 +1,2 @@ +acpid.8 +acpi_listen.8 --- acpid-1.0.8.orig/debian/README.debian +++ acpid-1.0.8/debian/README.debian @@ -0,0 +1,34 @@ +acpid for Debian +================ + +The acpid daemon can handle user defined events. Place event files under +/etc/acpi/events. + +If an event occurs, acpid recurses through the event files in order to +see if the regex defined after "event" matches. If they do, action is +executed. + +An example with /etc/acpi/events/powerbtn to handle presses on the power +button. + +new style: + event=button/power .* + action=/etc/acpi/powerbtn.sh + +old style: + event=button power.* + action=/etc/acpi/powerbtn.sh + +to handle both styles: + event=button[ /]power + action=/etc/acpi/powerbtn.sh + +Your script will get the complete event string (as reported by +/proc/acpid/events), if you use %e as a parameter of your script. +You may want to split this by calling set $*. $1 then holds the +event group, $2 takes the event and $3 and $4 take the values as +reported by the kernel. + +When using acpid with modules, you can use /etc/default/acpid in order +to specify modules to be loaded at startup. + --- acpid-1.0.8.orig/debian/control +++ acpid-1.0.8/debian/control @@ -0,0 +1,30 @@ +Source: acpid +Section: admin +Priority: optional +Maintainer: Debian Acpi Team +Uploaders: Anibal Monsalve Salazar , + Michael Meskes , + Loic Minier +Standards-Version: 3.8.0 +Build-Depends: debhelper (>= 5), quilt (>= 0.40) +Vcs-Git: git://git.debian.org/git/pkg-acpi/acpid.git +Vcs-Browser: http://git.debian.org/?p=pkg-acpi/acpid.git +Homepage: http://acpid.sourceforge.net/ + +Package: acpid +Architecture: i386 ia64 amd64 lpia +Depends: ${shlibs:Depends}, + ${misc:Depends}, + lsb-base (>= 3.2-14), + module-init-tools (>= 3.1-rel-2ubuntu2) +Recommends: acpi-support-base +Description: Utilities for using ACPI power management + Modern computers support the Advanced Configuration and Power Interface (ACPI) + to allow intelligent power management on your system and to query battery and + configuration status. + . + ACPID is a completely flexible, totally extensible daemon for delivering + ACPI events. It listens on a file (/proc/acpi/event) and when an event + occurs, executes programs to handle the event. The programs it executes + are configured through a set of configuration files, which can be + dropped into place by packages or by the admin. --- acpid-1.0.8.orig/debian/watch +++ acpid-1.0.8/debian/watch @@ -0,0 +1,2 @@ +version=3 +http://sf.net/acpid/acpid-(\d\.\d\.\d.*)\.tar\.gz --- acpid-1.0.8.orig/debian/powerbtn +++ acpid-1.0.8/debian/powerbtn @@ -0,0 +1,13 @@ +# /etc/acpi/events/powerbtn +# This is called when the user presses the power button and calls +# /etc/acpi/powerbtn.sh for further processing. + +# Optionally you can specify the placeholder %e. It will pass +# through the whole kernel event message to the program you've +# specified. + +# We need to react on "button power.*" and "button/power.*" because +# of kernel changes. + +event=button[ /]power +action=/etc/acpi/powerbtn.sh --- acpid-1.0.8.orig/debian/acpid.preinst +++ acpid-1.0.8/debian/acpid.preinst @@ -0,0 +1,38 @@ +#!/bin/sh + +set -e + +#DEBHELPER# + +# Remove a no-longer used conffile +rm_conffile() { + PKGNAME="$1" + CONFFILE="$2" + if [ -e "$CONFFILE" ]; then + md5sum="`md5sum \"$CONFFILE\" | sed -e \"s/ .*//\"`" + old_md5sum="`dpkg-query -W -f='${Conffiles}' $PKGNAME | sed -n -e \"\\\\' $CONFFILE '{s/ obsolete$//;s/.* //p}\"`" + if [ "$md5sum" != "$old_md5sum" ]; then + echo "Obsolete conffile $CONFFILE has been modified by you." + echo "Saving as $CONFFILE.dpkg-bak ..." + mv -f "$CONFFILE" "$CONFFILE".dpkg-bak + else + if [ "$CONFFILE" = "/etc/acpi/events/powerbtn" -a -e /etc/acpi/powerbtn.sh.dpkg-bak ]; then + # we need some special logic for /etc/acpi/events/powerbtn because it might + # be kept because it was changed itself or because /etc/acpi/powerbtn.sh was changed + echo "Obsolete conffile $CONFFILE saved as $CONFFILE.dpkg-bak ..." + sed -e 's#/etc/acpi/powerbtn.sh#/etc/acpi/powerbtn.sh.dpkg-bak#' < "$CONFFILE" > "$CONFFILE".dpkg-bak + else + echo "Removing obsolete conffile $CONFFILE ..." + fi + rm -f "$CONFFILE" + fi + fi +} +case "$1" in + install|upgrade) + rm_conffile acpid /etc/logrotate.d/acpid + rm_conffile acpid /etc/acpi/powerbtn.sh + rm_conffile acpid /etc/acpi/events/powerbtn + ;; +esac + --- acpid-1.0.8.orig/debian/acpid.docs +++ acpid-1.0.8/debian/acpid.docs @@ -0,0 +1 @@ +README --- acpid-1.0.8.orig/debian/copyright +++ acpid-1.0.8/debian/copyright @@ -0,0 +1,14 @@ +This is the Debian GNU/Linux prepackaged version of acpid. +It was packaged by Cajus Pollmeier +from sources obtained from http://acpid.sourceforge.net. + +Copyright: + +Copyright (C) 2000 Andrew Henroid + +License: + +acpid is distributed under the terms of the GNU General Public License, +version 2 or later. On Debian GNU/Linux system you can find a copy of this +license in `/usr/share/common-licenses/GPL'. + --- acpid-1.0.8.orig/debian/acpid.init +++ acpid-1.0.8/debian/acpid.init @@ -0,0 +1,84 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: acpid +# Required-Start: $remote_fs $syslog +# Required-Stop: $remote_fs $syslog +# X-Start-Before: kdm gdm xdm hal +# X-Stop-After: kdm gdm xdm hal +# Default-Start: 2 3 4 5 +# Default-Stop: 1 +# Short-Description: Start the Advanced Configuration and Power Interface daemon +# Description: Provide a socket for X11, hald and others to multiplex +# kernel ACPI events. +### END INIT INFO + +set -e + +ACPID="/usr/sbin/acpid" +DEFAULTS="/etc/default/acpid" + +# Check for daemon presence +[ -x "$ACPID" ] || exit 0 + +OPTIONS="" +MODULES="" +# Include acpid defaults if available +if [ -r "$DEFAULTS" ]; then + . "$DEFAULTS" +fi + +# Get lsb functions +. /lib/lsb/init-functions +. /etc/default/rcS + +# As the name says. If the kernel supports modules, it'll try to load +# the ones listed in "MODULES". +load_modules() { + [ -f /proc/modules ] || return 0 + if [ "$MODULES" = "all" ]; then + MODULES="$(sed -rn 's#^/lib/modules/[^/]+/kernel/(drivers|ubuntu)/acpi/([^/]+/)*(.*)\.ko:.*#\3#p' "/lib/modules/$(uname -r)/modules.dep")" + fi + + if [ -z "$MODULES" ]; then + return + fi + + log_begin_msg "Loading ACPI modules..." + # work around a bug in initramfs which leaks this env var Launchpad #291619 + # and a bug in modprobe --all --quiet which doesn't load all modules and + # exits with non-zero exit status Debian #504088 + unset MODPROBE_OPTIONS + modprobe --all --use-blacklist $MODULES 2>/dev/null + log_end_msg $? +} + +case "$1" in + start) + load_modules || true + log_begin_msg "Starting ACPI services..." + start-stop-daemon --start --quiet --oknodo --exec "$ACPID" -- $OPTIONS + log_end_msg $? + ;; + stop) + log_begin_msg "Stopping ACPI services..." + start-stop-daemon --stop --quiet --oknodo --retry 2 --exec "$ACPID" + log_end_msg $? + ;; + restart) + $0 stop + sleep 1 + $0 start + ;; + reload|force-reload) + log_begin_msg "Reloading ACPI services..." + start-stop-daemon --stop --signal 1 --exec "$ACPID" + log_end_msg $? + ;; + status) + status_of_proc "$ACPID" acpid + ;; + *) + log_success_msg "Usage: /etc/init.d/acpid {start|stop|restart|reload|force-reload|status}" + exit 1 +esac + --- acpid-1.0.8.orig/debian/gbp.conf +++ acpid-1.0.8/debian/gbp.conf @@ -0,0 +1,6 @@ +[DEFAULT] +upstream-branch = upstream +debian-branch = master +upstream-tag = upstream/%(version)s +debian-tag = debian/%(version)s +pristine-tar = True --- acpid-1.0.8.orig/debian/examples/ac.sh +++ acpid-1.0.8/debian/examples/ac.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# /etc/acpid/ac.sh +# Detect loss of AC power and regaining of AC power, and take action +# appropriatly. + +# On my laptop anyway, this script doesn't not get different parameters for +# loss of power and regained power. So, I have to use a separate program to +# tell what the adapter status is. + +# This uses the spicctrl program for probing the sonypi device. +BACKLIGHT=$(spicctrl -B) + +if on_ac_power; then + # Now on AC power. + + # Tell longrun to go crazy. + longrun -f performance + longrun -s 0 100 + + # Turn up the backlight unless it's up far enough. + if [ "$BACKLIGHT" -lt 108 ]; then + spicctrl -b 108 + fi +else + # Now off AC power. + + # Tell longrun to be a miser. + longrun -f economy + longrun -s 0 50 # adjust to suite.. + + # Don't allow the screen to be too bright, but don't turn the + # backlight _up_ on removal, and don't turn it all the way down, as + # that is unusable on my laptop in most conditions. Adjust to + # taste. + if [ "$BACKLIGHT" -gt 68 ]; then + spicctrl -b 68 + fi +fi + --- acpid-1.0.8.orig/debian/examples/default.sh +++ acpid-1.0.8/debian/examples/default.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# Default acpi script that takes an entry for all actions + +set $* + +# Take care about the way events are reported +ev_type=`echo "$1" | cut -d/ -f1` +if [ "$ev_type" = "$1" ]; then + event="$2"; +else + event=`echo "$1" | cut -d/ -f2` +fi + + +case "$ev_type" in + button) + case "$event" in + power) + logger "acpid: received a shutdown request" + /sbin/init 0 + break + ;; + *) + logger "acpid: action $2 is not defined" + ;; + esac + ;; + + *) + logger "ACPI group $1 / action $2 is not defined" + ;; +esac --- acpid-1.0.8.orig/debian/examples/ac +++ acpid-1.0.8/debian/examples/ac @@ -0,0 +1,11 @@ +# /etc/acpid/events/ac +# This detects changes to AC power status, and passes them to +# /etc/acpi/ac.sh for further processing. + +# Optionally you can specify the placeholder %e. It will pass +# through the whole kernel event message to the program you've +# specified. + +event=ac_adapter +action=/etc/acpi/ac.sh + --- acpid-1.0.8.orig/debian/examples/default +++ acpid-1.0.8/debian/examples/default @@ -0,0 +1,18 @@ +# This is the ACPID default configuration, it takes all +# events and passes them to /etc/acpi/default.sh for further +# processing. + +# event keeps a regular expression matching the event. To get +# power events only, just use something like "event=button power.*" +# to catch it. +# action keeps the command to be executed after an event occurs +# In case of the power event above, your entry may look this way: +#event=button power.* +#action=/sbin/init 0 + +# Optionally you can specify the placeholder %e. It will pass +# through the whole kernel event message to the program you've +# specified. + +event=.* +action=/etc/acpi/default.sh %e --- acpid-1.0.8.orig/debian/patches/event.c.diff +++ acpid-1.0.8/debian/patches/event.c.diff @@ -0,0 +1,43 @@ +--- acpid-1.0.8.orig/event.c ++++ acpid-1.0.8/event.c +@@ -23,6 +23,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -90,6 +91,8 @@ + struct dirent *dirent; + char *file = NULL; + int nrules = 0; ++ char *basen = NULL; ++ regex_t preg; + + lock_rules(); + +@@ -139,10 +142,19 @@ + continue; /* skip non-regular files */ + } + +- r = parse_file(file); +- if (r) { +- enlist_rule(&cmd_list, r); +- nrules++; ++ /* check for run-parts style filename */ ++ basen = basename(file); ++ if (regcomp(&preg, "^[a-zA-Z0-9_-]+$", RULE_REGEX_FLAGS) == 0){ ++ if (regexec(&preg, basen, 0, NULL, 0) == 0){ ++ r = parse_file(file); ++ if (r) { ++ enlist_rule(&cmd_list, r); ++ nrules++; ++ } ++ } else { ++ acpid_log(LOG_DEBUG, "ignoring conf file %s\n", file); ++ } ++ + } + free(file); + } --- acpid-1.0.8.orig/debian/patches/netlink.diff +++ acpid-1.0.8/debian/patches/netlink.diff @@ -0,0 +1,2796 @@ +diff -Nru acpid-1.0.8/acpid.8 acpid-1.0.8ted1/acpid.8 +--- acpid-1.0.8/acpid.8 2008-10-27 06:41:34.000000000 +0100 ++++ acpid-1.0.8ted1/acpid.8 2008-11-15 01:15:06.000000000 +0100 +@@ -10,11 +10,13 @@ + \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 will ignore all incoming ACPI events if a lock file exists +-(\fI/var/lock/acpid\fP by default). ++(\fI/proc/acpi/event\fP by default) and attempt to read whole lines which ++represent ACPI events. If the events file does not exist, \fBacpid\fP will ++attempt to connect to the Linux kernel via the input layer and netlink. When an ++ACPI event is received from one of these sources, \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), +@@ -69,6 +71,9 @@ + This option changes the event file from which \fBacpid\fP reads events. + Default is \fI/proc/acpi/event\fP. + .TP ++.BI \-n "\fR, \fP" \--netlink ++This option forces \fBacpid\fP to use the Linux kernel input layer and netlink interface for ACPI events. ++.TP + .BI \-f "\fR, \fP" \--foreground + This option keeps \fBacpid\fP in the foreground by not forking at startup. + .TP +@@ -122,6 +127,8 @@ + .PD 0 + .B /proc/acpi/event + .br ++.B /dev/input/event* ++.br + .B /etc/acpi/ + .br + .B /var/run/acpid.socket +diff -Nru acpid-1.0.8/acpid.c acpid-1.0.8ted1/acpid.c +--- acpid-1.0.8/acpid.c 2008-10-27 07:07:25.000000000 +0100 ++++ acpid-1.0.8ted1/acpid.c 2008-11-15 02:36:21.000000000 +0100 +@@ -20,23 +20,23 @@ + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +-#include +-#include ++#include + #include + #include +-#include ++#include + #include + #include +-#include + #include + #include +-#include +-#include +-#include +-#include ++#include + + #include "acpid.h" +-#include "ud_socket.h" ++#include "event.h" ++#include "connection_list.h" ++#include "proc.h" ++#include "sock.h" ++#include "input_layer.h" ++#include "netlink.h" + + static int handle_cmdline(int *argc, char ***argv); + static void close_fds(void); +@@ -45,7 +45,6 @@ + static int create_pidfile(void); + static void clean_exit(int sig); + static void reload_conf(int sig); +-static char *read_line(int fd); + + /* global debug level */ + int acpid_debug; +@@ -53,23 +52,18 @@ + /* do we log event info? */ + int logevents; + +-static const char *progname; +-static const char *confdir = ACPID_CONFDIR; +-static const char *eventfile = ACPID_EVENTFILE; +-static const char *socketfile = ACPID_SOCKETFILE; ++const char *progname; ++ + static const char *lockfile = ACPID_LOCKFILE; ++static const char *confdir = ACPID_CONFDIR; + static int nosocket; +-static const char *socketgroup; +-static mode_t socketmode = ACPID_SOCKETMODE; + static int foreground; + static const char *pidfile = ACPID_PIDFILE; ++static int netlink; + + int + main(int argc, char **argv) + { +- int event_fd; +- int sock_fd = -1; /* init to avoid a compiler warning */ +- + /* learn who we really are */ + progname = (const char *)strrchr(argv[0], '/'); + progname = progname ? (progname + 1) : argv[0]; +@@ -80,14 +74,22 @@ + /* close any extra file descriptors */ + close_fds(); + +- /* actually open the event file */ +- event_fd = open(eventfile, O_RDONLY); +- if (event_fd < 0) { +- fprintf(stderr, "%s: can't open %s: %s\n", progname, +- eventfile, strerror(errno)); +- exit(EXIT_FAILURE); ++ if (!netlink) ++ { ++ /* open the acpi event file in the proc fs */ ++ /* if the open fails, try netlink */ ++ if (open_proc()) ++ netlink = 1; ++ } ++ ++ if (netlink) ++ { ++ /* open the input layer */ ++ open_input(); ++ ++ /* open netlink */ ++ open_netlink(); + } +- fcntl(event_fd, F_SETFD, FD_CLOEXEC); + + /* + * if there is data, and the kernel is NOT broken, this eats 1 byte. We +@@ -124,34 +126,7 @@ + + /* open our socket */ + if (!nosocket) { +- sock_fd = ud_create_socket(socketfile); +- if (sock_fd < 0) { +- fprintf(stderr, "%s: can't open socket %s: %s\n", +- progname, socketfile, strerror(errno)); +- exit(EXIT_FAILURE); +- } +- fcntl(sock_fd, F_SETFD, FD_CLOEXEC); +- chmod(socketfile, socketmode); +- if (socketgroup) { +- struct group *gr; +- struct stat buf; +- gr = getgrnam(socketgroup); +- if (!gr) { +- fprintf(stderr, "%s: group %s does not exist\n", +- progname, socketgroup); +- exit(EXIT_FAILURE); +- } +- if (stat(socketfile, &buf) < 0) { +- fprintf(stderr, "%s: can't stat %s\n", +- progname, socketfile); +- exit(EXIT_FAILURE); +- } +- if (chown(socketfile, buf.st_uid, gr->gr_gid) < 0) { +- fprintf(stderr, "%s: chown(): %s\n", +- progname, strerror(errno)); +- exit(EXIT_FAILURE); +- } +- } ++ open_sock(); + } + + /* if we're running in foreground, we don't daemonize */ +@@ -164,7 +139,8 @@ + if (open_log() < 0) { + exit(EXIT_FAILURE); + } +- acpid_log(LOG_INFO, "starting up\n"); ++ acpid_log(LOG_INFO, "starting up with %s\n", ++ netlink ? "netlink and the input layer" : "proc fs"); + + /* trap key signals */ + signal(SIGHUP, reload_conf); +@@ -183,109 +159,50 @@ + 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; +- int fds = 0; +- +- /* poll for the socket and the event file */ +- ar[0].fd = event_fd; ar[0].events = POLLIN; fds++; +- if (!nosocket) { +- ar[1].fd = sock_fd; ar[1].events = POLLIN; fds++; +- } +- r = poll(ar, fds, -1); + +- if (r < 0 && errno == EINTR) { ++ /* main loop */ ++ while (1) ++ { ++ fd_set readfds; ++ int nready; ++ int i; ++ struct connection *p; ++ ++ /* it's going to get clobbered, so use a copy */ ++ readfds = *get_fdset(); ++ ++ /* wait on data */ ++ nready = select(get_highestfd() + 1, &readfds, NULL, NULL, NULL); ++ ++ if (nready < 0 && errno == EINTR) { + continue; +- } else if (r < 0) { +- acpid_log(LOG_ERR, "poll(): %s\n", strerror(errno)); ++ } else if (nready < 0) { ++ acpid_log(LOG_ERR, "select(): %s\n", strerror(errno)); + continue; + } + +- /* 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, +- "odd, poll set flags 0x%x\n", +- ar[0].revents); +- continue; +- } ++ /* for each connection */ ++ for (i = 0; i <= get_number_of_connections(); ++i) ++ { ++ int fd; + +- /* read an event */ +- event = read_line(event_fd); ++ p = get_connection(i); + +- /* 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) { +- if (logevents) { +- acpid_log(LOG_INFO, +- "received event \"%s\"\n", event); +- } +- acpid_handle_event(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"); ++ /* if this connection is invalid, bail */ ++ if (!p) + break; +- } else { +- static int nerrs; +- if (++nerrs >= ACPID_MAX_ERRS) { +- acpid_log(LOG_ERR, +- "too many errors reading " +- "events file - aborting\n"); +- break; +- } +- } +- } + +- /* was it a new connection? */ +- if (!nosocket && ar[1].revents) { +- int cli_fd; +- struct ucred creds; +- char buf[32]; +- +- /* this shouldn't happen */ +- if (!ar[1].revents & POLLIN) { +- acpid_log(LOG_DEBUG, +- "odd, poll set flags 0x%x\n", +- ar[1].revents); +- continue; +- } ++ /* get the file descriptor */ ++ fd = p->fd; + +- /* accept and add to our lists */ +- cli_fd = ud_accept(sock_fd, &creds); +- if (cli_fd < 0) { +- acpid_log(LOG_ERR, "can't accept client: %s\n", +- strerror(errno)); +- continue; ++ /* if this file descriptor has data waiting */ ++ if (FD_ISSET(fd, &readfds)) ++ { ++ /* delegate to this connection's process function */ ++ p->process(fd); + } +- 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); + } + } + +@@ -312,6 +229,7 @@ + {"nosocket", 1, 0, 'S'}, + {"pidfile", 1, 0, 'p'}, + {"lockfile", 1, 0, 'L'}, ++ {"netlink", 1, 0, 'n'}, + {"version", 0, 0, 'v'}, + {"help", 0, 0, 'h'}, + {NULL, 0, 0, 0}, +@@ -327,7 +245,8 @@ + "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 */ ++ "Use the specified lockfile to stop processing.", /* lockfile */ ++ "Force netlink/input layer mode. (overrides -e)", /* netlink */ + "Print version information.", /* version */ + "Print this message.", /* help */ + }; +@@ -338,7 +257,7 @@ + for (;;) { + int i; + i = getopt_long(*argc, *argv, +- "c:de:flg:m:s:Sp:L:vh", opts, NULL); ++ "c:de:flg:m:s:Sp:L:nvh", opts, NULL); + if (i == -1) { + break; + } +@@ -377,6 +296,9 @@ + case 'L': + lockfile = optarg; + break; ++ case 'n': ++ netlink = 1; ++ break; + case 'v': + printf(PACKAGE "-" VERSION "\n"); + exit(EXIT_SUCCESS); +@@ -550,54 +472,11 @@ + return 0; + } + +-/* +- * This depends on fixes in linux ACPI after 2.4.8 +- */ +-#define MAX_BUFLEN 1024 +-static char * +-read_line(int fd) ++int ++locked() + { +- static char *buf; +- int buflen = 64; +- int i = 0; +- int r; +- int searching = 1; +- +- while (searching) { +- buf = realloc(buf, buflen); +- if (!buf) { +- acpid_log(LOG_ERR, "malloc(%d): %s\n", +- buflen, strerror(errno)); +- return NULL; +- } +- memset(buf+i, 0, buflen-i); +- +- while (i < buflen) { +- r = read(fd, buf+i, 1); +- if (r < 0 && errno != EINTR) { +- /* we should do something with the data */ +- acpid_log(LOG_ERR, "read(): %s\n", +- strerror(errno)); +- return NULL; +- } else if (r == 0) { +- /* signal this in an almost standard way */ +- errno = EPIPE; +- return NULL; +- } else if (r == 1) { +- /* scan for a newline */ +- if (buf[i] == '\n') { +- searching = 0; +- buf[i] = '\0'; +- break; +- } +- i++; +- } +- } +- if (buflen >= MAX_BUFLEN) { +- break; +- } +- buflen *= 2; +- } ++ struct stat trash; + +- return buf; ++ /* check for existence of a lockfile */ ++ return (stat(lockfile, &trash) == 0); + } +diff -Nru acpid-1.0.8/acpid.h acpid-1.0.8ted1/acpid.h +--- acpid-1.0.8/acpid.h 2008-10-27 06:52:07.000000000 +0100 ++++ acpid-1.0.8ted1/acpid.h 2008-11-13 02:37:07.000000000 +0100 +@@ -23,11 +23,7 @@ + #ifndef ACPID_H__ + #define ACPID_H__ + +-#include + #include +-#include +-#include +-#include + + #define ACPI_PROCDIR "/proc/acpi" + #define ACPID_EVENTFILE ACPI_PROCDIR "/event" +@@ -40,19 +36,12 @@ + + #define PACKAGE "acpid" + +-/* +- * acpid.c +- */ + extern int acpid_debug; + extern int logevents; ++extern const char *progname; ++ + extern int acpid_log(int level, const char *fmt, ...); + +-/* +- * event.c +- */ +-extern int acpid_read_conf(const char *confdir); +-extern int acpid_add_client(int client, const char *origin); +-extern int acpid_cleanup_rules(int do_detach); +-extern int acpid_handle_event(const char *event); ++extern int locked(); + + #endif /* ACPID_H__ */ +diff -Nru acpid-1.0.8/acpi_genetlink.h acpid-1.0.8ted1/acpi_genetlink.h +--- acpid-1.0.8/acpi_genetlink.h 1970-01-01 01:00:00.000000000 +0100 ++++ acpid-1.0.8ted1/acpi_genetlink.h 2007-07-20 08:30:46.000000000 +0200 +@@ -0,0 +1,33 @@ ++#ifndef __ACPI_GENETLINK_H__ ++#define __ACPI_GENETLINK_H__ 1 ++ ++#include ++ ++struct acpi_genl_event { ++ char device_class[20]; ++ char bus_id[15]; ++ __u32 type; ++ __u32 data; ++}; ++ ++/* attributes of acpi_genl_family */ ++enum { ++ ACPI_GENL_ATTR_UNSPEC, ++ ACPI_GENL_ATTR_EVENT, /* ACPI event info needed by user space */ ++ __ACPI_GENL_ATTR_MAX, ++}; ++#define ACPI_GENL_ATTR_MAX (__ACPI_GENL_ATTR_MAX - 1) ++ ++/* commands supported by the acpi_genl_family */ ++enum { ++ ACPI_GENL_CMD_UNSPEC, ++ ACPI_GENL_CMD_EVENT, /* kernel->user notifications for ACPI events */ __ACPI_GENL_CMD_MAX, ++}; ++#define ACPI_GENL_CMD_MAX (__ACPI_GENL_CMD_MAX - 1) ++#define GENL_MAX_FAM_OPS 256 ++#define GENL_MAX_FAM_GRPS 256 ++ ++#define ACPI_EVENT_FAMILY_NAME "acpi_event" ++#define ACPI_EVENT_MCAST_GROUP_NAME "acpi_mc_group" ++ ++#endif +diff -Nru acpid-1.0.8/acpi_ids.c acpid-1.0.8ted1/acpi_ids.c +--- acpid-1.0.8/acpi_ids.c 1970-01-01 01:00:00.000000000 +0100 ++++ acpid-1.0.8ted1/acpi_ids.c 2008-11-14 20:35:29.000000000 +0100 +@@ -0,0 +1,254 @@ ++/* ++ * acpi_ids.c - ACPI Netlink Group and Family IDs ++ * ++ * Copyright (C) 2008 Ted Felix (www.tedfelix.com) ++ * Portions from acpi_genl Copyright (C) Zhang Rui ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++ */ ++ ++#include ++/* needed by netlink.h, should be in there */ ++#include ++#include ++#include ++ ++#include "genetlink.h" ++#include "libnetlink.h" ++ ++#include "acpid.h" ++ ++#define GENL_MAX_FAM_GRPS 256 ++#define ACPI_EVENT_FAMILY_NAME "acpi_event" ++#define ACPI_EVENT_MCAST_GROUP_NAME "acpi_mc_group" ++ ++static int initialized = 0; ++static __u16 acpi_event_family_id = 0; ++static __u32 acpi_event_mcast_group_id = 0; ++ ++/* ++ * A CTRL_CMD_GETFAMILY message returns an attribute table that looks ++ * like this: ++ * ++ * CTRL_ATTR_FAMILY_ID Use this to make sure we get the proper msgs ++ * CTRL_ATTR_MCAST_GROUPS ++ * CTRL_ATTR_MCAST_GRP_NAME ++ * CTRL_ATTR_MCAST_GRP_ID Need this for the group mask ++ * ... ++ */ ++ ++static int ++get_ctrl_grp_id(struct rtattr *arg) ++{ ++ struct rtattr *tb[CTRL_ATTR_MCAST_GRP_MAX + 1]; ++ char *name; ++ ++ if (arg == NULL) ++ return -1; ++ ++ /* nested within the CTRL_ATTR_MCAST_GROUPS attribute are the */ ++ /* group name and ID */ ++ parse_rtattr_nested(tb, CTRL_ATTR_MCAST_GRP_MAX, arg); ++ ++ /* if either of the entries needed cannot be found, bail */ ++ if (!tb[CTRL_ATTR_MCAST_GRP_NAME] || !tb[CTRL_ATTR_MCAST_GRP_ID]) ++ return -1; ++ ++ /* get the name of this multicast group we've found */ ++ name = RTA_DATA(tb[CTRL_ATTR_MCAST_GRP_NAME]); ++ ++ /* if it does not match the ACPI event multicast group name, bail */ ++ if (strcmp(name, ACPI_EVENT_MCAST_GROUP_NAME)) ++ return -1; ++ ++ /* At this point, we've found what we were looking for. We now */ ++ /* have the multicast group ID for ACPI events over generic netlink. */ ++ acpi_event_mcast_group_id = ++ *((__u32 *)RTA_DATA(tb[CTRL_ATTR_MCAST_GRP_ID])); ++ ++ return 0; ++} ++ ++/* n = the response to a CTRL_CMD_GETFAMILY message */ ++static int ++genl_get_mcast_group_id(struct nlmsghdr *n) ++{ ++ /* ++ * Attribute table. Note the type name "rtattr" which means "route ++ * attribute". This is a vestige of one of netlink's main uses: ++ * routing. ++ */ ++ struct rtattr *tb[CTRL_ATTR_MAX + 1]; ++ /* pointer to the generic netlink header in the incoming message */ ++ struct genlmsghdr *ghdr = NLMSG_DATA(n); ++ /* length of the attribute and payload */ ++ int len = n->nlmsg_len - NLMSG_LENGTH(GENL_HDRLEN); ++ /* Pointer to the attribute portion of the message */ ++ struct rtattr *attrs; ++ ++ if (len < 0) { ++ fprintf(stderr, "%s: netlink CTRL_CMD_GETFAMILY response, " ++ "wrong controller message len: %d\n", progname, len); ++ return -1; ++ } ++ ++ if (n->nlmsg_type != GENL_ID_CTRL) { ++ fprintf(stderr, "%s: not a netlink controller message, " ++ "nlmsg_len=%d nlmsg_type=0x%x\n", ++ progname, n->nlmsg_len, n->nlmsg_type); ++ return 0; ++ } ++ ++ if (ghdr->cmd != CTRL_CMD_GETFAMILY && ++ ghdr->cmd != CTRL_CMD_DELFAMILY && ++ ghdr->cmd != CTRL_CMD_NEWFAMILY && ++ ghdr->cmd != CTRL_CMD_NEWMCAST_GRP && ++ ghdr->cmd != CTRL_CMD_DELMCAST_GRP) { ++ fprintf(stderr, "%s: unknown netlink controller command %d\n", ++ progname, ghdr->cmd); ++ return 0; ++ } ++ ++ /* set attrs to point to the attribute */ ++ attrs = (struct rtattr *)((char *)ghdr + GENL_HDRLEN); ++ /* Read the table from the message into "tb". This actually just */ ++ /* places pointers into the message into tb[]. */ ++ parse_rtattr(tb, CTRL_ATTR_MAX, attrs, len); ++ ++ /* if a family ID attribute is present, get it */ ++ if (tb[CTRL_ATTR_FAMILY_ID]) ++ { ++ acpi_event_family_id = ++ *((__u32 *)RTA_DATA(tb[CTRL_ATTR_FAMILY_ID])); ++ } ++ ++ /* if a "multicast groups" attribute is present... */ ++ if (tb[CTRL_ATTR_MCAST_GROUPS]) { ++ struct rtattr *tb2[GENL_MAX_FAM_GRPS + 1]; ++ int i; ++ ++ /* get the group table within this attribute */ ++ parse_rtattr_nested(tb2, GENL_MAX_FAM_GRPS, ++ tb[CTRL_ATTR_MCAST_GROUPS]); ++ ++ /* for each group */ ++ for (i = 0; i < GENL_MAX_FAM_GRPS; i++) ++ /* if this group is valid */ ++ if (tb2[i]) ++ /* Parse the ID. If successful, we're done. */ ++ if (!get_ctrl_grp_id(tb2[i])) ++ return 0; ++ } ++ ++ return -1; ++} ++ ++static int ++genl_get_ids(char *family_name) ++{ ++ /* handle to the netlink connection */ ++ struct rtnl_handle rth; ++ /* holds the request we are going to send and the reply */ ++ struct { ++ struct nlmsghdr n; ++ char buf[4096]; /* ??? Is this big enough for all cases? */ ++ } req; ++ /* pointer to the nlmsghdr in req */ ++ struct nlmsghdr *nlh; ++ /* pointer to the generic netlink header in req */ ++ struct genlmsghdr *ghdr; ++ /* return value */ ++ int ret = -1; ++ ++ /* clear out the request */ ++ memset(&req, 0, sizeof(req)); ++ ++ /* set up nlh to point to the netlink header in req */ ++ nlh = &req.n; ++ /* set up the netlink header */ ++ nlh->nlmsg_len = NLMSG_LENGTH(GENL_HDRLEN); ++ nlh->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; ++ nlh->nlmsg_type = GENL_ID_CTRL; ++ ++ /* set up ghdr to point to the generic netlink header */ ++ ghdr = NLMSG_DATA(&req.n); ++ /* set the command we want to run: "GETFAMILY" */ ++ ghdr->cmd = CTRL_CMD_GETFAMILY; ++ ++ /* the message payload is the family name */ ++ addattr_l(nlh, 128, CTRL_ATTR_FAMILY_NAME, ++ family_name, strlen(family_name) + 1); ++ ++ /* open a generic netlink connection */ ++ if (rtnl_open_byproto(&rth, 0, NETLINK_GENERIC) < 0) { ++ fprintf(stderr, "%s: cannot open generic netlink socket\n", ++ progname); ++ return -1; ++ } ++ ++ /* ++ * Send CTRL_CMD_GETFAMILY message (in nlh) to the generic ++ * netlink controller. Reply will be in nlh upon return. ++ */ ++ if (rtnl_talk(&rth, nlh, 0, 0, nlh, NULL, NULL) < 0) { ++ fprintf(stderr, "%s: error talking to the kernel via netlink\n", ++ progname); ++ goto ctrl_done; ++ } ++ ++ /* process the response */ ++ if (genl_get_mcast_group_id(nlh) < 0) { ++ fprintf(stderr, "%s: failed to get acpi_event netlink " ++ "multicast group\n", progname); ++ goto ctrl_done; ++ } ++ ++ ret = 0; ++ ++ctrl_done: ++ rtnl_close(&rth); ++ return ret; ++} ++ ++/* initialize the ACPI IDs */ ++static void ++acpi_ids_init() ++{ ++ genl_get_ids(ACPI_EVENT_FAMILY_NAME); ++ ++ initialized = 1; ++} ++ ++/* returns the netlink family ID for ACPI event messages */ ++__u16 ++acpi_ids_getfamily() ++{ ++ /* if the IDs haven't been initialized, initialize them */ ++ if (initialized == 0) ++ acpi_ids_init(); ++ ++ return acpi_event_family_id; ++} ++ ++/* returns the netlink multicast group ID for ACPI event messages */ ++__u32 ++acpi_ids_getgroup() ++{ ++ /* if the IDs haven't been initialized, initialize them */ ++ if (initialized == 0) ++ acpi_ids_init(); ++ ++ return acpi_event_mcast_group_id; ++} +diff -Nru acpid-1.0.8/acpi_ids.h acpid-1.0.8ted1/acpi_ids.h +--- acpid-1.0.8/acpi_ids.h 1970-01-01 01:00:00.000000000 +0100 ++++ acpid-1.0.8ted1/acpi_ids.h 2008-11-09 21:44:59.000000000 +0100 +@@ -0,0 +1,30 @@ ++/* ++ * acpi_ids.h - ACPI Netlink Group and Family IDs ++ * ++ * Copyright (C) 2008 Ted Felix (www.tedfelix.com) ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++ */ ++ ++#ifndef ACPI_IDS_H__ ++#define ACPI_IDS_H__ ++ ++/* returns the netlink family ID for ACPI event messages */ ++extern __u16 acpi_ids_getfamily(); ++ ++/* returns the netlink multicast group ID for ACPI event messages */ ++extern __u32 acpi_ids_getgroup(); ++ ++#endif /* ACPI_IDS_H__ */ +diff -Nru acpid-1.0.8/acpi_listen.c acpid-1.0.8ted1/acpi_listen.c +--- acpid-1.0.8/acpi_listen.c 2007-11-25 06:30:03.000000000 +0100 ++++ acpid-1.0.8ted1/acpi_listen.c 2008-11-12 03:00:28.000000000 +0100 +@@ -42,8 +42,8 @@ + static int handle_cmdline(int *argc, char ***argv); + static char *read_line(int fd); + +-static const char *progname; +-static const char *socketfile = ACPID_SOCKETFILE; ++const char *progname; ++const char *socketfile = ACPID_SOCKETFILE; + static int max_events; + + static void +diff -Nru acpid-1.0.8/connection_list.c acpid-1.0.8ted1/connection_list.c +--- acpid-1.0.8/connection_list.c 1970-01-01 01:00:00.000000000 +0100 ++++ acpid-1.0.8ted1/connection_list.c 2008-11-14 03:10:03.000000000 +0100 +@@ -0,0 +1,124 @@ ++/* ++ * connection_list.c - ACPI daemon connection list ++ * ++ * Copyright (C) 2008, Ted Felix (www.tedfelix.com) ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++ * ++ * Tabs at 4 ++ */ ++ ++#include ++#include ++#include ++ ++#include "acpid.h" ++ ++#include "connection_list.h" ++ ++#define max(a, b) (((a)>(b))?(a):(b)) ++ ++/*---------------------------------------------------------------*/ ++/* private objects */ ++ ++#define MAX_CONNECTIONS 10 ++ ++static struct connection connection_list[MAX_CONNECTIONS]; ++ ++static int nconnections = 0; ++ ++/* fd_set containing all the fd's that come in */ ++static fd_set allfds; ++ ++/* highest fd that is opened */ ++/* (-2 + 1) causes select() to return immediately */ ++static int highestfd = -2; ++ ++/*---------------------------------------------------------------*/ ++/* public functions */ ++ ++void ++add_connection(struct connection *p) ++{ ++ if (nconnections < 0) ++ return; ++ if (nconnections >= MAX_CONNECTIONS) { ++ acpid_log(LOG_ERR, "Too many connections.\n"); ++ return; ++ } ++ ++ if (nconnections == 0) ++ FD_ZERO(&allfds); ++ ++ /* add the connection to the connection list */ ++ connection_list[nconnections] = *p; ++ ++nconnections; ++ ++ /* add to the fd set */ ++ FD_SET(p->fd, &allfds); ++ highestfd = max(highestfd, p->fd); ++} ++ ++/*---------------------------------------------------------------*/ ++ ++struct connection * ++find_connection(int fd) ++{ ++ int i; ++ ++ /* for each connection */ ++ for (i = 0; i < nconnections; ++i) { ++ /* if the file descriptors match, return the connection */ ++ if (connection_list[i].fd == fd) ++ return &connection_list[i]; ++ } ++ ++ return NULL; ++} ++ ++/*---------------------------------------------------------------*/ ++ ++int ++get_number_of_connections() ++{ ++ return nconnections; ++} ++ ++/*---------------------------------------------------------------*/ ++ ++struct connection * ++get_connection(int i) ++{ ++ if (i < 0 || i >= nconnections) ++ return NULL; ++ ++ return &connection_list[i]; ++} ++ ++/*---------------------------------------------------------------*/ ++ ++const fd_set * ++get_fdset() ++{ ++ return &allfds; ++} ++ ++/*---------------------------------------------------------------*/ ++ ++int ++get_highestfd() ++{ ++ return highestfd; ++} +diff -Nru acpid-1.0.8/connection_list.h acpid-1.0.8ted1/connection_list.h +--- acpid-1.0.8/connection_list.h 1970-01-01 01:00:00.000000000 +0100 ++++ acpid-1.0.8ted1/connection_list.h 2008-11-13 23:56:03.000000000 +0100 +@@ -0,0 +1,59 @@ ++/* ++ * connection_list.h - ACPI daemon connection list ++ * ++ * Copyright (C) 2008, Ted Felix (www.tedfelix.com) ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++ * ++ * Tabs at 4 ++ */ ++ ++#ifndef CONNECTION_LIST_H__ ++#define CONNECTION_LIST_H__ ++ ++#include ++ ++/***************************************************************** ++ * Connection List Public Members ++ *****************************************************************/ ++ ++struct connection ++{ ++ /* file descriptor */ ++ int fd; ++ ++ /* process incoming data on the connection */ ++ void (* process)(int fd); ++}; ++ ++/* add a connection to the list */ ++extern void add_connection(struct connection *p); ++ ++/* find a connection in the list by file descriptor */ ++extern struct connection *find_connection(int fd); ++ ++/* get the number of connections in the list */ ++extern int get_number_of_connections(); ++ ++/* get a specific connection by index from the list */ ++extern struct connection *get_connection(int i); ++ ++/* get an fd_set with all the fd's that have been added to the list */ ++extern const fd_set *get_fdset(); ++ ++/* get the highest fd that was added to the list */ ++extern int get_highestfd(); ++ ++#endif /* CONNECTION_LIST_H__ */ +diff -Nru acpid-1.0.8/event.c acpid-1.0.8ted1/event.c +--- acpid-1.0.8/event.c 2008-10-27 06:25:55.000000000 +0100 ++++ acpid-1.0.8ted1/event.c 2008-11-12 23:15:13.000000000 +0100 +@@ -1,5 +1,5 @@ + /* +- * event.c - ACPI daemon ++ * event.c - ACPI daemon event handler + * + * Copyright (C) 2000 Andrew Henroid + * Copyright (C) 2001 Sun Microsystems (thockin@sun.com) +diff -Nru acpid-1.0.8/event.h acpid-1.0.8ted1/event.h +--- acpid-1.0.8/event.h 1970-01-01 01:00:00.000000000 +0100 ++++ acpid-1.0.8ted1/event.h 2008-11-12 23:14:28.000000000 +0100 +@@ -0,0 +1,31 @@ ++/* ++ * event.h - ACPI daemon event handler ++ * ++ * Copyright (C) 1999-2000 Andrew Henroid ++ * Copyright (C) 2001 Sun Microsystems ++ * Portions Copyright (C) 2004 Tim Hockin (thockin@hockin.org) ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++ */ ++ ++#ifndef EVENT_H__ ++#define EVENT_H__ ++ ++extern int acpid_read_conf(const char *confdir); ++extern int acpid_add_client(int client, const char *origin); ++extern int acpid_cleanup_rules(int do_detach); ++extern int acpid_handle_event(const char *event); ++ ++#endif /* EVENT_H__ */ +diff -Nru acpid-1.0.8/genetlink.h acpid-1.0.8ted1/genetlink.h +--- acpid-1.0.8/genetlink.h 1970-01-01 01:00:00.000000000 +0100 ++++ acpid-1.0.8ted1/genetlink.h 2008-11-10 01:45:55.000000000 +0100 +@@ -0,0 +1,81 @@ ++#ifndef __LINUX_GENERIC_NETLINK_H ++#define __LINUX_GENERIC_NETLINK_H ++ ++#include ++ ++#define GENL_NAMSIZ 16 /* length of family name */ ++ ++#define GENL_MIN_ID NLMSG_MIN_TYPE ++#define GENL_MAX_ID 1023 ++ ++struct genlmsghdr { ++ __u8 cmd; ++ __u8 version; ++ __u16 reserved; ++}; ++ ++#define GENL_HDRLEN NLMSG_ALIGN(sizeof(struct genlmsghdr)) ++ ++#define GENL_ADMIN_PERM 0x01 ++#define GENL_CMD_CAP_DO 0x02 ++#define GENL_CMD_CAP_DUMP 0x04 ++#define GENL_CMD_CAP_HASPOL 0x08 ++ ++/* ++ * List of reserved static generic netlink identifiers: ++ */ ++#define GENL_ID_GENERATE 0 ++#define GENL_ID_CTRL NLMSG_MIN_TYPE ++ ++/************************************************************************** ++ * Controller ++ **************************************************************************/ ++ ++enum { ++ CTRL_CMD_UNSPEC, ++ CTRL_CMD_NEWFAMILY, ++ CTRL_CMD_DELFAMILY, ++ CTRL_CMD_GETFAMILY, ++ CTRL_CMD_NEWOPS, ++ CTRL_CMD_DELOPS, ++ CTRL_CMD_GETOPS, ++ CTRL_CMD_NEWMCAST_GRP, ++ CTRL_CMD_DELMCAST_GRP, ++ CTRL_CMD_GETMCAST_GRP, /* unused */ ++ __CTRL_CMD_MAX, ++}; ++ ++#define CTRL_CMD_MAX (__CTRL_CMD_MAX - 1) ++ ++enum { ++ CTRL_ATTR_UNSPEC, ++ CTRL_ATTR_FAMILY_ID, ++ CTRL_ATTR_FAMILY_NAME, ++ CTRL_ATTR_VERSION, ++ CTRL_ATTR_HDRSIZE, ++ CTRL_ATTR_MAXATTR, ++ CTRL_ATTR_OPS, ++ CTRL_ATTR_MCAST_GROUPS, ++ __CTRL_ATTR_MAX, ++}; ++ ++#define CTRL_ATTR_MAX (__CTRL_ATTR_MAX - 1) ++ ++enum { ++ CTRL_ATTR_OP_UNSPEC, ++ CTRL_ATTR_OP_ID, ++ CTRL_ATTR_OP_FLAGS, ++ __CTRL_ATTR_OP_MAX, ++}; ++ ++#define CTRL_ATTR_OP_MAX (__CTRL_ATTR_OP_MAX - 1) ++ ++enum { ++ CTRL_ATTR_MCAST_GRP_UNSPEC, ++ CTRL_ATTR_MCAST_GRP_NAME, ++ CTRL_ATTR_MCAST_GRP_ID, ++ __CTRL_ATTR_MCAST_GRP_MAX, ++}; ++#define CTRL_ATTR_MCAST_GRP_MAX (__CTRL_ATTR_MCAST_GRP_MAX - 1) ++ ++#endif /* __LINUX_GENERIC_NETLINK_H */ +diff -Nru acpid-1.0.8/input_layer.c acpid-1.0.8ted1/input_layer.c +--- acpid-1.0.8/input_layer.c 1970-01-01 01:00:00.000000000 +0100 ++++ acpid-1.0.8ted1/input_layer.c 2008-11-16 02:33:58.000000000 +0100 +@@ -0,0 +1,262 @@ ++/* ++ * input_layer - Kernel ACPI Event Input Layer Interface ++ * ++ * Handles the details of getting kernel ACPI events from the input ++ * layer (/dev/input/event*). ++ * ++ * Inspired by (and in some cases blatantly lifted from) Vojtech Pavlik's ++ * evtest.c. ++ * ++ * Copyright (C) 2008, Ted Felix (www.tedfelix.com) ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++ * ++ * (tabs at 4) ++ */ ++ ++/* system */ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++/* local */ ++#include "acpid.h" ++#include "connection_list.h" ++#include "event.h" ++ ++#define DIM(a) (sizeof(a) / sizeof(a[0])) ++ ++struct evtab_entry { ++ struct input_event event; ++ const char *str; ++}; ++ ++/* event table: events we are interested in and their strings */ ++/* use evtest.c or acpi_genl to find new events to add to this table */ ++static struct evtab_entry evtab[] = { ++ {{{0,0}, EV_KEY, KEY_POWER, 1}, "button/power PBTN 00000080 00000000"}, ++ {{{0,0}, EV_KEY, KEY_SLEEP, 1}, "button/sleep SBTN 00000080 00000000"}, ++ {{{0,0}, EV_KEY, KEY_SUSPEND, 1}, ++ "button/suspend SUSP 00000080 00000000"}, ++ {{{0,0}, EV_SW, SW_LID, 1}, "button/lid LID close"}, ++ {{{0,0}, EV_SW, SW_LID, 0}, "button/lid LID open"} ++}; ++ ++/*----------------------------------------------------------------------*/ ++/* Given an input event, returns the string corresponding to that event. ++ If there is no corresponding string, NULL is returned. */ ++static const char * ++event_string(struct input_event event) ++{ ++ unsigned i; ++ ++ /* for each entry in the event table */ ++ for (i = 0; i < DIM(evtab); ++i) ++ { ++ /* if this is a matching event, return its string */ ++ if (event.type == evtab[i].event.type && ++ event.code == evtab[i].event.code && ++ event.value == evtab[i].event.value) { ++ return evtab[i].str; ++ } ++ } ++ ++ return NULL; ++} ++ ++/*-----------------------------------------------------------------*/ ++/* returns non-zero if the event type/code is one we need */ ++static int ++need_event(int type, int code) ++{ ++ unsigned i; ++ ++ /* for each entry in the event table */ ++ for (i = 0; i < DIM(evtab); ++i) { ++ /* if we found a matching event */ ++ if (type == evtab[i].event.type && ++ code == evtab[i].event.code) { ++ return 1; ++ } ++ } ++ ++ return 0; ++} ++ ++/*-----------------------------------------------------------------*/ ++/* called when an input layer event is received */ ++void process_input(int fd) ++{ ++ struct input_event event; ++ ssize_t nbytes; ++ const char *str; ++ static int nerrs; ++ ++ nbytes = read(fd, &event, sizeof(event)); ++ ++ if (nbytes == 0) { ++ acpid_log(LOG_WARNING, "input layer connection closed\n"); ++ exit(EXIT_FAILURE); ++ } ++ ++ if (nbytes < 0) { ++ /* if it's a signal, bail */ ++ if (errno == EINTR) ++ return; ++ ++ acpid_log(LOG_ERR, "input layer read error: %s (%d)\n", ++ strerror(errno), errno); ++ if (++nerrs >= ACPID_MAX_ERRS) { ++ acpid_log(LOG_ERR, ++ "too many errors reading " ++ "input layer - aborting\n"); ++ exit(EXIT_FAILURE); ++ } ++ return; ++ } ++ ++ /* ??? Is it possible for a partial message to come across? */ ++ /* If so, we've got more code to write... */ ++ ++ if (nbytes != sizeof(event)) { ++ acpid_log(LOG_WARNING, "input layer unexpected length: " ++ "%d expected: %d\n", nbytes, sizeof(event)); ++ return; ++ } ++ ++ /* convert the event into a string */ ++ str = event_string(event); ++ /* if this is not an event we care about, bail */ ++ if (str == NULL) ++ return; ++ ++ /* if we're locked, don't process the event */ ++ if (locked()) { ++ if (logevents) { ++ acpid_log(LOG_INFO, ++ "lockfile present, not processing " ++ "input layer event \"%s\"\n", str); ++ } ++ return; ++ } ++ ++ if (logevents) ++ acpid_log(LOG_INFO, ++ "received input layer event \"%s\"\n", str); ++ ++ /* send the event off to the handler */ ++ acpid_handle_event(str); ++ ++ if (logevents) ++ acpid_log(LOG_INFO, ++ "completed input layer event \"%s\"\n", str); ++} ++ ++#define BITS_PER_LONG (sizeof(long) * 8) ++#define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1) ++#define OFF(x) ((x)%BITS_PER_LONG) ++#define LONG(x) ((x)/BITS_PER_LONG) ++#define test_bit(bit, array) ((array[LONG(bit)] >> OFF(bit)) & 1) ++ ++/*--------------------------------------------------------------------*/ ++/* returns non-zero if the file descriptor supports one of the events */ ++/* supported by event_string(). */ ++static int ++has_event(int fd) ++{ ++ int type, code; ++ unsigned long bit[EV_MAX][NBITS(KEY_MAX)]; ++ ++ memset(bit, 0, sizeof(bit)); ++ /* get the event type bitmap */ ++ ioctl(fd, EVIOCGBIT(0, EV_MAX), bit[0]); ++ ++ /* for each event type */ ++ for (type = 0; type < EV_MAX; type++) { ++ /* if this event type is supported */ ++ if (test_bit(type, bit[0])) { ++ /* skip sync */ ++ if (type == EV_SYN) continue; ++ /* get the event code mask */ ++ ioctl(fd, EVIOCGBIT(type, KEY_MAX), bit[type]); ++ /* for each event code */ ++ for (code = 0; code < KEY_MAX; code++) { ++ /* if this event code is supported */ ++ if (test_bit(code, bit[type])) { ++ /* if we need this event */ ++ if (need_event(type, code) != 0) ++ return 1; ++ } ++ } ++ } ++ } ++ return 0; ++} ++ ++/* ??? make this changeable by commandline option */ ++#define INPUT_LAYER_FS "/dev/input/event*" ++ ++/*-----------------------------------------------------------------* ++ * open each of the appropriate /dev/input/event* files for input */ ++void open_input(void) ++{ ++ char *filename = NULL; ++ glob_t globbuf; ++ unsigned i; ++ int fd; ++ int success = 0; ++ struct connection c; ++ ++ /* get all the matching event filenames */ ++ glob(INPUT_LAYER_FS, 0, NULL, &globbuf); ++ ++ /* for each event file */ ++ for (i = 0; i < globbuf.gl_pathc; ++i) ++ { ++ filename = globbuf.gl_pathv[i]; ++ ++ fd = open(filename, O_RDONLY | O_NONBLOCK); ++ if (fd >= 0) { ++ /* if this file doesn't have events we need, try the next */ ++ if (!has_event(fd)) ++ { ++ close(fd); ++ continue; ++ } ++ ++ success = 1; ++ ++ if (acpid_debug) ++ fprintf(stderr, "%s: input layer %s " ++ "opened successfully\n", progname, filename); ++ ++ /* add a connection to the list */ ++ c.fd = fd; ++ c.process = process_input; ++ add_connection(&c); ++ } ++ } ++ ++ if (!success) ++ fprintf(stderr, "%s: cannot open input layer\n", progname); ++ ++ globfree(&globbuf); ++} +diff -Nru acpid-1.0.8/input_layer.h acpid-1.0.8ted1/input_layer.h +--- acpid-1.0.8/input_layer.h 1970-01-01 01:00:00.000000000 +0100 ++++ acpid-1.0.8ted1/input_layer.h 2008-11-12 23:31:25.000000000 +0100 +@@ -0,0 +1,32 @@ ++/* ++ * input_layer.h - Kernel ACPI Event Input Layer Interface ++ * ++ * Handles the details of getting kernel ACPI events from the input ++ * layer (/dev/input/event*). ++ * ++ * Copyright (C) 2008, Ted Felix (www.tedfelix.com) ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++ * ++ * (tabs at 4) ++ */ ++ ++#ifndef INPUT_LAYER_H__ ++#define INPUT_LAYER_H__ ++ ++/* Open each of the appropriate /dev/input/event* files for input. */ ++extern void open_input(void); ++ ++#endif /* INPUT_LAYER_H__ */ +diff -Nru acpid-1.0.8/libnetlink.c acpid-1.0.8ted1/libnetlink.c +--- acpid-1.0.8/libnetlink.c 1970-01-01 01:00:00.000000000 +0100 ++++ acpid-1.0.8ted1/libnetlink.c 2008-11-14 00:36:54.000000000 +0100 +@@ -0,0 +1,593 @@ ++/* ++ * libnetlink.c RTnetlink service routines. ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License ++ * as published by the Free Software Foundation; either version ++ * 2 of the License, or (at your option) any later version. ++ * ++ * Authors: Alexey Kuznetsov, ++ * ++ * Modified by Ted Felix (www.tedfelix.com) to fix warnings. ++ * ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "libnetlink.h" ++ ++void rtnl_close(struct rtnl_handle *rth) ++{ ++ if (rth->fd >= 0) { ++ close(rth->fd); ++ rth->fd = -1; ++ } ++} ++ ++int rtnl_open_byproto(struct rtnl_handle *rth, unsigned subscriptions, ++ int protocol) ++{ ++ socklen_t addr_len; ++ int sndbuf = 32768; ++ int rcvbuf = 32768; ++ ++ memset(rth, 0, sizeof(rth)); ++ ++ rth->fd = socket(AF_NETLINK, SOCK_RAW, protocol); ++ if (rth->fd < 0) { ++ perror("Cannot open netlink socket"); ++ return -1; ++ } ++ ++ if (setsockopt(rth->fd,SOL_SOCKET,SO_SNDBUF,&sndbuf,sizeof(sndbuf)) < 0) { ++ perror("SO_SNDBUF"); ++ return -1; ++ } ++ ++ if (setsockopt(rth->fd,SOL_SOCKET,SO_RCVBUF,&rcvbuf,sizeof(rcvbuf)) < 0) { ++ perror("SO_RCVBUF"); ++ return -1; ++ } ++ ++ memset(&rth->local, 0, sizeof(rth->local)); ++ rth->local.nl_family = AF_NETLINK; ++ rth->local.nl_groups = subscriptions; ++ ++ if (bind(rth->fd, (struct sockaddr*)&rth->local, sizeof(rth->local)) < 0) { ++ perror("Cannot bind netlink socket"); ++ return -1; ++ } ++ addr_len = sizeof(rth->local); ++ if (getsockname(rth->fd, (struct sockaddr*)&rth->local, &addr_len) < 0) { ++ perror("Cannot getsockname"); ++ return -1; ++ } ++ if (addr_len != sizeof(rth->local)) { ++ fprintf(stderr, "Wrong address length %d\n", addr_len); ++ return -1; ++ } ++ if (rth->local.nl_family != AF_NETLINK) { ++ fprintf(stderr, "Wrong address family %d\n", rth->local.nl_family); ++ return -1; ++ } ++ rth->seq = time(NULL); ++ return 0; ++} ++ ++int rtnl_open(struct rtnl_handle *rth, unsigned subscriptions) ++{ ++ return rtnl_open_byproto(rth, subscriptions, NETLINK_ROUTE); ++} ++ ++int rtnl_wilddump_request(struct rtnl_handle *rth, int family, int type) ++{ ++ struct { ++ struct nlmsghdr nlh; ++ struct rtgenmsg g; ++ } req; ++ struct sockaddr_nl nladdr; ++ ++ memset(&nladdr, 0, sizeof(nladdr)); ++ nladdr.nl_family = AF_NETLINK; ++ ++ memset(&req, 0, sizeof(req)); ++ req.nlh.nlmsg_len = sizeof(req); ++ req.nlh.nlmsg_type = type; ++ req.nlh.nlmsg_flags = NLM_F_ROOT|NLM_F_MATCH|NLM_F_REQUEST; ++ req.nlh.nlmsg_pid = 0; ++ req.nlh.nlmsg_seq = rth->dump = ++rth->seq; ++ req.g.rtgen_family = family; ++ ++ return sendto(rth->fd, (void*)&req, sizeof(req), 0, ++ (struct sockaddr*)&nladdr, sizeof(nladdr)); ++} ++ ++int rtnl_send(struct rtnl_handle *rth, const char *buf, int len) ++{ ++ struct sockaddr_nl nladdr; ++ ++ memset(&nladdr, 0, sizeof(nladdr)); ++ nladdr.nl_family = AF_NETLINK; ++ ++ return sendto(rth->fd, buf, len, 0, (struct sockaddr*)&nladdr, sizeof(nladdr)); ++} ++ ++int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, int len) ++{ ++ struct nlmsghdr nlh; ++ struct sockaddr_nl nladdr; ++ struct iovec iov[2] = { ++ { .iov_base = &nlh, .iov_len = sizeof(nlh) }, ++ { .iov_base = req, .iov_len = len } ++ }; ++ struct msghdr msg = { ++ .msg_name = &nladdr, ++ .msg_namelen = sizeof(nladdr), ++ .msg_iov = iov, ++ .msg_iovlen = 2, ++ }; ++ ++ memset(&nladdr, 0, sizeof(nladdr)); ++ nladdr.nl_family = AF_NETLINK; ++ ++ nlh.nlmsg_len = NLMSG_LENGTH(len); ++ nlh.nlmsg_type = type; ++ nlh.nlmsg_flags = NLM_F_ROOT|NLM_F_MATCH|NLM_F_REQUEST; ++ nlh.nlmsg_pid = 0; ++ nlh.nlmsg_seq = rth->dump = ++rth->seq; ++ ++ return sendmsg(rth->fd, &msg, 0); ++} ++ ++int rtnl_dump_filter(struct rtnl_handle *rth, ++ rtnl_filter_t filter, ++ void *arg1, ++ rtnl_filter_t junk, ++ void *arg2) ++{ ++ struct sockaddr_nl nladdr; ++ struct iovec iov; ++ struct msghdr msg = { ++ .msg_name = &nladdr, ++ .msg_namelen = sizeof(nladdr), ++ .msg_iov = &iov, ++ .msg_iovlen = 1, ++ }; ++ char buf[16384]; ++ ++ iov.iov_base = buf; ++ while (1) { ++ int status; ++ struct nlmsghdr *h; ++ ++ iov.iov_len = sizeof(buf); ++ status = recvmsg(rth->fd, &msg, 0); ++ ++ if (status < 0) { ++ if (errno == EINTR) ++ continue; ++ perror("OVERRUN"); ++ continue; ++ } ++ ++ if (status == 0) { ++ fprintf(stderr, "EOF on netlink\n"); ++ return -1; ++ } ++ ++ h = (struct nlmsghdr*)buf; ++ while (NLMSG_OK(h, (unsigned)status)) { ++ int err; ++ ++ if (nladdr.nl_pid != 0 || ++ h->nlmsg_pid != rth->local.nl_pid || ++ h->nlmsg_seq != rth->dump) { ++ if (junk) { ++ err = junk(&nladdr, h, arg2); ++ if (err < 0) ++ return err; ++ } ++ goto skip_it; ++ } ++ ++ if (h->nlmsg_type == NLMSG_DONE) ++ return 0; ++ if (h->nlmsg_type == NLMSG_ERROR) { ++ struct nlmsgerr *msgerr = (struct nlmsgerr*)NLMSG_DATA(h); ++ if (h->nlmsg_len < NLMSG_LENGTH(sizeof(struct nlmsgerr))) { ++ fprintf(stderr, "ERROR truncated\n"); ++ } else { ++ errno = -msgerr->error; ++ perror("RTNETLINK answers"); ++ } ++ return -1; ++ } ++ err = filter(&nladdr, h, arg1); ++ if (err < 0) ++ return err; ++ ++skip_it: ++ h = NLMSG_NEXT(h, status); ++ } ++ if (msg.msg_flags & MSG_TRUNC) { ++ fprintf(stderr, "Message truncated\n"); ++ continue; ++ } ++ if (status) { ++ fprintf(stderr, "!!!Remnant of size %d\n", status); ++ exit(1); ++ } ++ } ++} ++ ++int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer, ++ unsigned groups, struct nlmsghdr *answer, ++ rtnl_filter_t junk, ++ void *jarg) ++{ ++ int status; ++ unsigned seq; ++ struct nlmsghdr *h; ++ struct sockaddr_nl nladdr; ++ struct iovec iov = { ++ .iov_base = (void*) n, ++ .iov_len = n->nlmsg_len ++ }; ++ struct msghdr msg = { ++ .msg_name = &nladdr, ++ .msg_namelen = sizeof(nladdr), ++ .msg_iov = &iov, ++ .msg_iovlen = 1, ++ }; ++ char buf[16384]; ++ ++ memset(&nladdr, 0, sizeof(nladdr)); ++ nladdr.nl_family = AF_NETLINK; ++ nladdr.nl_pid = peer; ++ nladdr.nl_groups = groups; ++ ++ n->nlmsg_seq = seq = ++rtnl->seq; ++ ++ if (answer == NULL) ++ n->nlmsg_flags |= NLM_F_ACK; ++ ++ status = sendmsg(rtnl->fd, &msg, 0); ++ ++ if (status < 0) { ++ perror("Cannot talk to rtnetlink"); ++ return -1; ++ } ++ ++ memset(buf,0,sizeof(buf)); ++ ++ iov.iov_base = buf; ++ ++ while (1) { ++ iov.iov_len = sizeof(buf); ++ status = recvmsg(rtnl->fd, &msg, 0); ++ ++ if (status < 0) { ++ if (errno == EINTR) ++ continue; ++ perror("OVERRUN"); ++ continue; ++ } ++ if (status == 0) { ++ fprintf(stderr, "EOF on netlink\n"); ++ return -1; ++ } ++ if (msg.msg_namelen != sizeof(nladdr)) { ++ fprintf(stderr, "sender address length == %d\n", msg.msg_namelen); ++ exit(1); ++ } ++ for (h = (struct nlmsghdr*)buf; (unsigned)status >= sizeof(*h); ) { ++ int err; ++ int len = h->nlmsg_len; ++ int l = len - sizeof(*h); ++ ++ if (l<0 || len>status) { ++ if (msg.msg_flags & MSG_TRUNC) { ++ fprintf(stderr, "Truncated message\n"); ++ return -1; ++ } ++ fprintf(stderr, "!!!malformed message: len=%d\n", len); ++ exit(1); ++ } ++ ++ if (nladdr.nl_pid != (unsigned)peer || ++ h->nlmsg_pid != rtnl->local.nl_pid || ++ h->nlmsg_seq != seq) { ++ if (junk) { ++ err = junk(&nladdr, h, jarg); ++ if (err < 0) ++ return err; ++ } ++ /* Don't forget to skip that message. */ ++ status -= NLMSG_ALIGN(len); ++ h = (struct nlmsghdr*)((char*)h + NLMSG_ALIGN(len)); ++ continue; ++ } ++ ++ if (h->nlmsg_type == NLMSG_ERROR) { ++ struct nlmsgerr *msgerr = (struct nlmsgerr*)NLMSG_DATA(h); ++ if ((unsigned)l < sizeof(struct nlmsgerr)) { ++ fprintf(stderr, "ERROR truncated\n"); ++ } else { ++ errno = -msgerr->error; ++ if (errno == 0) { ++ if (answer) ++ memcpy(answer, h, h->nlmsg_len); ++ return 0; ++ } ++ perror("RTNETLINK1 answers"); ++ } ++ return -1; ++ } ++ if (answer) { ++ memcpy(answer, h, h->nlmsg_len); ++ return 0; ++ } ++ ++ fprintf(stderr, "Unexpected reply!!!\n"); ++ ++ status -= NLMSG_ALIGN(len); ++ h = (struct nlmsghdr*)((char*)h + NLMSG_ALIGN(len)); ++ } ++ if (msg.msg_flags & MSG_TRUNC) { ++ fprintf(stderr, "Message truncated\n"); ++ continue; ++ } ++ if (status) { ++ fprintf(stderr, "!!!Remnant of size %d\n", status); ++ exit(1); ++ } ++ } ++} ++ ++int rtnl_listen(struct rtnl_handle *rtnl, ++ rtnl_filter_t handler, ++ void *jarg) ++{ ++ int status; ++ struct nlmsghdr *h; ++ struct sockaddr_nl nladdr; ++ struct iovec iov; ++ struct msghdr msg = { ++ .msg_name = &nladdr, ++ .msg_namelen = sizeof(nladdr), ++ .msg_iov = &iov, ++ .msg_iovlen = 1, ++ }; ++ char buf[8192]; ++ ++ memset(&nladdr, 0, sizeof(nladdr)); ++ nladdr.nl_family = AF_NETLINK; ++ nladdr.nl_pid = 0; ++ nladdr.nl_groups = 0; ++ ++ iov.iov_base = buf; ++ while (1) { ++ iov.iov_len = sizeof(buf); ++ status = recvmsg(rtnl->fd, &msg, 0); ++ ++ if (status < 0) { ++ if (errno == EINTR) ++ continue; ++ perror("OVERRUN"); ++ continue; ++ } ++ if (status == 0) { ++ fprintf(stderr, "EOF on netlink\n"); ++ return -1; ++ } ++ if (msg.msg_namelen != sizeof(nladdr)) { ++ fprintf(stderr, "Sender address length == %d\n", msg.msg_namelen); ++ exit(1); ++ } ++ for (h = (struct nlmsghdr*)buf; (unsigned)status >= sizeof(*h); ) { ++ int err; ++ int len = h->nlmsg_len; ++ int l = len - sizeof(*h); ++ ++ if (l<0 || len>status) { ++ if (msg.msg_flags & MSG_TRUNC) { ++ fprintf(stderr, "Truncated message\n"); ++ return -1; ++ } ++ fprintf(stderr, "!!!malformed message: len=%d\n", len); ++ exit(1); ++ } ++ ++ err = handler(&nladdr, h, jarg); ++ if (err < 0) ++ return err; ++ ++ status -= NLMSG_ALIGN(len); ++ h = (struct nlmsghdr*)((char*)h + NLMSG_ALIGN(len)); ++ } ++ if (msg.msg_flags & MSG_TRUNC) { ++ fprintf(stderr, "Message truncated\n"); ++ continue; ++ } ++ if (status) { ++ fprintf(stderr, "!!!Remnant of size %d\n", status); ++ exit(1); ++ } ++ } ++} ++ ++int rtnl_from_file(FILE *rtnl, rtnl_filter_t handler, ++ void *jarg) ++{ ++ int status; ++ struct sockaddr_nl nladdr; ++ char buf[8192]; ++ struct nlmsghdr *h = (void*)buf; ++ ++ memset(&nladdr, 0, sizeof(nladdr)); ++ nladdr.nl_family = AF_NETLINK; ++ nladdr.nl_pid = 0; ++ nladdr.nl_groups = 0; ++ ++ while (1) { ++ int err, len, type; ++ int l; ++ ++ status = fread(&buf, 1, sizeof(*h), rtnl); ++ ++ if (status < 0) { ++ if (errno == EINTR) ++ continue; ++ perror("rtnl_from_file: fread"); ++ return -1; ++ } ++ if (status == 0) ++ return 0; ++ ++ len = h->nlmsg_len; ++ type= h->nlmsg_type; ++ l = len - sizeof(*h); ++ ++ if (l<0 || (unsigned)len>sizeof(buf)) { ++ fprintf(stderr, "!!!malformed message: len=%d @%lu\n", ++ len, ftell(rtnl)); ++ return -1; ++ } ++ ++ status = fread(NLMSG_DATA(h), 1, NLMSG_ALIGN(l), rtnl); ++ ++ if (status < 0) { ++ perror("rtnl_from_file: fread"); ++ return -1; ++ } ++ if (status < l) { ++ fprintf(stderr, "rtnl-from_file: truncated message\n"); ++ return -1; ++ } ++ ++ err = handler(&nladdr, h, jarg); ++ if (err < 0) ++ return err; ++ } ++} ++ ++int addattr32(struct nlmsghdr *n, int maxlen, int type, __u32 data) ++{ ++ int len = RTA_LENGTH(4); ++ struct rtattr *rta; ++ if ((int)NLMSG_ALIGN(n->nlmsg_len) + len > maxlen) { ++ fprintf(stderr,"addattr32: Error! max allowed bound %d exceeded\n",maxlen); ++ return -1; ++ } ++ rta = NLMSG_TAIL(n); ++ rta->rta_type = type; ++ rta->rta_len = len; ++ memcpy(RTA_DATA(rta), &data, 4); ++ n->nlmsg_len = NLMSG_ALIGN(n->nlmsg_len) + len; ++ return 0; ++} ++ ++int addattr_l(struct nlmsghdr *n, int maxlen, int type, const void *data, ++ int alen) ++{ ++ int len = RTA_LENGTH(alen); ++ struct rtattr *rta; ++ ++ if ((int)NLMSG_ALIGN(n->nlmsg_len) + RTA_ALIGN(len) > maxlen) { ++ fprintf(stderr, "addattr_l ERROR: message exceeded bound of %d\n",maxlen); ++ return -1; ++ } ++ rta = NLMSG_TAIL(n); ++ rta->rta_type = type; ++ rta->rta_len = len; ++ memcpy(RTA_DATA(rta), data, alen); ++ n->nlmsg_len = NLMSG_ALIGN(n->nlmsg_len) + RTA_ALIGN(len); ++ return 0; ++} ++ ++int addraw_l(struct nlmsghdr *n, int maxlen, const void *data, int len) ++{ ++ if ((int)NLMSG_ALIGN(n->nlmsg_len) + NLMSG_ALIGN(len) > maxlen) { ++ fprintf(stderr, "addraw_l ERROR: message exceeded bound of %d\n",maxlen); ++ return -1; ++ } ++ ++ memcpy(NLMSG_TAIL(n), data, len); ++ memset((void *) NLMSG_TAIL(n) + len, 0, NLMSG_ALIGN(len) - len); ++ n->nlmsg_len = NLMSG_ALIGN(n->nlmsg_len) + NLMSG_ALIGN(len); ++ return 0; ++} ++ ++int rta_addattr32(struct rtattr *rta, int maxlen, int type, __u32 data) ++{ ++ int len = RTA_LENGTH(4); ++ struct rtattr *subrta; ++ ++ if (RTA_ALIGN(rta->rta_len) + len > maxlen) { ++ fprintf(stderr,"rta_addattr32: Error! max allowed bound %d exceeded\n",maxlen); ++ return -1; ++ } ++ subrta = (struct rtattr*)(((char*)rta) + RTA_ALIGN(rta->rta_len)); ++ subrta->rta_type = type; ++ subrta->rta_len = len; ++ memcpy(RTA_DATA(subrta), &data, 4); ++ rta->rta_len = NLMSG_ALIGN(rta->rta_len) + len; ++ return 0; ++} ++ ++int rta_addattr_l(struct rtattr *rta, int maxlen, int type, ++ const void *data, int alen) ++{ ++ struct rtattr *subrta; ++ int len = RTA_LENGTH(alen); ++ ++ if (RTA_ALIGN(rta->rta_len) + RTA_ALIGN(len) > maxlen) { ++ fprintf(stderr,"rta_addattr_l: Error! max allowed bound %d exceeded\n",maxlen); ++ return -1; ++ } ++ subrta = (struct rtattr*)(((char*)rta) + RTA_ALIGN(rta->rta_len)); ++ subrta->rta_type = type; ++ subrta->rta_len = len; ++ memcpy(RTA_DATA(subrta), data, alen); ++ rta->rta_len = NLMSG_ALIGN(rta->rta_len) + RTA_ALIGN(len); ++ return 0; ++} ++ ++int parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len) ++{ ++ memset(tb, 0, sizeof(struct rtattr *) * (max + 1)); ++ while (RTA_OK(rta, len)) { ++ if (rta->rta_type <= max) ++ tb[rta->rta_type] = rta; ++ rta = RTA_NEXT(rta,len); ++ } ++ if (len) ++ fprintf(stderr, "!!!Deficit %d, rta_len=%d\n", len, rta->rta_len); ++ return 0; ++} ++ ++int parse_rtattr_byindex(struct rtattr *tb[], int max, struct rtattr *rta, int len) ++{ ++ int i = 0; ++ ++ memset(tb, 0, sizeof(struct rtattr *) * max); ++ while (RTA_OK(rta, len)) { ++ if (rta->rta_type <= max && i < max) ++ tb[i++] = rta; ++ rta = RTA_NEXT(rta,len); ++ } ++ if (len) ++ fprintf(stderr, "!!!Deficit %d, rta_len=%d\n", len, rta->rta_len); ++ return i; ++} +diff -Nru acpid-1.0.8/libnetlink.h acpid-1.0.8ted1/libnetlink.h +--- acpid-1.0.8/libnetlink.h 1970-01-01 01:00:00.000000000 +0100 ++++ acpid-1.0.8ted1/libnetlink.h 2008-11-09 22:19:54.000000000 +0100 +@@ -0,0 +1,91 @@ ++#ifndef __LIBNETLINK_H__ ++#define __LIBNETLINK_H__ 1 ++ ++#include ++// needed by netlink.h, should be in there ++#include ++#include ++#include ++ ++struct rtnl_handle ++{ ++ int fd; ++ struct sockaddr_nl local; ++ struct sockaddr_nl peer; ++ __u32 seq; ++ __u32 dump; ++}; ++ ++extern int rtnl_open(struct rtnl_handle *rth, unsigned subscriptions); ++extern int rtnl_open_byproto(struct rtnl_handle *rth, unsigned subscriptions, int protocol); ++extern void rtnl_close(struct rtnl_handle *rth); ++extern int rtnl_wilddump_request(struct rtnl_handle *rth, int fam, int type); ++extern int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, int len); ++ ++typedef int (*rtnl_filter_t)(const struct sockaddr_nl *, ++ struct nlmsghdr *n, void *); ++extern int rtnl_dump_filter(struct rtnl_handle *rth, rtnl_filter_t filter, ++ void *arg1, ++ rtnl_filter_t junk, ++ void *arg2); ++extern int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer, ++ unsigned groups, struct nlmsghdr *answer, ++ rtnl_filter_t junk, ++ void *jarg); ++extern int rtnl_send(struct rtnl_handle *rth, const char *buf, int); ++ ++ ++extern int addattr32(struct nlmsghdr *n, int maxlen, int type, __u32 data); ++extern int addattr_l(struct nlmsghdr *n, int maxlen, int type, const void *data, int alen); ++extern int addraw_l(struct nlmsghdr *n, int maxlen, const void *data, int len); ++extern int rta_addattr32(struct rtattr *rta, int maxlen, int type, __u32 data); ++extern int rta_addattr_l(struct rtattr *rta, int maxlen, int type, const void *data, int alen); ++ ++extern int parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len); ++extern int parse_rtattr_byindex(struct rtattr *tb[], int max, struct rtattr *rta, int len); ++ ++#define parse_rtattr_nested(tb, max, rta) \ ++ (parse_rtattr((tb), (max), RTA_DATA(rta), RTA_PAYLOAD(rta))) ++ ++extern int rtnl_listen(struct rtnl_handle *, rtnl_filter_t handler, ++ void *jarg); ++extern int rtnl_from_file(FILE *, rtnl_filter_t handler, ++ void *jarg); ++ ++#define NLMSG_TAIL(nmsg) \ ++ ((struct rtattr *) (((void *) (nmsg)) + NLMSG_ALIGN((nmsg)->nlmsg_len))) ++ ++#ifndef IFA_RTA ++#define IFA_RTA(r) \ ++ ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifaddrmsg)))) ++#endif ++#ifndef IFA_PAYLOAD ++#define IFA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifaddrmsg)) ++#endif ++ ++#ifndef IFLA_RTA ++#define IFLA_RTA(r) \ ++ ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifinfomsg)))) ++#endif ++#ifndef IFLA_PAYLOAD ++#define IFLA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifinfomsg)) ++#endif ++ ++#ifndef NDA_RTA ++#define NDA_RTA(r) \ ++ ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ndmsg)))) ++#endif ++#ifndef NDA_PAYLOAD ++#define NDA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ndmsg)) ++#endif ++ ++#ifndef NDTA_RTA ++#define NDTA_RTA(r) \ ++ ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ndtmsg)))) ++#endif ++#ifndef NDTA_PAYLOAD ++#define NDTA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ndtmsg)) ++#endif ++ ++#endif /* __LIBNETLINK_H__ */ ++ +diff -Nru acpid-1.0.8/Makefile acpid-1.0.8ted1/Makefile +--- acpid-1.0.8/Makefile 2008-10-29 04:48:52.000000000 +0100 ++++ acpid-1.0.8ted1/Makefile 2008-12-12 02:48:05.000000000 +0100 +@@ -12,7 +12,8 @@ + BIN_PROGS = acpi_listen + PROGS = $(SBIN_PROGS) $(BIN_PROGS) + +-acpid_SRCS = acpid.c event.c ud_socket.c ++acpid_SRCS = acpid.c acpi_ids.c connection_list.c event.c input_layer.c \ ++ libnetlink.c netlink.c proc.c sock.c ud_socket.c + acpid_OBJS = $(acpid_SRCS:.c=.o) + + acpi_listen_SRCS = acpi_listen.c ud_socket.c +diff -Nru acpid-1.0.8/netlink.c acpid-1.0.8ted1/netlink.c +--- acpid-1.0.8/netlink.c 1970-01-01 01:00:00.000000000 +0100 ++++ acpid-1.0.8ted1/netlink.c 2008-11-15 02:42:51.000000000 +0100 +@@ -0,0 +1,239 @@ ++/* ++ * netlink.c - Kernel ACPI Event Netlink Interface ++ * ++ * Handles the details of getting kernel ACPI events from netlink. ++ * ++ * Inspired by (and in some cases blatantly lifted from) Zhang Rui's ++ * acpi_genl and Alexey Kuznetsov's libnetlink. Thanks also to Yi Yang ++ * at intel. ++ * ++ * Copyright (C) 2008, Ted Felix (www.tedfelix.com) ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++ * ++ * (tabs at 4) ++ */ ++ ++/* system */ ++#include ++#include ++#include ++#include ++#include ++ ++/* local */ ++#include "acpid.h" ++#include "event.h" ++ ++#include "libnetlink.h" ++#include "genetlink.h" ++#include "acpi_genetlink.h" ++ ++#include "acpi_ids.h" ++#include "connection_list.h" ++ ++static void ++format_netlink(struct nlmsghdr *msg) ++{ ++ struct rtattr *tb[ACPI_GENL_ATTR_MAX + 1]; ++ struct genlmsghdr *ghdr = NLMSG_DATA(msg); ++ int len; ++ struct rtattr *attrs; ++ ++ len = msg->nlmsg_len; ++ ++ /* if this message doesn't have the proper family ID, drop it */ ++ if (msg->nlmsg_type != acpi_ids_getfamily()) { ++ if (logevents) { ++ acpid_log(LOG_INFO, "wrong netlink family ID.\n"); ++ } ++ return; ++ } ++ ++ len -= NLMSG_LENGTH(GENL_HDRLEN); ++ ++ if (len < 0) { ++ acpid_log(LOG_WARNING, ++ "wrong netlink controller message len: %d\n", len); ++ return; ++ } ++ ++ attrs = (struct rtattr *)((char *)ghdr + GENL_HDRLEN); ++ /* parse the attributes in this message */ ++ parse_rtattr(tb, ACPI_GENL_ATTR_MAX, attrs, len); ++ ++ /* if there's an ACPI event attribute... */ ++ if (tb[ACPI_GENL_ATTR_EVENT]) { ++ /* get the actual event struct */ ++ struct acpi_genl_event *event = ++ RTA_DATA(tb[ACPI_GENL_ATTR_EVENT]); ++ char buf[64]; ++ ++ /* format it */ ++ snprintf(buf, sizeof(buf), "%s %s %08x %08x", ++ event->device_class, event->bus_id, event->type, event->data); ++ ++ /* if we're locked, don't process the event */ ++ if (locked()) { ++ if (logevents) { ++ acpid_log(LOG_INFO, ++ "lockfile present, not processing " ++ "netlink event \"%s\"\n", buf); ++ } ++ return; ++ } ++ ++ if (logevents) ++ acpid_log(LOG_INFO, ++ "received netlink event \"%s\"\n", buf); ++ ++ /* send the event off to the handler */ ++ acpid_handle_event(buf); ++ ++ if (logevents) ++ acpid_log(LOG_INFO, ++ "completed netlink event \"%s\"\n", buf); ++ } ++} ++ ++/* (based on rtnl_listen() in libnetlink.c) */ ++void ++process_netlink(int fd) ++{ ++ int status; ++ struct nlmsghdr *h; ++ /* the address for recvmsg() */ ++ struct sockaddr_nl nladdr; ++ /* the io vector for recvmsg() */ ++ struct iovec iov; ++ /* recvmsg() parameters */ ++ struct msghdr msg = { ++ .msg_name = &nladdr, ++ .msg_namelen = sizeof(nladdr), ++ .msg_iov = &iov, ++ .msg_iovlen = 1, ++ }; ++ /* buffer for the incoming data */ ++ char buf[8192]; ++ static int nerrs; ++ ++ /* set up the netlink address */ ++ memset(&nladdr, 0, sizeof(nladdr)); ++ nladdr.nl_family = AF_NETLINK; ++ nladdr.nl_pid = 0; ++ nladdr.nl_groups = 0; ++ ++ /* set up the I/O vector */ ++ iov.iov_base = buf; ++ iov.iov_len = sizeof(buf); ++ ++ /* read the data into the buffer */ ++ status = recvmsg(fd, &msg, 0); ++ ++ /* if there was a problem, print a message and keep trying */ ++ if (status < 0) { ++ /* if we were interrupted by a signal, bail */ ++ if (errno == EINTR) ++ return; ++ ++ acpid_log(LOG_ERR, "netlink read error: %s (%d)\n", ++ strerror(errno), errno); ++ if (++nerrs >= ACPID_MAX_ERRS) { ++ acpid_log(LOG_ERR, ++ "too many errors reading via " ++ "netlink - aborting\n"); ++ exit(EXIT_FAILURE); ++ } ++ return; ++ } ++ /* if an orderly shutdown has occurred, we're done */ ++ if (status == 0) { ++ acpid_log(LOG_WARNING, "netlink connection closed\n"); ++ exit(EXIT_FAILURE); ++ } ++ /* check to see if the address length has changed */ ++ if (msg.msg_namelen != sizeof(nladdr)) { ++ acpid_log(LOG_WARNING, "netlink unexpected length: " ++ "%d expected: %d\n", msg.msg_namelen, sizeof(nladdr)); ++ return; ++ } ++ ++ /* for each message received */ ++ for (h = (struct nlmsghdr*)buf; (unsigned)status >= sizeof(*h); ) { ++ int len = h->nlmsg_len; ++ int l = len - sizeof(*h); ++ ++ if (l < 0 || len > status) { ++ if (msg.msg_flags & MSG_TRUNC) { ++ acpid_log(LOG_WARNING, "netlink msg truncated (1)\n"); ++ return; ++ } ++ acpid_log(LOG_WARNING, ++ "malformed netlink msg, length %d\n", len); ++ return; ++ } ++ ++ /* format the message */ ++ format_netlink(h); ++ ++ status -= NLMSG_ALIGN(len); ++ h = (struct nlmsghdr*)((char*)h + NLMSG_ALIGN(len)); ++ } ++ if (msg.msg_flags & MSG_TRUNC) { ++ acpid_log(LOG_WARNING, "netlink msg truncated (2)\n"); ++ return; ++ } ++ if (status) { ++ acpid_log(LOG_WARNING, "netlink remnant of size %d\n", status); ++ return; ++ } ++ ++ return; ++} ++ ++/* convert the netlink multicast group number into a bit map */ ++/* (e.g. 4 => 16, 5 => 32) */ ++static __u32 ++nl_mgrp(__u32 group) ++{ ++ if (group > 31) { ++ fprintf(stderr, "%s: unexpected group number %d\n", ++ progname, group); ++ return 0; ++ } ++ return group ? (1 << (group - 1)) : 0; ++} ++ ++void open_netlink(void) ++{ ++ struct rtnl_handle rth; ++ struct connection c; ++ ++ /* open the appropriate netlink socket for input */ ++ if (rtnl_open_byproto( ++ &rth, nl_mgrp(acpi_ids_getgroup()), NETLINK_GENERIC) < 0) { ++ fprintf(stderr, "%s: cannot open generic netlink socket\n", ++ progname); ++ return; ++ } ++ ++ if (acpid_debug) ++ fprintf(stderr, "%s: netlink opened successfully\n", progname); ++ ++ /* add a connection to the list */ ++ c.fd = rth.fd; ++ c.process = process_netlink; ++ add_connection(&c); ++} +diff -Nru acpid-1.0.8/netlink.h acpid-1.0.8ted1/netlink.h +--- acpid-1.0.8/netlink.h 1970-01-01 01:00:00.000000000 +0100 ++++ acpid-1.0.8ted1/netlink.h 2008-11-14 00:40:06.000000000 +0100 +@@ -0,0 +1,31 @@ ++/* ++ * netlink.h - Kernel ACPI Event Netlink Interface ++ * ++ * Handles the details of getting kernel ACPI events from netlink. ++ * ++ * Copyright (C) 2008, Ted Felix (www.tedfelix.com) ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++ * ++ * (tabs at 4) ++ */ ++ ++#ifndef NETLINK_H__ ++#define NETLINK_H__ ++ ++/* open the netlink connection */ ++extern void open_netlink(void); ++ ++#endif /* NETLINK_H__ */ +diff -Nru acpid-1.0.8/proc.c acpid-1.0.8ted1/proc.c +--- acpid-1.0.8/proc.c 1970-01-01 01:00:00.000000000 +0100 ++++ acpid-1.0.8ted1/proc.c 2008-11-15 04:04:02.000000000 +0100 +@@ -0,0 +1,206 @@ ++/* ++ * proc.c - ACPI daemon proc filesystem interface ++ * ++ * Portions Copyright (C) 2000 Andrew Henroid ++ * Portions Copyright (C) 2001 Sun Microsystems ++ * Portions Copyright (C) 2004 Tim Hockin (thockin@hockin.org) ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "acpid.h" ++#include "event.h" ++#include "connection_list.h" ++ ++const char *eventfile = ACPID_EVENTFILE; ++ ++static char *read_line(int fd); ++ ++static void ++process_proc(int fd) ++{ ++ char *event; ++ ++ /* read an event */ ++ event = read_line(fd); ++ ++ /* if we're locked, don't process the event */ ++ if (locked()) { ++ if (logevents && event != NULL) { ++ acpid_log(LOG_INFO, ++ "lockfile present, not processing " ++ "event \"%s\"\n", event); ++ } ++ return; ++ } ++ ++ /* handle the event */ ++ if (event) { ++ if (logevents) { ++ acpid_log(LOG_INFO, ++ "procfs received event \"%s\"\n", event); ++ } ++ acpid_handle_event(event); ++ if (logevents) { ++ acpid_log(LOG_INFO, ++ "procfs completed event \"%s\"\n", event); ++ } ++ } else if (errno == EPIPE) { ++ acpid_log(LOG_WARNING, ++ "events file connection closed\n"); ++ exit(EXIT_FAILURE); ++ } else { ++ static int nerrs; ++ if (++nerrs >= ACPID_MAX_ERRS) { ++ acpid_log(LOG_ERR, ++ "too many errors reading " ++ "events file - aborting\n"); ++ exit(EXIT_FAILURE); ++ } ++ } ++} ++ ++int ++open_proc() ++{ ++ int fd; ++ struct connection c; ++ ++ fd = open(eventfile, O_RDONLY); ++ if (fd < 0) { ++ fprintf(stderr, "%s: can't open %s: %s\n", progname, ++ eventfile, strerror(errno)); ++ return -1; ++ } ++ fcntl(fd, F_SETFD, FD_CLOEXEC); ++ ++ if (acpid_debug) ++ fprintf(stderr, "%s: proc fs opened successfully\n", progname); ++ ++ /* add a connection to the list */ ++ c.fd = fd; ++ c.process = process_proc; ++ add_connection(&c); ++ ++ return 0; ++} ++ ++/* ++ * This depends on fixes in linux ACPI after 2.4.8 ++ */ ++#define BUFLEN 1024 ++static char * ++read_line(int fd) ++{ ++ static char buf[BUFLEN]; ++ int i = 0; ++ int r; ++ int searching = 1; ++ ++ while (searching) { ++ memset(buf+i, 0, BUFLEN-i); ++ ++ /* only go to BUFLEN-1 so there will always be a 0 at the end */ ++ while (i < BUFLEN-1) { ++ r = read(fd, buf+i, 1); ++ if (r < 0 && errno != EINTR) { ++ /* we should do something with the data */ ++ acpid_log(LOG_ERR, "read(): %s\n", ++ strerror(errno)); ++ return NULL; ++ } else if (r == 0) { ++ /* signal this in an almost standard way */ ++ errno = EPIPE; ++ return NULL; ++ } else if (r == 1) { ++ /* scan for a newline */ ++ if (buf[i] == '\n') { ++ searching = 0; ++ buf[i] = '\0'; ++ break; ++ } ++ i++; ++ } ++ } ++ if (i >= BUFLEN - 1) ++ break; ++ } ++ ++ return buf; ++} ++ ++#if 0 ++/* This version leaks memory. The above version is simpler and leak-free. */ ++/* Downside is that the above version always uses 1k of RAM. */ ++/* ++ * This depends on fixes in linux ACPI after 2.4.8 ++ */ ++#define MAX_BUFLEN 1024 ++static char * ++read_line(int fd) ++{ ++ static char *buf; ++ int buflen = 64; ++ int i = 0; ++ int r; ++ int searching = 1; ++ ++ while (searching) { ++ /* ??? This memory is leaked since it is never freed */ ++ buf = realloc(buf, buflen); ++ if (!buf) { ++ acpid_log(LOG_ERR, "malloc(%d): %s\n", ++ buflen, strerror(errno)); ++ return NULL; ++ } ++ memset(buf+i, 0, buflen-i); ++ ++ while (i < buflen) { ++ r = read(fd, buf+i, 1); ++ if (r < 0 && errno != EINTR) { ++ /* we should do something with the data */ ++ acpid_log(LOG_ERR, "read(): %s\n", ++ strerror(errno)); ++ return NULL; ++ } else if (r == 0) { ++ /* signal this in an almost standard way */ ++ errno = EPIPE; ++ return NULL; ++ } else if (r == 1) { ++ /* scan for a newline */ ++ if (buf[i] == '\n') { ++ searching = 0; ++ buf[i] = '\0'; ++ break; ++ } ++ i++; ++ } ++ } ++ if (buflen >= MAX_BUFLEN) { ++ break; ++ } ++ buflen *= 2; ++ } ++ ++ return buf; ++} ++#endif +diff -Nru acpid-1.0.8/proc.h acpid-1.0.8ted1/proc.h +--- acpid-1.0.8/proc.h 1970-01-01 01:00:00.000000000 +0100 ++++ acpid-1.0.8ted1/proc.h 2008-11-14 01:06:53.000000000 +0100 +@@ -0,0 +1,30 @@ ++/* ++ * proc.h - ACPI daemon proc filesystem interface ++ * ++ * Portions Copyright (C) 2000 Andrew Henroid ++ * Portions Copyright (C) 2001 Sun Microsystems ++ * Portions Copyright (C) 2004 Tim Hockin (thockin@hockin.org) ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++ */ ++ ++#ifndef PROC_H__ ++#define PROC_H__ ++ ++extern const char *eventfile; ++ ++extern int open_proc(); ++ ++#endif /* PROC_H__ */ +diff -Nru acpid-1.0.8/sock.c acpid-1.0.8ted1/sock.c +--- acpid-1.0.8/sock.c 1970-01-01 01:00:00.000000000 +0100 ++++ acpid-1.0.8ted1/sock.c 2008-11-15 00:48:06.000000000 +0100 +@@ -0,0 +1,98 @@ ++/* ++ * sock.c - ACPI daemon socket interface ++ * ++ * Portions Copyright (C) 2000 Andrew Henroid ++ * Portions Copyright (C) 2001 Sun Microsystems ++ * Portions Copyright (C) 2004 Tim Hockin (thockin@hockin.org) ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "acpid.h" ++#include "event.h" ++#include "ud_socket.h" ++#include "connection_list.h" ++ ++const char *socketfile = ACPID_SOCKETFILE; ++const char *socketgroup; ++mode_t socketmode = ACPID_SOCKETMODE; ++ ++static void ++process_sock(int fd) ++{ ++ int cli_fd; ++ struct ucred creds; ++ char buf[32]; ++ ++ /* accept and add to our lists */ ++ cli_fd = ud_accept(fd, &creds); ++ if (cli_fd < 0) { ++ acpid_log(LOG_ERR, "can't accept client: %s\n", ++ strerror(errno)); ++ return; ++ } ++ 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); ++} ++ ++void ++open_sock() ++{ ++ int fd; ++ struct connection c; ++ ++ fd = ud_create_socket(socketfile); ++ if (fd < 0) { ++ fprintf(stderr, "%s: can't open socket %s: %s\n", ++ progname, socketfile, strerror(errno)); ++ exit(EXIT_FAILURE); ++ } ++ fcntl(fd, F_SETFD, FD_CLOEXEC); ++ chmod(socketfile, socketmode); ++ if (socketgroup) { ++ struct group *gr; ++ struct stat buf; ++ gr = getgrnam(socketgroup); ++ if (!gr) { ++ fprintf(stderr, "%s: group %s does not exist\n", ++ progname, socketgroup); ++ exit(EXIT_FAILURE); ++ } ++ if (stat(socketfile, &buf) < 0) { ++ fprintf(stderr, "%s: can't stat %s\n", ++ progname, socketfile); ++ exit(EXIT_FAILURE); ++ } ++ if (chown(socketfile, buf.st_uid, gr->gr_gid) < 0) { ++ fprintf(stderr, "%s: chown(): %s\n", ++ progname, strerror(errno)); ++ exit(EXIT_FAILURE); ++ } ++ } ++ ++ /* add a connection to the list */ ++ c.fd = fd; ++ c.process = process_sock; ++ add_connection(&c); ++} +diff -Nru acpid-1.0.8/sock.h acpid-1.0.8ted1/sock.h +--- acpid-1.0.8/sock.h 1970-01-01 01:00:00.000000000 +0100 ++++ acpid-1.0.8ted1/sock.h 2008-11-13 02:13:56.000000000 +0100 +@@ -0,0 +1,32 @@ ++/* ++ * sock.h - ACPI daemon socket interface ++ * ++ * Portions Copyright (C) 2000 Andrew Henroid ++ * Portions Copyright (C) 2001 Sun Microsystems ++ * Portions Copyright (C) 2004 Tim Hockin (thockin@hockin.org) ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++ */ ++ ++#ifndef SOCK_H__ ++#define SOCK_H__ ++ ++extern const char *socketfile; ++extern const char *socketgroup; ++extern mode_t socketmode; ++ ++extern void open_sock(); ++ ++#endif /* SOCK_H__ */ --- acpid-1.0.8.orig/debian/patches/series +++ acpid-1.0.8/debian/patches/series @@ -0,0 +1,3 @@ +event.c.diff +fixfd.diff +netlink.diff --- acpid-1.0.8.orig/debian/patches/fixfd.diff +++ acpid-1.0.8/debian/patches/fixfd.diff @@ -0,0 +1,12 @@ +diff -Nru a/acpid.c b/acpid.c +--- a/acpid.c 2008-11-03 14:04:43.000000000 +0100 ++++ b/acpid.c 2008-12-19 18:38:14.291127677 +0100 +@@ -456,7 +456,7 @@ + int log_opts; + + /* open /dev/null */ +- nullfd = open("/dev/null", O_RDONLY); ++ nullfd = open("/dev/null", O_RDWR); + if (nullfd < 0) { + fprintf(stderr, "%s: can't open %s: %s\n", progname, + "/dev/null", strerror(errno));