Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 65211 - apcupsd cannot issue killpower command to UPS because /usr/sbin is no longer mounted
Summary: apcupsd cannot issue killpower command to UPS because /usr/sbin is no longer ...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Michael Imhof (RETIRED)
URL:
Whiteboard:
Keywords:
: 116349 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-09-24 08:02 UTC by Nathan Thompson
Modified: 2008-02-13 00:34 UTC (History)
9 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Initial ebuild for 3.14.2 (apcupsd-3.14.2.ebuild,3.25 KB, text/plain)
2007-10-06 03:49 UTC, Chris Bandy
Details
Updated patch for 3.14.2 (apcupsd-3.14.2-apccontrol-gentoo.patch,401 bytes, text/plain)
2007-10-06 03:50 UTC, Chris Bandy
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nathan Thompson 2004-09-24 08:02:25 UTC
apcupsd's ebuild (3.10.13 and 3.10.15-r1) configure the sbin directory to be in /usr/sbin rather than /sbin and loggging to be in /var/log rather than /etc/apcupsd.  This is fine for normal operations, but when a power failure occurs and the ups batteries become exhasted, the killpower command can not be run if /usr and/or /var are separate mountpoints from root (/).

Note that I have modifed /etc/init.d/halt.sh to include essentially the code in /etc/init.d/halt at the end of the file (after unmounting and remounting root read-only).

Reproducible: Always
Steps to Reproduce:
1. Configure drive partitions to have separate mount points for {/,/usr,/var}
2. emerge & configure apcupsd
3. unplug power from UPS, let batteries drain
4. When apcupsd shuts down the system /usr and /var are unmounted
5. code at end of halt.sh issues command `/etc/apcupsd/apccontrol killpower`
6. previous command tries to call `/usr/sbin/apcupsd --killpower` but /usr is no longer mounted. (and if you copy apcupsd to /sbin it will bomb out because it cannot log to /var/log/apcupsd.events).

Actual Results:  
/usr/sbin/apcupsd does not exist (because /usr is not mounted).  Results in UPS
never being powered down.

Expected Results:  
issued killpower command to UPS, resulting in UPS turning itself off.
Comment 1 Michael Imhof (RETIRED) gentoo-dev 2005-09-05 05:48:00 UTC
If this problem still exists for apcupsd-3.10.18 then feel free to reopen this bug.
Comment 2 Jakub Moc (RETIRED) gentoo-dev 2005-12-22 00:02:39 UTC
*** Bug 116349 has been marked as a duplicate of this bug. ***
Comment 3 Jakub Moc (RETIRED) gentoo-dev 2005-12-22 00:02:57 UTC
Still unfixed, reopen.
Comment 4 Daniel 2005-12-29 04:50:50 UTC
(In reply to comment #3)
> Still unfixed, reopen.
> 
the same occurs here using 3.10.18-r1

--> /usr/sbin/apcupsd not found - which is clear, because /usr was unmounted just before :-/
Comment 5 Fernando Loureiro 2006-08-10 15:36:56 UTC
(In reply to comment #4)
> (In reply to comment #3)
> > Still unfixed, reopen.
> > 
> the same occurs here using 3.10.18-r1
> 
> --> /usr/sbin/apcupsd not found - which is clear, because /usr was unmounted
> just before :-/
> 

Is it already ok? =/
Comment 6 Matteo Guglielmi 2007-02-17 18:26:09 UTC
(In reply to comment #0)

> Note that I have modifed /etc/init.d/halt.sh to include essentially the code in
> /etc/init.d/halt at the end of the file (after unmounting and remounting root
> read-only).
> 

The same problem here (/usr, /var, /home, /tmp and /opt on LVM2).

How did you modify the "halt.sh" script in order to mount readonly /usr?

And what about the log file /var/log/apcupsd.events? Is there any problem with apcupsd if he cannot access it?

Thanks. 
Comment 7 CJ Kucera 2007-03-18 23:46:01 UTC
Yeah, I just ran into this too.  It seems like apcupsd is the kind of executable that should really be going into /sbin anyway...  Seems like that'd be a pretty quick fix, and that seems to be the recommended installation method, a la: http://www.apcupsd.org/manual/Building_Installing_apcupsd.html#SECTION000115000000000000000
Comment 8 CJ Kucera 2007-03-18 23:51:14 UTC
Well, looks like the most recent ~x86 (3.12.4) already does the install-to-/sbin trick, so I guess I'll just move to that instead of putting together a patch for this version.
Comment 9 parafin 2007-06-27 18:37:55 UTC
It still doesn't work even with binary in /sbin, because it linked with libstdc++ (and one more library), which is located in (yeah, you guessed it) /usr. See bug #178931. I don't see any possible solution to be honest, cause you can't build apcupsd staticly, because it uses pthreads and you can't switch it off. Is there a way to staticly link only some libraries to executable?
Anyway, there is a quick workaround:
1. mkdir /root/root ; mount --bind / /root/root
2. mkdir /root/root/usr/lib ; cp -a /usr/lib/gcc /root/root/usr/lib/
3. umount /root/root ; rmdir /root/root
Now it works fine, but it's not a real solution.
Comment 10 Chris Bandy 2007-10-06 03:47:52 UTC
good news: apcupsd-3.14.2 no longer links to libstdc++

it does however link to libnetsnmp and libcrypt (both in /usr/lib), but only with certain configure arguments / use variables.

setting USE="-snmp" (configure --disable-net-snmp) appears to remove this dependency and allow apcupsd to run with /usr unmounted, i.e. power-down the battery during shutdown.

No alteration of halt.sh is required. I did not try EVERY combination of USE variables, so if you find a build parameter that links user libs again please post your results.

I will attach the updated ebuild and new patch I used. Other patches are from 3.14.1 in portage.
Comment 11 Chris Bandy 2007-10-06 03:49:23 UTC
Created attachment 132698 [details]
Initial ebuild for 3.14.2
Comment 12 Chris Bandy 2007-10-06 03:50:39 UTC
Created attachment 132700 [details]
Updated patch for 3.14.2
Comment 13 Michael Imhof (RETIRED) gentoo-dev 2007-11-26 08:18:41 UTC
In cvs.
Could you please check?
Comment 14 Jakub Moc (RETIRED) gentoo-dev 2008-02-13 00:34:42 UTC
*apcupsd-3.14.2 (26 Nov 2007)

  26 Nov 2007; Michael Imhof <tantive@gentoo.org>
  +files/3.14.2/apcupsd.in.patch, +files/3.14.2/apcupsd.initd,
  +files/3.14.2/etc.patch, +files/3.14.2/no-parallel.patch,
  +apcupsd-3.14.2.ebuild:
  Version bump. Closes #65211, #197022.