S025: cookies encrypted at rest with a key in the OS keyring (R1-19)

servo-net hands its public cookie jar to Nacre instead of writing plain
cookie_jar.json; store::cookies seals it in cookies.bin (XChaCha20-Poly1305)
with a keyring-held key, saves on change and at exit, migrates the old plain
jar. No keyring: cookies for the run only, Settings says so (D-019).
Smokes with a throwaway GNOME Keyring (SMOKE_KEYRING=1).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
astar76 2026-11-12 19:30:09 -06:00
commit a5982a7c1b
23 changed files with 1109 additions and 46 deletions

View file

@ -65,7 +65,7 @@ Never modify: `~/Documents/Apps/Nacre` (the original Python Nacre, reference onl
| `nice cargo build --release -j 2` | compile check, produces `target/release/nacre` | now |
| `nice cargo test --release -j 2` | unit tests (44, ~16 s test-profile build then <1 s run; shares the S001 build) (util, settings, history, bookmarks, permissions, vault, dns, bridge loopback, download, adblock, keys, scripts, updates, inject, hub, theme, ui::widgets input, ui::paint, ui::pages::newtab) | first successful build; not alongside a build |
| `src/selftest.rs` | in-app self test: `NACRE_SCRIPT=<file>` runs script commands (listed at its top) | now |
| `tools/smoke.sh <script> [outdir]` | smoke run on a hidden Xvfb display with a throwaway home and software GL; outdir (default `target/smoke/<name>-<time>`) gets `nacre.log`, `selftest.log`, `<shot>.png`, `<status>.json`, `home/`; exits non-zero on crash, panic, no `status done` or a failed `assert <js>`. Scripts in `tests/smoke/` (`launch.txt` offline, `https.txt` needs internet, `restore.txt` with `SMOKE_HOME=<launch outdir>/home`, `chrome.txt` chrome and every flyout dark and light, offline; `colours.txt` colours after welcome and site colour vs internal pages, hidden `SMOKE_SIZE=1280x1100`; `input.txt` real clicks, typing, right click, wheel on a web page, offline; `basics.txt` tabs, navigation, find, zoom, full screen, pop-ups, offline; `heavy-web.txt` DuckDuckGo, Wikipedia, YouTube, needs internet, `SMOKE_TIMEOUT=900`; `keys.txt` every shortcut action, offline; `privacy-net.txt` DNT/GPC/Save-Data headers and third-party cookies on a loopback server, offline, start `python3 tests/smoke/net/server.py &` first; `site-doctor.txt` Google sign-in, captchas, Reddit, GitHub, needs internet; `cache.txt` HTTP cache, offline, start `python3 tests/smoke/cache/server.py &` first; selftest `launch <args>` checks single instance); header documents env vars and commands. `SMOKE_VISIBLE=1` shows the run on the user's screen (DP-1, real GPU, niri tiles the window so shots are narrower); use it whenever the user is watching (D-009). Read the PNGs | now (S003) |
| `tools/smoke.sh <script> [outdir]` | smoke run on a hidden Xvfb display with a throwaway home and software GL; outdir (default `target/smoke/<name>-<time>`) gets `nacre.log`, `selftest.log`, `<shot>.png`, `<status>.json`, `home/`; exits non-zero on crash, panic, no `status done` or a failed `assert <js>`. Scripts in `tests/smoke/` (`launch.txt` offline, `https.txt` needs internet, `restore.txt` with `SMOKE_HOME=<launch outdir>/home`, `chrome.txt` chrome and every flyout dark and light, offline; `colours.txt` colours after welcome and site colour vs internal pages, hidden `SMOKE_SIZE=1280x1100`; `input.txt` real clicks, typing, right click, wheel on a web page, offline; `basics.txt` tabs, navigation, find, zoom, full screen, pop-ups, offline; `heavy-web.txt` DuckDuckGo, Wikipedia, YouTube, needs internet, `SMOKE_TIMEOUT=900`; `keys.txt` every shortcut action, offline; `privacy-net.txt` DNT/GPC/Save-Data headers and third-party cookies on a loopback server, offline, start `python3 tests/smoke/net/server.py &` first; `site-doctor.txt` Google sign-in, captchas, Reddit, GitHub, needs internet; `cache.txt` HTTP cache, offline, start `python3 tests/smoke/cache/server.py &` first; selftest `launch <args>` checks single instance; `cookies.txt` → `cookies-restart.txt` → `cookies-cleared.txt` encrypted cookies across restarts with `SMOKE_KEYRING=1` (own throwaway GNOME Keyring + bus) and `SMOKE_HOME`, `cookies-nokeyring.txt` without, server.py first); header documents env vars and commands. `SMOKE_VISIBLE=1` shows the run on the user's screen (DP-1, real GPU, niri tiles the window so shots are narrower); use it whenever the user is watching (D-009). Read the PNGs | now (S003) |
| `nacre://gallery` + `SMOKE_SIZE=1400x2800 tools/smoke.sh tests/smoke/gallery.txt` | every design token and widget, dark and light (+ new tab and settings shots); read the PNGs | now (S015) |
| `SMOKE_SIZE=1400x1200 tools/smoke.sh tests/smoke/newtab.txt` | new tab page dark/light, nothing playing and a video playing, weather failed state, tall/narrow/phone widths (offline); `tests/smoke/newtab-weather.txt` shoots the real weather card (needs internet); read the PNGs | now (S017) |
| `SMOKE_SIZE=1400x900 tools/smoke.sh tests/smoke/backgrounds.txt` | every new tab background with the pointer, Customize panel dark/light, image + blur, GIF frames; `perf-*-a/b.json` `frames` (median/max draw ms, `drawn` count) per background at Lots/Fast, hidden tab, still, Motion off. Selftest `pointer x y`, `customize`; `@PAGESDIR@` = path of tests/smoke/pages | now (S018) |

625
Cargo.lock generated
View file

@ -106,6 +106,17 @@ dependencies = [
"inout 0.2.2",
]
[[package]]
name = "aes"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0"
dependencies = [
"cfg-if",
"cipher 0.4.4",
"cpufeatures 0.2.17",
]
[[package]]
name = "aes"
version = "0.9.3"
@ -125,7 +136,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f2b8006a0c83f52b62ba44a97b58bf76fe2f70a329e588f67f89691d93d498f"
dependencies = [
"aead 0.6.1",
"aes",
"aes 0.9.3",
"cipher 0.5.2",
"ctr",
"ctutils",
@ -139,7 +150,7 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41ac571010bd60765c56085a4f1d412012a9be2663b1a2f2b19b49318653fd0d"
dependencies = [
"aes",
"aes 0.9.3",
"const-oid",
"zeroize",
]
@ -430,6 +441,30 @@ dependencies = [
"stable_deref_trait",
]
[[package]]
name = "async-broadcast"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "435a87a52755b8f27fcf321ac4f04b2802e337c8c4872923137471ec39c37532"
dependencies = [
"event-listener",
"event-listener-strategy",
"futures-core",
"pin-project-lite",
]
[[package]]
name = "async-channel"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "924ed96dd52d1b75e9c1a3e6275715fd320f5f9439fb5a4a11fa51f4221158d2"
dependencies = [
"concurrent-queue",
"event-listener-strategy",
"futures-core",
"pin-project-lite",
]
[[package]]
name = "async-compression"
version = "0.4.48"
@ -442,6 +477,53 @@ dependencies = [
"tokio",
]
[[package]]
name = "async-io"
version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "456b8a8feb6f42d237746d4b3e9a178494627745c3c56c6ea55d92ba50d026fc"
dependencies = [
"autocfg",
"cfg-if",
"concurrent-queue",
"futures-io",
"futures-lite",
"parking",
"polling",
"rustix 1.1.5",
"slab",
"windows-sys 0.61.2",
]
[[package]]
name = "async-lock"
version = "3.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0876700b0d007ad25d5508865a4259c3af9af6d296bf663a0d586d0bc3369f6f"
dependencies = [
"event-listener",
"event-listener-strategy",
"pin-project-lite",
]
[[package]]
name = "async-process"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc50921ec0055cdd8a16de48773bfeec5c972598674347252c0399676be7da75"
dependencies = [
"async-channel",
"async-io",
"async-lock",
"async-signal",
"async-task",
"blocking",
"cfg-if",
"event-listener",
"futures-lite",
"rustix 1.1.5",
]
[[package]]
name = "async-recursion"
version = "1.1.1"
@ -453,6 +535,30 @@ dependencies = [
"syn 2.0.119",
]
[[package]]
name = "async-signal"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52b5aaafa020cf5053a01f2a60e8ff5dccf550f0f77ec54a4e47285ac2bab485"
dependencies = [
"async-io",
"async-lock",
"atomic-waker",
"cfg-if",
"futures-core",
"futures-io",
"rustix 1.1.5",
"signal-hook-registry",
"slab",
"windows-sys 0.61.2",
]
[[package]]
name = "async-task"
version = "4.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de"
[[package]]
name = "async-trait"
version = "0.1.92"
@ -701,6 +807,15 @@ dependencies = [
"zeroize",
]
[[package]]
name = "block-padding"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8894febbff9f758034a5b8e12d87918f56dfc64a8e1fe757d65e29041538d93"
dependencies = [
"generic-array",
]
[[package]]
name = "block-padding"
version = "0.4.2"
@ -728,6 +843,19 @@ dependencies = [
"objc2 0.6.4",
]
[[package]]
name = "blocking"
version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a70e4329df6cb94385eed412ec92375c3cdd8a6e502493d1229b6414e4036dfa"
dependencies = [
"async-channel",
"async-task",
"futures-io",
"futures-lite",
"piper",
]
[[package]]
name = "bluez-async"
version = "0.9.0"
@ -950,6 +1078,15 @@ dependencies = [
"wayland-client",
]
[[package]]
name = "cbc"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26b52a9543ae338f279b96b0b9fed9c8093744685043739079ce85cd58f289a6"
dependencies = [
"cipher 0.4.4",
]
[[package]]
name = "cbc"
version = "0.2.1"
@ -1671,6 +1808,24 @@ dependencies = [
"windows-sys 0.61.2",
]
[[package]]
name = "dbus-secret-service"
version = "4.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "708b509edf7889e53d7efb0ffadd994cc6c2345ccb62f55cfd6b0682165e4fa6"
dependencies = [
"aes 0.8.4",
"block-padding 0.3.3",
"cbc 0.1.2",
"dbus",
"fastrand",
"hkdf 0.12.4",
"num",
"once_cell",
"sha2 0.10.9",
"zeroize",
]
[[package]]
name = "dbus-tokio"
version = "0.7.6"
@ -2073,7 +2228,7 @@ dependencies = [
"digest 0.11.3",
"ff",
"group",
"hkdf",
"hkdf 0.13.0",
"hybrid-array",
"pem-rfc7468",
"pkcs8",
@ -2137,6 +2292,33 @@ dependencies = [
"simdutf8",
]
[[package]]
name = "endi"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "66b7e2430c6dff6a955451e2cfc438f09cea1965a9d6f87f7e3b90decc014099"
[[package]]
name = "enumflags2"
version = "0.7.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1027f7680c853e056ebcec683615fb6fbbc07dbaa13b4d5d9442b146ded4ecef"
dependencies = [
"enumflags2_derive",
"serde",
]
[[package]]
name = "enumflags2_derive"
version = "0.7.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67c78a4d8fdf9953a5c9d458f9efe940fd97a0cab0941c075a813ac594733827"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.119",
]
[[package]]
name = "enumn"
version = "0.1.14"
@ -2263,6 +2445,26 @@ dependencies = [
"serde",
]
[[package]]
name = "event-listener"
version = "5.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a23add41df1562121a9393cb065eab5146a1242410f23a644851e90cfd669d2"
dependencies = [
"parking",
"pin-project-lite",
]
[[package]]
name = "event-listener-strategy"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8be9f3dfaaffdae2972880079a491a1a8bb7cbed0b8dd7a347f668b4150a3b93"
dependencies = [
"event-listener",
"pin-project-lite",
]
[[package]]
name = "exr"
version = "1.74.2"
@ -2573,6 +2775,19 @@ version = "0.3.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed"
[[package]]
name = "futures-lite"
version = "2.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f78e10609fe0e0b3f4157ffab1876319b5b0db102a2c60dc4626306dc46b44ad"
dependencies = [
"fastrand",
"futures-core",
"futures-io",
"parking",
"pin-project-lite",
]
[[package]]
name = "futures-macro"
version = "0.3.34"
@ -2724,7 +2939,7 @@ dependencies = [
"libc",
"libudev-sys",
"log",
"nix",
"nix 0.31.3",
"objc2-core-foundation",
"objc2-io-kit",
"uuid",
@ -3341,13 +3556,31 @@ version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
[[package]]
name = "hkdf"
version = "0.12.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7"
dependencies = [
"hmac 0.12.1",
]
[[package]]
name = "hkdf"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4aaa26c720c68b866f2c96ef5c1264b3e6f473fe5d4ce61cd44bbe913e553018"
dependencies = [
"hmac",
"hmac 0.13.0",
]
[[package]]
name = "hmac"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e"
dependencies = [
"digest 0.10.7",
]
[[package]]
@ -4054,6 +4287,7 @@ version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01"
dependencies = [
"block-padding 0.3.3",
"generic-array",
]
@ -4063,7 +4297,7 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4250ce6452e92010fdf7268ccc5d14faa80bb12fc741938534c58f16804e03c7"
dependencies = [
"block-padding",
"block-padding 0.4.2",
"hybrid-array",
]
@ -4317,6 +4551,20 @@ dependencies = [
"unicode-segmentation",
]
[[package]]
name = "keyring"
version = "3.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eebcc3aff044e5944a8fbaf69eb277d11986064cba30c468730e8b9909fb551c"
dependencies = [
"byteorder",
"dbus-secret-service",
"log",
"secret-service",
"windows-sys 0.60.2",
"zeroize",
]
[[package]]
name = "khronos_api"
version = "3.1.0"
@ -4571,6 +4819,15 @@ dependencies = [
"libc",
]
[[package]]
name = "memoffset"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
dependencies = [
"autocfg",
]
[[package]]
name = "mime"
version = "0.3.17"
@ -4896,6 +5153,7 @@ dependencies = [
"http",
"image",
"keyboard-types",
"keyring",
"libc",
"log",
"material-colors",
@ -4950,6 +5208,19 @@ version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086"
[[package]]
name = "nix"
version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46"
dependencies = [
"bitflags 2.13.2",
"cfg-if",
"cfg_aliases",
"libc",
"memoffset",
]
[[package]]
name = "nix"
version = "0.31.3"
@ -5023,6 +5294,20 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0676bb32a98c1a483ce53e500a81ad9c3d5b3f7c920c28c24e9cb0980d0b5bc8"
[[package]]
name = "num"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23"
dependencies = [
"num-bigint",
"num-complex",
"num-integer",
"num-iter",
"num-rational",
"num-traits",
]
[[package]]
name = "num-bigint"
version = "0.4.8"
@ -5069,6 +5354,16 @@ dependencies = [
"num-traits",
]
[[package]]
name = "num-iter"
version = "0.1.46"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c92800bd69a1eac91786bcfe9da64a897eb72911b8dc3095decbd07429e8048b"
dependencies = [
"num-integer",
"num-traits",
]
[[package]]
name = "num-rational"
version = "0.4.2"
@ -5638,6 +5933,16 @@ dependencies = [
"crossbeam-channel",
]
[[package]]
name = "ordered-stream"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9aa2b01e1d916879f73a53d01d1d6cee68adbb31d6d9177a8cfce093cced1d50"
dependencies = [
"futures-core",
"pin-project-lite",
]
[[package]]
name = "os_pipe"
version = "1.2.3"
@ -5698,6 +6003,12 @@ dependencies = [
"sha2 0.11.0",
]
[[package]]
name = "parking"
version = "2.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba"
[[package]]
name = "parking_lot"
version = "0.12.5"
@ -5918,6 +6229,17 @@ version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"
[[package]]
name = "piper"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c835479a4443ded371d6c535cbfd8d31ad92c5d23ae9770a61bc155e4992a3c1"
dependencies = [
"atomic-waker",
"fastrand",
"futures-io",
]
[[package]]
name = "pkcs1"
version = "0.8.0-rc.4"
@ -6269,13 +6591,24 @@ version = "5.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
[[package]]
name = "rand"
version = "0.8.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e058c7de0b26af77780c769414d6257830bb240f3c38477dbc2c16e5f54d6d4c"
dependencies = [
"libc",
"rand_chacha 0.3.1",
"rand_core 0.6.4",
]
[[package]]
name = "rand"
version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9ef1d0d795eb7d84685bca4f72f3649f064e6641543d3a8c415898726a57b41"
dependencies = [
"rand_chacha",
"rand_chacha 0.9.0",
"rand_core 0.9.5",
]
@ -6290,6 +6623,16 @@ dependencies = [
"rand_core 0.10.1",
]
[[package]]
name = "rand_chacha"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
dependencies = [
"ppv-lite86",
"rand_core 0.6.4",
]
[[package]]
name = "rand_chacha"
version = "0.9.0"
@ -6352,7 +6695,7 @@ dependencies = [
"paste",
"profiling",
"rand 0.9.5",
"rand_chacha",
"rand_chacha 0.9.0",
"simd_helpers",
"thiserror 2.0.21",
"v_frame",
@ -6557,7 +6900,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4a459cddafb3fe76b31fd8f1108007566c40301feb64dc7b54656eb7388172b"
dependencies = [
"crypto-bigint",
"hmac",
"hmac 0.13.0",
]
[[package]]
@ -6921,6 +7264,25 @@ dependencies = [
"zeroize",
]
[[package]]
name = "secret-service"
version = "4.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4d35ad99a181be0a60ffcbe85d680d98f87bdc4d7644ade319b87076b9dbfd4"
dependencies = [
"aes 0.8.4",
"cbc 0.1.2",
"futures-util",
"generic-array",
"hkdf 0.12.4",
"num",
"once_cell",
"rand 0.8.8",
"serde",
"sha2 0.10.9",
"zbus",
]
[[package]]
name = "security-framework"
version = "3.7.0"
@ -7041,6 +7403,17 @@ dependencies = [
"zmij",
]
[[package]]
name = "serde_repr"
version = "0.1.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d3b1629de253c70a0508c3899572da79ca359fdab27c7920ff00406df418906"
dependencies = [
"proc-macro2",
"quote",
"syn 3.0.4",
]
[[package]]
name = "serde_spanned"
version = "1.1.1"
@ -8096,6 +8469,7 @@ dependencies = [
"sea-query",
"sea-query-rusqlite",
"serde",
"serde_json",
"servo-base",
"servo-config",
"servo-devtools-traits",
@ -8302,7 +8676,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84ab625df5e83104d2b1ef7066f6fbc879d24be07c14438eb25f427657ed7fee"
dependencies = [
"accesskit 0.24.0",
"aes",
"aes 0.9.3",
"aes-gcm",
"aes-kw",
"app_units",
@ -8317,7 +8691,7 @@ dependencies = [
"brotli",
"buf-read-ext",
"bytes",
"cbc",
"cbc 0.2.1",
"chacha20poly1305 0.11.0",
"chardetng",
"chrono",
@ -8339,7 +8713,7 @@ dependencies = [
"flate2",
"glow",
"headers",
"hkdf",
"hkdf 0.13.0",
"html5ever",
"http",
"httparse",
@ -9797,9 +10171,21 @@ checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100"
dependencies = [
"log",
"pin-project-lite",
"tracing-attributes",
"tracing-core",
]
[[package]]
name = "tracing-attributes"
version = "0.1.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.119",
]
[[package]]
name = "tracing-core"
version = "0.1.36"
@ -9892,6 +10278,17 @@ dependencies = [
"ohos-sys-opaque-types",
]
[[package]]
name = "uds_windows"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2f6fb2847f6742cd76af783a2a2c49e9375d0a111c7bef6f71cd9e738c72d6e"
dependencies = [
"memoffset",
"tempfile",
"windows-sys 0.61.2",
]
[[package]]
name = "uluru"
version = "3.1.0"
@ -10803,7 +11200,25 @@ version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
dependencies = [
"windows-targets",
"windows-targets 0.52.6",
]
[[package]]
name = "windows-sys"
version = "0.59.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
dependencies = [
"windows-targets 0.52.6",
]
[[package]]
name = "windows-sys"
version = "0.60.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb"
dependencies = [
"windows-targets 0.53.5",
]
[[package]]
@ -10821,14 +11236,31 @@ version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_gnullvm",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
"windows_aarch64_gnullvm 0.52.6",
"windows_aarch64_msvc 0.52.6",
"windows_i686_gnu 0.52.6",
"windows_i686_gnullvm 0.52.6",
"windows_i686_msvc 0.52.6",
"windows_x86_64_gnu 0.52.6",
"windows_x86_64_gnullvm 0.52.6",
"windows_x86_64_msvc 0.52.6",
]
[[package]]
name = "windows-targets"
version = "0.53.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3"
dependencies = [
"windows-link",
"windows_aarch64_gnullvm 0.53.1",
"windows_aarch64_msvc 0.53.1",
"windows_i686_gnu 0.53.1",
"windows_i686_gnullvm 0.53.1",
"windows_i686_msvc 0.53.1",
"windows_x86_64_gnu 0.53.1",
"windows_x86_64_gnullvm 0.53.1",
"windows_x86_64_msvc 0.53.1",
]
[[package]]
@ -10846,48 +11278,96 @@ version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.53.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53"
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
[[package]]
name = "windows_aarch64_msvc"
version = "0.53.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006"
[[package]]
name = "windows_i686_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
[[package]]
name = "windows_i686_gnu"
version = "0.53.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3"
[[package]]
name = "windows_i686_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
[[package]]
name = "windows_i686_gnullvm"
version = "0.53.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c"
[[package]]
name = "windows_i686_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
[[package]]
name = "windows_i686_msvc"
version = "0.53.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2"
[[package]]
name = "windows_x86_64_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
[[package]]
name = "windows_x86_64_gnu"
version = "0.53.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.53.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1"
[[package]]
name = "windows_x86_64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
[[package]]
name = "windows_x86_64_msvc"
version = "0.53.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650"
[[package]]
name = "winit"
version = "0.30.13"
@ -11238,6 +11718,16 @@ version = "0.3.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "163b33ed8786455e2fa5d72f554057ce3f3182425434f756cd39c99839d88e23"
[[package]]
name = "xdg-home"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec1cdab258fb55c0da61328dc52c8764709b249011b2cad0454c72f0bf10a1f6"
dependencies = [
"libc",
"windows-sys 0.59.0",
]
[[package]]
name = "xkbcommon-dl"
version = "0.4.2"
@ -11335,6 +11825,62 @@ dependencies = [
"rayon",
]
[[package]]
name = "zbus"
version = "4.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb97012beadd29e654708a0fdb4c84bc046f537aecfde2c3ee0a9e4b4d48c725"
dependencies = [
"async-broadcast",
"async-process",
"async-recursion",
"async-trait",
"enumflags2",
"event-listener",
"futures-core",
"futures-sink",
"futures-util",
"hex 0.4.3",
"nix 0.29.0",
"ordered-stream",
"rand 0.8.8",
"serde",
"serde_repr",
"sha1 0.10.6",
"static_assertions",
"tracing",
"uds_windows",
"windows-sys 0.52.0",
"xdg-home",
"zbus_macros",
"zbus_names",
"zvariant",
]
[[package]]
name = "zbus_macros"
version = "4.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "267db9407081e90bbfa46d841d3cbc60f59c0351838c4bc65199ecd79ab1983e"
dependencies = [
"proc-macro-crate",
"proc-macro2",
"quote",
"syn 2.0.119",
"zvariant_utils",
]
[[package]]
name = "zbus_names"
version = "3.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4b9b1fef7d021261cc16cba64c351d291b715febe0fa10dc3a443ac5a5022e6c"
dependencies = [
"serde",
"static_assertions",
"zvariant",
]
[[package]]
name = "zeitstempel"
version = "0.2.2"
@ -11500,3 +12046,40 @@ checksum = "27bc9d5b815bc103f142aa054f561d9187d191692ec7c2d1e2b4737f8dbd7296"
dependencies = [
"zune-core",
]
[[package]]
name = "zvariant"
version = "4.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2084290ab9a1c471c38fc524945837734fbf124487e105daec2bb57fd48c81fe"
dependencies = [
"endi",
"enumflags2",
"serde",
"static_assertions",
"zvariant_derive",
]
[[package]]
name = "zvariant_derive"
version = "4.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73e2ba546bda683a90652bac4a279bc146adad1386f25379cf73200d2002c449"
dependencies = [
"proc-macro-crate",
"proc-macro2",
"quote",
"syn 2.0.119",
"zvariant_utils",
]
[[package]]
name = "zvariant_utils"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c51bcff7cc3dbb5055396bcf774748c3dab426b4b8659046963523cee4808340"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.119",
]

View file

@ -68,6 +68,8 @@ base64 = "0.22"
chacha20poly1305 = "0.10"
argon2 = "0.5"
getrandom = "0.3"
# Cookie key in the OS keyring (S025, D-019): Secret Service over libdbus on Linux, Credential Manager on Windows
keyring = { version = "3.6", features = ["sync-secret-service", "crypto-rust", "windows-native"] }
# Gamepads (Servo gets gamepad input from the embedder)
gilrs = "0.11"

View file

@ -11,13 +11,13 @@ R1-19: protect cookies against infostealers copying the profile. Run Servo witho
- `vendor/servo-net/cookie_storage.rs` and how `Opts.config_dir` persists cookies; `src/store/vault.rs` (existing encryption)
## Steps
- [ ] Find how Servo 0.7 persists cookies under `config_dir` and the cleanest hook: site data manager calls vs. a small patch in the vendored servo-net to load/save through Nacre
- [ ] Key in the OS keyring (crate choice recorded in DECISIONS; fallback when no keyring: say so in Settings, don't silently write plain text)
- [ ] Encrypted cookie store: load at start before the first page, save on change (debounced) and at exit; migrate existing plain cookies once and delete the plain file
- [ ] "Clear cookies on close" and clear-data page still work; private windows never persist
- [ ] Verify with a restart smoke (log in to a loopback test site, quit, relaunch with SMOKE_HOME, still logged in; the profile has no plain cookie file; the cookie file is unreadable without the key)
- [ ] Unit tests for the store round-trip and the migration
- [ ] PROGRESS entry, INDEX line, commit `S025: …` and push
- [x] Find how Servo 0.7 persists cookies under `config_dir` and the cleanest hook: site data manager calls vs. a small patch in the vendored servo-net to load/save through Nacre
- [x] Key in the OS keyring (crate choice recorded in DECISIONS; fallback when no keyring: say so in Settings, don't silently write plain text)
- [x] Encrypted cookie store: load at start before the first page, save on change (debounced) and at exit; migrate existing plain cookies once and delete the plain file
- [x] "Clear cookies on close" and clear-data page still work; private windows never persist
- [x] Verify with a restart smoke (log in to a loopback test site, quit, relaunch with SMOKE_HOME, still logged in; the profile has no plain cookie file; the cookie file is unreadable without the key)
- [x] Unit tests for the store round-trip and the migration
- [x] PROGRESS entry, INDEX line, commit `S025: …` and push
## End criteria
- Restart smoke keeps the session; `grep` finds no cookie values in the profile dir; tests pass.

View file

@ -44,7 +44,7 @@ Tracker: https://claude.ai/artifact/9AD7fPfwJ4ASFzVTJGKU4h
## 06 Privacy
- [x] [S023 — Request headers and third-party cookies in servo-net](06%20Privacy/S023-net-headers-cookies.md) · Opus medium
- [x] [S024 — Privacy mode that holds up](06%20Privacy/S024-privacy-mode.md) · Opus high
- [ ] [S025 — Cookies encrypted at rest](06%20Privacy/S025-cookie-encryption.md) · Opus medium
- [x] [S025 — Cookies encrypted at rest](06%20Privacy/S025-cookie-encryption.md) · Opus medium
## 07 Polish pass
- [ ] [S031 — Fix the SIGSEGV after an ad-blocked script load](07%20Polish%20pass/S031-adblock-crash.md) · Opus high

View file

@ -22,6 +22,7 @@
- D-017 — 2026-11-12 — Request headers and third-party cookie blocking are Nacre patches in the vendored servo-net (S023): new module `nacre.rs` holds embedder-set state (extra headers, block switch, top-level site per webview); `http_loader.rs` and `websocket_loader.rs` read it. A request is third-party when its host's registrable domain differs from its webview's top-level site; blocking is on when the setting or privacy mode is on (`App::refresh_hub_config`). — Servo 0.7 has neither; the user wants engine fixes. `document.cookie` in cross-site frames stays uncovered (script isn't vendored). — S024 (privacy mode only needs `privacy_mode_on`), any Servo upgrade (re-apply from DESIGN.md "Vendored servo-net patches", re-run `privacy-net.txt`)
- D-017 — 2026-11-12 — MSE DOM design (S027). (1) `dom_media_source_enabled` is not a servo-config pref: adding a field to `Preferences` means vendoring servo-config, which rebuilds nearly every Servo crate. Instead the three interfaces carry `[Func="MediaSource::enabled"]`, which reads `NACRE_DOM_MEDIA_SOURCE_ENABLED` once (`0`/`false` = off, default on; `servo_media_player::mse::enabled`). A settings switch, if wanted, sets that variable before Servo starts. (2) The DOM owns the spec state (readyState, updating, both lists, events, always queued as media element tasks); gst_mse owns parsing, buffering and removal. Only `sourceopen` after attaching, update-end/error, duration and active-list changes come from the backend. (3) The backend's event sink names its MediaSource by id through a thread-local map of weak references (no `Trusted`, so a dropped MediaSource is collected). (4) MediaSource object URLs live in a per-global map (`GlobalScope::media_source_urls`), revoked one task later (pages revoke right after setting `src`), cleared on unload. (5) gst_mse defects found here are fixed in vendor/gst-mse like D-016 (patches 5–9 in docs/engine/gst-mse-patches.md). — Keeps rebuilds to servo-script and the media crates; matches Servo's own direction (#22416). — S028 (player integration, merge), S029, any Servo upgrade
- D-018 — 2026-11-12 — Privacy mode looks like desktop Firefox (S024): values that can't be hidden are made consistent with the Firefox user agent (platform, oscpu, appVersion, WebGL "Mozilla", no touch points, Firefox's language list in both `navigator.languages` and Accept-Language); canvas/WebGL/audio/fonts get noise seeded per run and top-level site; time zone and locale stay real; the TouchEvent globals stay (removing them broke Wikipedia). Engine gaps that stop fingerprint or site scripts get a small always-on JS layer (`FONTS_CHECK_JS`, `COMPRESSOR_JS`). — Inconsistent spoofing is itself a fingerprint; Firefox is the UA Nacre sends. — S025 and later privacy or UA work: keep the navigator values in step with any user agent change (`inject::firefox_navigator`).
- D-019 — 2026-11-12 — Cookies at rest (S025, R1-19): servo-net hands its public cookie jar to Nacre (patch in `resource_thread.rs` + `nacre.rs`, no more plain `cookie_jar.json`); Nacre seals it like the vault (XChaCha20-Poly1305) in `cookies.bin` with a key in the OS keyring through the `keyring` 3.6 crate (`sync-secret-service` over the libdbus Servo already links, `crypto-rust`, `windows-native` = Credential Manager, itself DPAPI-protected). No keyring: cookies live for the run only, never written plain, Settings says so (no key-file fallback: a key next to the file stops nothing an infostealer does). An undecryptable file is moved aside, never deleted. — Whole-jar persistence keeps Servo's own cookie metadata (host-only, expiry, session flag) that the site data manager API drops; keyring 4.x splits into per-platform store crates, 3.6 is one dependency. — any Servo upgrade (re-apply the patch), Windows packaging (Credential Manager entry per profile), a later move of auth_cache.json/hsts_list.json into Nacre
- D-020 — 2026-11-12 — Phase 5 polish pass = `Plans/07 Polish pass` S031–S042, ordered crash (S031) → performance (S032, after S031: same ad-block path) → SVG/masks → small fixes → flyouts + context menu → custom DLM → DevTools (2 plans) → motion (after flyouts) → little-things sweep → site passes (after S028 MSE merge) → user review. R4-04/R4-06/R4-08 and the PROGRESS "Later" items Turnstile, Bookmark flyout, mask-image squares, YouTube result list folded in. — phase5.md order (crash first); flyouts and motion share menus.rs so motion goes after. — S031–S042
- D-021 — 2026-11-12 — DevTools is a separate egui window (dock/undock) fed by Servo's own devtools server (Firefox Remote Debugging Protocol) on loopback with a per-open token; Nacre has its own RDP client. Data Servo's actors lack is added by patching the vendored devtools crate, not by injecting page JS. — The user wants engine fixes over workarounds; RDP already has DOM walker, styles, console, network actors. — S037, S038
- D-022 — 2026-11-12 — Custom download manager contract: user-set endpoint URL, loopback only (`127.0.0.1`, `localhost`, `[::1]`). Hand-over = `POST <url>` with `Content-Type: application/json` body `{"url","filename","referrer","cookies" (Cookie header string for that URL),"user_agent","headers" (object),"size" (bytes or null),"mime" (or null)}` and, when a token is set, header `Authorization: Bearer <token>`; any 2xx = taken, else Nacre downloads itself and says why. Status ping = `GET <url>` (same token header), any 2xx = reachable. — Same shape as the other managers in `dlm.rs`; loopback-only keeps cookies on the machine. — S036

View file

@ -163,6 +163,7 @@ picture-in-picture, extensions, password capture, printing.
| `http_loader.rs` `http_network_or_cache_fetch` (step 8.15) | appends the embedder's extra headers (`DNT`, `Sec-GPC`, `Save-Data`) unless the request already has them; records a `Document` request's site as its webview's top-level site; skips the `Cookie` header for a third-party request (S023) | `privacy-net.txt` |
| `http_loader.rs` `http_network_fetch` (step 15) | doesn't store `Set-Cookie` from a third-party response (S023) | `privacy-net.txt` |
| `websocket_loader.rs` `create_handshake_request`, `process_ws_response` | the same third-party rule for WebSocket handshakes (S023) | unit tests only |
| `resource_thread.rs` `create_http_states`, Exit; `nacre.rs` `set_cookie_persistence`, `cookie_jar_snapshot`; `Cargo.toml` (+ `serde_json`) | the public cookie jar comes from and goes to the embedder instead of plain `cookie_jar.json`: Nacre's initial jar at start, a JSON copy on demand, the final jar at Exit (S025, D-019) | `cookies.txt` + `cookies-restart.txt` + `cookies-cleared.txt` |
| `fetch/methods.rs` `main_fetch` (step 12) | privacy mode's Firefox-style Accept-Language ("en-US,en;q=0.5", `nacre::append_accept_language`) replaces Servo's single locale; a page's own value stays (S024) | `privacy-net.txt` |
Third-party rule (S023): a request is third-party when its host's site (registrable domain, eTLD+1; an IP address
@ -175,6 +176,18 @@ checked like any subresource. `document.cookie` and the Cookie Store API in a th
webview id (servo-script isn't vendored); Nacre's `FRAME_COOKIE_JS` (`inject.rs`, S024) empties them in a frame
whose top page is another site.
## Cookies at rest (S025)
`store::cookies` keeps Servo's public cookie jar in `<data>/cookies.bin`: the jar's JSON (Servo's own
`CookieStorage` format) sealed with XChaCha20-Poly1305 (`vault::seal`, AAD `nacre-cookies-v1`, magic `NACRECK1`).
The 256-bit key lives in the OS keyring (crate `keyring` 3: Secret Service on Linux, Credential Manager on Windows),
service `Nacre`, account `cookies <data folder>`. Loaded before Servo starts (`App::servo_first_setup`), saved by a
`cookie-saver` thread every 5 s when the jar changed and by servo-net at Exit (after "delete cookies when Nacre
closes" ran). Without a keyring cookies live for the run only and nothing is written (Settings → Privacy → Site data
says so). An old plain `engine/cookie_jar.json` is migrated once and deleted after the encrypted copy reads back; a
file that doesn't decrypt is moved to `cookies-unreadable-<time>.bin`. Incognito and private webviews write nothing.
`auth_cache.json` (HTTP auth) and `hsts_list.json` are still Servo's plain files.
## Privacy mode (S024)
Page script `PRIVACY_JS` (`inject.rs`) plus the servo-net switches (third-party cookies, Accept-Language list);

View file

@ -305,6 +305,13 @@ Later: S010 list: user checks the Discord icon with their own client (the Discor
- Not done: plugins list, IndexedDB, DOM-measured fonts, web workers (engine/coverage limits); real sign-ins with privacy mode on (for the user).
- Later: normal mode still shows Servo's "Linux"/"4.0" platform values next to the Firefox UA; the YouTube results step of heavy-web crashes/times out on main.
## S025 — Cookies encrypted at rest (2026-11-12)
- Done: servo-net hands its public cookie jar to Nacre (`nacre::set_cookie_persistence`, `cookie_jar_snapshot`; `resource_thread.rs` load/Exit; DESIGN.md patch table, D-019). `store::cookies` seals it (vault's XChaCha20-Poly1305) in `<data>/cookies.bin`, key in the OS keyring (`keyring` 3.6: Secret Service, Windows Credential Manager); saved every 5 s when changed and at exit; old plain `engine/cookie_jar.json` migrated and deleted after the encrypted copy reads back. Settings → Privacy → Site data shows "Cookies on disk"; selftest status has `cookies`.
- Recovery: no keyring → cookies for the run only, nothing written, Settings says so. A file that doesn't decrypt is moved to `cookies-unreadable-<time>.bin` (kept); it opens again only with the old keyring entry (service `Nacre`, account `cookies <data folder>`).
- Tests: 3 unit tests (round trip + wrong key, migration, moved aside), 70 green. Smokes (loopback `/login`, `/whoami`): `cookies.txt` → `cookies-restart.txt` (still signed in) → `cookies-cleared.txt` (clear on close) with `SMOKE_KEYRING=1` (smoke.sh: own bus without activation + throwaway GNOME Keyring); no cookie_jar.json, `grep` of the home finds no cookie value; `cookies-nokeyring.txt` (nothing written, Settings shot); incognito with keyring (nothing written). launch, privacy-net green. keyring crate `cargo check`s for x86_64-pc-windows-gnu (scratch crate; Nacre itself not).
- Not done: clear-data page not driven by a smoke (same `clear_cookies` call as clear-on-close, picked up by the 5 s save); no real-keyring run on the user's desktop (KWallet/gnome-keyring prompt) — for the user; Windows run untested.
- Later: `engine/auth_cache.json` (HTTP auth passwords) and `hsts_list.json` are still Servo's plain files; Nacre has no logger, so `log::` lines (incl. the cookie store's) go nowhere.
## Later
- Turnstile widget paints as a black half-disc (Servo painting of its iframe/shadow DOM, S006 site doctor).
- Google sign-in past the email step: press Next with a real account, by the user (S006).

View file

@ -383,6 +383,8 @@ impl App {
prefs.shell_background_color_rgba = if dark { [0.1, 0.1, 0.1, 1.0] } else { [1.0, 1.0, 1.0, 1.0] };
let opts = Opts { config_dir: Some(self.shared.paths.engine()), temporary_storage: self.shared.incognito, multiprocess: false, ..Opts::default() };
let _ = std::fs::create_dir_all(self.shared.paths.engine());
// Cookies are kept encrypted by Nacre, not in Servo's plain cookie_jar.json (R1-19).
crate::store::cookies::start(&self.shared.paths.data, &self.shared.paths.engine(), self.shared.incognito);
let servo = ServoBuilder::default().opts(opts).preferences(prefs).event_loop_waker(Box::new(Waker(self.proxy.clone()))).build();
servo.set_delegate(self.hub.clone());
servo.setup_logging();

View file

@ -767,6 +767,7 @@ impl App {
serde_json::json!({
"windows": self.windows.len(),
"tab_count": tabs.len(),
"cookies": crate::store::cookies::keeping().map(|k| format!("{k:?}")),
"active_index": self.windows.get(&window).map(|w| w.active),
"fullscreen": self.windows.get(&window).map(|w| w.fullscreen),
"frames": frames,

271
src/store/cookies.rs Normal file
View file

@ -0,0 +1,271 @@
//! Cookies encrypted at rest (R1-19).
//!
//! Servo 0.7 keeps its cookie jar as plain JSON (`engine/cookie_jar.json`), which an infostealer copying the profile
//! can replay to take over signed-in sessions. The vendored servo-net hands the jar to Nacre instead
//! (`net::nacre::set_cookie_persistence`); Nacre keeps it in `cookies.bin`, sealed like the vault
//! (XChaCha20-Poly1305) with a 256-bit key held in the OS keyring: Secret Service (GNOME Keyring, KWallet) on Linux,
//! Credential Manager on Windows. The file alone is useless without the user's unlocked keyring.
//!
//! - Loaded before Servo starts; saved every few seconds when the jar changed, and when Servo exits.
//! - A plain cookie_jar.json from older builds is read once and deleted after the first encrypted save reads back.
//! - No keyring: cookies stay in memory for this run only (nothing plain is written); Settings says so.
//! - A file that doesn't decrypt (key gone, keyring reset) is moved to `cookies-unreadable-<time>.bin`, never
//! deleted; it opens again if the old key comes back into the keyring.
//! - Incognito: nothing is read or written.
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
use std::path::{Path, PathBuf};
use std::sync::{Arc, Mutex, OnceLock};
use std::time::Duration;
use base64::Engine as _;
use base64::engine::general_purpose::STANDARD as B64;
use crate::store::vault::{seal, unseal};
use crate::util;
pub const FILE: &str = "cookies.bin";
/// The plain jar Servo writes into its config dir.
pub const PLAIN_FILE: &str = "cookie_jar.json";
const MAGIC: &[u8] = b"NACRECK1";
const AAD: &[u8] = b"nacre-cookies-v1";
const KEYRING_SERVICE: &str = "Nacre";
const SAVE_EVERY: Duration = Duration::from_secs(5);
static KEEPING: OnceLock<Keeping> = OnceLock::new();
/// How this run keeps cookies between restarts.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Keeping {
Encrypted,
NoKeyring,
Incognito,
}
impl Keeping {
pub fn describe(self) -> &'static str {
match self {
Keeping::Encrypted => "Encrypted on disk with a key in your system keyring",
Keeping::NoKeyring => "No system keyring found: cookies are kept until Nacre closes, never written unencrypted",
Keeping::Incognito => "Incognito: cookies are never written to disk",
}
}
}
/// How cookies are kept in this run (`None` before the engine started).
pub fn keeping() -> Option<Keeping> {
KEEPING.get().copied()
}
pub fn encrypt(key: &[u8; 32], json: &[u8]) -> Vec<u8> {
let mut out = MAGIC.to_vec();
out.extend(seal(key, AAD, json));
out
}
pub fn decrypt(key: &[u8; 32], bytes: &[u8]) -> Option<Vec<u8>> {
unseal(key, AAD, bytes.strip_prefix(MAGIC)?)
}
fn digest(json: &[u8]) -> u64 {
let mut hasher = DefaultHasher::new();
json.hash(&mut hasher);
hasher.finish()
}
#[derive(Default)]
struct SaveState {
/// Digest of the jar last written, to skip unchanged saves.
last: Option<u64>,
/// A plain jar still waiting to be deleted once the encrypted copy is safe.
plain: Option<PathBuf>,
/// Servo has exited and the final jar is written: later saves would be older.
closed: bool,
}
pub struct CookieStore {
path: PathBuf,
key: [u8; 32],
state: Mutex<SaveState>,
}
impl CookieStore {
/// Opens `dir/cookies.bin` and returns the jar to start with: the decrypted file, or else the plain jar at
/// `plain` (migration). A file that doesn't decrypt is moved aside.
pub fn open(dir: &Path, plain: &Path, key: [u8; 32]) -> (CookieStore, Option<Vec<u8>>) {
let path = dir.join(FILE);
let mut initial = None;
match std::fs::read(&path) {
Ok(bytes) => match decrypt(&key, &bytes) {
Some(json) => initial = Some(json),
None => {
let aside = dir.join(format!("cookies-unreadable-{}.bin", util::now()));
log::warn!("cookies: {} doesn't decrypt with the keyring key; moved to {}", path.display(), aside.display());
if let Err(e) = std::fs::rename(&path, &aside) {
log::warn!("cookies: could not move it aside: {e}");
}
}
},
Err(e) if e.kind() == std::io::ErrorKind::NotFound => {}
Err(e) => log::warn!("cookies: can't read {}: {e}", path.display()),
}
let plain = plain.exists().then(|| plain.to_path_buf());
if let (None, Some(plain)) = (&initial, &plain) {
log::info!("cookies: moving the plain cookie jar into the encrypted store");
initial = std::fs::read(plain).ok();
}
let state = SaveState { plain, ..SaveState::default() };
(CookieStore { path, key, state: Mutex::new(state) }, initial)
}
/// Writes the jar if it changed. True when written.
pub fn save(&self, json: &[u8]) -> bool {
let mut state = self.state.lock().unwrap_or_else(|e| e.into_inner());
let digest = digest(json);
if state.closed || state.last == Some(digest) {
return false;
}
if let Err(e) = util::write_atomic(&self.path, &encrypt(&self.key, json), true) {
log::warn!("cookies: not saved: {e}");
return false;
}
state.last = Some(digest);
if let Some(plain) = state.plain.take() {
let reads_back = std::fs::read(&self.path).ok().and_then(|b| decrypt(&self.key, &b)).is_some_and(|b| b == json);
if reads_back && std::fs::remove_file(&plain).is_ok() {
log::info!("cookies: plain cookie jar deleted");
} else {
state.plain = Some(plain);
}
}
true
}
/// The last save (Servo's exit): nothing after it may overwrite the file.
pub fn close(&self) {
self.state.lock().unwrap_or_else(|e| e.into_inner()).closed = true;
}
fn closed(&self) -> bool {
self.state.lock().unwrap_or_else(|e| e.into_inner()).closed
}
}
/// The cookie key from the OS keyring, made on first use. `None` when there is no usable keyring.
fn keyring_key(account: &str) -> Option<[u8; 32]> {
let entry = keyring::Entry::new(KEYRING_SERVICE, account).map_err(|e| log::warn!("cookies: no keyring: {e}")).ok()?;
let text = match entry.get_password() {
Ok(text) => text,
Err(keyring::Error::NoEntry) => {
let mut key = [0u8; 32];
util::random_bytes(&mut key);
let text = B64.encode(key);
if let Err(e) = entry.set_password(&text) {
log::warn!("cookies: keyring refused the key: {e}");
return None;
}
log::info!("cookies: new key stored in the keyring");
// Read it back: a keyring that drops what it is given would lose every cookie at the next start.
entry.get_password().ok().filter(|t| *t == text)?
}
Err(e) => {
log::warn!("cookies: keyring unavailable: {e}");
return None;
}
};
B64.decode(text.trim()).ok()?.try_into().ok()
}
/// Wires Servo's cookie jar to Nacre before Servo starts (see the module docs). `data` is the profile's data folder,
/// `engine` Servo's config dir (where the plain jar may be).
pub fn start(data: &Path, engine: &Path, incognito: bool) -> Keeping {
let keeping = if incognito {
net::nacre::set_cookie_persistence(None, Box::new(|_| {}));
Keeping::Incognito
} else if let Some(key) = keyring_key(&format!("cookies {}", data.display())) {
let (store, initial) = CookieStore::open(data, &engine.join(PLAIN_FILE), key);
let store = Arc::new(store);
let at_exit = store.clone();
net::nacre::set_cookie_persistence(
initial,
Box::new(move |json| {
at_exit.save(json);
at_exit.close();
}),
);
let _ = std::thread::Builder::new().name("cookie-saver".into()).spawn(move || {
while !store.closed() {
std::thread::sleep(SAVE_EVERY);
if let Some(json) = net::nacre::cookie_jar_snapshot() {
store.save(&json);
}
}
});
Keeping::Encrypted
} else {
// Use the old plain jar for this run, but write nothing.
net::nacre::set_cookie_persistence(std::fs::read(engine.join(PLAIN_FILE)).ok(), Box::new(|_| {}));
Keeping::NoKeyring
};
let _ = KEEPING.set(keeping);
log::info!("cookies: {keeping:?}");
keeping
}
#[cfg(test)]
mod tests {
use super::*;
const JAR: &[u8] = br#"{"version":1,"cookies_map":{"example.com":[]},"max_per_host":150}"#;
fn temp_dir(name: &str) -> PathBuf {
let dir = std::env::temp_dir().join(format!("nacre-cookies-{name}-{}", util::random_hex(6)));
std::fs::create_dir_all(&dir).unwrap();
dir
}
#[test]
fn round_trip() {
let dir = temp_dir("round");
let key = [7u8; 32];
let (store, initial) = CookieStore::open(&dir, &dir.join(PLAIN_FILE), key);
assert!(initial.is_none());
assert!(store.save(JAR));
assert!(!store.save(JAR), "unchanged jar is not written again");
let bytes = std::fs::read(dir.join(FILE)).unwrap();
assert!(!bytes.windows(11).any(|w| w == b"example.com"), "no plain text on disk");
assert!(decrypt(&[8u8; 32], &bytes).is_none(), "unreadable without the key");
let (_, initial) = CookieStore::open(&dir, &dir.join(PLAIN_FILE), key);
assert_eq!(initial.as_deref(), Some(JAR));
store.close();
assert!(!store.save(b"{}"), "nothing after the exit save");
let _ = std::fs::remove_dir_all(dir);
}
#[test]
fn migrates_plain_jar() {
let dir = temp_dir("migrate");
let plain = dir.join(PLAIN_FILE);
std::fs::write(&plain, JAR).unwrap();
let (store, initial) = CookieStore::open(&dir, &plain, [1u8; 32]);
assert_eq!(initial.as_deref(), Some(JAR));
assert!(plain.exists(), "plain jar kept until the encrypted copy is saved");
assert!(store.save(JAR));
assert!(!plain.exists());
let _ = std::fs::remove_dir_all(dir);
}
#[test]
fn wrong_key_moves_file_aside() {
let dir = temp_dir("aside");
let (store, _) = CookieStore::open(&dir, &dir.join(PLAIN_FILE), [1u8; 32]);
store.save(JAR);
let (_, initial) = CookieStore::open(&dir, &dir.join(PLAIN_FILE), [2u8; 32]);
assert!(initial.is_none());
assert!(!dir.join(FILE).exists());
let aside: Vec<_> = std::fs::read_dir(&dir).unwrap().flatten().filter(|e| e.file_name().to_string_lossy().starts_with("cookies-unreadable-")).collect();
assert_eq!(aside.len(), 1, "the unreadable file is kept");
let _ = std::fs::remove_dir_all(dir);
}
}

View file

@ -2,6 +2,7 @@
pub mod apps;
pub mod bookmarks;
pub mod cookies;
pub mod downloads;
pub mod history;
pub mod permissions;

View file

@ -123,22 +123,24 @@ impl std::fmt::Display for VaultError {
}
}
fn seal(key: &[u8; 32], plain: &[u8]) -> Vec<u8> {
/// XChaCha20-Poly1305 with a fresh random nonce: nonce || ciphertext. `aad` names what is sealed. Also used by the
/// cookie store.
pub(crate) fn seal(key: &[u8; 32], aad: &[u8], plain: &[u8]) -> Vec<u8> {
let cipher = XChaCha20Poly1305::new(chacha20poly1305::Key::from_slice(key));
let mut nonce = [0u8; 24];
util::random_bytes(&mut nonce);
let sealed = cipher.encrypt(XNonce::from_slice(&nonce), Payload { msg: plain, aad: AAD }).expect("encryption with a valid key cannot fail");
let sealed = cipher.encrypt(XNonce::from_slice(&nonce), Payload { msg: plain, aad }).expect("encryption with a valid key cannot fail");
let mut out = nonce.to_vec();
out.extend(sealed);
out
}
fn unseal(key: &[u8; 32], blob: &[u8]) -> Option<Vec<u8>> {
pub(crate) fn unseal(key: &[u8; 32], aad: &[u8], blob: &[u8]) -> Option<Vec<u8>> {
if blob.len() < 24 + 16 {
return None;
}
let cipher = XChaCha20Poly1305::new(chacha20poly1305::Key::from_slice(key));
cipher.decrypt(XNonce::from_slice(&blob[..24]), Payload { msg: &blob[24..], aad: AAD }).ok()
cipher.decrypt(XNonce::from_slice(&blob[..24]), Payload { msg: &blob[24..], aad }).ok()
}
fn password_key(password: &str, salt: &[u8]) -> [u8; 32] {
@ -211,7 +213,7 @@ impl Vault {
self.contents = Contents::default();
} else {
let blob = B64.decode(&self.meta.data).map_err(|e| VaultError::Damaged(e.to_string()))?;
let plain = unseal(&key, &blob).ok_or(VaultError::WrongPassword)?;
let plain = unseal(&key, AAD, &blob).ok_or(VaultError::WrongPassword)?;
self.contents = serde_json::from_slice(&plain).map_err(|e| VaultError::Damaged(e.to_string()))?;
}
self.key = Some(key);
@ -235,7 +237,7 @@ impl Vault {
let salt = B64.decode(&self.meta.salt).map_err(|e| VaultError::Damaged(e.to_string()))?;
let wrapped = B64.decode(&self.meta.wrapped).map_err(|e| VaultError::Damaged(e.to_string()))?;
let kek = password_key(password, &salt);
let key_bytes = unseal(&kek, &wrapped).ok_or(VaultError::WrongPassword)?;
let key_bytes = unseal(&kek, AAD, &wrapped).ok_or(VaultError::WrongPassword)?;
let key = <[u8; 32]>::try_from(key_bytes.as_slice()).map_err(|_| VaultError::Damaged("bad key".into()))?;
self.unlock_with(key)?;
self.last_auth = util::now();
@ -249,7 +251,7 @@ impl Vault {
}
let Ok(salt) = B64.decode(&self.meta.salt) else { return false };
let Ok(wrapped) = B64.decode(&self.meta.wrapped) else { return false };
let ok = unseal(&password_key(password, &salt), &wrapped).is_some();
let ok = unseal(&password_key(password, &salt), AAD, &wrapped).is_some();
if ok {
self.last_auth = util::now();
}
@ -286,7 +288,7 @@ impl Vault {
return Ok(());
}
let plain = serde_json::to_vec(&self.contents).map_err(|e| VaultError::Io(e.to_string()))?;
self.meta.data = B64.encode(seal(&key, &plain));
self.meta.data = B64.encode(seal(&key, AAD, &plain));
util::save_json_private(&self.path, &self.meta).map_err(|e| VaultError::Io(e.to_string()))
}
@ -297,7 +299,7 @@ impl Vault {
util::random_bytes(&mut salt);
let kek = password_key(password, &salt);
self.meta.salt = B64.encode(salt);
self.meta.wrapped = B64.encode(seal(&kek, &key));
self.meta.wrapped = B64.encode(seal(&kek, AAD, &key));
self.meta.mode = Mode::Master;
self.save()?;
if !self.read_only {

View file

@ -775,6 +775,9 @@ fn privacy(ui: &mut Ui, f: &mut Frame, s: &mut Settings) {
if icon_row(ui, icons::DELETE, "Delete browsing data", "History, cookies, cache and more", |ui| button(ui, ButtonKind::Tonal, None, "Delete…").clicked()) {
f.send(Command::ShowPage(Page::ClearData));
}
if let Some(keeping) = crate::store::cookies::keeping() {
icon_row(ui, icons::COOKIE, "Cookies on disk", keeping.describe(), |_| {});
}
wide_row(ui, "Delete when Nacre closes", "", |ui| {
toggle_chips(ui, &mut s.privacy.clear_on_exit, &[("history", "History"), ("cookies", "Cookies"), ("cache", "Cache"), ("downloads", "Downloads list")]);
});

View file

@ -0,0 +1,7 @@
# Cookies encrypted at rest (S025), part 3 (see cookies.txt): the cookies deleted at the last close stay deleted.
wait 3
set /privacy/clear_on_exit []
open http://127.0.0.1:8767/whoami
waitfor 20 document.title === "Signed out"
status done
quit

View file

@ -0,0 +1,20 @@
# Cookies without a keyring (S025): run WITHOUT SMOKE_KEYRING (no session bus). Cookies work for the run, nothing
# is written: afterwards the home has no cookies.bin, no engine/cookie_jar.json. With SMOKE_KEYRING=1
# SMOKE_ARGS=--incognito and `expect /cookies "Incognito"` instead, the same for an incognito run.
wait 3
set /vpn/enabled false
set /privacy/https_only false
wait 1
open http://127.0.0.1:8767/login?user=smoke
waitfor 20 document.title === "Signed in smoke"
open http://127.0.0.1:8767/whoami
waitfor 20 document.title === "Signed in as smoke"
expect /cookies "NoKeyring"
wait 6
page nacre://settings/privacy
wait 2
scroll 700 500 900
wait 1
shot settings-privacy
status done
quit

View file

@ -0,0 +1,13 @@
# Cookies encrypted at rest (S025), part 2 (see cookies.txt): still signed in after the restart, then "delete cookies
# when Nacre closes" is turned on; part 3 (cookies-cleared.txt, same home) finds no cookie.
wait 3
open http://127.0.0.1:8767/whoami
waitfor 20 document.title === "Signed in as smoke"
expect /cookies "Encrypted"
page nacre://settings/privacy
wait 2
shot settings-privacy
set /privacy/clear_on_exit ["cookies"]
wait 1
status done
quit

18
tests/smoke/cookies.txt Normal file
View file

@ -0,0 +1,18 @@
# Cookies encrypted at rest (S025, R1-19), part 1: sign in to a loopback site and quit. Offline, never Tor or proxies.
# Start the server first: python3 tests/smoke/net/server.py &
# Run (own throwaway keyring): SMOKE_KEYRING=1 tools/smoke.sh tests/smoke/cookies.txt <out>
# Then part 2 with the same home: SMOKE_KEYRING=1 SMOKE_HOME=<out>/home tools/smoke.sh tests/smoke/cookies-restart.txt
# Check afterwards: no engine/cookie_jar.json, `grep -r nacre-test-session <out>/home` finds nothing, cookies.bin exists (the title "Signed in as smoke" is in history, the cookie value never).
wait 3
set /vpn/enabled false
set /privacy/https_only false
wait 1
open http://127.0.0.1:8767/login?user=smoke
waitfor 20 document.title === "Signed in smoke"
open http://127.0.0.1:8767/whoami
waitfor 20 document.title === "Signed in as smoke"
# Longer than the store's 5 s save interval: the jar is on disk before quitting too.
wait 7
expect /cookies "Encrypted"
status done
quit

View file

@ -18,6 +18,8 @@ certificate for *.nacre.test. Port 8767 speaks plain HTTP only (an HTTPS upgrade
/setcookie?name=N[&domain=D] sets cookie N=1 (Path=/, Domain=D if given); /cookies shows the Cookie header in
the title; /pixel is a 1x1 GIF; /tp?tag=T is a page with a cross-site iframe and picture
(127.0.0.1:8767) and a same-site picture (img.nacre.test:8766), titled "TP T done" when loaded
/login?user=U signs in: a persistent cookie session=nacre-test-session-U (Max-Age a day, HttpOnly); /whoami
is titled "Signed in as U" or "Signed out" (S025 restart smoke; the value stays out of history)
/jstp?tag=T page with a cross-site frame (/jscookie) that writes and reads document.cookie and reports what
it read as /note?tag=T&seen=... (S024)
/reset empties the "reqs" list of /log
@ -27,6 +29,7 @@ Runs until killed. Usage: python3 tests/smoke/net/server.py &
"""
import json
import os
import re
import socket
import ssl
import subprocess
@ -158,6 +161,14 @@ class Handler(BaseHTTPRequestHandler):
name = query.get("name", ["c"])[0]
cookie = f"{name}=1; Path=/" + (f"; Domain={query['domain'][0]}" if "domain" in query else "")
return self.reply(f"<!doctype html><title>Set {name}</title><p>Set {name}".encode(), "text/html", {"Set-Cookie": cookie})
if path == "/login":
user = parse_qs(url.query).get("user", ["u"])[0]
cookie = f"session=nacre-test-session-{user}; Path=/; Max-Age=86400; HttpOnly"
return self.reply(f"<!doctype html><title>Signed in {user}</title>".encode(), "text/html", {"Set-Cookie": cookie})
if path == "/whoami":
signed_in = re.search(r"(?:^|; )session=nacre-test-session-(\w+)", self.headers.get("Cookie", ""))
title = f"Signed in as {signed_in.group(1)}" if signed_in else "Signed out"
return self.reply(f"<!doctype html><title>{title}</title>".encode(), "text/html")
if path == "/cookies":
return self.reply(f"<!doctype html><title>Cookies {self.headers.get('Cookie', '')}</title>".encode(), "text/html")
if path == "/pixel":

View file

@ -19,6 +19,9 @@
# NACRE_NO_BRIDGE=1 passed through: no network bridge
# SMOKE_FAKE_DISCORD=1 start tests/smoke/net/fake-discord.py on $XDG_RUNTIME_DIR/discord-ipc-0; it logs every frame
# it gets to outdir/discord.log (one JSON line each)
# SMOKE_KEYRING=1 give the run its own session bus with a throwaway GNOME Keyring (password "smoke", unlocked)
# kept in home/, so the OS keyring path is used (cookie key, S025); SMOKE_HOME reruns find the
# same key. Without it the run has no session bus, hence no keyring.
# SMOKE_VISIBLE=1 show the window on the user's screen (their Wayland display, niri monitor
# SMOKE_MONITOR, default DP-1) with the real GPU instead of hidden Xvfb + software GL;
# only the Wayland socket is shared, profile/runtime dir/bus stay throwaway
@ -60,6 +63,8 @@ xvfb_pid=
cleanup() {
[ -n "$xvfb_pid" ] && kill "$xvfb_pid" 2>/dev/null
[ -n "${discord_pid:-}" ] && kill "$discord_pid" 2>/dev/null
[ -n "${keyring_pid:-}" ] && kill "$keyring_pid" 2>/dev/null
[ -n "${bus_pid:-}" ] && kill "$bus_pid" 2>/dev/null
rm -rf "$runtime"
}
trap cleanup EXIT
@ -90,9 +95,34 @@ if [ -n "${SMOKE_FAKE_DISCORD:-}" ]; then
for _ in $(seq 50); do [ -S "$runtime/discord-ipc-0" ] && break; sleep 0.1; done
fi
busvars=()
if [ -n "${SMOKE_KEYRING:-}" ]; then
mkdir -p "$home/.local/share"
# A bus without service activation: only the keyring on it (no gvfs mounts, portals or the user's services).
cat >"$runtime/bus.conf" <<CONF
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig><type>session</type><listen>unix:path=$runtime/bus</listen>
<policy context="default"><allow send_destination="*" eavesdrop="true"/><allow eavesdrop="true"/><allow own="*"/></policy></busconfig>
CONF
env -i PATH="$PATH" HOME="$home" XDG_RUNTIME_DIR="$runtime" \
dbus-daemon --config-file="$runtime/bus.conf" --nofork --nopidfile >"$out/bus.log" 2>&1 &
bus_pid=$!
for _ in $(seq 50); do [ -S "$runtime/bus" ] && break; sleep 0.1; done
busvars=(DBUS_SESSION_BUS_ADDRESS="unix:path=$runtime/bus")
# The login keyring's password is "smoke" (an empty one leaves no default collection).
printf 'smoke' | env -i PATH="$PATH" HOME="$home" XDG_DATA_HOME="$home/.local/share" XDG_RUNTIME_DIR="$runtime" \
"${busvars[@]}" gnome-keyring-daemon --foreground --unlock --components=secrets >"$out/keyring.log" 2>&1 &
keyring_pid=$!
for _ in $(seq 50); do
env "${busvars[@]}" dbus-send --session --dest=org.freedesktop.DBus --print-reply /org/freedesktop/DBus org.freedesktop.DBus.NameHasOwner \
string:org.freedesktop.secrets 2>/dev/null | grep -q true && break
sleep 0.1
done
fi
env -u WAYLAND_DISPLAY -u DISPLAY -u DBUS_SESSION_BUS_ADDRESS -u NACRE_HOME \
-u http_proxy -u https_proxy -u all_proxy -u HTTP_PROXY -u HTTPS_PROXY -u ALL_PROXY \
"${dispvars[@]}" \
"${dispvars[@]}" "${busvars[@]}" \
HOME="$home" XDG_CONFIG_HOME="$home/.config" XDG_DATA_HOME="$home/.local/share" \
XDG_CACHE_HOME="$home/.cache" XDG_STATE_HOME="$home/.local/state" XDG_RUNTIME_DIR="$runtime" \
RUST_BACKTRACE=1 NACRE_SCRIPT="$out/script.txt" \

Some files were not shown because too many files have changed in this diff Show more