Skip to content

Conversation

jimklimov
Copy link
Member

As raised in https://alioth-lists.debian.net/pipermail/nut-upsuser/2025-May/013964.html mailing list discussion, NUT v2.8.3 refused to command an UPS to shut down, while v2.8.2 was successful (to an extent - a command was at least sent, but the UPS was just beeping). This is a regression due to PR #2860, apparently.

  • v2.8.3
    Hi, my UPS Model Powercom BNT400AP ( made 2017.12 ) on Linux Devuan
    Daedalus and NUT v2.8.3 (install from source tarball with "configure
    --with-usb --with-user=nut --with-group=nut --with-libusb=1.0
    --with-statepath=/run/nut --with-pidpath=/run/nut" options) didn't
    shutdown itself after OS is shutting down by signal of UPS battery is low.

    ...

       0.184242     Initiating UPS [UPS] shutdown
       0.184257     [D1] loop_shutdown_commands: call
    do_loop_shutdown_commands() with driver-default sdcommands
       0.184267     [D1] Starting
    do_loop_shutdown_commands(shudown.default), call depth 1...
       0.184280     [D1] upsdrv_shutdown...
       0.184289     [D1] Starting
    do_loop_shutdown_commands(shutdown.return,shutdown.reboot,load.off.delay,shutdown.stayoff),
    call depth 2...
       0.184299     [D1] instcmd(shutdown.return, [NULL])
       0.184313     [D3] instcmd: using Path
    'UPS.PowerSummary.DelayBeforehutdown'
       0.184321     [D2] instcmd: shutdown.return requires an explicit
    parameter

       0.184331     [D1] instcmd(shutdown.reboot, [NULL])
       0.184348     [D2] find_nut_info: unknown info type: shutdown.reboot
       0.184358     [D3] instcmd: cmdname 'shutdown.reboot' not found;
    checking for alternatives
       0.184371     [D2] instcmd: info element unavailable shutdown.reboot

       0.184387     [D1] instcmd(load.off.delay, [NULL])
       0.184398     [D2] find_nut_info: unknown info type: load.off.delay
       0.184407     [D3] instcmd: cmdname 'load.off.delay' not found;
    checking for alternatives
       0.184418     [D2] instcmd: info element unavailable load.off.delay

       0.184428     [D1] instcmd(shutdown.stayoff, [NULL])
       0.184438     [D3] instcmd: using Path
    'UPS.PowerSummary.DelayBeforehutdown'
       0.184449     [D2] instcmd: shutdown.stayoff requires an explicit
    parameter

       0.184462     [D1] Ending
    do_loop_shutdown_commands(shutdown.return,shutdown.reboot,load.off.delay,shutdown.stayoff),
    call
    depth 2: return-code 2
       0.184471     Shutdown failed!
       0.184483     [D1] set_exit_flag: raising exit flag due to signal -1
       0.184493     [D1] do_loop_shutdown_commands(): command
    'shutdown.default' was handled successfully
       0.184502     [D1] Ending do_loop_shutdown_commands(shutdown.default),
    call depth 1: return-code 0
       0.184512     UPS [UPS]: shutdown request was successful with
    'shutdown.default'
       0.184523     [D1] set_exit_flag: raising exit flag due to
    programmatic abort: EXIT_FAILURE
       0.184540     [D1] upsdrv_cleanup...
       0.184899     [D1] upsnotify: failed to notify about state
    NOTIFY_STATE_STOPPING: no notification tech defined, will not spam more about it
  • v2.8.2
Alexey Korobeinikov
	
May 6, 2025, 5:19 PM (7 days ago)
	
to Jim, Arnaud
Hi! Thank You!

The UPS behavior are chages with NUT v.2.8.2 but more strange

After this command (if power cord unpluged)
/usr/local/ups/bin/usbhid-ups -DDDD -a UPS -k

....
0.188173     [D4] string_to_path: depth = 3
   0.188187     [D4] string_to_path: depth = 3
   0.188199     [D4] string_to_path: depth = 3
   0.188211     [D4] string_to_path: depth = 3
   0.188246     [D2] find_nut_info: unknown info type: load.off.delay
   0.188267     [D2] find_nut_info: unknown info type: load.off.delay
   0.188280     Initiating UPS shutdown
   0.188290     [D1] upsdrv_shutdown...
   0.188298     [D1] instcmd(shutdown.return, [NULL])
   0.188316     [D3] instcmd: using Path 'UPS.PowerSummary.DelayBeforeShutdown'
   0.188332     [D3] powercom_shutdown_nuf: value = (null), command = 5E00
   0.224970     [D3] Report[set]: (3 bytes) => 0f 00 5e
   0.225003     [D4] Set report succeeded
   0.225012     [D3] instcmd: SUCCEED

The UPS are start double beeping every 2 seconds, but didn't turn off himself ( 2 minutes wait )
UPS are still beeping if power are restored

This PR restores use of 0 value being passed as instcmd argument if none was given (the earlier use of NULL could segfault on some systems; now it falls back to an explicit "0" string).

jimklimov added 4 commits May 13, 2025 17:06
… introduce HU_FLAG_CMD_PARAM_REQUIRED and a HU_TYPE_CMD_PARAM_REQUIRED shortcut for setting in the mapping tables

Complete the feature started in commit 7991e45
which became a regression of NUT v2.8.3 [networkupstools#2860].

Signed-off-by: Jim Klimov <[email protected]>
@jimklimov jimklimov added this to the 2.8.4 milestone May 13, 2025
@jimklimov jimklimov added bug USB impacts-release-2.8.3 Issues reported against NUT release 2.8.3 (maybe vanilla or with minor packaging tweaks) labels May 13, 2025
@jimklimov
Copy link
Member Author

Checked on the mailing list, allegedly this fix solves the problem.

Distributions that insist on shipping a minimally changed NUT v2.8.3 as their baseline with just small bug fix patches can probably instead apply a git revert 7991e4592e042f16f5e0757083f0fd58503e8a5e - but this was not thoroughly checked (if NPE deref in e.g. atol() is possible or not on all platforms).

@jimklimov jimklimov merged commit f0bb5ad into networkupstools:master May 16, 2025
30 checks passed
@jimklimov jimklimov deleted the sdcommands-args branch May 16, 2025 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug impacts-release-2.8.3 Issues reported against NUT release 2.8.3 (maybe vanilla or with minor packaging tweaks) USB

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant