]> git.99rst.org Git - openwrt-packages.git/commitdiff
nut: fix matching hotplugged device
authorDaniel F. Dickinson <redacted>
Thu, 27 Aug 2026 11:50:43 +0000 (07:50 -0400)
committerJosef Schlehofer <redacted>
Thu, 10 Sep 2026 08:22:36 +0000 (10:22 +0200)
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 <redacted>
net/nut/files/libhid-ups.hotplug
net/nut/files/nut-serial.hotplug

index e3d3546914088637fc57dd48ae2435234fc5a8bb..140ac5656c41bd95e0eb0d6f1b3433b20e2411aa 100644 (file)
@@ -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
index c8e0f368d034d5e9cc18f591505312bfa9796d59..7a7988d8c97c5c1c3e3d737c842438f41267219f 100644 (file)
@@ -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
git clone https://git.99rst.org/PROJECT