Fix DNS resolution across Wi-Fi, cellular, USB tethering, and VPNs
- Add NetworkManager rc-manager=file with dnsmasq caching and baseline /etc/resolv.conf, isolate usb0 routes/DNS in USB_Networking.nmconnection, enable loopback in boot runlevel, and guard 90-nm-cloud-setup.sh for OpenRC. - Rewrite 50-dns-filter.sh to handle dhcp4/dhcp6/dns events, drop BusyBox-invalid logger -i and blocking gateway sleeps, gate IPv6 AAAA filtering on global unicast addresses and accept_ra, and fall back to 1.1.1.1/9.9.9.9 when no upstream DNS is advertised. - Fix bananarchy-privacy-ctl musl parallel-query leaks (omit 127.0.0.1 in VPN mode, add sync-dns recovery, replace pkill/pgrep), add usb-tether DNS DNAT, rebuild and verify all four a1120 target images and release zips, and add scripts/test-dns-resolution.py.
This commit is contained in:
1 parent
6cedcf980c
commit
63ef9299fc
15 files changed
+764
-105
No files matched your search
@@ -83,7 +83,11 @@ Keep this file short. Full details live in `README.md`, `MANUAL.md`, `SDK.md`, `
|
|||||||
the sqlite CLI stay excluded.
|
the sqlite CLI stay excluded.
|
||||||
- Keep power/network behaviour event-driven: `superctl disable sxmo_networkmonitor`, no long `nmcli device monitor`, no
|
- Keep power/network behaviour event-driven: `superctl disable sxmo_networkmonitor`, no long `nmcli device monitor`, no
|
||||||
infinite wakelocks, no forced `sxmo.noidle`/`sxmo.nosuspend`, lz4 zram via `/usr/bin/zramstart`, and
|
infinite wakelocks, no forced `sxmo.noidle`/`sxmo.nosuspend`, lz4 zram via `/usr/bin/zramstart`, and
|
||||||
`vm.compaction_proactiveness=0`. GPS resolves through `bananarchy-gps-modem.sh`, never `mmcli -m any`.
|
`vm.compaction_proactiveness=0`. Keep `rc-manager=file` + `dns=dnsmasq` in `20-bananarchy-dns.conf`, baseline
|
||||||
|
`overlay/rootfs/etc/resolv.conf`, `0600` `USB_Networking.nmconnection` (`never-default=true`, `ignore-auto-dns=true`),
|
||||||
|
`loopback` in `boot`, non-blocking `50-dns-filter.sh` (`dhcp4-change`/`dhcp6-change`/`dns-change`, no `logger -i` or
|
||||||
|
`sleep` loops), non-leaking VPN `/etc/resolv.conf` pinning (`bananarchy-privacy-ctl sync-dns` without `127.0.0.1`), and
|
||||||
|
`scripts/test-dns-resolution.py`. GPS resolves through `bananarchy-gps-modem.sh`, never `mmcli -m any`.
|
||||||
- Keep idle and autostart daemons as compiled C ARM ELF binaries (`bananarchy-lid`, `bananarchy-cover-idle`,
|
- Keep idle and autostart daemons as compiled C ARM ELF binaries (`bananarchy-lid`, `bananarchy-cover-idle`,
|
||||||
`bananarchy-volume-keys`, `bananarchy-dsds`, `bananarchy-modemmonitor`, `bananarchy-soundmonitor`,
|
`bananarchy-volume-keys`, `bananarchy-dsds`, `bananarchy-modemmonitor`, `bananarchy-soundmonitor`,
|
||||||
`bananarchy-notifmonitor`, `bananarchy-run-aligned`, `bananarchy-session-loop`), not Python or `/bin/sh` loops.
|
`bananarchy-notifmonitor`, `bananarchy-run-aligned`, `bananarchy-session-loop`), not Python or `/bin/sh` loops.
|
||||||
|
|||||||
+10
-4
@@ -14,6 +14,12 @@ Release versions follow the `<year-letter><MM><DD>` format (where `2026` is `a`,
|
|||||||
|
|
||||||
Upcoming release build (`a1120` / `cocojamboo` via `scripts/version.sh`) targeting **Nokia 8110 4G (`nokia-argon`)**, **Nokia 2720 Flip (`nokia-beatles`)**, **Nokia 800 Tough (`nokia-coconut`)**, and **Nokia 8000 4G (`nokia-sparkler`)** while keeping `a1114` (`carbonara`) as the current published release.
|
Upcoming release build (`a1120` / `cocojamboo` via `scripts/version.sh`) targeting **Nokia 8110 4G (`nokia-argon`)**, **Nokia 2720 Flip (`nokia-beatles`)**, **Nokia 800 Tough (`nokia-coconut`)**, and **Nokia 8000 4G (`nokia-sparkler`)** while keeping `a1114` (`carbonara`) as the current published release.
|
||||||
|
|
||||||
|
### DNS resolution, NetworkManager dispatcher, USB tethering DNS, and VPN leak fixes across all targets
|
||||||
|
|
||||||
|
- **Atomic NetworkManager `rc-manager=file` and baseline `/etc/resolv.conf` (`etc/NetworkManager/conf.d/20-bananarchy-dns.conf`, `etc/resolv.conf`, `usr/lib/NetworkManager/system-connections/USB_Networking.nmconnection`, `90-nm-cloud-setup.sh`)**: kept NetworkManager's local caching `dnsmasq` plugin (`dns=dnsmasq`) while switching `rc-manager=file` so `openresolv`'s `# Generated by resolvconf` signature check can never lock out `/etc/resolv.conf` updates across privacy-tunnel runs or reboots and network transitions avoid spawning subscriber scripts; added baseline `/etc/resolv.conf` (`nameserver 127.0.0.1`), configured `USB_Networking.nmconnection` (`0600`, `never-default=true`, `ignore-auto-dns=true`, `[ipv6] method=ignore`), guarded `90-nm-cloud-setup.sh` with `command -v systemctl`, and enabled `loopback` in the `boot` runlevel across `scripts/bootstrap-rootfs-container.sh`, `scripts/apply-bananarchy-overlay.sh`, and `rebuild-image.sh`.
|
||||||
|
- **Event-driven dual-stack `50-dns-filter.sh` and zero-DNS fallback (`overlay/rootfs/usr/lib/NetworkManager/dispatcher.d/50-dns-filter.sh`, `msm-modem-uim-selection`)**: replaced BusyBox-incompatible `logger -i`, `NameHasNoOwner` crashes, and 5 s gateway `sleep` loops with non-blocking IPv4/IPv6 state checks across `up`/`down`/`reapply`/`dhcp4-change`/`dhcp6-change`/`dns-change`; distinguished global unicast IPv6 (`2000::/3`) from link-local SLAAC/RA (and muted `wlan0/accept_ra`) so early RAs no longer latch `SetFilterA true` and drop IPv4 `A` records; handled QMI `raw-ip` point-to-point `wwan0` bearers without `IP4Config.Gateway`; added automatic `1.1.1.1`/`9.9.9.9` fallback and stub recovery when an active IPv4 bearer omits DNS; and enabled `usb0.route_localnet=1` plus `nft` DNAT (`172.16.42.1:53` -> `127.0.0.1:53`) in `msm-modem-uim-selection usb-tether on`.
|
||||||
|
- **Privacy tunnel musl DNS leak fix, recovery, and regression suite (`bananarchy-privacy-ctl`, `scripts/test-dns-resolution.py`, `scripts/check-rebuild.sh`)**: omitted `127.0.0.1` alongside tunneled VPN resolvers in `sync_dns_resolv()` (preventing musl parallel DNS queries from bypassing tunnel policy routing via local `dnsmasq`), added `sync-dns` (restoring `/run/NetworkManager/resolv.conf` on crash/reboot recovery while keeping active tunnel DNS pinned even when screen-locked), replaced remaining `pkill`/`pgrep` calls with `/proc/[0-9]*/cmdline` matching (`find_proc_pids`/`kill_proc_matches`), and added `scripts/test-dns-resolution.py` wired into `scripts/check-rebuild.sh`.
|
||||||
|
|
||||||
### Bluetooth 5.x/6.x headset support (`A2DP` + `HSP/HFP`), Android OBEX file transfer, AVRCP controls, and power safeguards across all targets
|
### Bluetooth 5.x/6.x headset support (`A2DP` + `HSP/HFP`), Android OBEX file transfer, AVRCP controls, and power safeguards across all targets
|
||||||
|
|
||||||
- **Android SSP/PIN/Passkey pairing agent & NeoUI confirmation popup (`etc/bluetooth/main.conf`, `bananarchy-bt-le-enable.sh`, `sxmo_bluetoothtoggle.sh`, `sxmo_hook_start.sh`, `bananarchy-bt-obex`, `networks_plugin.cpp`)**: switched the persistent `Agent1` capability from dummy `"NoInputNoOutput"` (which replied `"0000"` / `0` with zero prompt and tripped BlueZ/WCNSS `"incorrect PIN or passkey"`) to `"KeyboardDisplay"` backed by `/run/bananarchy/bt-obex/{pair_prompt,pair_decision,op_done}.tsv` IPC and `NetModal::BtPairingPrompt` (`CONFIRM` 6-digit passkey match, keypad `PIN` / `PASSKEY` entry, `DISPLAY` keyboard code, and `Cancel`/`Close` rejection, while auto-confirming screenless Classic Audio headsets); enabled `bredr on`, `ssp on`, `linksec on`, `bondable on`, and `advertising off` alongside `class 2 3` and `le on` in `bananarchy-bt-le-enable.sh` (`PairableTimeout = 0` in `main.conf` while keeping `DiscoverableTimeout = 60` hidden by default); fixed root/`user` daemon UID collisions and sticky-`/tmp` PID/status writes (`errno != EPERM` + `doas -n bananarchy-bt-obex start` + boot hook restart when BT is enabled); made `networks_plugin.cpp` `Connect`/`Pair` non-blocking (`--async-ui`), prevented `cli_agent` hijacking and 8 s `Pair` aborts (`50 s` timeout), and fixed phone `Icon: phone`/`computer` (`OBEX/PAN`) vs Classic Audio classification across `queryBtDevices()` and `is_phone_or_computer_props()`.
|
- **Android SSP/PIN/Passkey pairing agent & NeoUI confirmation popup (`etc/bluetooth/main.conf`, `bananarchy-bt-le-enable.sh`, `sxmo_bluetoothtoggle.sh`, `sxmo_hook_start.sh`, `bananarchy-bt-obex`, `networks_plugin.cpp`)**: switched the persistent `Agent1` capability from dummy `"NoInputNoOutput"` (which replied `"0000"` / `0` with zero prompt and tripped BlueZ/WCNSS `"incorrect PIN or passkey"`) to `"KeyboardDisplay"` backed by `/run/bananarchy/bt-obex/{pair_prompt,pair_decision,op_done}.tsv` IPC and `NetModal::BtPairingPrompt` (`CONFIRM` 6-digit passkey match, keypad `PIN` / `PASSKEY` entry, `DISPLAY` keyboard code, and `Cancel`/`Close` rejection, while auto-confirming screenless Classic Audio headsets); enabled `bredr on`, `ssp on`, `linksec on`, `bondable on`, and `advertising off` alongside `class 2 3` and `le on` in `bananarchy-bt-le-enable.sh` (`PairableTimeout = 0` in `main.conf` while keeping `DiscoverableTimeout = 60` hidden by default); fixed root/`user` daemon UID collisions and sticky-`/tmp` PID/status writes (`errno != EPERM` + `doas -n bananarchy-bt-obex start` + boot hook restart when BT is enabled); made `networks_plugin.cpp` `Connect`/`Pair` non-blocking (`--async-ui`), prevented `cli_agent` hijacking and 8 s `Pair` aborts (`50 s` timeout), and fixed phone `Icon: phone`/`computer` (`OBEX/PAN`) vs Classic Audio classification across `queryBtDevices()` and `is_phone_or_computer_props()`.
|
||||||
@@ -75,10 +81,10 @@ Upcoming release build (`a1120` / `cocojamboo` via `scripts/version.sh`) targeti
|
|||||||
### Image persistence and upcoming `a1120` (`cocojamboo`) release archives
|
### Image persistence and upcoming `a1120` (`cocojamboo`) release archives
|
||||||
|
|
||||||
- **Verified `a1120` / `cocojamboo` image set (`--mkinitfs`) and packaged archives**:
|
- **Verified `a1120` / `cocojamboo` image set (`--mkinitfs`) and packaged archives**:
|
||||||
- `images/bananarchy-nokia-argon.img`: SHA-256 `0a6760f8ff4a4d2baa6af88ce080898a1e3aff206e15b8474efa3ea4274d6dee` (packaged in `bananarchy-nokia-argon-a1120-cocojamboo.zip`, SHA-256 `e7ccaa6baf3518896b22c60070508ab65f3938f204f0ddb2e7d0d5f2e39d271f`, alongside `bootloader/lk2nd-msm8909.img`).
|
- `images/bananarchy-nokia-argon.img`: SHA-256 `dfd5361d4c38f2a88d45693f7456f7464a89f121ad05e7f8ac0497b498788d20` (packaged in `bananarchy-nokia-argon-a1120-cocojamboo.zip`, SHA-256 `09306cee5824fda8bdea0ac316554274d68395510b63a8c0dc2fe404e2646b47`, alongside `bootloader/lk2nd-msm8909.img`).
|
||||||
- `images/bananarchy-nokia-beatles.img`: SHA-256 `7bb47f4e938d412e2e5fed5eb5b766bbbe36c71fa6e7b77d2cda346b48a82e17`, `images/boot-bananarchy-nokia-beatles.img`: SHA-256 `496890063eda83adafaf5e7796a801100795b825064cf6f7fd967e6565dca325`, and `images/boot-lk2nd-nokia-beatles-display.img`: SHA-256 `f13db705a714aaebd2d8fcc2e0f7266d0e40268c0a276208117dfdf9d8f45351` (packaged in `bananarchy-nokia-beatles-a1120-cocojamboo.zip`, SHA-256 `7caffc7057fa89df92e33a1915e064df1deee3c1f7e650ad8486d4a1d179d7b6`).
|
- `images/bananarchy-nokia-beatles.img`: SHA-256 `83d7369e114b4db90ae3dfeefc88f3aa864bf3283469fe00965addd86fa8751f`, `images/boot-bananarchy-nokia-beatles.img`: SHA-256 `7f21313963f2868349924da0eb8e6a54131de76bd03bdd3a900f6eb68250b3e2`, and `images/boot-lk2nd-nokia-beatles-display.img`: SHA-256 `f13db705a714aaebd2d8fcc2e0f7266d0e40268c0a276208117dfdf9d8f45351` (packaged in `bananarchy-nokia-beatles-a1120-cocojamboo.zip`, SHA-256 `c81f19dbe83165b1b4d9b3f72988481ede716f8041bfe74b3442b4ea8c029500`).
|
||||||
- `images/bananarchy-nokia-coconut.img`: SHA-256 `d3b385a84c6546d35edca03eac684f3d7ee6de0faab25172b9af5252137c6815`, `images/boot-bananarchy-nokia-coconut.img`: SHA-256 `0a91c165e370b35a1604d08ddb6b08c46823455e5aee9701807f78221059e26c`, and `images/boot-lk2nd-nokia-coconut-display.img`: SHA-256 `9a5bd2da6cfd95c745d9c1acb2e3bc61afa339824810e3d160bf079e17b23192` (packaged in `bananarchy-nokia-coconut-a1120-cocojamboo.zip`, SHA-256 `f92c2681dce97a51a98bb13f33f8b7a0a185625ab0cd85e6664074e816d1282c`).
|
- `images/bananarchy-nokia-coconut.img`: SHA-256 `cf0826eaf298b9161012cad38d66f979af004aeb71f29fa1818f4f7fe222db86`, `images/boot-bananarchy-nokia-coconut.img`: SHA-256 `310169cfb5d434c10a0af56e4185aeea8d74013c0b548ea27ec581236d9ac131`, and `images/boot-lk2nd-nokia-coconut-display.img`: SHA-256 `9a5bd2da6cfd95c745d9c1acb2e3bc61afa339824810e3d160bf079e17b23192` (packaged in `bananarchy-nokia-coconut-a1120-cocojamboo.zip`, SHA-256 `604ddcd61fb1fb45600adbbd370be2ab88183f1126a82ac1ff7385462977900b`).
|
||||||
- `images/bananarchy-nokia-sparkler.img`: SHA-256 `a262cb31ddb38e222e5f4bd14d82c82bb7941839a34bb48fa120b74189d319ae`, `images/boot-bananarchy-nokia-sparkler.img`: SHA-256 `affc62ff400c082c29b0d0c11a06bdd2eefdd06e09f1d2e93e7eae6a47a5a7b1`, and `images/boot-lk2nd-nokia-sparkler-display.img`: SHA-256 `120ade81bc5416263a1afd95a29981675358b98516e105e5ed611edf258a29f7` (packaged in `bananarchy-nokia-sparkler-a1120-cocojamboo.zip`, SHA-256 `d38201d4bd0c2d2d889a9444dbed72059594a96d56716621a437c2d753abaa47`).
|
- `images/bananarchy-nokia-sparkler.img`: SHA-256 `01860ac705afe193cd5252f0d42907ba35fe98be1a0509097d4994d824d0cb4d`, `images/boot-bananarchy-nokia-sparkler.img`: SHA-256 `7f95573f8caa6b07387836feb52bac9167ad0dede9922fb3b0cbf1eb32ad9119`, and `images/boot-lk2nd-nokia-sparkler-display.img`: SHA-256 `120ade81bc5416263a1afd95a29981675358b98516e105e5ed611edf258a29f7` (packaged in `bananarchy-nokia-sparkler-a1120-cocojamboo.zip`, SHA-256 `a17d9d32657de1feddffcfb15e76f9802e6703729221d3099b6371176ae8b990`).
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ All twenty-five phone applications are compiled as shared-object plugins (`/usr/
|
|||||||
- **Open**: select **Networks** or **Bluetooth** from the System menu, or run `xnetworks` / `xbluetooth`.
|
- **Open**: select **Networks** or **Bluetooth** from the System menu, or run `xnetworks` / `xbluetooth`.
|
||||||
- **Three connectivity tabs (`Left`/`Right` or `1`–`3`)**:
|
- **Three connectivity tabs (`Left`/`Right` or `1`–`3`)**:
|
||||||
- **`1:Wi-Fi`**: toggle Wi-Fi radio, rescan (`*`), toggle **Wi-Fi Hotspot**, and connect to WPA2/open networks with a multi-tap password dialog (`*` toggles password visibility).
|
- **`1:Wi-Fi`**: toggle Wi-Fi radio, rescan (`*`), toggle **Wi-Fi Hotspot**, and connect to WPA2/open networks with a multi-tap password dialog (`*` toggles password visibility).
|
||||||
- **`2:Cell/APN`**: toggle **Mobile Data** (configuring the QMI `bam-dmux` `wwan0` static IPv4 bearer, default route, and DNS automatically), inspect `wwan0` IPv4 status, edit **APN Configuration**, and toggle **USB Tethering**.
|
- **`2:Cell/APN`**: toggle **Mobile Data** (configuring the QMI `bam-dmux` `wwan0` static IPv4 bearer, default route, and DNS via NetworkManager `rc-manager=file` + local `dnsmasq` caching, with automatic `1.1.1.1`/`9.9.9.9` fallback when a carrier omits DNS), inspect `wwan0` IPv4 status, edit **APN Configuration**, and toggle **USB Tethering** (forwarding tethered `172.16.42.1:53` queries to local `dnsmasq`).
|
||||||
- **`3:Bluetooth`**: toggle **Bluetooth Power** (showing a live `ON (N Active)` badge and starting `/usr/bin/bananarchy-bt-obex`), toggle **Discoverable** (`OFF (Hidden)` by default to avoid continuous Inquiry Scan standby draw, or `ON (Visible for 60s)`, persisted in `~/.config/sxmo/bt_discoverable`), edit the **Bluetooth Device Name** (`Name: <Alias> [Edit]`, persisted in `~/.config/sxmo/bt_name` and applied via `bluetoothctl system-alias` independently of the system hostname), configure the **OBEX File Receiver** (`OBEX Dir: <folder> [Set]`, opening actions to **Set Target Directory...** via an interactive folder picker including `/media/sdcard`, **Open Folder in Files**, or **Reset to ~/Downloads**, persisted in `~/.config/sxmo/bt_obex_dir`; `#` quick-opens the folder in `xfiles`), scan nearby devices (`*` or `Scan`, 15-second discovery scan), and manage paired/discovered devices. Pairing runs via a persistent `KeyboardDisplay` `Agent1` in `/usr/bin/bananarchy-bt-obex` (with `ssp on`, `bondable on`, `linksec on`, `advertising off`, Smartphone class `2 3`, and `PairableTimeout = 0`), popping up an interactive pairing dialog in `xnetworks` for 6-digit passkey confirmation (`Accept & Pair` / `Reject Pairing`), keypad PIN/passkey entry, or outgoing keyboard pairing codes (while auto-confirming screenless Classic Audio headsets). Incoming OBEX file pushes (over both L2CAP `SOCK_SEQPACKET` and RFCOMM, with Smartphone Class of Device `0x5a020c` and no `a2dp_source` role so paired Android phones recognize OPP rather than a headset) pop up an interactive confirmation dialog showing sender, filename, size, **Accept & Save File**, **Dir: ... [Set]** to pick a different destination folder on the spot, and **Reject Transfer**. The scan now drives one interactive `bluetoothctl` client through `script(1)` (`/usr/local/bin/bluetoothctl` -> `/usr/bin/bananarchy-bt-scan.sh`), sets auto transport and duplicate-data, asks the same client for `devices` three times while discovery is active, parses both `[NEW] Device ...` / `[CHG] Device ...` and `Device <MAC> <Name>` lines, and stops discovery cleanly before the client exits; the controller is also powered on automatically if `bluetoothctl show` reports `Powered: no`. A narrow `doas` helper runs `btmgmt -i hci0 le on` alongside BR/EDR SSP/bondable flags before discovery because this WCNSS controller otherwise starts with LE and pairing flags unconfigured. BlueZ keeps `ControllerMode = dual`: `bredr` mode rejects the LE-only HOGP profile, so BLE HID devices would connect at the GATT level but never create a keyboard or mouse input node. **Connect Device** and **Pair & Trust Device** run non-blockingly (`--async-ui`), power the adapter on, enable LE/SSP, select the `le` bearer for HID-over-GATT devices, prefer public BR/EDR entries and the `bredr` bearer (`ConnectProfile` A2DP/HFP fallback) for Classic Audio / dual-mode Bluetooth 5.x/6.x headsets or `OBEX/PAN` phones, and automatically pair unpaired peripherals. Active connections are pinned to the top of the device list with a green border and live profile/battery badges (`[ACTIVE: A2DP]`, `[ACTIVE: HSP/HFP]`, `[ACTIVE: HID Gamepad]`, `[ACTIVE: HID Keyboard]`, `[ACTIVE: HID Mouse]`), and the device actions menu (`Center OK`) provides **Connect Device**, **Disconnect Device**, **Pair & Trust Device**, **Switch Audio (A2DP / HSP-HFP)**, and **Forget / Remove Device**. Supports Bluetooth **A2DP** (`sbc`, `sbc_xq`, `aac`, `ldac` ABR `auto`, `aptx`, `aptx_hd`) with AVRCP hardware volume and Play/Pause/Next/Prev headset button control of `xmusic`, and **HSP/HFP** (`CVSD` 8 kHz over QDSP6 `INTERNAL_BT_SCO`, with `mSBC`/`LC3-A127`/`LC3` and unsupported LE Audio BAP roles disabled, plus headset `ATA` call answer/A2DP restore synchronization), **HID keyboards** (automatically switching `fcitx5-t9` and NeoUI/plugin inputs to `[KBD]` direct QWERTY mode so `0-9`, `*`, `#`, `Shift+0-9`, and letters bypass T9 multi-tap and preedit popups), **HID mice** (automatically showing the X11 mouse cursor whenever a mouse is connected and hiding it when disconnected), and **HID gamepads** (automatically bridged to the phone's D-Pad, softkeys, and action keys via `/dev/uinput`).
|
- **`3:Bluetooth`**: toggle **Bluetooth Power** (showing a live `ON (N Active)` badge and starting `/usr/bin/bananarchy-bt-obex`), toggle **Discoverable** (`OFF (Hidden)` by default to avoid continuous Inquiry Scan standby draw, or `ON (Visible for 60s)`, persisted in `~/.config/sxmo/bt_discoverable`), edit the **Bluetooth Device Name** (`Name: <Alias> [Edit]`, persisted in `~/.config/sxmo/bt_name` and applied via `bluetoothctl system-alias` independently of the system hostname), configure the **OBEX File Receiver** (`OBEX Dir: <folder> [Set]`, opening actions to **Set Target Directory...** via an interactive folder picker including `/media/sdcard`, **Open Folder in Files**, or **Reset to ~/Downloads**, persisted in `~/.config/sxmo/bt_obex_dir`; `#` quick-opens the folder in `xfiles`), scan nearby devices (`*` or `Scan`, 15-second discovery scan), and manage paired/discovered devices. Pairing runs via a persistent `KeyboardDisplay` `Agent1` in `/usr/bin/bananarchy-bt-obex` (with `ssp on`, `bondable on`, `linksec on`, `advertising off`, Smartphone class `2 3`, and `PairableTimeout = 0`), popping up an interactive pairing dialog in `xnetworks` for 6-digit passkey confirmation (`Accept & Pair` / `Reject Pairing`), keypad PIN/passkey entry, or outgoing keyboard pairing codes (while auto-confirming screenless Classic Audio headsets). Incoming OBEX file pushes (over both L2CAP `SOCK_SEQPACKET` and RFCOMM, with Smartphone Class of Device `0x5a020c` and no `a2dp_source` role so paired Android phones recognize OPP rather than a headset) pop up an interactive confirmation dialog showing sender, filename, size, **Accept & Save File**, **Dir: ... [Set]** to pick a different destination folder on the spot, and **Reject Transfer**. The scan now drives one interactive `bluetoothctl` client through `script(1)` (`/usr/local/bin/bluetoothctl` -> `/usr/bin/bananarchy-bt-scan.sh`), sets auto transport and duplicate-data, asks the same client for `devices` three times while discovery is active, parses both `[NEW] Device ...` / `[CHG] Device ...` and `Device <MAC> <Name>` lines, and stops discovery cleanly before the client exits; the controller is also powered on automatically if `bluetoothctl show` reports `Powered: no`. A narrow `doas` helper runs `btmgmt -i hci0 le on` alongside BR/EDR SSP/bondable flags before discovery because this WCNSS controller otherwise starts with LE and pairing flags unconfigured. BlueZ keeps `ControllerMode = dual`: `bredr` mode rejects the LE-only HOGP profile, so BLE HID devices would connect at the GATT level but never create a keyboard or mouse input node. **Connect Device** and **Pair & Trust Device** run non-blockingly (`--async-ui`), power the adapter on, enable LE/SSP, select the `le` bearer for HID-over-GATT devices, prefer public BR/EDR entries and the `bredr` bearer (`ConnectProfile` A2DP/HFP fallback) for Classic Audio / dual-mode Bluetooth 5.x/6.x headsets or `OBEX/PAN` phones, and automatically pair unpaired peripherals. Active connections are pinned to the top of the device list with a green border and live profile/battery badges (`[ACTIVE: A2DP]`, `[ACTIVE: HSP/HFP]`, `[ACTIVE: HID Gamepad]`, `[ACTIVE: HID Keyboard]`, `[ACTIVE: HID Mouse]`), and the device actions menu (`Center OK`) provides **Connect Device**, **Disconnect Device**, **Pair & Trust Device**, **Switch Audio (A2DP / HSP-HFP)**, and **Forget / Remove Device**. Supports Bluetooth **A2DP** (`sbc`, `sbc_xq`, `aac`, `ldac` ABR `auto`, `aptx`, `aptx_hd`) with AVRCP hardware volume and Play/Pause/Next/Prev headset button control of `xmusic`, and **HSP/HFP** (`CVSD` 8 kHz over QDSP6 `INTERNAL_BT_SCO`, with `mSBC`/`LC3-A127`/`LC3` and unsupported LE Audio BAP roles disabled, plus headset `ATA` call answer/A2DP restore synchronization), **HID keyboards** (automatically switching `fcitx5-t9` and NeoUI/plugin inputs to `[KBD]` direct QWERTY mode so `0-9`, `*`, `#`, `Shift+0-9`, and letters bypass T9 multi-tap and preedit popups), **HID mice** (automatically showing the X11 mouse cursor whenever a mouse is connected and hiding it when disconnected), and **HID gamepads** (automatically bridged to the phone's D-Pad, softkeys, and action keys via `/dev/uinput`).
|
||||||
|
|
||||||
13. **Ringtones, notification/SMS sounds, and ringer manager (`ringtones.so` / `xringtones`)**:
|
13. **Ringtones, notification/SMS sounds, and ringer manager (`ringtones.so` / `xringtones`)**:
|
||||||
@@ -336,7 +336,7 @@ All twenty-five phone applications are compiled as shared-object plugins (`/usr/
|
|||||||
- **`3:OVPN` (OpenVPN)**: start/stop OpenVPN (`tun_ovpn`) using any `.ovpn` configuration file selected via the built-in file picker or path editor, and independently toggle **Route Native Traffic** and **Route Wi-Fi/USB Tether** (`table 220`).
|
- **`3:OVPN` (OpenVPN)**: start/stop OpenVPN (`tun_ovpn`) using any `.ovpn` configuration file selected via the built-in file picker or path editor, and independently toggle **Route Native Traffic** and **Route Wi-Fi/USB Tether** (`table 220`).
|
||||||
- **`4:GS` (GSocket single TCP port)**: start/stop `gs-netcat` (`gsocket`) for a single configurable **TCP Port** (`1`–`65535`) with a custom **GSocket Secret** (or generate a random secret via `gs-netcat -g`), switch between `Client (Out)` and `Server (In)` mode, and independently toggle **Route Native Port** and **Route Tethered Port** (`iptables -t nat REDIRECT` for that TCP port).
|
- **`4:GS` (GSocket single TCP port)**: start/stop `gs-netcat` (`gsocket`) for a single configurable **TCP Port** (`1`–`65535`) with a custom **GSocket Secret** (or generate a random secret via `gs-netcat -g`), switch between `Client (Out)` and `Server (In)` mode, and independently toggle **Route Native Port** and **Route Tethered Port** (`iptables -t nat REDIRECT` for that TCP port).
|
||||||
- **`5:WG` (WireGuard)**: start/stop a kernel WireGuard interface (`wg0`), generate a fresh Curve25519 keypair (`Generate New Keypair`), import a standard WireGuard `.conf` file, edit custom `PrivateKey`, `Peer PublicKey`, optional `PresharedKey`, `Endpoint (host:port)`, `Interface IP/CIDR`, and `Tunnel DNS`, and independently toggle **Route Native Traffic** and **Route Wi-Fi/USB Tether** (`table 230` with `fwmark 0xca6c` loop avoidance).
|
- **`5:WG` (WireGuard)**: start/stop a kernel WireGuard interface (`wg0`), generate a fresh Curve25519 keypair (`Generate New Keypair`), import a standard WireGuard `.conf` file, edit custom `PrivateKey`, `Peer PublicKey`, optional `PresharedKey`, `Endpoint (host:port)`, `Interface IP/CIDR`, and `Tunnel DNS`, and independently toggle **Route Native Traffic** and **Route Wi-Fi/USB Tether** (`table 230` with `fwmark 0xca6c` loop avoidance).
|
||||||
- **Zero-drain standby**: no background OpenRC daemons run when services are turned off, and `privacy.so` sleeps at `0%` CPU on `poll()` when hidden.
|
- **Zero-drain standby & DNS leak protection**: no background OpenRC daemons run when services are turned off, `privacy.so` sleeps at `0%` CPU on `poll()` when hidden, and active VPN tunnels pin only tunneled nameservers (`sync-dns` without `127.0.0.1`) so musl parallel queries never leak outside the tunnel and `/etc/resolv.conf` restores cleanly after tunnel shutdown or reboot.
|
||||||
|
|
||||||
27. **Engineering menu (`engmenu.so` / `xengmenu`) and extended logging toggle (`bananarchy-engmenu-ctl`)**:
|
27. **Engineering menu (`engmenu.so` / `xengmenu`) and extended logging toggle (`bananarchy-engmenu-ctl`)**:
|
||||||
- **Open**: dial **`*#0001#`** (or `###`) in `xdialer`, or run `xengmenu` (hidden and blocked in Duress Mode).
|
- **Open**: dial **`*#0001#`** (or `###`) in `xdialer`, or run `xengmenu` (hidden and blocked in Duress Mode).
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
# Keep NetworkManager's local caching/interface-scoped dnsmasq plugin, but
|
||||||
|
# manage /etc/resolv.conf atomically as a file instead of openresolv so
|
||||||
|
# signature mismatches never lock out DNS updates across reboots and network
|
||||||
|
# transitions do not fork resolvconf subscriber scripts.
|
||||||
|
[main]
|
||||||
|
dns=dnsmasq
|
||||||
|
rc-manager=file
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# Generated by NetworkManager
|
||||||
|
nameserver 127.0.0.1
|
||||||
|
options edns0 trust-ad
|
||||||
@@ -4,10 +4,16 @@
|
|||||||
# with zero background CPU/battery drain when services are turned off.
|
# with zero background CPU/battery drain when services are turned off.
|
||||||
set -u
|
set -u
|
||||||
|
|
||||||
STATE_DIR="/tmp/bananarchy-privacy"
|
STATE_DIR="${BANANARCHY_PRIVACY_STATE_DIR:-/tmp/bananarchy-privacy}"
|
||||||
USER_HOME="/home/user"
|
USER_HOME="/home/user"
|
||||||
CONF_DIR="$USER_HOME/.config/bananarchy"
|
CONF_DIR="${BANANARCHY_PRIVACY_CONF_DIR:-$USER_HOME/.config/bananarchy}"
|
||||||
CONF_FILE="$CONF_DIR/privacy.conf"
|
CONF_FILE="${BANANARCHY_PRIVACY_CONF:-$CONF_DIR/privacy.conf}"
|
||||||
|
RESOLV_CONF="${BANANARCHY_RESOLV_CONF:-/etc/resolv.conf}"
|
||||||
|
NM_RESOLV_CONF="${BANANARCHY_NM_RESOLV_CONF:-/run/NetworkManager/resolv.conf}"
|
||||||
|
NM_NOSTUB_RESOLV_CONF="${BANANARCHY_NM_NOSTUB_RESOLV_CONF:-/run/NetworkManager/no-stub-resolv.conf}"
|
||||||
|
DURESS_FILE="${BANANARCHY_DURESS_FILE:-/tmp/bananarchy_duress_mode}"
|
||||||
|
SCREEN_LOCKED_FILE="${BANANARCHY_SCREEN_LOCKED_FILE:-/tmp/bananarchy_screen_locked}"
|
||||||
|
PRIVACY_NO_ROOT="${BANANARCHY_PRIVACY_NO_ROOT:-0}"
|
||||||
DEFAULT_GSWARP_OVPN="$USER_HOME/.config/gs-warp/client.ovpn"
|
DEFAULT_GSWARP_OVPN="$USER_HOME/.config/gs-warp/client.ovpn"
|
||||||
if [ ! -f "$DEFAULT_GSWARP_OVPN" ] && [ -f "/etc/gs-warp/client.ovpn" ]; then
|
if [ ! -f "$DEFAULT_GSWARP_OVPN" ] && [ -f "/etc/gs-warp/client.ovpn" ]; then
|
||||||
DEFAULT_GSWARP_OVPN="/etc/gs-warp/client.ovpn"
|
DEFAULT_GSWARP_OVPN="/etc/gs-warp/client.ovpn"
|
||||||
@@ -16,15 +22,18 @@ fi
|
|||||||
CMD="${1:-status}"
|
CMD="${1:-status}"
|
||||||
|
|
||||||
# Block all operations except stop-all when in duress mode or screen locked
|
# Block all operations except stop-all when in duress mode or screen locked
|
||||||
if [ "$CMD" != "stop-all" ] && [ "$CMD" != "_ovpn_up" ] && [ "$CMD" != "_tor_up" ]; then
|
# Allow sync-dns while screen-locked (unless in duress) so Wi-Fi roam keeps tunnel DNS pinned
|
||||||
if [ -e "/tmp/bananarchy_duress_mode" ] || [ -e "/tmp/bananarchy_screen_locked" ]; then
|
if [ "$CMD" != "stop-all" ] && [ "$CMD" != "_ovpn_up" ] && [ "$CMD" != "_tor_up" ] && [ "$CMD" != "sync-dns" ]; then
|
||||||
|
if [ -e "$DURESS_FILE" ] || [ -e "$SCREEN_LOCKED_FILE" ]; then
|
||||||
echo "Error: Privacy Center is unavailable." >&2
|
echo "Error: Privacy Center is unavailable." >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
elif [ "$CMD" = "sync-dns" ] && [ -e "$DURESS_FILE" ]; then
|
||||||
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Escalate to root via doas or bananarchy-engmenu-exec if invoked as normal user
|
# Escalate to root via doas or bananarchy-engmenu-exec if invoked as normal user
|
||||||
if [ "$(id -u)" -ne 0 ]; then
|
if [ "$PRIVACY_NO_ROOT" != "1" ] && [ "$(id -u)" -ne 0 ]; then
|
||||||
if command -v doas >/dev/null 2>&1; then
|
if command -v doas >/dev/null 2>&1; then
|
||||||
exec doas -n /usr/bin/bananarchy-privacy-ctl "$@"
|
exec doas -n /usr/bin/bananarchy-privacy-ctl "$@"
|
||||||
elif [ -x /usr/bin/bananarchy-engmenu-exec ]; then
|
elif [ -x /usr/bin/bananarchy-engmenu-exec ]; then
|
||||||
@@ -38,7 +47,11 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
if [ -n "${BANANARCHY_TEST_PATH_PREFIX:-}" ]; then
|
||||||
|
export PATH="${BANANARCHY_TEST_PATH_PREFIX}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||||
|
else
|
||||||
|
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||||
|
fi
|
||||||
mkdir -p "$STATE_DIR" "$CONF_DIR"
|
mkdir -p "$STATE_DIR" "$CONF_DIR"
|
||||||
|
|
||||||
# Default configuration values
|
# Default configuration values
|
||||||
@@ -159,7 +172,7 @@ is_tor_active() {
|
|||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
pgrep -x tor >/dev/null 2>&1
|
pidof tor >/dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
is_gswarp_active() {
|
is_gswarp_active() {
|
||||||
@@ -203,6 +216,27 @@ is_wg_active() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Remove an iptables chain from a table and all references from hook chains
|
# Remove an iptables chain from a table and all references from hook chains
|
||||||
|
find_proc_pids() {
|
||||||
|
_pat="$1"
|
||||||
|
for _pdir in /proc/[0-9]*; do
|
||||||
|
[ -r "$_pdir/cmdline" ] || continue
|
||||||
|
_pid="${_pdir#/proc/}"
|
||||||
|
[ "$_pid" = "$$" ] && continue
|
||||||
|
_cmd="$(tr '\0' ' ' < "$_pdir/cmdline" 2>/dev/null || true)"
|
||||||
|
case "$_cmd" in
|
||||||
|
*$_pat*)
|
||||||
|
printf '%s\n' "$_pid"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
kill_proc_matches() {
|
||||||
|
for _pid in $(find_proc_pids "$1"); do
|
||||||
|
kill "$_pid" 2>/dev/null || true
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
flush_and_delete_chain() {
|
flush_and_delete_chain() {
|
||||||
tbl="$1"
|
tbl="$1"
|
||||||
chain="$2"
|
chain="$2"
|
||||||
@@ -276,30 +310,26 @@ sync_dns_resolv() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$active_dns" ]; then
|
if [ -n "$active_dns" ]; then
|
||||||
if [ ! -f "$STATE_DIR/resolv.conf.orig" ] && [ -f /etc/resolv.conf ]; then
|
|
||||||
cp -f /etc/resolv.conf "$STATE_DIR/resolv.conf.orig" 2>/dev/null || true
|
|
||||||
fi
|
|
||||||
{
|
{
|
||||||
echo "# Managed by bananarchy-privacy-ctl (tunneled DNS)"
|
echo "# Managed by bananarchy-privacy-ctl (tunneled DNS)"
|
||||||
echo "nameserver $active_dns"
|
echo "nameserver $active_dns"
|
||||||
if [ "$active_dns" != "1.1.1.1" ]; then
|
if [ "$active_dns" != "127.0.0.1" ] && [ "$active_dns" != "1.1.1.1" ]; then
|
||||||
echo "nameserver 1.1.1.1"
|
echo "nameserver 1.1.1.1"
|
||||||
fi
|
fi
|
||||||
if [ "$active_dns" != "127.0.0.1" ]; then
|
|
||||||
echo "nameserver 127.0.0.1"
|
|
||||||
fi
|
|
||||||
} > "$STATE_DIR/resolv.conf.new"
|
} > "$STATE_DIR/resolv.conf.new"
|
||||||
cp -f "$STATE_DIR/resolv.conf.new" /etc/resolv.conf 2>/dev/null || true
|
cp -f "$STATE_DIR/resolv.conf.new" "$RESOLV_CONF" 2>/dev/null || true
|
||||||
else
|
else
|
||||||
if [ -f "$STATE_DIR/resolv.conf.orig" ]; then
|
rm -f "$STATE_DIR/resolv.conf.orig" "$STATE_DIR/resolv.conf.new" 2>/dev/null || true
|
||||||
cp -f "$STATE_DIR/resolv.conf.orig" /etc/resolv.conf 2>/dev/null || true
|
if grep -q '^nameserver ' "$NM_RESOLV_CONF" 2>/dev/null; then
|
||||||
rm -f "$STATE_DIR/resolv.conf.orig"
|
cp -f "$NM_RESOLV_CONF" "$RESOLV_CONF" 2>/dev/null || true
|
||||||
fi
|
elif grep -q '^nameserver ' "$NM_NOSTUB_RESOLV_CONF" 2>/dev/null; then
|
||||||
if ! grep -q '^nameserver ' /etc/resolv.conf 2>/dev/null; then
|
cp -f "$NM_NOSTUB_RESOLV_CONF" "$RESOLV_CONF" 2>/dev/null || true
|
||||||
|
else
|
||||||
{
|
{
|
||||||
|
echo "# Generated by NetworkManager"
|
||||||
echo "nameserver 127.0.0.1"
|
echo "nameserver 127.0.0.1"
|
||||||
echo "nameserver 1.1.1.1"
|
echo "options edns0 trust-ad"
|
||||||
} > /etc/resolv.conf 2>/dev/null || true
|
} > "$RESOLV_CONF" 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -490,7 +520,7 @@ stop_tor() {
|
|||||||
kill "$(cat "$STATE_DIR/tor.pid" 2>/dev/null)" 2>/dev/null || true
|
kill "$(cat "$STATE_DIR/tor.pid" 2>/dev/null)" 2>/dev/null || true
|
||||||
rm -f "$STATE_DIR/tor.pid"
|
rm -f "$STATE_DIR/tor.pid"
|
||||||
fi
|
fi
|
||||||
pkill -x tor 2>/dev/null || true
|
killall -q tor 2>/dev/null || true
|
||||||
sync_dns_resolv
|
sync_dns_resolv
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -627,7 +657,7 @@ start_gswarp() {
|
|||||||
-D -p 1194 -s "$GSWARP_SECRET" 2>/dev/null || \
|
-D -p 1194 -s "$GSWARP_SECRET" 2>/dev/null || \
|
||||||
/usr/bin/gs-netcat -D -p 1194 -s "$GSWARP_SECRET" 2>/dev/null
|
/usr/bin/gs-netcat -D -p 1194 -s "$GSWARP_SECRET" 2>/dev/null
|
||||||
sleep 0.2
|
sleep 0.2
|
||||||
gs_pid="$(pgrep -f "gs-netcat -D -p 1194" | head -n 1 || true)"
|
gs_pid="$(find_proc_pids "gs-netcat -D -p 1194" | head -n 1 || true)"
|
||||||
if [ -z "$gs_pid" ]; then
|
if [ -z "$gs_pid" ]; then
|
||||||
echo "Error: failed to start gs-netcat for GS-Warp." >&2
|
echo "Error: failed to start gs-netcat for GS-Warp." >&2
|
||||||
return 1
|
return 1
|
||||||
@@ -673,8 +703,8 @@ stop_gswarp() {
|
|||||||
rm -f "$pidf"
|
rm -f "$pidf"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
pkill -f "gs-netcat -D -p 1194" 2>/dev/null || true
|
kill_proc_matches "gs-netcat -D -p 1194"
|
||||||
pkill -f "openvpn.*tun_gswarp" 2>/dev/null || true
|
kill_proc_matches "openvpn*tun_gswarp"
|
||||||
ip link del dev tun_gswarp 2>/dev/null || true
|
ip link del dev tun_gswarp 2>/dev/null || true
|
||||||
sync_base_vpn_rules
|
sync_base_vpn_rules
|
||||||
sync_dns_resolv
|
sync_dns_resolv
|
||||||
@@ -730,7 +760,7 @@ stop_ovpn() {
|
|||||||
kill "$(cat "$STATE_DIR/ovpn.pid" 2>/dev/null)" 2>/dev/null || true
|
kill "$(cat "$STATE_DIR/ovpn.pid" 2>/dev/null)" 2>/dev/null || true
|
||||||
rm -f "$STATE_DIR/ovpn.pid"
|
rm -f "$STATE_DIR/ovpn.pid"
|
||||||
fi
|
fi
|
||||||
pkill -f "openvpn.*tun_ovpn" 2>/dev/null || true
|
kill_proc_matches "openvpn*tun_ovpn"
|
||||||
ip link del dev tun_ovpn 2>/dev/null || true
|
ip link del dev tun_ovpn 2>/dev/null || true
|
||||||
sync_base_vpn_rules
|
sync_base_vpn_rules
|
||||||
sync_dns_resolv
|
sync_dns_resolv
|
||||||
@@ -816,13 +846,13 @@ start_gsocket() {
|
|||||||
-D -l -s "$GSOCKET_SECRET" -d 127.0.0.1 -p "$GSOCKET_PORT" 2>/dev/null || \
|
-D -l -s "$GSOCKET_SECRET" -d 127.0.0.1 -p "$GSOCKET_PORT" 2>/dev/null || \
|
||||||
/usr/bin/gs-netcat -D -l -s "$GSOCKET_SECRET" -d 127.0.0.1 -p "$GSOCKET_PORT" 2>/dev/null
|
/usr/bin/gs-netcat -D -l -s "$GSOCKET_SECRET" -d 127.0.0.1 -p "$GSOCKET_PORT" 2>/dev/null
|
||||||
sleep 0.2
|
sleep 0.2
|
||||||
gs_pid="$(pgrep -f "gs-netcat -D -l -s .* -p $GSOCKET_PORT" | head -n 1 || true)"
|
gs_pid="$(find_proc_pids "gs-netcat -D -l -s *-p $GSOCKET_PORT" | head -n 1 || true)"
|
||||||
else
|
else
|
||||||
start-stop-daemon -S -g openvpn -x /usr/bin/gs-netcat -- \
|
start-stop-daemon -S -g openvpn -x /usr/bin/gs-netcat -- \
|
||||||
-D -s "$GSOCKET_SECRET" -p "$GSOCKET_PORT" 2>/dev/null || \
|
-D -s "$GSOCKET_SECRET" -p "$GSOCKET_PORT" 2>/dev/null || \
|
||||||
/usr/bin/gs-netcat -D -s "$GSOCKET_SECRET" -p "$GSOCKET_PORT" 2>/dev/null
|
/usr/bin/gs-netcat -D -s "$GSOCKET_SECRET" -p "$GSOCKET_PORT" 2>/dev/null
|
||||||
sleep 0.2
|
sleep 0.2
|
||||||
gs_pid="$(pgrep -f "gs-netcat -D -s .* -p $GSOCKET_PORT" | head -n 1 || true)"
|
gs_pid="$(find_proc_pids "gs-netcat -D -s *-p $GSOCKET_PORT" | head -n 1 || true)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$gs_pid" ]; then
|
if [ -z "$gs_pid" ]; then
|
||||||
@@ -839,8 +869,8 @@ stop_gsocket() {
|
|||||||
kill "$(cat "$STATE_DIR/gsocket-port.pid" 2>/dev/null)" 2>/dev/null || true
|
kill "$(cat "$STATE_DIR/gsocket-port.pid" 2>/dev/null)" 2>/dev/null || true
|
||||||
rm -f "$STATE_DIR/gsocket-port.pid"
|
rm -f "$STATE_DIR/gsocket-port.pid"
|
||||||
fi
|
fi
|
||||||
pkill -f "gs-netcat -D -s .* -p $GSOCKET_PORT" 2>/dev/null || true
|
kill_proc_matches "gs-netcat -D -s *-p $GSOCKET_PORT"
|
||||||
pkill -f "gs-netcat -D -l -s .* -p $GSOCKET_PORT" 2>/dev/null || true
|
kill_proc_matches "gs-netcat -D -l -s *-p $GSOCKET_PORT"
|
||||||
}
|
}
|
||||||
|
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
@@ -1168,5 +1198,12 @@ case "$CMD" in
|
|||||||
stop_gsocket
|
stop_gsocket
|
||||||
stop_wg
|
stop_wg
|
||||||
;;
|
;;
|
||||||
|
sync-dns)
|
||||||
|
if is_tor_active || is_gswarp_active || is_ovpn_active || is_wg_active; then
|
||||||
|
sync_dns_resolv
|
||||||
|
elif grep -q '^# Managed by bananarchy-privacy-ctl' "$RESOLV_CONF" 2>/dev/null; then
|
||||||
|
sync_dns_resolv
|
||||||
|
fi
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
exit 0
|
exit 0
|
||||||
@@ -1,17 +1,28 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# This dispatcher script configures NetworkManager's dnsmasq instance to
|
# Configure NetworkManager's dnsmasq instance and /etc/resolv.conf fallback state
|
||||||
# restrict DNS responses based on the IP families supported by the Primary
|
# according to active upstream connectivity, treating "/" D-Bus paths as null.
|
||||||
# Connection, treating D-Bus null object paths ("/") as absent.
|
|
||||||
|
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
log_tag="nm-dns-filter"
|
log_tag="nm-dns-filter"
|
||||||
dbus="busctl --json=short"
|
dbus="${BANANARCHY_BUSCTL:-busctl --json=short}"
|
||||||
jq=gojq
|
jq="${BANANARCHY_JQ:-gojq}"
|
||||||
|
ip_cmd="${BANANARCHY_IP_CMD:-ip}"
|
||||||
|
logger_cmd="${BANANARCHY_LOGGER_CMD:-logger}"
|
||||||
|
privacy_ctl="${BANANARCHY_PRIVACY_CTL:-/usr/bin/bananarchy-privacy-ctl}"
|
||||||
|
resolv_conf="${BANANARCHY_RESOLV_CONF:-/etc/resolv.conf}"
|
||||||
|
nm_resolv_conf="${BANANARCHY_NM_RESOLV_CONF:-/run/NetworkManager/resolv.conf}"
|
||||||
|
nm_nostub_resolv_conf="${BANANARCHY_NM_NOSTUB_RESOLV_CONF:-/run/NetworkManager/no-stub-resolv.conf}"
|
||||||
|
accept_ra_dir="${BANANARCHY_IPV6_CONF_DIR:-/proc/sys/net/ipv6/conf}"
|
||||||
|
|
||||||
|
iface="${1:-}"
|
||||||
action="${2:-}"
|
action="${2:-}"
|
||||||
|
|
||||||
get_gateway() {
|
log_msg() {
|
||||||
|
"$logger_cmd" -t "$log_tag" "$*" 2>/dev/null || true
|
||||||
|
}
|
||||||
|
|
||||||
|
get_ipcfg_path() {
|
||||||
_conn="$1"
|
_conn="$1"
|
||||||
_ver="$2"
|
_ver="$2"
|
||||||
|
|
||||||
@@ -25,39 +36,74 @@ get_gateway() {
|
|||||||
echo ""
|
echo ""
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
logger -i -t "$log_tag" "pri conn ip$_ver config path: $_ipcfg"
|
log_msg "pri conn ip$_ver config path: $_ipcfg"
|
||||||
|
echo "$_ipcfg"
|
||||||
|
}
|
||||||
|
|
||||||
_attempt=0
|
get_gateway() {
|
||||||
_gateway=""
|
_ipcfg="$1"
|
||||||
while [ "$_attempt" -lt 5 ]; do
|
_ver="$2"
|
||||||
_gateway="$($dbus get-property \
|
|
||||||
org.freedesktop.NetworkManager \
|
|
||||||
"$_ipcfg" \
|
|
||||||
"org.freedesktop.NetworkManager.IP${_ver}Config" \
|
|
||||||
Gateway 2>/dev/null | $jq -r '.data // empty' 2>/dev/null || true)"
|
|
||||||
if [ -n "$_gateway" ]; then
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
sleep 1
|
|
||||||
_attempt=$(( _attempt + 1 ))
|
|
||||||
done
|
|
||||||
|
|
||||||
logger -i -t "$log_tag" "ip$_ver gateway: $_gateway"
|
if [ -z "$_ipcfg" ] || [ "$_ipcfg" = "/" ]; then
|
||||||
|
echo ""
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
_gateway="$($dbus get-property \
|
||||||
|
org.freedesktop.NetworkManager \
|
||||||
|
"$_ipcfg" \
|
||||||
|
"org.freedesktop.NetworkManager.IP${_ver}Config" \
|
||||||
|
Gateway 2>/dev/null | $jq -r '.data // empty' 2>/dev/null || true)"
|
||||||
|
|
||||||
|
log_msg "ip$_ver gateway: $_gateway"
|
||||||
echo "$_gateway"
|
echo "$_gateway"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dnsmasq_running() {
|
||||||
|
$dbus call org.freedesktop.DBus \
|
||||||
|
/org/freedesktop/DBus \
|
||||||
|
org.freedesktop.DBus \
|
||||||
|
NameHasOwner s org.freedesktop.NetworkManager.dnsmasq 2>/dev/null | \
|
||||||
|
$jq -r '.data[0] // empty' 2>/dev/null | grep -qx 'true'
|
||||||
|
}
|
||||||
|
|
||||||
set_filter() {
|
set_filter() {
|
||||||
_type="$1"
|
_type="$1"
|
||||||
_val="$2"
|
_val="$2"
|
||||||
logger -i -t "$log_tag" "setting $_type filter to '$_val'"
|
log_msg "setting $_type filter to '$_val'"
|
||||||
$dbus call org.freedesktop.NetworkManager.dnsmasq \
|
$dbus call org.freedesktop.NetworkManager.dnsmasq \
|
||||||
/uk/org/thekelleys/dnsmasq \
|
/uk/org/thekelleys/dnsmasq \
|
||||||
org.freedesktop.NetworkManager.dnsmasq \
|
org.freedesktop.NetworkManager.dnsmasq \
|
||||||
"SetFilter$_type" b "$_val"
|
"SetFilter$_type" b "$_val" >/dev/null 2>&1 || true
|
||||||
|
}
|
||||||
|
|
||||||
|
sync_privacy_or_fallback_resolv() {
|
||||||
|
_has_v4="$1"
|
||||||
|
|
||||||
|
if [ -x "$privacy_ctl" ]; then
|
||||||
|
"$privacy_ctl" sync-dns >/dev/null 2>&1 || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
if grep -q '^# Managed by bananarchy-privacy-ctl' "$resolv_conf" 2>/dev/null; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$_has_v4" = "1" ] && ! grep -q '^nameserver ' "$nm_nostub_resolv_conf" 2>/dev/null; then
|
||||||
|
log_msg "no upstream DNS advertised; writing public fallback resolvers"
|
||||||
|
{
|
||||||
|
echo "# Generated by NetworkManager"
|
||||||
|
echo "nameserver 1.1.1.1"
|
||||||
|
echo "nameserver 9.9.9.9"
|
||||||
|
} > "$resolv_conf" 2>/dev/null || true
|
||||||
|
elif grep -q '^nameserver ' "$nm_resolv_conf" 2>/dev/null && \
|
||||||
|
grep -q '^nameserver 1\.1\.1\.1$' "$resolv_conf" 2>/dev/null && \
|
||||||
|
grep -q '^nameserver 127\.0\.0\.1$' "$nm_resolv_conf" 2>/dev/null; then
|
||||||
|
cp -f "$nm_resolv_conf" "$resolv_conf" 2>/dev/null || true
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
case "$action" in
|
case "$action" in
|
||||||
"up" | "down" | "reapply")
|
"up" | "down" | "reapply" | "dhcp4-change" | "dhcp6-change" | "dns-change")
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
exit 0
|
exit 0
|
||||||
@@ -70,40 +116,71 @@ primaryConn="$($dbus get-property \
|
|||||||
org.freedesktop.NetworkManager \
|
org.freedesktop.NetworkManager \
|
||||||
PrimaryConnection 2>/dev/null | $jq -r '.data // empty' 2>/dev/null || true)"
|
PrimaryConnection 2>/dev/null | $jq -r '.data // empty' 2>/dev/null || true)"
|
||||||
|
|
||||||
if [ -z "$primaryConn" ] || [ "$primaryConn" = "/" ]; then
|
ip4cfg=""
|
||||||
|
ip6cfg=""
|
||||||
|
ip4gateway=""
|
||||||
|
ip6gateway=""
|
||||||
|
|
||||||
|
if [ -n "$primaryConn" ] && [ "$primaryConn" != "/" ]; then
|
||||||
|
ip4cfg="$(get_ipcfg_path "$primaryConn" 4)"
|
||||||
|
ip6cfg="$(get_ipcfg_path "$primaryConn" 6)"
|
||||||
|
ip4gateway="$(get_gateway "$ip4cfg" 4)"
|
||||||
|
ip6gateway="$(get_gateway "$ip6cfg" 6)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
has_ipv4=0
|
||||||
|
if [ -n "$ip4gateway" ] && [ "$ip4gateway" != "0.0.0.0" ]; then
|
||||||
|
has_ipv4=1
|
||||||
|
elif "$ip_cmd" -4 route show default 2>/dev/null | grep -q .; then
|
||||||
|
has_ipv4=1
|
||||||
|
elif "$ip_cmd" -4 -o addr show scope global 2>/dev/null | \
|
||||||
|
awk '$2 != "usb0" && $2 != "lo" { found=1 } END { exit !found }'; then
|
||||||
|
has_ipv4=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
has_ipv6=0
|
||||||
|
v6_gw_ok=0
|
||||||
|
if [ -n "$ip6gateway" ] && [ "$ip6gateway" != "::" ]; then
|
||||||
|
v6_gw_ok=1
|
||||||
|
elif "$ip_cmd" -6 route show default 2>/dev/null | grep -q .; then
|
||||||
|
v6_gw_ok=1
|
||||||
|
fi
|
||||||
|
if [ "$v6_gw_ok" = "1" ] && \
|
||||||
|
"$ip_cmd" -6 -o addr show scope global 2>/dev/null | grep -Eq 'inet6 [23][0-9a-fA-F]{0,3}:'; then
|
||||||
|
has_ipv6=1
|
||||||
|
v6_def_dev="$("$ip_cmd" -6 route show default 2>/dev/null | awk '{ for (i = 1; i <= NF; i++) if ($i == "dev") { print $(i + 1); exit } }')"
|
||||||
|
if [ "$v6_def_dev" = "wlan0" ] || { [ -z "$v6_def_dev" ] && [ "$iface" = "wlan0" ]; }; then
|
||||||
|
if [ -r "$accept_ra_dir/wlan0/accept_ra" ]; then
|
||||||
|
IFS= read -r wlan_ra < "$accept_ra_dir/wlan0/accept_ra" 2>/dev/null || wlan_ra=""
|
||||||
|
if [ "$wlan_ra" = "0" ]; then
|
||||||
|
has_ipv6=0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
sync_privacy_or_fallback_resolv "$has_ipv4"
|
||||||
|
|
||||||
|
if ! dnsmasq_running; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ip4gateway="$(get_gateway "$primaryConn" 4)"
|
filter_a="false"
|
||||||
ip6gateway="$(get_gateway "$primaryConn" 6)"
|
filter_aaaa="false"
|
||||||
|
if [ "$has_ipv4" = "0" ] && [ "$has_ipv6" = "1" ] && { [ -z "$ip4cfg" ] || [ "$ip4cfg" = "/" ]; }; then
|
||||||
if [ -z "$ip4gateway" ] && [ -z "$ip6gateway" ]; then
|
filter_a="true"
|
||||||
logger -i -t "$log_tag" "no gateways for primary connection"
|
|
||||||
logger -i -t "$log_tag" "disabling IPv4 filter"
|
|
||||||
set_filter A false
|
|
||||||
logger -i -t "$log_tag" "disabling IPv6 filter"
|
|
||||||
set_filter AAAA false
|
|
||||||
else
|
|
||||||
if [ -z "$ip4gateway" ]; then
|
|
||||||
logger -i -t "$log_tag" "enabling IPv4 filter"
|
|
||||||
set_filter A true
|
|
||||||
else
|
|
||||||
logger -i -t "$log_tag" "disabling IPv4 filter"
|
|
||||||
set_filter A false
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$ip6gateway" ]; then
|
|
||||||
logger -i -t "$log_tag" "enabling IPv6 filter"
|
|
||||||
set_filter AAAA true
|
|
||||||
else
|
|
||||||
logger -i -t "$log_tag" "disabling IPv6 filter"
|
|
||||||
set_filter AAAA false
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
if [ "$has_ipv4" = "1" ] && [ "$has_ipv6" = "0" ]; then
|
||||||
|
filter_aaaa="true"
|
||||||
|
fi
|
||||||
|
|
||||||
|
set_filter A "$filter_a"
|
||||||
|
set_filter AAAA "$filter_aaaa"
|
||||||
|
|
||||||
$dbus call \
|
$dbus call \
|
||||||
org.freedesktop.NetworkManager.dnsmasq \
|
org.freedesktop.NetworkManager.dnsmasq \
|
||||||
/uk/org/thekelleys/dnsmasq org.freedesktop.NetworkManager.dnsmasq \
|
/uk/org/thekelleys/dnsmasq \
|
||||||
ClearCache
|
org.freedesktop.NetworkManager.dnsmasq \
|
||||||
|
ClearCache >/dev/null 2>&1 || true
|
||||||
|
|
||||||
logger -i -t "$log_tag" "dns filter config applied successfully"
|
log_msg "dns filter config applied successfully"
|
||||||
+19
@@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
command -v systemctl >/dev/null 2>&1 || exit 0
|
||||||
|
|
||||||
|
case "$2" in
|
||||||
|
pre-up)
|
||||||
|
NO_BLOCK=
|
||||||
|
;;
|
||||||
|
dhcp4-change)
|
||||||
|
NO_BLOCK=--no-block
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if systemctl -q is-enabled nm-cloud-setup.service; then
|
||||||
|
exec systemctl $NO_BLOCK restart nm-cloud-setup.service
|
||||||
|
fi
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
[connection]
|
||||||
|
id=USB Networking
|
||||||
|
uuid=83bd1823-feca-4c2b-9205-4b83dc792e1f
|
||||||
|
type=ethernet
|
||||||
|
interface-name=usb0
|
||||||
|
|
||||||
|
[ethernet]
|
||||||
|
|
||||||
|
[ipv4]
|
||||||
|
address1=172.16.42.1/16
|
||||||
|
method=manual
|
||||||
|
never-default=true
|
||||||
|
ignore-auto-dns=true
|
||||||
|
|
||||||
|
[ipv6]
|
||||||
|
addr-gen-mode=default
|
||||||
|
method=ignore
|
||||||
|
|
||||||
|
[proxy]
|
||||||
@@ -1310,8 +1310,13 @@ PY
|
|||||||
on)
|
on)
|
||||||
ensure_usb_network_gadget
|
ensure_usb_network_gadget
|
||||||
sysctl -w net.ipv4.ip_forward=1 >/dev/null 2>&1 || true
|
sysctl -w net.ipv4.ip_forward=1 >/dev/null 2>&1 || true
|
||||||
|
sysctl -w net.ipv4.conf.usb0.route_localnet=1 >/dev/null 2>&1 || true
|
||||||
nft add table ip nat 2>/dev/null || true
|
nft add table ip nat 2>/dev/null || true
|
||||||
|
nft 'add chain ip nat prerouting { type nat hook prerouting priority -100 ; }' 2>/dev/null || true
|
||||||
nft 'add chain ip nat postrouting { type nat hook postrouting priority 100 ; }' 2>/dev/null || true
|
nft 'add chain ip nat postrouting { type nat hook postrouting priority 100 ; }' 2>/dev/null || true
|
||||||
|
nft flush chain ip nat prerouting 2>/dev/null || true
|
||||||
|
nft add rule ip nat prerouting iifname "usb*" udp dport 53 dnat to 127.0.0.1:53 2>/dev/null || true
|
||||||
|
nft add rule ip nat prerouting iifname "usb*" tcp dport 53 dnat to 127.0.0.1:53 2>/dev/null || true
|
||||||
nft add rule ip nat postrouting oifname "wwan*" masquerade 2>/dev/null || true
|
nft add rule ip nat postrouting oifname "wwan*" masquerade 2>/dev/null || true
|
||||||
nft add rule ip nat postrouting oifname "wlan*" masquerade 2>/dev/null || true
|
nft add rule ip nat postrouting oifname "wlan*" masquerade 2>/dev/null || true
|
||||||
ip addr show dev usb0 2>/dev/null | grep -q "172.16.42.1" || ip addr add 172.16.42.1/16 dev usb0 2>/dev/null || true
|
ip addr show dev usb0 2>/dev/null | grep -q "172.16.42.1" || ip addr add 172.16.42.1/16 dev usb0 2>/dev/null || true
|
||||||
@@ -1320,6 +1325,7 @@ PY
|
|||||||
;;
|
;;
|
||||||
off)
|
off)
|
||||||
ensure_usb_network_gadget
|
ensure_usb_network_gadget
|
||||||
|
sysctl -w net.ipv4.conf.usb0.route_localnet=0 >/dev/null 2>&1 || true
|
||||||
sysctl -w net.ipv4.ip_forward=0 >/dev/null 2>&1 || true
|
sysctl -w net.ipv4.ip_forward=0 >/dev/null 2>&1 || true
|
||||||
nft delete table ip nat 2>/dev/null || true
|
nft delete table ip nat 2>/dev/null || true
|
||||||
nmcli connection delete USBNetworkShare >/dev/null 2>&1 || true
|
nmcli connection delete USBNetworkShare >/dev/null 2>&1 || true
|
||||||
|
|||||||
@@ -290,6 +290,15 @@ EOF
|
|||||||
if [ -e "$ROOTFS/etc/sudoers.d/wheel" ]; then
|
if [ -e "$ROOTFS/etc/sudoers.d/wheel" ]; then
|
||||||
chmod 440 "$ROOTFS/etc/sudoers.d/wheel"
|
chmod 440 "$ROOTFS/etc/sudoers.d/wheel"
|
||||||
fi
|
fi
|
||||||
|
for nmconn in \
|
||||||
|
"$ROOTFS/usr/lib/NetworkManager/system-connections"/*.nmconnection \
|
||||||
|
"$ROOTFS/etc/NetworkManager/system-connections"/*.nmconnection; do
|
||||||
|
[ -f "$nmconn" ] && chmod 0600 "$nmconn"
|
||||||
|
done
|
||||||
|
if [ -e "$ROOTFS/etc/init.d/loopback" ]; then
|
||||||
|
mkdir -p "$ROOTFS/etc/runlevels/boot"
|
||||||
|
ln -sf /etc/init.d/loopback "$ROOTFS/etc/runlevels/boot/loopback"
|
||||||
|
fi
|
||||||
MB_GID="$(awk -F: "/^messagebus:/ {print \$3}" "$ROOTFS/etc/group" 2>/dev/null || true)"
|
MB_GID="$(awk -F: "/^messagebus:/ {print \$3}" "$ROOTFS/etc/group" 2>/dev/null || true)"
|
||||||
MB_GID="${MB_GID:-103}"
|
MB_GID="${MB_GID:-103}"
|
||||||
if [ -e "$ROOTFS/usr/libexec/dbus-daemon-launch-helper" ]; then
|
if [ -e "$ROOTFS/usr/libexec/dbus-daemon-launch-helper" ]; then
|
||||||
|
|||||||
@@ -220,9 +220,18 @@ chown 0:0 "$TARGET_ROOTFS/etc/chrony/chrony.conf" \
|
|||||||
"$TARGET_ROOTFS/etc/NetworkManager/dispatcher.d/20-bananarchy-time-sync.sh" \
|
"$TARGET_ROOTFS/etc/NetworkManager/dispatcher.d/20-bananarchy-time-sync.sh" \
|
||||||
"$TARGET_ROOTFS/etc/NetworkManager/dispatcher.d/30-bananarchy-network-status.sh" \
|
"$TARGET_ROOTFS/etc/NetworkManager/dispatcher.d/30-bananarchy-network-status.sh" \
|
||||||
"$TARGET_ROOTFS/usr/lib/NetworkManager/dispatcher.d/50-dns-filter.sh" \
|
"$TARGET_ROOTFS/usr/lib/NetworkManager/dispatcher.d/50-dns-filter.sh" \
|
||||||
|
"$TARGET_ROOTFS/usr/lib/NetworkManager/dispatcher.d/pre-up.d/90-nm-cloud-setup.sh" \
|
||||||
|
"$TARGET_ROOTFS/usr/lib/NetworkManager/system-connections/USB_Networking.nmconnection" \
|
||||||
|
"$TARGET_ROOTFS/etc/NetworkManager/conf.d/20-bananarchy-dns.conf" \
|
||||||
|
"$TARGET_ROOTFS/etc/resolv.conf" \
|
||||||
"$TARGET_ROOTFS/usr/bin/zramstart" \
|
"$TARGET_ROOTFS/usr/bin/zramstart" \
|
||||||
2>/dev/null || true
|
2>/dev/null || true
|
||||||
chmod 0644 "$TARGET_ROOTFS/etc/chrony/chrony.conf" 2>/dev/null || true
|
chmod 0644 "$TARGET_ROOTFS/etc/chrony/chrony.conf" \
|
||||||
|
"$TARGET_ROOTFS/etc/NetworkManager/conf.d/20-bananarchy-dns.conf" \
|
||||||
|
"$TARGET_ROOTFS/etc/resolv.conf" \
|
||||||
|
2>/dev/null || true
|
||||||
|
chmod 0600 "$TARGET_ROOTFS/usr/lib/NetworkManager/system-connections/USB_Networking.nmconnection" \
|
||||||
|
2>/dev/null || true
|
||||||
# The idle-blank lock helper is spawned directly by dwm's blank handler, so
|
# The idle-blank lock helper is spawned directly by dwm's blank handler, so
|
||||||
# keep it executable even if the overlay was copied with restrictive modes.
|
# keep it executable even if the overlay was copied with restrictive modes.
|
||||||
chmod 0755 "$TARGET_ROOTFS/usr/bin/bananarchy-idle-blank.sh" \
|
chmod 0755 "$TARGET_ROOTFS/usr/bin/bananarchy-idle-blank.sh" \
|
||||||
@@ -250,6 +259,7 @@ chmod 0755 "$TARGET_ROOTFS/usr/bin/bananarchy-idle-blank.sh" \
|
|||||||
"$TARGET_ROOTFS/etc/NetworkManager/dispatcher.d/20-bananarchy-time-sync.sh" \
|
"$TARGET_ROOTFS/etc/NetworkManager/dispatcher.d/20-bananarchy-time-sync.sh" \
|
||||||
"$TARGET_ROOTFS/etc/NetworkManager/dispatcher.d/30-bananarchy-network-status.sh" \
|
"$TARGET_ROOTFS/etc/NetworkManager/dispatcher.d/30-bananarchy-network-status.sh" \
|
||||||
"$TARGET_ROOTFS/usr/lib/NetworkManager/dispatcher.d/50-dns-filter.sh" \
|
"$TARGET_ROOTFS/usr/lib/NetworkManager/dispatcher.d/50-dns-filter.sh" \
|
||||||
|
"$TARGET_ROOTFS/usr/lib/NetworkManager/dispatcher.d/pre-up.d/90-nm-cloud-setup.sh" \
|
||||||
"$TARGET_ROOTFS/usr/bin/zramstart" \
|
"$TARGET_ROOTFS/usr/bin/zramstart" \
|
||||||
2>/dev/null || true
|
2>/dev/null || true
|
||||||
CHRONY_UID="$(awk -F: '/^chrony:/ {print $3}' "$TARGET_ROOTFS/etc/passwd" 2>/dev/null || true)"
|
CHRONY_UID="$(awk -F: '/^chrony:/ {print $3}' "$TARGET_ROOTFS/etc/passwd" 2>/dev/null || true)"
|
||||||
@@ -488,6 +498,10 @@ ln -sf /etc/init.d/kill-plymouth "$TARGET_ROOTFS/etc/runlevels/default/kill-plym
|
|||||||
ln -sf /etc/init.d/bananarchy-power-policy "$TARGET_ROOTFS/etc/runlevels/default/bananarchy-power-policy"
|
ln -sf /etc/init.d/bananarchy-power-policy "$TARGET_ROOTFS/etc/runlevels/default/bananarchy-power-policy"
|
||||||
ln -sf /etc/init.d/bananarchy-time-sync "$TARGET_ROOTFS/etc/runlevels/default/bananarchy-time-sync"
|
ln -sf /etc/init.d/bananarchy-time-sync "$TARGET_ROOTFS/etc/runlevels/default/bananarchy-time-sync"
|
||||||
ln -sf /etc/init.d/bananarchy-sshd-debug "$TARGET_ROOTFS/etc/runlevels/default/bananarchy-sshd-debug"
|
ln -sf /etc/init.d/bananarchy-sshd-debug "$TARGET_ROOTFS/etc/runlevels/default/bananarchy-sshd-debug"
|
||||||
|
if [ -e "$TARGET_ROOTFS/etc/init.d/loopback" ]; then
|
||||||
|
mkdir -p "$TARGET_ROOTFS/etc/runlevels/boot"
|
||||||
|
ln -sf /etc/init.d/loopback "$TARGET_ROOTFS/etc/runlevels/boot/loopback"
|
||||||
|
fi
|
||||||
mkdir -p "$TARGET_ROOTFS/usr/share/bananarchy"
|
mkdir -p "$TARGET_ROOTFS/usr/share/bananarchy"
|
||||||
printf '%s\n' "$LID_PROFILE" > "$TARGET_ROOTFS/usr/share/bananarchy/lid-profile"
|
printf '%s\n' "$LID_PROFILE" > "$TARGET_ROOTFS/usr/share/bananarchy/lid-profile"
|
||||||
chmod 0644 "$TARGET_ROOTFS/usr/share/bananarchy/lid-profile"
|
chmod 0644 "$TARGET_ROOTFS/usr/share/bananarchy/lid-profile"
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ enable_service() {
|
|||||||
for svc in devfs dmesg msm-firmware-loader udev udev-trigger udev-settle; do
|
for svc in devfs dmesg msm-firmware-loader udev udev-trigger udev-settle; do
|
||||||
enable_service sysinit "$svc"
|
enable_service sysinit "$svc"
|
||||||
done
|
done
|
||||||
for svc in bootmisc hostname modules msm-firmware-loader-unpack osclock \
|
for svc in bootmisc hostname loopback modules msm-firmware-loader-unpack osclock \
|
||||||
swclock-offset-boot sysctl tmpfs; do
|
swclock-offset-boot sysctl tmpfs; do
|
||||||
enable_service boot "$svc"
|
enable_service boot "$svc"
|
||||||
done
|
done
|
||||||
|
|||||||
+35
-10
@@ -564,15 +564,15 @@ fi
|
|||||||
|
|
||||||
echo "[check] Known-good flashable image set..."
|
echo "[check] Known-good flashable image set..."
|
||||||
for pair in \
|
for pair in \
|
||||||
"0a6760f8ff4a4d2baa6af88ce080898a1e3aff206e15b8474efa3ea4274d6dee images/bananarchy-nokia-argon.img" \
|
"dfd5361d4c38f2a88d45693f7456f7464a89f121ad05e7f8ac0497b498788d20 images/bananarchy-nokia-argon.img" \
|
||||||
"7bb47f4e938d412e2e5fed5eb5b766bbbe36c71fa6e7b77d2cda346b48a82e17 images/bananarchy-nokia-beatles.img" \
|
"83d7369e114b4db90ae3dfeefc88f3aa864bf3283469fe00965addd86fa8751f images/bananarchy-nokia-beatles.img" \
|
||||||
"496890063eda83adafaf5e7796a801100795b825064cf6f7fd967e6565dca325 images/boot-bananarchy-nokia-beatles.img" \
|
"7f21313963f2868349924da0eb8e6a54131de76bd03bdd3a900f6eb68250b3e2 images/boot-bananarchy-nokia-beatles.img" \
|
||||||
"f13db705a714aaebd2d8fcc2e0f7266d0e40268c0a276208117dfdf9d8f45351 images/boot-lk2nd-nokia-beatles-display.img" \
|
"f13db705a714aaebd2d8fcc2e0f7266d0e40268c0a276208117dfdf9d8f45351 images/boot-lk2nd-nokia-beatles-display.img" \
|
||||||
"d3b385a84c6546d35edca03eac684f3d7ee6de0faab25172b9af5252137c6815 images/bananarchy-nokia-coconut.img" \
|
"cf0826eaf298b9161012cad38d66f979af004aeb71f29fa1818f4f7fe222db86 images/bananarchy-nokia-coconut.img" \
|
||||||
"0a91c165e370b35a1604d08ddb6b08c46823455e5aee9701807f78221059e26c images/boot-bananarchy-nokia-coconut.img" \
|
"310169cfb5d434c10a0af56e4185aeea8d74013c0b548ea27ec581236d9ac131 images/boot-bananarchy-nokia-coconut.img" \
|
||||||
"9a5bd2da6cfd95c745d9c1acb2e3bc61afa339824810e3d160bf079e17b23192 images/boot-lk2nd-nokia-coconut-display.img" \
|
"9a5bd2da6cfd95c745d9c1acb2e3bc61afa339824810e3d160bf079e17b23192 images/boot-lk2nd-nokia-coconut-display.img" \
|
||||||
"a262cb31ddb38e222e5f4bd14d82c82bb7941839a34bb48fa120b74189d319ae images/bananarchy-nokia-sparkler.img" \
|
"01860ac705afe193cd5252f0d42907ba35fe98be1a0509097d4994d824d0cb4d images/bananarchy-nokia-sparkler.img" \
|
||||||
"affc62ff400c082c29b0d0c11a06bdd2eefdd06e09f1d2e93e7eae6a47a5a7b1 images/boot-bananarchy-nokia-sparkler.img" \
|
"7f95573f8caa6b07387836feb52bac9167ad0dede9922fb3b0cbf1eb32ad9119 images/boot-bananarchy-nokia-sparkler.img" \
|
||||||
"120ade81bc5416263a1afd95a29981675358b98516e105e5ed611edf258a29f7 images/boot-lk2nd-nokia-sparkler-display.img"; do
|
"120ade81bc5416263a1afd95a29981675358b98516e105e5ed611edf258a29f7 images/boot-lk2nd-nokia-sparkler-display.img"; do
|
||||||
set -- $pair
|
set -- $pair
|
||||||
want=$1
|
want=$1
|
||||||
@@ -1660,24 +1660,49 @@ fi
|
|||||||
echo "[check] ZRAM, NetworkManager DNS filter, and target pkill cleanup..."
|
echo "[check] ZRAM, NetworkManager DNS filter, and target pkill cleanup..."
|
||||||
ZRAMSTART="$BASE_DIR/overlay/rootfs/usr/bin/zramstart"
|
ZRAMSTART="$BASE_DIR/overlay/rootfs/usr/bin/zramstart"
|
||||||
NM_DNS_FILTER="$BASE_DIR/overlay/rootfs/usr/lib/NetworkManager/dispatcher.d/50-dns-filter.sh"
|
NM_DNS_FILTER="$BASE_DIR/overlay/rootfs/usr/lib/NetworkManager/dispatcher.d/50-dns-filter.sh"
|
||||||
|
NM_DNS_CONF="$BASE_DIR/overlay/rootfs/etc/NetworkManager/conf.d/20-bananarchy-dns.conf"
|
||||||
|
BASE_RESOLV="$BASE_DIR/overlay/rootfs/etc/resolv.conf"
|
||||||
|
USB_NMCONN="$BASE_DIR/overlay/rootfs/usr/lib/NetworkManager/system-connections/USB_Networking.nmconnection"
|
||||||
|
CLOUD_SETUP="$BASE_DIR/overlay/rootfs/usr/lib/NetworkManager/dispatcher.d/pre-up.d/90-nm-cloud-setup.sh"
|
||||||
if [ ! -x "$ZRAMSTART" ] || ! sh -n "$ZRAMSTART" 2>/dev/null || \
|
if [ ! -x "$ZRAMSTART" ] || ! sh -n "$ZRAMSTART" 2>/dev/null || \
|
||||||
! grep -qF 'MemTotal' "$ZRAMSTART"; then
|
! grep -qF 'MemTotal' "$ZRAMSTART"; then
|
||||||
fail "overlay zramstart is missing, not executable, has bad syntax, or lost MemTotal sizing"
|
fail "overlay zramstart is missing, not executable, has bad syntax, or lost MemTotal sizing"
|
||||||
fi
|
fi
|
||||||
if [ ! -x "$NM_DNS_FILTER" ] || ! sh -n "$NM_DNS_FILTER" 2>/dev/null || \
|
if [ ! -x "$NM_DNS_FILTER" ] || ! sh -n "$NM_DNS_FILTER" 2>/dev/null || \
|
||||||
! grep -qF '[ "$_ipcfg" = "/" ]' "$NM_DNS_FILTER"; then
|
! grep -qF '[ "$_ipcfg" = "/" ]' "$NM_DNS_FILTER" || \
|
||||||
fail "overlay NM 50-dns-filter.sh is missing, not executable, has bad syntax, or lost null object path guard"
|
grep -q 'logger -i' "$NM_DNS_FILTER" || \
|
||||||
|
! grep -qF 'dhcp4-change' "$NM_DNS_FILTER" || \
|
||||||
|
! grep -qF 'dns-change' "$NM_DNS_FILTER"; then
|
||||||
|
fail "overlay NM 50-dns-filter.sh is missing, not executable, has bad syntax, or drifted from DNS resolution invariants"
|
||||||
|
fi
|
||||||
|
if [ ! -f "$NM_DNS_CONF" ] || \
|
||||||
|
! grep -qxF 'rc-manager=file' "$NM_DNS_CONF" || \
|
||||||
|
! grep -qxF 'dns=dnsmasq' "$NM_DNS_CONF" || \
|
||||||
|
[ ! -f "$BASE_RESOLV" ] || \
|
||||||
|
! grep -qxF 'nameserver 127.0.0.1' "$BASE_RESOLV" || \
|
||||||
|
[ ! -f "$USB_NMCONN" ] || \
|
||||||
|
! grep -qxF 'never-default=true' "$USB_NMCONN" || \
|
||||||
|
! grep -qxF 'ignore-auto-dns=true' "$USB_NMCONN" || \
|
||||||
|
[ ! -x "$CLOUD_SETUP" ] || ! sh -n "$CLOUD_SETUP" 2>/dev/null || \
|
||||||
|
! grep -qF 'command -v systemctl' "$CLOUD_SETUP"; then
|
||||||
|
fail "overlay NetworkManager DNS config, baseline resolv.conf, USB_Networking.nmconnection, or 90-nm-cloud-setup.sh guard is invalid"
|
||||||
fi
|
fi
|
||||||
for no_pkill in \
|
for no_pkill in \
|
||||||
"$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-x11-session.sh" \
|
"$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-x11-session.sh" \
|
||||||
"$BASE_DIR/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_start.sh" \
|
"$BASE_DIR/overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_start.sh" \
|
||||||
"$BASE_DIR/overlay/rootfs/etc/skel/.config/sxmo/hooks/sxmo_hook_start.sh" \
|
"$BASE_DIR/overlay/rootfs/etc/skel/.config/sxmo/hooks/sxmo_hook_start.sh" \
|
||||||
"$BASE_DIR/overlay/rootfs/home/user/.config/sxmo/hooks/sxmo_hook_start.sh" \
|
"$BASE_DIR/overlay/rootfs/home/user/.config/sxmo/hooks/sxmo_hook_start.sh" \
|
||||||
"$BASE_DIR/overlay/rootfs/usr/bin/sxmo_modemaudio.sh"; do
|
"$BASE_DIR/overlay/rootfs/usr/bin/sxmo_modemaudio.sh" \
|
||||||
|
"$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-privacy-ctl"; do
|
||||||
if grep -q 'pkill' "$no_pkill"; then
|
if grep -q 'pkill' "$no_pkill"; then
|
||||||
fail "${no_pkill#"$BASE_DIR/"} still depends on pkill"
|
fail "${no_pkill#"$BASE_DIR/"} still depends on pkill"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
if [ -x "$BASE_DIR/scripts/test-dns-resolution.py" ] && \
|
||||||
|
command -v python3 >/dev/null 2>&1 && \
|
||||||
|
! python3 -B "$BASE_DIR/scripts/test-dns-resolution.py" >/dev/null 2>&1; then
|
||||||
|
fail "scripts/test-dns-resolution.py failed"
|
||||||
|
fi
|
||||||
echo "[check] Boot ICC/OPP/USB/Q6ASM kernel patch 0011 and DTS guards..."
|
echo "[check] Boot ICC/OPP/USB/Q6ASM kernel patch 0011 and DTS guards..."
|
||||||
if [ ! -f "$BASE_DIR/patches/kernel/0011-msm8909-boot-icc-opp-usb-audio-fixes.patch" ] || \
|
if [ ! -f "$BASE_DIR/patches/kernel/0011-msm8909-boot-icc-opp-usb-audio-fixes.patch" ] || \
|
||||||
! grep -qF '0011-msm8909-boot-icc-opp-usb-audio-fixes.patch' "$BASE_DIR/scripts/build-kernel-audio.sh"; then
|
! grep -qF '0011-msm8909-boot-icc-opp-usb-audio-fixes.patch' "$BASE_DIR/scripts/build-kernel-audio.sh"; then
|
||||||
|
|||||||
Executable
+433
@@ -0,0 +1,433 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Host regression tests for Bananarchy DNS resolution and NM dispatcher."""
|
||||||
|
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import pathlib
|
||||||
|
import stat
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import tempfile
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
|
ROOT = pathlib.Path(__file__).resolve().parent.parent
|
||||||
|
OVERLAY = ROOT / "overlay" / "rootfs"
|
||||||
|
DNS_FILTER = OVERLAY / "usr" / "lib" / "NetworkManager" / "dispatcher.d" / "50-dns-filter.sh"
|
||||||
|
PRIVACY_CTL = OVERLAY / "usr" / "bin" / "bananarchy-privacy-ctl"
|
||||||
|
CLOUD_SETUP = OVERLAY / "usr" / "lib" / "NetworkManager" / "dispatcher.d" / "pre-up.d" / "90-nm-cloud-setup.sh"
|
||||||
|
DNS_CONF = OVERLAY / "etc" / "NetworkManager" / "conf.d" / "20-bananarchy-dns.conf"
|
||||||
|
BASE_RESOLV = OVERLAY / "etc" / "resolv.conf"
|
||||||
|
USB_NMCONN = OVERLAY / "usr" / "lib" / "NetworkManager" / "system-connections" / "USB_Networking.nmconnection"
|
||||||
|
MODEM_UIM_SEL = OVERLAY / "usr" / "libexec" / "msm-modem-uim-selection"
|
||||||
|
BOOTSTRAP_CONTAINER = ROOT / "scripts" / "bootstrap-rootfs-container.sh"
|
||||||
|
APPLY_OVERLAY = ROOT / "scripts" / "apply-bananarchy-overlay.sh"
|
||||||
|
REBUILD_IMAGE = ROOT / "rebuild-image.sh"
|
||||||
|
|
||||||
|
|
||||||
|
def write_exec(path: pathlib.Path, content: str) -> None:
|
||||||
|
path.write_text(content, encoding="utf-8")
|
||||||
|
path.chmod(0o755)
|
||||||
|
|
||||||
|
|
||||||
|
def setup_mocks(tmp: pathlib.Path) -> dict:
|
||||||
|
mock_bin = tmp / "mock_bin"
|
||||||
|
mock_bin.mkdir()
|
||||||
|
state_file = tmp / "state.json"
|
||||||
|
calls_log = tmp / "dbus_calls.log"
|
||||||
|
logger_calls = tmp / "logger_calls.log"
|
||||||
|
|
||||||
|
write_exec(
|
||||||
|
mock_bin / "logger",
|
||||||
|
"#!/usr/bin/env python3\n"
|
||||||
|
"import os, pathlib, sys\n"
|
||||||
|
"log_path = pathlib.Path(os.environ['MOCK_LOGGER_LOG'])\n"
|
||||||
|
"args = sys.argv[1:]\n"
|
||||||
|
"i = 0\n"
|
||||||
|
"while i < len(args):\n"
|
||||||
|
" a = args[i]\n"
|
||||||
|
" if a == '-s':\n"
|
||||||
|
" i += 1\n"
|
||||||
|
" elif a in ('-t', '-p'):\n"
|
||||||
|
" if i + 1 >= len(args):\n"
|
||||||
|
" sys.exit(1)\n"
|
||||||
|
" i += 2\n"
|
||||||
|
" elif a.startswith('-'):\n"
|
||||||
|
" sys.stderr.write(f'logger: unrecognized option: {a}\\n')\n"
|
||||||
|
" sys.exit(1)\n"
|
||||||
|
" else:\n"
|
||||||
|
" break\n"
|
||||||
|
"with log_path.open('a', encoding='utf-8') as f:\n"
|
||||||
|
" f.write(' '.join(args) + '\\n')\n",
|
||||||
|
)
|
||||||
|
|
||||||
|
write_exec(
|
||||||
|
mock_bin / "jq",
|
||||||
|
"#!/usr/bin/env python3\n"
|
||||||
|
"import json, sys\n"
|
||||||
|
"expr = sys.argv[-1]\n"
|
||||||
|
"raw = sys.stdin.read().strip()\n"
|
||||||
|
"if not raw:\n"
|
||||||
|
" sys.exit(0)\n"
|
||||||
|
"obj = json.loads(raw)\n"
|
||||||
|
"if expr == '.data // empty':\n"
|
||||||
|
" v = obj.get('data')\n"
|
||||||
|
" if v is not None and v != '':\n"
|
||||||
|
" if isinstance(v, bool):\n"
|
||||||
|
" print('true' if v else 'false')\n"
|
||||||
|
" else:\n"
|
||||||
|
" print(v)\n"
|
||||||
|
"elif expr == '.data[0] // empty':\n"
|
||||||
|
" arr = obj.get('data') or []\n"
|
||||||
|
" if arr:\n"
|
||||||
|
" v = arr[0]\n"
|
||||||
|
" if isinstance(v, bool):\n"
|
||||||
|
" print('true' if v else 'false')\n"
|
||||||
|
" else:\n"
|
||||||
|
" print(v)\n"
|
||||||
|
"else:\n"
|
||||||
|
" raise ValueError(f'unsupported jq expr: {expr}')\n",
|
||||||
|
)
|
||||||
|
|
||||||
|
write_exec(
|
||||||
|
mock_bin / "busctl",
|
||||||
|
"#!/usr/bin/env python3\n"
|
||||||
|
"import json, os, pathlib, sys\n"
|
||||||
|
"state = json.loads(pathlib.Path(os.environ['MOCK_STATE_JSON']).read_text(encoding='utf-8'))\n"
|
||||||
|
"args = [a for a in sys.argv[1:] if not a.startswith('--')]\n"
|
||||||
|
"calls_path = pathlib.Path(os.environ['MOCK_DBUS_LOG'])\n"
|
||||||
|
"if args[0] == 'get-property':\n"
|
||||||
|
" _, dest, path, iface, prop = args[:5]\n"
|
||||||
|
" val = state.get('props', {}).get(f'{path}:{iface}:{prop}', '')\n"
|
||||||
|
" if prop in ('Ip4Config', 'Ip6Config') and not val:\n"
|
||||||
|
" val = '/'\n"
|
||||||
|
" print(json.dumps({'type': 's', 'data': val}))\n"
|
||||||
|
"elif args[0] == 'call':\n"
|
||||||
|
" _, dest, path, iface, member = args[:5]\n"
|
||||||
|
" rest = args[5:]\n"
|
||||||
|
" if dest == 'org.freedesktop.DBus' and member == 'NameHasOwner':\n"
|
||||||
|
" name = rest[1] if len(rest) > 1 else ''\n"
|
||||||
|
" owned = bool(state.get('dnsmasq_running', False)) if name == 'org.freedesktop.NetworkManager.dnsmasq' else False\n"
|
||||||
|
" print(json.dumps({'type': 'b', 'data': [owned]}))\n"
|
||||||
|
" elif dest == 'org.freedesktop.NetworkManager.dnsmasq':\n"
|
||||||
|
" if not state.get('dnsmasq_running', False):\n"
|
||||||
|
" sys.stderr.write('NameHasNoOwner\\n')\n"
|
||||||
|
" sys.exit(1)\n"
|
||||||
|
" with calls_path.open('a', encoding='utf-8') as f:\n"
|
||||||
|
" line = (member + ' ' + ' '.join(rest)).strip()\n"
|
||||||
|
" f.write(line + '\\n')\n"
|
||||||
|
" print(json.dumps({'type': '', 'data': []}))\n"
|
||||||
|
"else:\n"
|
||||||
|
" sys.exit(1)\n",
|
||||||
|
)
|
||||||
|
|
||||||
|
write_exec(
|
||||||
|
mock_bin / "ip",
|
||||||
|
"#!/usr/bin/env python3\n"
|
||||||
|
"import json, os, pathlib, sys\n"
|
||||||
|
"state = json.loads(pathlib.Path(os.environ['MOCK_STATE_JSON']).read_text(encoding='utf-8'))\n"
|
||||||
|
"args = sys.argv[1:]\n"
|
||||||
|
"if args == ['-4', 'route', 'show', 'default']:\n"
|
||||||
|
" for line in state.get('v4_routes', []):\n"
|
||||||
|
" print(line)\n"
|
||||||
|
"elif args == ['-6', 'route', 'show', 'default']:\n"
|
||||||
|
" for line in state.get('v6_routes', []):\n"
|
||||||
|
" print(line)\n"
|
||||||
|
"elif args == ['-4', '-o', 'addr', 'show', 'scope', 'global']:\n"
|
||||||
|
" for line in state.get('v4_addrs', []):\n"
|
||||||
|
" print(line)\n"
|
||||||
|
"elif args == ['-6', '-o', 'addr', 'show', 'scope', 'global']:\n"
|
||||||
|
" for line in state.get('v6_addrs', []):\n"
|
||||||
|
" print(line)\n"
|
||||||
|
"elif len(args) >= 4 and args[:3] == ['link', 'show', 'dev']:\n"
|
||||||
|
" dev = args[3]\n"
|
||||||
|
" if dev in state.get('up_links', []):\n"
|
||||||
|
" print(f'10: {dev}: <POINTOPOINT,NOARP,UP,LOWER_UP> state UNKNOWN')\n"
|
||||||
|
" else:\n"
|
||||||
|
" sys.exit(1)\n"
|
||||||
|
"elif len(args) >= 6 and args[:4] == ['-4', '-o', 'addr', 'show'] and args[4] == 'dev':\n"
|
||||||
|
" dev = args[5]\n"
|
||||||
|
" for line in state.get('v4_addrs', []):\n"
|
||||||
|
" if dev in line.split():\n"
|
||||||
|
" print(line)\n"
|
||||||
|
"elif len(args) >= 5 and args[:3] == ['-4', 'addr', 'show'] and args[3] == 'dev':\n"
|
||||||
|
" dev = args[4]\n"
|
||||||
|
" for line in state.get('v4_addrs', []):\n"
|
||||||
|
" if dev in line.split():\n"
|
||||||
|
" print(line)\n"
|
||||||
|
"else:\n"
|
||||||
|
" sys.exit(0)\n",
|
||||||
|
)
|
||||||
|
|
||||||
|
write_exec(
|
||||||
|
mock_bin / "ip6tables",
|
||||||
|
"#!/bin/sh\nfor a in \"$@\"; do [ \"$a\" = \"-D\" ] && exit 1; done\nexit 0\n",
|
||||||
|
)
|
||||||
|
write_exec(
|
||||||
|
mock_bin / "iptables",
|
||||||
|
"#!/bin/sh\nfor a in \"$@\"; do [ \"$a\" = \"-D\" ] && exit 1; done\nexit 0\n",
|
||||||
|
)
|
||||||
|
write_exec(mock_bin / "pidof", "#!/bin/sh\nexit 1\n")
|
||||||
|
|
||||||
|
privacy_state = tmp / "privacy_state"
|
||||||
|
privacy_conf_dir = tmp / "privacy_conf"
|
||||||
|
privacy_state.mkdir()
|
||||||
|
privacy_conf_dir.mkdir()
|
||||||
|
(privacy_conf_dir / "privacy.conf").write_text(
|
||||||
|
"WG_NATIVE=0\nWG_DNS=1.1.1.1\n",
|
||||||
|
encoding="utf-8",
|
||||||
|
)
|
||||||
|
|
||||||
|
resolv_conf = tmp / "resolv.conf"
|
||||||
|
nm_resolv = tmp / "nm_resolv.conf"
|
||||||
|
nm_nostub = tmp / "nm_nostub_resolv.conf"
|
||||||
|
accept_ra_dir = tmp / "ipv6_conf"
|
||||||
|
(accept_ra_dir / "wlan0").mkdir(parents=True)
|
||||||
|
(accept_ra_dir / "wlan0" / "accept_ra").write_text("1\n", encoding="utf-8")
|
||||||
|
|
||||||
|
duress_file = tmp / "duress"
|
||||||
|
locked_file = tmp / "screen_locked"
|
||||||
|
|
||||||
|
return {
|
||||||
|
"tmp": tmp,
|
||||||
|
"mock_bin": mock_bin,
|
||||||
|
"state_file": state_file,
|
||||||
|
"calls_log": calls_log,
|
||||||
|
"logger_calls": logger_calls,
|
||||||
|
"privacy_state": privacy_state,
|
||||||
|
"privacy_conf_dir": privacy_conf_dir,
|
||||||
|
"resolv_conf": resolv_conf,
|
||||||
|
"nm_resolv": nm_resolv,
|
||||||
|
"nm_nostub": nm_nostub,
|
||||||
|
"accept_ra_dir": accept_ra_dir,
|
||||||
|
"duress_file": duress_file,
|
||||||
|
"locked_file": locked_file,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def run_filter(ctx: dict, state: dict, iface: str, action: str) -> tuple:
|
||||||
|
ctx["state_file"].write_text(json.dumps(state), encoding="utf-8")
|
||||||
|
ctx["calls_log"].write_text("", encoding="utf-8")
|
||||||
|
env = os.environ.copy()
|
||||||
|
env.update({
|
||||||
|
"MOCK_STATE_JSON": str(ctx["state_file"]),
|
||||||
|
"MOCK_DBUS_LOG": str(ctx["calls_log"]),
|
||||||
|
"MOCK_LOGGER_LOG": str(ctx["logger_calls"]),
|
||||||
|
"BANANARCHY_BUSCTL": str(ctx["mock_bin"] / "busctl"),
|
||||||
|
"BANANARCHY_JQ": str(ctx["mock_bin"] / "jq"),
|
||||||
|
"BANANARCHY_IP_CMD": str(ctx["mock_bin"] / "ip"),
|
||||||
|
"BANANARCHY_LOGGER_CMD": str(ctx["mock_bin"] / "logger"),
|
||||||
|
"BANANARCHY_PRIVACY_CTL": str(PRIVACY_CTL),
|
||||||
|
"BANANARCHY_RESOLV_CONF": str(ctx["resolv_conf"]),
|
||||||
|
"BANANARCHY_NM_RESOLV_CONF": str(ctx["nm_resolv"]),
|
||||||
|
"BANANARCHY_NM_NOSTUB_RESOLV_CONF": str(ctx["nm_nostub"]),
|
||||||
|
"BANANARCHY_IPV6_CONF_DIR": str(ctx["accept_ra_dir"]),
|
||||||
|
"BANANARCHY_PRIVACY_STATE_DIR": str(ctx["privacy_state"]),
|
||||||
|
"BANANARCHY_PRIVACY_CONF_DIR": str(ctx["privacy_conf_dir"]),
|
||||||
|
"BANANARCHY_DURESS_FILE": str(ctx["duress_file"]),
|
||||||
|
"BANANARCHY_SCREEN_LOCKED_FILE": str(ctx["locked_file"]),
|
||||||
|
"BANANARCHY_PRIVACY_NO_ROOT": "1",
|
||||||
|
"BANANARCHY_TEST_PATH_PREFIX": str(ctx["mock_bin"]),
|
||||||
|
})
|
||||||
|
t0 = time.monotonic()
|
||||||
|
res = subprocess.run(
|
||||||
|
["/bin/sh", str(DNS_FILTER), iface, action],
|
||||||
|
env=env,
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
timeout=5,
|
||||||
|
)
|
||||||
|
elapsed = time.monotonic() - t0
|
||||||
|
calls = [l for l in ctx["calls_log"].read_text(encoding="utf-8").splitlines() if l]
|
||||||
|
return res, calls, elapsed, env
|
||||||
|
|
||||||
|
|
||||||
|
def test_runtime_scenarios(tmp: pathlib.Path) -> None:
|
||||||
|
ctx = setup_mocks(tmp)
|
||||||
|
|
||||||
|
# 1. usb0 up + wlan0 down when dnsmasq is NOT running (must succeed cleanly, no -i logger failure)
|
||||||
|
state_no_dnsmasq = {"dnsmasq_running": False, "props": {}}
|
||||||
|
for ifn, act in [("usb0", "up"), ("wlan0", "down")]:
|
||||||
|
res, calls, elapsed, _ = run_filter(ctx, state_no_dnsmasq, ifn, act)
|
||||||
|
assert res.returncode == 0, f"{ifn} {act} failed: {res.stderr}"
|
||||||
|
assert calls == [], f"unexpected dnsmasq calls when not running: {calls}"
|
||||||
|
assert elapsed < 1.0, f"expected fast exit, took {elapsed:.2f}s"
|
||||||
|
|
||||||
|
# 2. Wi-Fi early SLAAC RA before DHCPv4 completes, then dhcp4-change recovery
|
||||||
|
ctx["nm_resolv"].write_text("# Generated by NetworkManager\nnameserver 127.0.0.1\n", encoding="utf-8")
|
||||||
|
ctx["nm_nostub"].write_text("# Generated by NetworkManager\nnameserver 192.168.1.1\n", encoding="utf-8")
|
||||||
|
ctx["resolv_conf"].write_text("# Generated by NetworkManager\nnameserver 127.0.0.1\n", encoding="utf-8")
|
||||||
|
|
||||||
|
state_slaac_race = {
|
||||||
|
"dnsmasq_running": True,
|
||||||
|
"props": {
|
||||||
|
"/org/freedesktop/NetworkManager:org.freedesktop.NetworkManager:PrimaryConnection": "/AC/1",
|
||||||
|
"/AC/1:org.freedesktop.NetworkManager.Connection.Active:Ip4Config": "/IP4/1",
|
||||||
|
"/AC/1:org.freedesktop.NetworkManager.Connection.Active:Ip6Config": "/IP6/1",
|
||||||
|
"/IP4/1:org.freedesktop.NetworkManager.IP4Config:Gateway": "",
|
||||||
|
"/IP6/1:org.freedesktop.NetworkManager.IP6Config:Gateway": "fe80::1",
|
||||||
|
},
|
||||||
|
"v4_routes": [],
|
||||||
|
"v6_routes": ["default via fe80::1 dev wlan0 proto ra metric 600"],
|
||||||
|
"v4_addrs": [],
|
||||||
|
"v6_addrs": ["3: wlan0 inet6 fe80::1234/64 scope link"],
|
||||||
|
}
|
||||||
|
res, calls, elapsed, _ = run_filter(ctx, state_slaac_race, "wlan0", "up")
|
||||||
|
assert res.returncode == 0, res.stderr
|
||||||
|
assert elapsed < 1.0, f"blocking sleep detected in 50-dns-filter.sh ({elapsed:.2f}s)"
|
||||||
|
assert "SetFilterA b false" in calls, f"early SLAAC RA must not block IPv4 A records: {calls}"
|
||||||
|
|
||||||
|
state_dhcp4_done = {
|
||||||
|
"dnsmasq_running": True,
|
||||||
|
"props": {
|
||||||
|
"/org/freedesktop/NetworkManager:org.freedesktop.NetworkManager:PrimaryConnection": "/AC/1",
|
||||||
|
"/AC/1:org.freedesktop.NetworkManager.Connection.Active:Ip4Config": "/IP4/1",
|
||||||
|
"/AC/1:org.freedesktop.NetworkManager.Connection.Active:Ip6Config": "/IP6/1",
|
||||||
|
"/IP4/1:org.freedesktop.NetworkManager.IP4Config:Gateway": "192.168.1.1",
|
||||||
|
"/IP6/1:org.freedesktop.NetworkManager.IP6Config:Gateway": "fe80::1",
|
||||||
|
},
|
||||||
|
"v4_routes": ["default via 192.168.1.1 dev wlan0 proto dhcp src 192.168.1.50 metric 600"],
|
||||||
|
"v6_routes": ["default via fe80::1 dev wlan0 proto ra metric 600"],
|
||||||
|
"v4_addrs": ["3: wlan0 inet 192.168.1.50/24 brd 192.168.1.255 scope global wlan0"],
|
||||||
|
"v6_addrs": ["3: wlan0 inet6 fe80::1234/64 scope link"],
|
||||||
|
}
|
||||||
|
res, calls, elapsed, _ = run_filter(ctx, state_dhcp4_done, "wlan0", "dhcp4-change")
|
||||||
|
assert res.returncode == 0, res.stderr
|
||||||
|
assert elapsed < 1.0, f"dhcp4-change took too long ({elapsed:.2f}s)"
|
||||||
|
assert calls == ["SetFilterA b false", "SetFilterAAAA b true", "ClearCache"], f"unexpected dhcp4-change calls: {calls}"
|
||||||
|
|
||||||
|
# 3. True dual-stack (2001:db8::2/64 GUA + IPv4)
|
||||||
|
state_dual = dict(state_dhcp4_done)
|
||||||
|
state_dual["v6_addrs"] = ["3: wlan0 inet6 2001:db8::2/64 scope global dynamic"]
|
||||||
|
res, calls, _, _ = run_filter(ctx, state_dual, "wlan0", "dhcp6-change")
|
||||||
|
assert res.returncode == 0, res.stderr
|
||||||
|
assert calls == ["SetFilterA b false", "SetFilterAAAA b false", "ClearCache"], calls
|
||||||
|
|
||||||
|
# 4. Screen-off mute_wifi_ipv6_ra (accept_ra=0 on wlan0)
|
||||||
|
(ctx["accept_ra_dir"] / "wlan0" / "accept_ra").write_text("0\n", encoding="utf-8")
|
||||||
|
res, calls, _, _ = run_filter(ctx, state_dual, "wlan0", "up")
|
||||||
|
assert res.returncode == 0, res.stderr
|
||||||
|
assert calls == ["SetFilterA b false", "SetFilterAAAA b true", "ClearCache"], calls
|
||||||
|
(ctx["accept_ra_dir"] / "wlan0" / "accept_ra").write_text("1\n", encoding="utf-8")
|
||||||
|
|
||||||
|
# 5. Pure IPv6-only (Ip4Config="/", 2001:db8::2/64 GUA + v6 gateway)
|
||||||
|
state_v6_only = {
|
||||||
|
"dnsmasq_running": True,
|
||||||
|
"props": {
|
||||||
|
"/org/freedesktop/NetworkManager:org.freedesktop.NetworkManager:PrimaryConnection": "/AC/1",
|
||||||
|
"/AC/1:org.freedesktop.NetworkManager.Connection.Active:Ip4Config": "/",
|
||||||
|
"/AC/1:org.freedesktop.NetworkManager.Connection.Active:Ip6Config": "/IP6/1",
|
||||||
|
"/IP6/1:org.freedesktop.NetworkManager.IP6Config:Gateway": "fe80::1",
|
||||||
|
},
|
||||||
|
"v4_routes": [],
|
||||||
|
"v6_routes": ["default via fe80::1 dev wlan0 proto ra metric 600"],
|
||||||
|
"v4_addrs": [],
|
||||||
|
"v6_addrs": ["3: wlan0 inet6 2001:db8::2/64 scope global dynamic"],
|
||||||
|
}
|
||||||
|
res, calls, _, _ = run_filter(ctx, state_v6_only, "wlan0", "up")
|
||||||
|
assert res.returncode == 0, res.stderr
|
||||||
|
assert calls == ["SetFilterA b true", "SetFilterAAAA b false", "ClearCache"], calls
|
||||||
|
|
||||||
|
# 6. QMI raw-ip point-to-point cellular wwan0 (empty IP4 Gateway)
|
||||||
|
state_wwan = {
|
||||||
|
"dnsmasq_running": True,
|
||||||
|
"props": {
|
||||||
|
"/org/freedesktop/NetworkManager:org.freedesktop.NetworkManager:PrimaryConnection": "/AC/2",
|
||||||
|
"/AC/2:org.freedesktop.NetworkManager.Connection.Active:Ip4Config": "/IP4/2",
|
||||||
|
"/AC/2:org.freedesktop.NetworkManager.Connection.Active:Ip6Config": "/",
|
||||||
|
"/IP4/2:org.freedesktop.NetworkManager.IP4Config:Gateway": "",
|
||||||
|
},
|
||||||
|
"v4_routes": ["default dev wwan0 proto static scope link metric 700"],
|
||||||
|
"v6_routes": [],
|
||||||
|
"v4_addrs": ["4: wwan0 inet 100.64.0.2/30 scope global wwan0"],
|
||||||
|
"v6_addrs": [],
|
||||||
|
}
|
||||||
|
res, calls, _, _ = run_filter(ctx, state_wwan, "wwan0", "up")
|
||||||
|
assert res.returncode == 0, res.stderr
|
||||||
|
assert calls == ["SetFilterA b false", "SetFilterAAAA b true", "ClearCache"], calls
|
||||||
|
|
||||||
|
# 7. Zero-DNS DHCP/QMI fallback then recovery on dns-change
|
||||||
|
ctx["nm_nostub"].write_text("# Generated by NetworkManager\n", encoding="utf-8")
|
||||||
|
ctx["nm_resolv"].write_text("# Generated by NetworkManager\n", encoding="utf-8")
|
||||||
|
ctx["resolv_conf"].write_text("# Generated by NetworkManager\n", encoding="utf-8")
|
||||||
|
state_zero_dns = dict(state_wwan)
|
||||||
|
state_zero_dns["dnsmasq_running"] = False
|
||||||
|
res, _, _, _ = run_filter(ctx, state_zero_dns, "wwan0", "up")
|
||||||
|
assert res.returncode == 0, res.stderr
|
||||||
|
rc_text = ctx["resolv_conf"].read_text(encoding="utf-8")
|
||||||
|
assert "nameserver 1.1.1.1" in rc_text and "nameserver 9.9.9.9" in rc_text, rc_text
|
||||||
|
|
||||||
|
ctx["nm_nostub"].write_text("# Generated by NetworkManager\nnameserver 10.0.0.1\n", encoding="utf-8")
|
||||||
|
ctx["nm_resolv"].write_text("# Generated by NetworkManager\nnameserver 127.0.0.1\n", encoding="utf-8")
|
||||||
|
state_zero_dns["dnsmasq_running"] = True
|
||||||
|
res, _, _, _ = run_filter(ctx, state_zero_dns, "wwan0", "dns-change")
|
||||||
|
assert res.returncode == 0, res.stderr
|
||||||
|
rc_text = ctx["resolv_conf"].read_text(encoding="utf-8")
|
||||||
|
assert rc_text.strip() == "# Generated by NetworkManager\nnameserver 127.0.0.1", rc_text
|
||||||
|
|
||||||
|
# 8. bananarchy-privacy-ctl WG DNS leak prevention & screen-lock / crash recovery
|
||||||
|
(ctx["privacy_conf_dir"] / "privacy.conf").write_text(
|
||||||
|
"WG_NATIVE=1\nWG_DNS=10.64.0.1\n",
|
||||||
|
encoding="utf-8",
|
||||||
|
)
|
||||||
|
ctx["locked_file"].write_text("1\n", encoding="utf-8")
|
||||||
|
state_wg = dict(state_dhcp4_done)
|
||||||
|
state_wg["up_links"] = ["wg0"]
|
||||||
|
state_wg["v4_addrs"].append("8: wg0 inet 10.66.66.2/32 scope global wg0")
|
||||||
|
res, _, _, env = run_filter(ctx, state_wg, "wlan0", "dhcp4-change")
|
||||||
|
assert res.returncode == 0, res.stderr
|
||||||
|
rc_text = ctx["resolv_conf"].read_text(encoding="utf-8")
|
||||||
|
assert rc_text.startswith("# Managed by bananarchy-privacy-ctl"), rc_text
|
||||||
|
assert "nameserver 10.64.0.1" in rc_text and "nameserver 1.1.1.1" in rc_text, rc_text
|
||||||
|
assert "127.0.0.1" not in rc_text, f"musl leak: 127.0.0.1 present in VPN resolv.conf:\n{rc_text}"
|
||||||
|
|
||||||
|
# Simulate crash/reboot where wg0 is gone, locked_file cleared, stale privacy resolv.conf remains
|
||||||
|
ctx["locked_file"].unlink(missing_ok=True)
|
||||||
|
state_post_crash = dict(state_dhcp4_done)
|
||||||
|
state_post_crash["up_links"] = []
|
||||||
|
res, _, _, _ = run_filter(ctx, state_post_crash, "wlan0", "up")
|
||||||
|
assert res.returncode == 0, res.stderr
|
||||||
|
rc_text = ctx["resolv_conf"].read_text(encoding="utf-8")
|
||||||
|
assert rc_text.startswith("# Generated by NetworkManager"), f"failed post-crash recovery:\n{rc_text}"
|
||||||
|
assert "nameserver 127.0.0.1" in rc_text, rc_text
|
||||||
|
|
||||||
|
|
||||||
|
def test_static_invariants() -> None:
|
||||||
|
dns_conf = DNS_CONF.read_text(encoding="utf-8")
|
||||||
|
assert "dns=dnsmasq" in dns_conf and "rc-manager=file" in dns_conf, dns_conf
|
||||||
|
|
||||||
|
base_rc = BASE_RESOLV.read_text(encoding="utf-8")
|
||||||
|
assert "nameserver 127.0.0.1" in base_rc, base_rc
|
||||||
|
|
||||||
|
usb_conn = USB_NMCONN.read_text(encoding="utf-8")
|
||||||
|
assert "never-default=true" in usb_conn and "ignore-auto-dns=true" in usb_conn, usb_conn
|
||||||
|
assert "\nmethod=ignore\n" in usb_conn, usb_conn
|
||||||
|
assert stat.S_IMODE(USB_NMCONN.stat().st_mode) == 0o600, "USB_Networking.nmconnection must be 0600"
|
||||||
|
|
||||||
|
cloud = CLOUD_SETUP.read_text(encoding="utf-8")
|
||||||
|
assert "command -v systemctl" in cloud, cloud
|
||||||
|
|
||||||
|
uim = MODEM_UIM_SEL.read_text(encoding="utf-8")
|
||||||
|
assert "net.ipv4.conf.usb0.route_localnet=1" in uim
|
||||||
|
assert "dnat to 127.0.0.1:53" in uim
|
||||||
|
|
||||||
|
priv = PRIVACY_CTL.read_text(encoding="utf-8")
|
||||||
|
assert "pkill" not in priv, "bananarchy-privacy-ctl still uses pkill"
|
||||||
|
assert "pgrep" not in priv, "bananarchy-privacy-ctl still uses pgrep"
|
||||||
|
assert "sync-dns)" in priv
|
||||||
|
|
||||||
|
assert " loopback " in BOOTSTRAP_CONTAINER.read_text(encoding="utf-8")
|
||||||
|
assert "etc/init.d/loopback" in APPLY_OVERLAY.read_text(encoding="utf-8")
|
||||||
|
assert "etc/init.d/loopback" in REBUILD_IMAGE.read_text(encoding="utf-8")
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> int:
|
||||||
|
test_static_invariants()
|
||||||
|
with tempfile.TemporaryDirectory(prefix="bananarchy-dns-test-") as td:
|
||||||
|
test_runtime_scenarios(pathlib.Path(td))
|
||||||
|
print("OK: all Bananarchy DNS resolution regression checks passed.")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(main())
|
||||||
Reference in new issue
Block a user