From: Daniel F. Dickinson Date: Thu, 27 Aug 2026 11:50:43 +0000 (-0400) Subject: nut: fix matching hotplugged device X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=9ce5146f9fe2e5dbff998a76e80b89eed0baae26;p=openwrt-packages.git nut: fix matching hotplugged device The match against known device was badly formatted, and was not being used as a result. Fix that. Also, completely ignore events which are incomplete for our purposes (that is, which are missing ACTION or DEVNAME). Signed-off-by: Daniel F. Dickinson --- diff --git a/net/nut/files/libhid-ups.hotplug b/net/nut/files/libhid-ups.hotplug index e3d354691..140ac5656 100644 --- a/net/nut/files/libhid-ups.hotplug +++ b/net/nut/files/libhid-ups.hotplug @@ -228,9 +228,6 @@ perform_libhid_action() { local nd_driver_config_error=false local pvendid pprodid - [ -n "$DEVNAME" ] || return 0 - [ -n "$ACTION" ] || return 0 - # Only find statepath and runas once per event # defines STATEPATH find_statepath "upsd" "nut_server" || { @@ -313,24 +310,28 @@ perform_libhid_action() { # return) and shellcheck will complain if we do. } +# Ignore incomplete (for our purposes) events +[ -n "$DEVNAME" ] || exit 0 +[ -n "$ACTION" ] || exit 0 + # PRODUCT comes from the calling hotplug event, and # is of the form vendorid/productid/other # This is an incomplete script which gets filled by libhid-ups.parsed-usermap. -# This confuses shellcheck and reviewers, hence the disables below. -# shellcheck disable=SC1073,SC1072 -case "$PRODUCT" in -### insert libhid-ups.parsed-usermap content here ### + # The result is cases of the form # "vendorid/productid/other" ) | \ # to be matched against the PRODUCT from the calling hotplug event -# and does NOT use ';;' (so falls through to code below). # The empty string matches when PRODUCT is empty, but does not match # when PRODUCT is neither empty nor one of the case targets, above +# This confuses shellcheck and reviewers, hence the disables below. +# shellcheck disable=SC1073,SC1072 +case "$PRODUCT" in +### insert libhid-ups.parsed-usermap content here ### "") # Skip hotplug actions if NUT hotplug is disabled - # Uses NUT_DISABLE_HOTPLUG_PATH, defined in nut-service.sh and sourced + # Uses NUT_DISABLE_HOTPLUG_PATH, defined in nut-service.sh and sourced # NUT_DISABLE_HOTPLUG_PATH is an external sentinel used to indicate NUT # hotplug is disabled. if ! allow_hotplug_restart; then diff --git a/net/nut/files/nut-serial.hotplug b/net/nut/files/nut-serial.hotplug index c8e0f368d..7a7988d8c 100644 --- a/net/nut/files/nut-serial.hotplug +++ b/net/nut/files/nut-serial.hotplug @@ -159,6 +159,10 @@ nut_on_hotplug_add() { return 0 } +# Ignore incomplete (for our purposes) events +[ -n "$DEVNAME" ] || exit 0 +[ -n "$ACTION" ] || exit 0 + # Do not do any hotplug actions if hotplug is disabled. Not an error but log # for information if ! allow_hotplug_restart; then