[Nut-upsdev] "upsdrvctl shutdown" ignores "-u"

Arjen de Korte nut+devel at de-korte.org
Sat Jan 12 09:57:37 UTC 2008


> it seems to me that "upsdrvctl shutdown" fails to pass the "-u" flag to
> the driver.  See drivers/upsdrvctl.c:shutdown_driver(), and compare to
> start_driver() in the same file. This has been so since ancient
> history (I checked back to 1.5.0), so there must be a reason, but I
> can't think of any.

I think the reason if fairly trivial, we never thought this would be needed.

> I have a good reason for passing "-u root": at the time the shutdown
> script reaches power-off, most file systems, including the USB
> filesystem, have been unmounted. One must remount the USB filesystem
> to access the UPS. But at that point, hotplugging can't be relied
> upon, and therefore I would like to run the driver as root.

You have every reason to do so and I want to take this even further. I
don't think it is a good idea to drop privileges at all when running the
shutdown command. So rather than appending '-u root', I would suggest to
make dropping privileges in the main driver body depending on the command
sent to the driver. If we're shutting down anyway, dropping privileges is
probably a waste of effort and might even be counter productive (as you
made very clear).

> The reason I didn't notice this problem before is that I always called
> the driver directly, rather than upsdrvctl. But that would not be the
> case in a standard installation.
>
> Moreover, this problem is hard to debug without reading the source
> code, because -DD prints out a made-up command line, rather than the
> one actually used.
>
> Any objections to fixing this?

Not at all. Thanks for the tip!

Best regards, Arjen
-- 
Eindhoven - The Netherlands
Key fingerprint - 66 4E 03 2C 9D B5 CB 9B  7A FE 7E C1 EE 88 BC 57




More information about the Nut-upsdev mailing list