Introduction

ちょっと毛色の違う備忘録。
XRDP 経由で Wi-Fi 設定を GUI で編集しようとするとダイアログを表示しただけで認証ダイアログが無限にループする事象に襲われる。

Authentication required. System policy prevents WiFi scans (認証が必要です。システムポリシーによりwi-fiスキャンが阻止されます) と。

firewall

How to resolve?

“Authentication required. System policy prevents WiFi scans” in FocalFossa

Ask Ubuntu に悩めるユーが多数。

結論としては Ubuntu 23 より以降とそれより前では対処法が違う。
polkit の記法が javascript になったから Ubuntu 23 以降では記事内で提示されている設定が使えない、という話。
なので、ここでは 23 以降で使える方法を。

上記の url 内で

If you’re experiencing issues with authorization messages for WiFi and network settings in a remote desktop environment, a script I developed might help. PolkitFullAccessSetup.sh automates the creation of Polkit rules, granting full access to specified users or groups. This can effectively bypass the authorization messages you’re encountering.

Note: This script grants extensive permissions and should be used with caution. It’s more suitable for controlled environments and not recommended for general use on production systems.

と、有志がスクリプトを作ってくれた。

1
2
3
4
5
6
7
8
9
10
$ curl https://raw.githubusercontent.com/GabrielRamirez/Raspbian-Remote-Polkit-FullAccess/refs/heads/master/PolkitFullAccessSetup.sh -o PolkitFullAccessSetup.sh
$ chmod +x PolkitFullAccessSetup.sh
$ sudo ./PolkitFullAccessSetup.sh
Enter the username to grant full Polkit access: <許可を与えたいユーザ名>
Enter the group to grant full Polkit access (or leave blank):
This will create or overwrite Polkit rules in /etc/polkit-1/rules.d/99-full-access.rules.
Are you sure you want to proceed? (y/n) y
Polkit rules updated successfully.

$ sudo reboot

これで認証ダイアログが出なくなった。

あと、これが原因だったのか Wi-Fi ホットスポットも有効にできるようになった。
XRDP 経由だと色々セキュリティが厳しいのかも。

とはいえ、XRDP 経由ならこの問題は起きないし、上にあるようにセキュリティ的にはかなりリスクがあるので避けるのが無難。

駄目だった方法

polkit の記法が javascript になったから Ubuntu 23 以降はダメ、という話だったので、 ChatGPT で古い記法を変更して試してみた。

1
$ sudo vi /etc/polkit-1/rules.d/50-allow-wifi-scan.rules

下記を追加。

1
2
3
4
5
6
7
8
9
10
11
12
13
polkit.addRule(function(action, subject) {
if (subject.isInGroup("wheel") || subject.user == "*") {
if (
action.id == "org.freedesktop.NetworkManager.wifi.scan" ||
action.id == "org.freedesktop.NetworkManager.enable-disable-wifi" ||
action.id == "org.freedesktop.NetworkManager.settings.modify.own" ||
action.id == "org.freedesktop.NetworkManager.settings.modify.system" ||
action.id == "org.freedesktop.NetworkManager.network-control"
) {
return polkit.Result.YES;
}
}
});

subject.user =="*" は、元は subject.user == "USERNAME" だったが全員許可に変えた。

1
2
3
$ sudo chmod 644 /etc/polkit-1/rules.d/50-allow-wifi-scan.rules
$ sudo systemctl restart polkit
$ sudo reboot

polkit を再起動しようがマシンを再起動しようがダメ。