How to disable WPS button?

I am trying to free up WPS button so that I can launch custom scripts by pressing it but it seems like the button is actually being used to trigger WPS?

Can someone help me figure out if WPS is actually being triggered ? And how can I disable it... My initial guess would be to just rename /etc/rc.button/wps to /etc/rc.button/wps-backup or something?

ls /etc/rc.button/
failsafe  power     reboot    reset     rfkill    wps

cat /etc/rc.button/wps


wps_catch_credentials() {
	local iface ifaces ifc ifname ssid encryption key radio radios
	local found=0

	. /usr/share/libubox/
	ubus -S -t 30 listen wps_credentials | while read creds; do
		json_load "$creds"
		json_select wps_credentials || continue
		json_get_vars ifname ssid key encryption
		local ifcname="$ifname"
		json_load "$(ubus -S call network.wireless status)"
		json_get_keys radios
		for radio in $radios; do
			json_select $radio
			json_select interfaces
			json_get_keys ifaces
			for ifc in $ifaces; do
				json_select $ifc
				json_get_vars ifname
				[ "$ifname" = "$ifcname" ] && {
					ubus -S call uci set "{\"config\":\"wireless\", \"type\":\"wifi-iface\",	\
								\"match\": { \"device\": \"$radio\", \"encryption\": \"wps\" },	\
								\"values\": { \"encryption\": \"$encryption\", 		\
										\"ssid\": \"$ssid\", 			\
										\"key\": \"$key\" } }"
					ubus -S call uci commit '{"config": "wireless"}'
					ubus -S call uci apply
				json_select ..
			json_select ..
			json_select ..

if [ "$ACTION" = "released" ] && [ "$BUTTON" = "wps" ]; then
	# If the button was pressed for 3 seconds or more, trigger WPS on
	# wpa_supplicant only, no matter if hostapd is running or not.  If
	# was pressed for less than 3 seconds, try triggering on
	# hostapd. If there is no hostapd instance to trigger it on or WPS
	# is not enabled on them, trigger it on wpa_supplicant.
	if [ "$SEEN" -lt 3 ] ; then
		ubusobjs="$( ubus -S list hostapd.* )"
		for ubusobj in $ubusobjs; do
			ubus -S call $ubusobj wps_start && wps_done=1
		[ $wps_done = 0 ] || return 0
	ubusobjs="$( ubus -S list wpa_supplicant.* )"
	for ubusobj in $ubusobjs; do
		ifname="$(echo $ubusobj | cut -d'.' -f2 )"
		if [ -e "/var/run/wpa_supplicant-${ifname}.conf.is_multiap" ]; then
			ubus -S call $ubusobj wps_start '{ "multi_ap": true }' && wps_done=1
			ubus -S call $ubusobj wps_start && wps_done=1
	[ $wps_done = 0 ] || wps_catch_credentials &

return 0

No. The filenames of the scripts in /etc/rc.button actually don't matter, they are purely descriptive. All scripts, no matter their name, are executed and decide themselves to which buttons they want to react. E.g., this line here in /etc/rc.button/wps decides the script should react to the wps button:

if [ "$ACTION" = "released" ] && [ "$BUTTON" = "wps" ]; then

To "disable" a script you actually need to remove the file from the /etc/rc.button directory.

Thank you , would commenting out the whole file work xd

Idk where to place it I am very new to everything linux...

You could of course comment out every single line, but that'd be considerably more work than just to move it somewhere, especially if you for some reason want to restore it. You've got a "personal home directory" at /root, or ~ for short, you can just move it there for safekeeping.

That being said, I'm fairly confident your rom does already come with the wps script. Look if you have a file /rom/etc/rc.button/wps. If so, you can delete your /etc/rc.button/wps with prejudice, and should you ever need to restore it, get it back from the rom directory.

1 Like

Thank you!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.