hostapd: Report error on unknown ACCEPT_ACL/DENY_ACL commands

Currently when using ACCEPT_ACL or DENY_ACL, no error is reported if
the rest of the command is unknown (e.g. 'ACCEPT_ACL FOOBAR' reports
'OK').

On the other hand, hostapd_cli makes it possible to use 'accept_acl'
and 'deny_acl' in lowercase, but the rest of the command (i.e. 'SHOW',
'ADD_MAC', 'CLEAR', etc) must be in uppercase.

As a result, the command 'accept_acl clear' could seem valid when
using hostapd_cli (as it reports 'OK'), while it actually does not do
anything (because 'clear' must be in uppercase).

To let users know whether the command really succeeded or not, report
an error when the command was not understood.

Note that this is also consistent with the way it is currently
implemented in wpa_supplicant.

Signed-off-by: Raphaël Mélotte <raphael.melotte@mind.be>
This commit is contained in:
Raphaël Mélotte 2023-01-04 16:53:50 +01:00 committed by Jouni Malinen
parent 2cff340d17
commit 3915e8834e

View file

@ -3550,6 +3550,8 @@ static int hostapd_ctrl_iface_receive_process(struct hostapd_data *hapd,
if (hostapd_set_acl(hapd) || if (hostapd_set_acl(hapd) ||
hostapd_disassoc_accept_mac(hapd)) hostapd_disassoc_accept_mac(hapd))
reply_len = -1; reply_len = -1;
} else {
reply_len = -1;
} }
} else if (os_strncmp(buf, "DENY_ACL ", 9) == 0) { } else if (os_strncmp(buf, "DENY_ACL ", 9) == 0) {
if (os_strncmp(buf + 9, "ADD_MAC ", 8) == 0) { if (os_strncmp(buf + 9, "ADD_MAC ", 8) == 0) {
@ -3575,6 +3577,8 @@ static int hostapd_ctrl_iface_receive_process(struct hostapd_data *hapd,
&hapd->conf->num_deny_mac); &hapd->conf->num_deny_mac);
if (hostapd_set_acl(hapd)) if (hostapd_set_acl(hapd))
reply_len = -1; reply_len = -1;
} else {
reply_len = -1;
} }
#ifdef CONFIG_DPP #ifdef CONFIG_DPP
} else if (os_strncmp(buf, "DPP_QR_CODE ", 12) == 0) { } else if (os_strncmp(buf, "DPP_QR_CODE ", 12) == 0) {