Is it possible to disable reset button?

One of my friend wants to use it some kind of corporate environment. Wants to disable the reset button, for more security. Can I do it within openwrt?

Make a dummy /etc/rc.button/reset?

#!/bin/sh

. /lib/functions.sh

case "$ACTION" in
released)
    echo "Someone's being naughty!"
    ;;
esac

return 0
1 Like

Ok, is it just this script? Where does the echo go to tho? Dmesg?

Probably goes only to the serial console.

The script above is too verbose for something this simple. I have disabled extra buttons in my dumb ap/switch.

root@router2:~# cat /etc/rc.button/wps
#!/bin/sh

[ "${ACTION}" = "released" ] || exit 0

logger "wps button held for ${SEEN}s"

If you don't care about logging, all you need is:

#!/bin/sh

Or just delete the script that handles your button.

These scripts would only apply to when the router is booted.

The bootloader could still behave differently when the reset button is pressed. Potentially going into a recovery or tftp mode.

1 Like

True, and if somebody's malicious and has physical access, a disabled button is not going to stop them.

1 Like

The failsafe script is located at /etc/rc.button/failsafe. You can disable that one aswell and buttons will do nothing during boot (unless the bootloader is handling buttons too, but that should be a very small window in most models).

root@router2:~# cat /etc/rc.button/failsafe
#!/bin/sh

[ "${TYPE}" = "switch" ] || echo ${BUTTON} > /tmp/failsafe_button

return 0

/lib/preinit/30_failsafe_wait

if [ "$FAILSAFE" != "true" ]; then
    fs_wait_for_key f 'to enter failsafe mode' $fs_failsafe_wait_timeout && FAILSAFE=true
    [ -f "/tmp/failsafe_button" ] && FAILSAFE=true && echo "- failsafe button "$(cat /tmp/failsafe_button)" was pressed -"
    [ "$FAILSAFE" = "true" ] && export FAILSAFE && touch /tmp/failsafe
fi
1 Like

How to trigger a button to be pressed and held for 30 seconds before execution

I think /etc/rc.button/reset does something like that already, so you can use it for inspiration.

If you want the button to be fired only when released, you can follow the example of my script to disable wps.

[ "${ACTION}" = "released" -a ${SEEN} -ge 30 ] && {
*** do something after 30 seconds ***
}

If you want an action to fire after 30s, even if the button wasn't released, use a timeout (like the one in reset).

case "$ACTION" in
    pressed)
        return 30
        ;;
    timeout)
        *** do something after 30 seconds ***
        ;;
esac