Skip to content

Fix bugs in nmcli wifi driver #17857

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

Merged
merged 1 commit into from
May 5, 2025

Conversation

jecaro
Copy link
Contributor

@jecaro jecaro commented May 4, 2025

Description

I'm developing a nixos config for my RPI CM3 handheld.

I've tried using the nmcli wifi driver for the user to be able to configure his wifi with the builtin gamepad. However, it wasn't usable in this state.

A few bugs here and there, and most importantly, the driver was asking for a password each time one connected to a network. That makes the feature useless IMO. As a user, I'd like to be able to configure my wifi network with a password once, turn off the wifi to save battery and only turn it on when I need. But I really don't want to set the password each time I want to use the wifi. It's already cumbersome enough do it once.

Anyway, I dove into the driver and fixed a few things:

  • Disconnect menu item wasn't shown even when connected
  • Use the password stored in the connection profile instead of asking each time to the user
  • Don't consider wired connections when checking if the device is connected

@jecaro jecaro changed the title Fix bugs in nmcli driver Fix bugs in nmcli wifi driver May 4, 2025
@jecaro jecaro force-pushed the fix-nmcli-wifi-driver branch from bde3259 to 5ac5811 Compare May 4, 2025 19:14
else
/* This assumes the password doesn't contain single quotes */
snprintf(cmd, sizeof(cmd),
"nmcli dev wifi connect '%s' password '%s'",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Single quotes in SSIDs would probably be malicious, but generated passwords will contain those in legitimate cases.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tested this, but in principle if you pass "nmcli dev wifi connect $'%s' password $'%s'" then it should be only a matter of replacing each ' with \' in each the SSID and password.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree this is not super robust, and I'm not very happy with it. I'll come up with something better soon.

- Use the password stored in the connection profile instead of asking
  each time to the user

- `Disconnect` menu item wasn't shown even when connected

   When entering the Wi-Fi menu first, `nmcli_connection_info` is called with
   `NULL`. If we return `false` here, the menu doesn't show the `Disconnect`
   menu item even when the wifi is on and connected.

- Don't consider wired connections when checking if the device is connected

   `cmd_file = popen("nmcli -f NAME c show --active | tail -n+2", "r");`

   That command returns all active connections, even the wired ones. That
   means that if the wifi is not connected but we have a wired connection,
   retroarch shows the Disconnect menu item to disconnect ... a
   non-existent wifi connection.
@jecaro jecaro force-pushed the fix-nmcli-wifi-driver branch from 5ac5811 to 3637f49 Compare May 5, 2025 10:38
@LibretroAdmin LibretroAdmin merged commit 28f81e8 into libretro:master May 5, 2025
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants