Package: acpid
Version: 1.0.4-3
Severity: normal

Hello,

I found a rather strange bug in a "client" of acpid: laptop-mode-tools
When on verbose mode, this handler writes its output with >/dev/stdout
The very weird consequence is that /var/log/acpid is emptied by this!

A short experience to highlight the problem:
    $ echo one > /tmp/t; ( echo two >/dev/stdout ) >> /tmp/t;cat /tmp/t
    two
Yes, kinda counter-intuitive, it took me time to understand :-)
So you can indeed destroy the content of a file even with the >> operator
as you reopen the file but, thie time, not in append mode

I reported the problem to the laptop-mode-utils maintainer, cf #348923
as the problem could be solved by using >>/dev/stdout
but I think something should also be done in acpid to handle properly
the output of the handlers without destroying its own logfile.

One way could be to use a syslog mechanism as suggested already
a long time ago by #178894

Another way is, instead of giving the file descriptor to the handler,
(fd1 of acpid becomes /var/log/acpid and sons herit copies of the same fd)
to give a pipe as stdout/stderr descriptors to the handlers and
to transfer yourself the pipe content to the log file. 
Sth like this if acpid was in bash:
exec >>/var/log/acpid; m=$(handler); echo $m
versus the direct method used by acpid:
exec >>/var/log/acpid; handler

Note that if you play the same game under cygwin (still using bash)
    $ echo one > /tmp/t; ( echo two >/dev/stdout ) >> /tmp/t;cat /tmp/t
    one
    two
because here /dev/stdout is not a real file/link but is directly
interpreted by the bash.

Giving the log fd to the handlers can lead to other problems if, for example, 
a handler tries to drop its privileges (as it's always good to be non-root each 
time you can). Then the handler cannot even access to /dev/stdout.

Phil


-- System Information:
Debian Release: testing/unstable
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable'), (500, 'stable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.15-1-686
Locale: [EMAIL PROTECTED], [EMAIL PROTECTED] (charmap=ISO-8859-15)

Versions of packages acpid depends on:
ii  debconf [debconf-2.0]         1.4.67     Debian configuration management sy

acpid recommends no packages.

-- debconf information:
  acpid/noacpi:
* acpid/modules: all


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to