Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in hostapd setup script #8079

Closed
2 tasks done
uvNikita opened this issue Nov 21, 2024 · 4 comments
Closed
2 tasks done

Bug in hostapd setup script #8079

uvNikita opened this issue Nov 21, 2024 · 4 comments
Assignees
Labels
cleanup Low impact changes
Milestone

Comments

@uvNikita
Copy link

uvNikita commented Nov 21, 2024

Important notices

Before you add a new report, we ask you kindly to acknowledge the following:

Describe the bug
I had an issue that my configured WLAN was disappearing as soon as I would enable WPA2/AES on it.
After a lot of debugging, I found that the reason was this code in hostapd setup:

if (file_exists("/tmp/{$if}_oldmac")) {
if ($wancfg['spoofmac']) {
$if_curmac = $wancfg['spoofmac'];
} else {
$if_curmac = get_interface_mac($if);
}
if (is_macaddr($if_curmac)) {
fwrite($fd_set, "{$ifconfig} " . escapeshellarg($if) .
" link " . escapeshellarg($if_curmac) . "\n");
}
}

The generated script looks like that:

#!/bin/sh
# wireless configuration script.

/sbin/ifconfig 'run0_wlan1' link '<mac>'
/usr/local/sbin/hostapd -B -P /var/run/hostapd_run0_wlan1.pid /var/etc/hostapd_run0_wlan1.conf
/sbin/ifconfig 'run0_wlan1' link '<mac>'

What I think is happening is because of -B flag, hostapd goes into background mode as soon as it starts, and the third line gets executed attempting to change mac address right away. Due to this interface gets into a non-functional state.

Note that this is happening even if I don't touch mac spoofing configuration at all and both macs from the script above are identical.

As soon as I comment out the code that generates ifconfig command and re-run the interface configuration, everything is working as expected.

To Reproduce

Steps to reproduce the behavior:

  1. Create WLAN with no authentication
  2. Confirm it's working as expected
  3. Add WPA2/AES configuration (doesn't matter which options)
  4. SSID disappears
  5. Comment out the code generating the second ifconfig mac change
  6. Save, apply config, reboot firewall
  7. SSID appears as expected with WPA2 auth

Expected behavior

WLAN working with WPA2/AES enabled.

Describe alternatives you considered

  • Commenting out the part of the code that generates the second mac change fixes the problem.
  • I wonder if just removing the -B flag would also help since then the second mac change wouldn't happen right after hostapd is started but rather would ran after it's finished as intended. I haven't tested this solution.
  • Alternatively, I would be fine if those mac changing lines wouldn't generate at all if mac spoofing is not in use since it's just trying to change to the mac address it already has.

Additional context

WiFi module used: AW-NU706H / RT3070

Environment

Software version used and hardware type if relevant, e.g.:

OPNsense 24.7.9 (amd64).

@AdSchellevis
Copy link
Member

This stuff is really old, maybe we should try to remove both mac address switches and see if it works on your end, let me push a commit to try for you

AdSchellevis added a commit that referenced this issue Nov 22, 2024
…d for #8079

All of this stuff looks really old, it seems to originate from pfsense/pfsense@864bf77, which might be an issue that doesn't actually exist anymore..
@AdSchellevis
Copy link
Member

@uvNikita can you try cb6ec88?

opnsense-patch cb6ec88

@fichtner fichtner added the cleanup Low impact changes label Nov 22, 2024
@fichtner fichtner added this to the 25.1 milestone Nov 22, 2024
@uvNikita
Copy link
Author

Yes, this fixes the issue, thanks a lot!

@AdSchellevis
Copy link
Member

@uvNikita thanks for confirming, let's close this one then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup Low impact changes
Development

No branches or pull requests

3 participants