albfan / miraclecast

Connect external monitors to your system via Wifi-Display specification also known as Miracast
Other
3.66k stars 407 forks source link

[security & bug] Deprecate WPS & Fix Systemd Artifact #478

Open pinuke opened 1 year ago

pinuke commented 1 year ago

So while trying to port miraclecast over to ChromeOS via Chromebrew, we ran over errors involving how miracle-wifid interacts with wpa_supplicant

WARNING: cannot read hostname from systemd.hostname1: The name org.freedesktop.hostname1 was not provided by any .service files (manager_read_name() in ../src/wifi/wifid.c:400)
Successfully initialized wpa_supplicant
Line 2: unknown global field 'device_name=unknown'.
Line 2: Invalid configuration line 'device_name=unknown'.
Line 3: unknown global field 'device_type=1-0050F204-1'.
Line 3: Invalid configuration line 'device_type=1-0050F204-1'.
Line 4: unknown global field 'config_methods=pbc'.
Line 4: Invalid configuration line 'config_methods=pbc'.
Failed to read or parse configuration '/run/miracle/wifi/wlan0-2.conf'.
ERROR: supplicant: wpas (pid:9324) failed unexpectedly, relaunching after short grace period.. 

Now to touch briefly on systemd. According to this issue, miraclecast is trying to move away from its systemd dependency, so obvioudly, miracle-wifid should not be pulling the hostname from systemd if systemd does not exist. It should be pulling the hostname from elsewhere (user input if you have to)

Now the bigger issue is Line 2: Invalid configuration line 'device_name=unknown'. and Line 3: Invalid configuration line 'device_type=1-0050F204-1'.

After further discovery, we found the cause for the line 2 and line 3 errors was the fact that Chrome OS does not support WPS

Obviously, WPS is disabled on chromebooks for obvious security reasons, so this won't work on WPS-disabled systems

A better approach would be to support WiFi P2P (WiFi Direct) over WPA/WPA2 and deprecate WPS

albfan commented 1 year ago

run without systemd is just an option for some distros. hostname is get from dbus. elogind seems to provide sd_bus_call_method too.

Use wifi from network manager is cover on #75

if needed, a PR to get hostname from local command is welcome.

You can modify wpa_supplicant config to use keyboard PIN instead of WPS

pinuke commented 1 year ago

elogind seems to provide sd_bus_call_method too.

I'll have to take a look into that and see what effect that has on running it on ChromeOS

Use wifi from network manager is cover on #75

Interesting, ChromeOS doesn't use Network Manager. It uses an extremely locked down alternative known as shill (no command line. Can only be interacted with over dbus).

Though I do notice that a few things from that issue could be used to fix the issues on ChromeOS

if needed, a PR to get hostname from local command is welcome.

If I do end up forking miraclecast, I'll definitely submit one

run without systemd is just an option for some distros. hostname is get from dbus.

If I do end up forking and writing that out, it may be worth deprecating that systemd dependency and make miraclecast platform-agnostic.

However, I will say that this use case of miraclecast is pretty niche, and probably doesn't justify this platform-agnostic change. So I'll leave the topic of dropping the dependency on systemd.hostname to you guys.

You can modify wpa_supplicant config to use keyboard PIN instead of WPS

I'm exploring that now. I'll have to find a way to not use device_name and device_type in the .conf file. That's currently what I'm having to work around at the moment.

I'm not sure if disabling WPS on the original wpa_supplicant binary from hostapd disables those 2 fields or if it just disables it on ChromeOS's implementation.

pinuke commented 1 year ago

elogind seems to provide sd_bus_call_method too.

I'll have to take a look into that and see what effect that has on running it on ChromeOS

I do see this: https://github.com/elogind/elogind/commit/7640a5de1b3ffe6547200ad204d14e4f067caf4f#diff-0462e381b2fb3286568215681c8983490a37ac9ae0f0c5ee304df7fa6426d4afR182

pinuke commented 1 year ago

Found the current version:

It was moved under this commit: https://github.com/systemd/systemd/commit/681cfc6c40b176f73204c9088bfc5a7e8bad4317#diff-10f4d99565f6679227fc1c14a0bbea4a85084f4d7ec88e134903ea6138cff1c9

albfan commented 1 year ago

I was about to suggest https://gitlab.gnome.org/GNOME/gnome-network-displays (it is just a source not sink) but is even more heavily relying on network manager and dbus to configure Wifi P2P

Feel free to fork and provide PR with changes CHROMEOS_BUILD or similar