mirror of
https://github.com/VallierDev/uu-remote-linux.git
synced 2026-11-16 08:50:40 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
13a40f9733 | ||
|
|
5f28047a34 | ||
|
|
661263fe37 | ||
|
|
ff2bd9c582 | ||
|
|
0e1e935fb4 | ||
|
|
4649149ff5 | ||
|
|
50a7447b7b | ||
|
|
890c46e280 | ||
|
|
fe052cdca7 |
No files matched your search
Generated
+342
-2
@@ -172,6 +172,29 @@ dependencies = [
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[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-recursion"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4f8abc12baad266b1c8cec146854c195b5864b4221d4b2ca7296a7ae82d9e451"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 3.0.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-trait"
|
||||
version = "0.1.92"
|
||||
@@ -640,6 +663,33 @@ dependencies = [
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[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 = "env_filter"
|
||||
version = "2.0.0"
|
||||
@@ -663,6 +713,12 @@ dependencies = [
|
||||
"log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826"
|
||||
|
||||
[[package]]
|
||||
name = "errno"
|
||||
version = "0.3.14"
|
||||
@@ -673,6 +729,32 @@ dependencies = [
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[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 = "fastrand"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223"
|
||||
|
||||
[[package]]
|
||||
name = "fdeflate"
|
||||
version = "0.3.7"
|
||||
@@ -797,6 +879,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"
|
||||
@@ -912,6 +1007,12 @@ dependencies = [
|
||||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.17.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.5.3"
|
||||
@@ -1145,6 +1246,16 @@ dependencies = [
|
||||
"icu_properties",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.14.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855"
|
||||
dependencies = [
|
||||
"equivalent",
|
||||
"hashbrown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "inout"
|
||||
version = "0.1.4"
|
||||
@@ -1326,6 +1437,15 @@ dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memoffset"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "minimal-lexical"
|
||||
version = "0.2.1"
|
||||
@@ -1372,7 +1492,7 @@ dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"memoffset",
|
||||
"memoffset 0.7.1",
|
||||
"pin-utils",
|
||||
]
|
||||
|
||||
@@ -1475,6 +1595,16 @@ version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe"
|
||||
|
||||
[[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 = "owned_ttf_parser"
|
||||
version = "0.25.1"
|
||||
@@ -1508,6 +1638,12 @@ dependencies = [
|
||||
"sha2",
|
||||
]
|
||||
|
||||
[[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"
|
||||
@@ -1663,6 +1799,15 @@ dependencies = [
|
||||
"elliptic-curve",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-crate"
|
||||
version = "3.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f"
|
||||
dependencies = [
|
||||
"toml_edit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.107"
|
||||
@@ -2229,6 +2374,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.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_urlencoded"
|
||||
version = "0.7.1"
|
||||
@@ -2463,6 +2619,19 @@ dependencies = [
|
||||
"syn 3.0.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tempfile"
|
||||
version = "3.27.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"
|
||||
dependencies = [
|
||||
"fastrand",
|
||||
"getrandom 0.4.3",
|
||||
"once_cell",
|
||||
"rustix",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.69"
|
||||
@@ -2563,6 +2732,7 @@ dependencies = [
|
||||
"signal-hook-registry",
|
||||
"socket2 0.6.5",
|
||||
"tokio-macros",
|
||||
"tracing",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
@@ -2616,6 +2786,36 @@ dependencies = [
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_datetime"
|
||||
version = "1.1.3+spec-1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "173f25c883cd2176a2d8212155638c0a60d484a9d84546d270866f40f56b6e49"
|
||||
dependencies = [
|
||||
"serde_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_edit"
|
||||
version = "0.25.19+spec-1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dd43688c4858d7264ae1cf9a9f874a67c3feb74a883b1cd7bebd6a4ea8307218"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"toml_datetime",
|
||||
"toml_parser",
|
||||
"winnow",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_parser"
|
||||
version = "1.1.5+spec-1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baa693a8032d7e1cada7d0041e96126df243179ff061456783ac7f12bda4744c"
|
||||
dependencies = [
|
||||
"winnow",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tower"
|
||||
version = "0.5.3"
|
||||
@@ -2668,9 +2868,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100"
|
||||
dependencies = [
|
||||
"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"
|
||||
@@ -2738,6 +2950,17 @@ version = "1.20.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20"
|
||||
|
||||
[[package]]
|
||||
name = "uds_windows"
|
||||
version = "1.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f2f6fb2847f6742cd76af783a2a2c49e9375d0a111c7bef6f71cd9e738c72d6e"
|
||||
dependencies = [
|
||||
"memoffset 0.9.1",
|
||||
"tempfile",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.27"
|
||||
@@ -2804,7 +3027,7 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
||||
|
||||
[[package]]
|
||||
name = "uu-remote-linux"
|
||||
version = "0.2.57"
|
||||
version = "0.2.59"
|
||||
dependencies = [
|
||||
"ab_glyph",
|
||||
"async-trait",
|
||||
@@ -2834,6 +3057,7 @@ dependencies = [
|
||||
"tokio-tungstenite",
|
||||
"webrtc",
|
||||
"x11rb",
|
||||
"zbus",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2844,6 +3068,7 @@ checksum = "7cc1186384beb7dd8eedea376413fd654937285ea6c9cfbb928dc3043ea4b606"
|
||||
dependencies = [
|
||||
"getrandom 0.4.3",
|
||||
"js-sys",
|
||||
"serde_core",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
@@ -3291,6 +3516,15 @@ version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||
|
||||
[[package]]
|
||||
name = "winnow"
|
||||
version = "1.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8c3b93199df0ab874cdf0c6a94f0a0dc3423fe41f1cafb62b8bd7b1deb277aef"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "writeable"
|
||||
version = "0.6.4"
|
||||
@@ -3378,6 +3612,71 @@ dependencies = [
|
||||
"synstructure 0.14.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zbus"
|
||||
version = "5.19.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5db4be7c075cb421e4b7ee645541604239bd243ba7c357511f4ff3a74b555907"
|
||||
dependencies = [
|
||||
"async-broadcast",
|
||||
"async-recursion",
|
||||
"async-trait",
|
||||
"enumflags2",
|
||||
"event-listener",
|
||||
"futures-core",
|
||||
"futures-lite",
|
||||
"hex",
|
||||
"libc",
|
||||
"ordered-stream",
|
||||
"rustix",
|
||||
"serde",
|
||||
"serde_repr",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"uds_windows",
|
||||
"uuid",
|
||||
"windows-sys 0.61.2",
|
||||
"winnow",
|
||||
"zbus_macros",
|
||||
"zbus_names",
|
||||
"zvariant",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zbus_macros"
|
||||
version = "5.19.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2990635d09ade6df1868f72f8cac69a876a90981e8bd3c40b1be413f8dc88f40"
|
||||
dependencies = [
|
||||
"proc-macro-crate",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 3.0.9",
|
||||
"zbus_names",
|
||||
"zvariant",
|
||||
"zvariant_utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zbus_names"
|
||||
version = "4.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "812a12be4ead7a59e18ea8f047d08add0066b73bc62fc1467066a2472ae088dd"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"winnow",
|
||||
"zvariant",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zcheapstr"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "939f186d9ecebe044315a5cb6d6f78568bbc21152adc954d5a0c2f58bdbc9920"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy"
|
||||
version = "0.8.62"
|
||||
@@ -3483,3 +3782,44 @@ name = "zmij"
|
||||
version = "1.0.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
|
||||
|
||||
[[package]]
|
||||
name = "zvariant"
|
||||
version = "5.15.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "80bf6d6cd6a4b601acb64cfb8284cdc643fcfa75ef26ae3c46ec8aa4e8a1fbb7"
|
||||
dependencies = [
|
||||
"endi",
|
||||
"enumflags2",
|
||||
"serde",
|
||||
"winnow",
|
||||
"zcheapstr",
|
||||
"zvariant_derive",
|
||||
"zvariant_utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zvariant_derive"
|
||||
version = "5.15.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ef2672456ba1cb54b5eaec136e63135b3c7495fb938e53b28a62e633496d486d"
|
||||
dependencies = [
|
||||
"proc-macro-crate",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 3.0.9",
|
||||
"zvariant_utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zvariant_utils"
|
||||
version = "4.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bad0294361a320b694a328460dc73add56c306150f5cb6bfafc44446120008a3"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"serde",
|
||||
"syn 3.0.9",
|
||||
"winnow",
|
||||
]
|
||||
+2
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "uu-remote-linux"
|
||||
version = "0.2.57"
|
||||
version = "0.2.59"
|
||||
edition = "2021"
|
||||
default-run = "uuremote-server"
|
||||
authors = ["uu-remote-linux contributors"]
|
||||
@@ -38,6 +38,7 @@ inproc-av = ["dep:x11rb"]
|
||||
tokio = { version = "1", features = ["full"] }
|
||||
tokio-tungstenite = { version = "0.23", features = ["rustls-tls-webpki-roots"] }
|
||||
futures-util = "0.3"
|
||||
zbus = { version = "5", default-features = false, features = ["tokio"] }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls", "rustls-tls-native-roots"] }
|
||||
|
||||
+7
-2
@@ -126,7 +126,11 @@ GNOME Portal CONTROL no longer waits for a consent dialog or the first video fra
|
||||
|
||||
The host also accepts a desktop connection while GNOME is locked with no Portal session yet (a cold connection): it reports lock state and accepts auto unlock, then restores picture, input and clipboard after unlock. While Portal is pending, the host sends generated black video once per second on the negotiated track by default, allowing the official iPhone viewer to enter its auto-unlock flow without extra configuration. Verified on Ubuntu GNOME Wayland with the official Mac viewer; iPhone 4.42.0 with H.265 completed a same-executable control experiment: black video ON succeeded, OFF failed, and ON succeeded again ([#29](../../issues/29)). **Limitation**: this is synthetic black video, not the GNOME lock screen, and it does not enable native mouse/keyboard input while locked. Enable 「自动解锁被控端」 in the UU client under 控制中心 → 安全 and enter the password. Without saved Portal permission, local consent is still required after unlock before the real desktop can appear.
|
||||
|
||||
Existing screen-off and lock settings remain unchanged. Only capture recovery in an unlocked session temporarily holds a GNOME idle inhibitor; the first frame, lock, disconnect or initialization failure releases it. An idle viewer still allows the normal screen-off and lock timeout, and manual lock remains effective. Desktop input is blocked and real video is hidden while locked or when lock state is unknown. Independent terminal, file-transfer and port-mapping peers do not wait for video initialization and survive desktop reconnection. Automated protocol and lifecycle regression tests cover this path; auto unlock and capture recovery after a cold locked connection are verified on GNOME hardware with the official Mac and iPhone 4.42.0 viewers, while screen-off and the other scenarios still need acceptance testing. Waking a fully suspended or hibernating machine is outside this CONTROL path.
|
||||
On KDE Plasma (KWin), the Portal screencast stays alive after the session locks. The host now opens capture while locked by default, so a cold connection shows the real lock screen and the password can be entered with the remote keyboard instead of receiving black video ([#227](../../issues/227), [#229](../../pull/229)). Set `UU_LOCKED_CAPTURE=0` to disable this and return to the black-video and auto-unlock path. Detection requires `XDG_CURRENT_DESKTOP` or `XDG_SESSION_DESKTOP` in the systemd user environment. Without either the host falls back to black video, and `UU_LOCKED_CAPTURE=1` forces the new behavior. Portal pointer input remains blocked while locked, and the keyboard uses uinput and can enter the password. This does not apply to GNOME: Mutter closes the Portal session on lock, so the black-video and auto-unlock behavior above is unchanged.
|
||||
|
||||
Existing screen-off and lock settings remain unchanged. Only capture recovery in an unlocked session temporarily holds a GNOME idle inhibitor; the first frame, lock, disconnect or initialization failure releases it. An idle viewer still allows the normal screen-off and lock timeout, and manual lock remains effective. Portal input is blocked while locked. KDE keeps sending the real lock screen, while GNOME hides real video and uses black video. Independent terminal, file-transfer and port-mapping peers do not wait for video initialization and survive desktop reconnection. Automated protocol and lifecycle regression tests cover this path; auto unlock and capture recovery after a cold locked connection are verified on GNOME hardware with the official Mac and iPhone 4.42.0 viewers, while screen-off and the other scenarios still need acceptance testing. Waking a fully suspended or hibernating machine is outside this CONTROL path.
|
||||
|
||||
Lock monitoring reads logind `LockedHint` over the system D-Bus and subscribes to changes instead of spawning `loginctl` every second. Without a graphical session it stays subscribed with unknown state, so login signals trigger a fresh read. It reconciles the session over D-Bus every 30 seconds; if D-Bus fails, it retries with a bounded `loginctl` fallback every 30 seconds, resolving the executable path once. Notifications may be delayed during fallback; unreadable state remains unknown. The locker must still report its state to logind. Suspend, locking and remote connection policies are unchanged.
|
||||
|
||||
Locked black video requires FFmpeg's libx264/libx265 encoder for the negotiated H.264/H.265 codec; hardware encoding support alone does not satisfy this dependency. Encoder failures are logged explicitly. Synthetic video does not change capture permissions or advertised monitor dimensions. It pauses on unlock or unknown lock state, ends when capture is ready/rejected or the connection closes, and then hands the same video track to real capture. See [#29](../../issues/29) and [#34](../../pull/34) for the controlled experiment and validation scope.
|
||||
|
||||
@@ -227,6 +231,7 @@ sudo apt install libpulse-dev libopus-dev
|
||||
- `libgtk-3-dev` is optional. Without GTK, login works with a QR code in the terminal (`UU_NO_GTK=1` disables
|
||||
the login window explicitly).
|
||||
- On NVIDIA GPUs use an FFmpeg build with `h264_nvenc`; otherwise the CPU encoder (libx264) is used.
|
||||
- The NVENC API version FFmpeg requires comes from the nv-codec-headers it was built against. For example, Arch's FFmpeg 9 is built against nv-codec-headers 13.1 and needs driver 610 or newer; Pascal (GTX 10 series) tops out at driver 580 with NVENC API 13.0, so the log shows `Driver does not support the required nvenc API version` and encoding falls back to the CPU. Build a separate FFmpeg against nv-codec-headers 13.0 into its own prefix and point `ffmpeg_root` in `config.json` at it (#230).
|
||||
|
||||
### 2. Build
|
||||
|
||||
@@ -405,7 +410,7 @@ Common environment variables:
|
||||
| `UU_ASSIST_ALLOW=1` | Allow remote assistance at start (overrides the saved switch) |
|
||||
| `UU_LOGIN_WINDOW=0` | Do not open the login window automatically when credentials are missing |
|
||||
| `UU_PORT_MAPPING=0` | Disable port mapping (the official host's controlled-side switch) |
|
||||
| `UU_WOL_HELPER=1` | Experimental: act as a remote-boot helper like the official Windows host — report this host's LAN info after sign-in and send a magic packet to the LAN when the cloud asks to wake a PC (not verified end to end) |
|
||||
| `UU_WOL_HELPER=1` | Experimental: act as a remote-boot helper like the official Windows host — report this host's LAN info after sign-in and send a magic packet to the LAN when the cloud asks to wake a PC (verified end to end with a headless Linux host on a NAS and the official iOS controller) |
|
||||
| `UU_USE_PROXY=1` | Share environment HTTP/HTTPS proxy policy between REST and host/viewer WebSocket signaling; proxies are ignored by default |
|
||||
|
||||
|
||||
|
||||
@@ -112,7 +112,11 @@ GNOME Portal 的控制通道不再等待授权窗口或第一帧画面:先通
|
||||
|
||||
桌面锁屏且尚未建立 Portal 时(冷连接),主机也会建立控制通道:上报锁屏状态并接受自动解锁,解锁后再恢复画面、键鼠和剪贴板。Portal 等待就绪期间,主机默认通过已协商的视频轨每秒发送一帧生成的纯黑画面,让官方 iPhone 客户端进入自动解锁流程,无需额外配置。Ubuntu GNOME Wayland 上已用官方 Mac 客户端验证;iPhone 4.42.0 的 H.265 冷连接完成了同一实验二进制「开启黑帧成功 → 关闭失败 → 再开成功」对照([#29](../../issues/29))。**局限**:黑帧不是真实 GNOME 锁屏画面,也不支持在锁屏界面操作原生键鼠;需要在 UU 客户端 控制中心 → 安全 → 自动解锁被控端 中启用自动解锁并输入密码。若本机没有已保存的 Portal 授权,解锁后仍需本机确认授权才能显示真实桌面。
|
||||
|
||||
无需修改现有熄屏和锁屏设置。主机仅在会话已解锁的采集恢复期间临时申请 GNOME 的 idle 抑制,拿到首帧后立即释放;锁屏、断开或初始化失败也会释放。远控窗口空闲时仍按原策略熄屏和锁屏,手动锁屏也继续生效。锁屏及锁状态未知时停止桌面输入并隐藏真实画面;独立终端、文件传输和端口映射连接不依赖画面初始化,也不会因桌面重连被关闭。这一恢复路径已覆盖自动化协议与生命周期回归测试,锁屏冷连接后的自动解锁与采集恢复已用官方 Mac 和 iPhone 4.42.0 客户端在 GNOME 实机验证,熄屏等其余场景仍待验收;不支持从整机挂起或休眠状态通过现有控制通道唤醒。
|
||||
KDE Plasma(KWin)的 Portal 采集在锁屏后仍会继续。主机默认在锁屏时也打开采集,冷连接可以直接看到真实锁屏界面,并用远程键盘输入密码,不再只发黑帧([#227](../../issues/227)、[#229](../../pull/229))。`UU_LOCKED_CAPTURE=0` 关闭这一行为,回到黑帧和自动解锁的路径。KDE 判断依赖 systemd 用户环境里的 `XDG_CURRENT_DESKTOP` 或 `XDG_SESSION_DESKTOP`,两者都没有时回落到黑帧行为,可以手动设 `UU_LOCKED_CAPTURE=1` 开启。锁屏时 Portal 指针输入仍会被拦截,键盘通过 uinput 注入,可以输入密码。GNOME 不适用这一段,Mutter 在锁屏时关闭 Portal 会话,仍走上面的黑帧和自动解锁。
|
||||
|
||||
无需修改现有熄屏和锁屏设置。主机仅在会话已解锁的采集恢复期间临时申请 GNOME 的 idle 抑制,拿到首帧后立即释放;锁屏、断开或初始化失败也会释放。远控窗口空闲时仍按原策略熄屏和锁屏,手动锁屏也继续生效。锁屏时停止 Portal 输入。KDE 下继续传输真实锁屏画面,GNOME 下隐藏真实画面并发黑帧。独立终端、文件传输和端口映射连接不依赖画面初始化,也不会因桌面重连被关闭。这一恢复路径已覆盖自动化协议与生命周期回归测试,锁屏冷连接后的自动解锁与采集恢复已用官方 Mac 和 iPhone 4.42.0 客户端在 GNOME 实机验证,熄屏等其余场景仍待验收;不支持从整机挂起或休眠状态通过现有控制通道唤醒。
|
||||
|
||||
锁屏状态优先通过系统 D-Bus 读取 logind 的 `LockedHint` 并监听变化,正常监测不按秒启动 `loginctl`。尚无图形会话时保持未知并继续监听,登录后由信号触发重新读取。每 30 秒通过 D-Bus 校验会话;D-Bus 异常时每 30 秒重试并使用带超时的 `loginctl` 回退查询,命令路径只解析一次。回退期间状态通知可能延迟;无法读取时保持未知。锁屏程序仍需正确上报 logind 状态,这不改变睡眠、锁屏或远程连接策略。
|
||||
|
||||
锁屏黑帧使用 FFmpeg 的 libx264/libx265 编码器(按已协商的 H.264/H.265 选择),硬件编码器可用并不代表这些软件编码器已安装。编码失败会明确记录日志。黑帧不改变采集权限或上报的真实屏幕尺寸;解锁或锁状态未知时暂停,采集就绪、拒绝或连接关闭时结束,再由真实视频接续同一条视频轨。对照实验与验证范围见 [#29](../../issues/29)、[#34](../../pull/34)。
|
||||
|
||||
@@ -205,6 +209,7 @@ sudo apt install libpulse-dev libopus-dev
|
||||
- 需要 Rust 工具链(<https://rustup.rs>)。
|
||||
- `libgtk-3-dev` 是可选的:没有 GTK 时只能在终端里扫码登录(也可以设置 `UU_NO_GTK=1` 主动关闭登录窗口)。
|
||||
- NVIDIA 显卡用户需要使用带 `h264_nvenc` 的 FFmpeg,否则自动回落到 CPU 编码(libx264)。
|
||||
- FFmpeg 要求的 NVENC API 版本由编译时的 nv-codec-headers 决定。例如 Arch 的 FFmpeg 9 对着 nv-codec-headers 13.1 编译,需要 610 及以上驱动;Pascal(GTX 10 系)驱动最高 580,只有 NVENC API 13.0,日志会出现 `Driver does not support the required nvenc API version`,于是回落 CPU。可对着 nv-codec-headers 13.0 另编一份 FFmpeg 装到独立目录,在 `config.json` 里用 `ffmpeg_root` 指向它(#230)。
|
||||
|
||||
### 2. 编译
|
||||
|
||||
@@ -368,7 +373,7 @@ systemctl --user restart uuremote-native.service
|
||||
| `UU_REMOTE_ASSIST=0` | 关闭远程协助(未登录时也不再以访客身份提供协助) |
|
||||
| `UU_ASSIST_ALLOW=1` | 启动时就允许他人远程协助(覆盖窗口里保存的开关状态) |
|
||||
| `UU_PORT_MAPPING=0` | 关闭端口映射(对应官方被控端的开关) |
|
||||
| `UU_WOL_HELPER=1` | 实验性:让这台主机像官方 Windows 被控端一样充当「远程开机」辅助设备——登录后向网易上报本机局域网信息,收到云端唤醒请求时向同一局域网发送唤醒包(未经端到端验证) |
|
||||
| `UU_WOL_HELPER=1` | 实验性:让这台主机像官方 Windows 被控端一样充当「远程开机」辅助设备——登录后向网易上报本机局域网信息,收到云端唤醒请求时向同一局域网发送唤醒包(已在 NAS 上的无头 Linux 主机配合官方 iOS 控制端实测可远程开机) |
|
||||
| `UU_USE_PROXY=1` | REST API 与 host/viewer WebSocket 信令共用环境 HTTP/HTTPS 代理策略;默认忽略代理、直连 |
|
||||
|
||||
|
||||
|
||||
@@ -173,6 +173,11 @@ fn shared_engine(name: &str, sources: &[&str], includes: &[&std::path::Path], cf
|
||||
command.args(cflags.split_whitespace()).args(sources).args(libs.split_whitespace()).arg("-lpthread");
|
||||
let status = command.status().expect("C compiler for the engine plugin");
|
||||
assert!(status.success(), "building {name} failed");
|
||||
// OUT_DIR = target/<profile>/build/<package>-<hash>/out
|
||||
if let Some(profile) = out.ancestors().nth(3) { std::fs::copy(&library, profile.join(name)).expect("copy engine plugin"); }
|
||||
// OUT_DIR = target/<profile>/build/<package>-<hash>/out, or target/<profile>/build/<package>/<hash>/out with
|
||||
// the newer Cargo build-dir layout (Rust 1.100 CI): the profile dir is the parent of the `build` component.
|
||||
let profile = out.ancestors().find(|dir| dir.file_name().is_some_and(|n| n == "build")).and_then(|dir| dir.parent());
|
||||
match profile {
|
||||
Some(profile) => { std::fs::copy(&library, profile.join(name)).expect("copy engine plugin"); }
|
||||
None => println!("cargo:warning={name} built in {} but no target/<profile> dir found to copy it to", out.display()),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
修复版:唤醒助手注册、锁屏监测改用 logind D-Bus、HUD 中文字体。/ Fix release: wake-helper registration, logind D-Bus lock monitoring, CJK HUD font.
|
||||
|
||||
### 修复 / Fixed
|
||||
- **网络唤醒助手注册(#209)**:注册唤醒助手时补发 `inner_ip`,云端不再以 422 拒绝,`UU_WOL_HELPER=1` 的主机可以接收唤醒推送并发送魔术包。/ The wake helper registration now sends `inner_ip`, so the cloud accepts it and forwards wake-on-LAN pushes.
|
||||
- **锁屏监测(#217、#218)**:改为通过 D-Bus 订阅 logind `LockedHint`,不再每秒启动 `loginctl`,减少进程轮询与审计日志噪声;无图形会话时保持订阅、不阻塞启动。/ Lock state is now watched via logind D-Bus `LockedHint` instead of spawning `loginctl` every second.
|
||||
- **HUD 中文显示(#219)**:HUD 字体选择优先含汉字的字体,修复部分系统(如 Omarchy)HUD 中文显示为方框。/ The HUD prefers a CJK-capable font, fixing tofu boxes on some systems.
|
||||
|
||||
感谢 @enrzh、@AYssu、@Onekki 的贡献。/ Thanks to @enrzh, @AYssu and @Onekki.
|
||||
|
||||
### 验证范围 / Validation
|
||||
单元测试与 CI;#209 由贡献者端到端实测(iOS 控制端唤醒 Windows PC)。维护方未做锁屏监测与 HUD 字体实机验收。
|
||||
|
||||
### 下载 / Download
|
||||
`uu-remote-linux_0.2.58_<amd64|arm64>.deb`,或 `uu-remote-linux-v0.2.58-<x86_64|aarch64>-linux.tar.gz`(解压后运行 `./install.sh`),或 `docker pull ghcr.io/vallierdev/uu-remote-linux:v0.2.58`(x86_64)。
|
||||
|
||||
**非官方项目,与网易无关。** / **Unofficial, not affiliated with NetEase.**
|
||||
@@ -0,0 +1,15 @@
|
||||
修复版:KDE 锁屏冷连接显示真实锁屏界面、适配 Cargo 新 build-dir 布局。/ Fix release: real lock screen on KDE locked cold connections, Cargo build-dir layout fix.
|
||||
|
||||
### 修复 / Fixed
|
||||
- **KDE 锁屏冷连接(#227、#229)**:KDE Plasma(KWin)锁屏后 Portal 采集仍可用,主机默认在锁屏时也打开采集,冷连接直接看到真实锁屏界面并可用远程键盘输入密码,不再停在「正在传输画面」;`UU_LOCKED_CAPTURE=0` 关闭,`UU_LOCKED_CAPTURE=1` 在无法识别桌面时强制开启。GNOME 行为不变。/ On KDE Plasma the host now keeps Portal capture open while locked, so a cold connection shows the real lock screen; `UU_LOCKED_CAPTURE=0` disables it. GNOME is unchanged.
|
||||
- **源码构建(#226)**:适配 Cargo 新的 build-dir 布局,引擎插件复制到 profile 目录。/ Engine plugins are copied to the profile directory under Cargo's newer build-dir layout.
|
||||
|
||||
感谢 @RiverOnVenus 的贡献。/ Thanks to @RiverOnVenus.
|
||||
|
||||
### 验证范围 / Validation
|
||||
单元测试与 CI;#229 由贡献者在 Plasma 6.8.2 + 官方 Windows 控制端实测锁屏冷连接与远程键盘解锁。维护方未做 KDE 实机验收。
|
||||
|
||||
### 下载 / Download
|
||||
`uu-remote-linux_0.2.59_<amd64|arm64>.deb`,或 `uu-remote-linux-v0.2.59-<x86_64|aarch64>-linux.tar.gz`(解压后运行 `./install.sh`),或 `docker pull ghcr.io/vallierdev/uu-remote-linux:v0.2.59`(x86_64)。
|
||||
|
||||
**非官方项目,与网易无关。** / **Unofficial, not affiliated with NetEase.**
|
||||
@@ -243,7 +243,16 @@ async fn locked_control_unlock_requests_and_tools_work_without_a_video_frame() {
|
||||
let frame = tokio::time::timeout(Duration::from_secs(5), async {
|
||||
loop {
|
||||
let (channel, message) = terminal_viewer.messages.recv().await.unwrap();
|
||||
if channel == "BINARY_DATA_CHANNEL" { break crate::terminal::decode(&message).unwrap(); }
|
||||
if channel != "BINARY_DATA_CHANNEL" {
|
||||
continue;
|
||||
}
|
||||
// The process-global terminal change watch also broadcasts the field-28
|
||||
// list-invalidated notification here, which is not a TERM frame.
|
||||
if let Some(frame) = crate::terminal::decode(&message) {
|
||||
if frame.kind == crate::terminal::LIST_RESP && frame.session == 71 {
|
||||
break frame;
|
||||
}
|
||||
}
|
||||
}
|
||||
}).await.unwrap();
|
||||
assert_eq!((frame.kind, frame.session), (crate::terminal::LIST_RESP, 71));
|
||||
@@ -299,7 +308,16 @@ async fn locked_control_unlock_requests_and_tools_work_without_a_video_frame() {
|
||||
let frame = tokio::time::timeout(Duration::from_secs(5), async {
|
||||
loop {
|
||||
let (channel, message) = terminal_viewer.messages.recv().await.unwrap();
|
||||
if channel == "BINARY_DATA_CHANNEL" { break crate::terminal::decode(&message).unwrap(); }
|
||||
if channel != "BINARY_DATA_CHANNEL" {
|
||||
continue;
|
||||
}
|
||||
// The process-global terminal change watch also broadcasts the field-28
|
||||
// list-invalidated notification here, which is not a TERM frame.
|
||||
if let Some(frame) = crate::terminal::decode(&message) {
|
||||
if frame.kind == crate::terminal::LIST_RESP && frame.session == 72 {
|
||||
break frame;
|
||||
}
|
||||
}
|
||||
}
|
||||
}).await.unwrap();
|
||||
assert_eq!((frame.kind, frame.session), (crate::terminal::LIST_RESP, 72));
|
||||
|
||||
+199
-25
@@ -1,6 +1,6 @@
|
||||
//! Portal availability is independent of the authenticated CONTROL transport.
|
||||
use std::future::Future;
|
||||
use std::sync::{Arc, atomic::{AtomicBool, Ordering}};
|
||||
use std::sync::{Arc, OnceLock, atomic::{AtomicBool, Ordering}};
|
||||
use std::time::Instant;
|
||||
use tokio::sync::{watch, Mutex};
|
||||
use crate::{capture::ScreenCapture, input::DesktopInputSession};
|
||||
@@ -29,6 +29,7 @@ pub struct PortalDesktop {
|
||||
state: watch::Sender<State>,
|
||||
opening: Arc<Mutex<()>>,
|
||||
locked: watch::Receiver<Option<bool>>,
|
||||
capture_while_locked: bool,
|
||||
}
|
||||
|
||||
struct CancelOnDrop(Arc<AtomicBool>);
|
||||
@@ -71,6 +72,7 @@ enum AttemptOutcome {
|
||||
Ready(Arc<ScreenCapture>),
|
||||
Retry(String),
|
||||
Terminal(String),
|
||||
Deferred,
|
||||
Cancelled,
|
||||
}
|
||||
|
||||
@@ -85,14 +87,52 @@ fn classify(result: Result<Arc<ScreenCapture>, PortalError>) -> AttemptOutcome {
|
||||
}
|
||||
}
|
||||
|
||||
/// A consent dialog opened behind the lock screen cannot be approved, so its denied/timed-out
|
||||
/// error must not end this connection's supervisor: ask again after the local unlock.
|
||||
fn defer_consent(error: &PortalError, state: Option<bool>) -> bool {
|
||||
state == Some(true) && matches!(error.code, 4 | 5)
|
||||
}
|
||||
|
||||
/// True when this iteration sees a lock state it has not attempted under yet. Waking and resetting
|
||||
/// the retry delay must happen once per transition, not once per 200 ms poll: a locked state would
|
||||
/// otherwise re-run wake, inhibitor and publish on every tick and defeat the 5 s retry backoff.
|
||||
fn fresh_state(previous: Option<Option<bool>>, state: Option<bool>) -> bool {
|
||||
previous != Some(state)
|
||||
}
|
||||
|
||||
fn should_prepare_power(healthy: bool, force_wake: bool) -> bool {
|
||||
!healthy || force_wake
|
||||
}
|
||||
|
||||
/// KWin keeps the Portal screencast, including the lock screen, alive while the session is
|
||||
/// locked, so a cold connection can show the real lock screen. Mutter closes the session on
|
||||
/// lock, so other desktops keep the existing black-frame path. `UU_LOCKED_CAPTURE=0` opts out.
|
||||
fn capture_while_locked() -> bool {
|
||||
static ENABLED: OnceLock<bool> = OnceLock::new();
|
||||
*ENABLED.get_or_init(|| {
|
||||
match std::env::var("UU_LOCKED_CAPTURE").ok().filter(|value| !value.is_empty()) {
|
||||
Some(value) => !matches!(value.to_ascii_lowercase().as_str(), "0" | "off" | "false" | "no"),
|
||||
None => ["XDG_CURRENT_DESKTOP", "XDG_SESSION_DESKTOP"].iter().any(|key|
|
||||
std::env::var(key).is_ok_and(|desktop| desktop.split(':')
|
||||
.any(|part| part.eq_ignore_ascii_case("KDE")))),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/// Capture may start and continue in this lock state. An unknown state keeps the old wait on
|
||||
/// desktops whose compositor closes the session on lock.
|
||||
fn attempt_allowed(state: Option<bool>, capture_while_locked: bool) -> bool {
|
||||
match state {
|
||||
Some(false) => true,
|
||||
Some(true) | None => capture_while_locked,
|
||||
}
|
||||
}
|
||||
|
||||
fn prepare_attempt<W, I>(
|
||||
cancelled: &AtomicBool,
|
||||
owner: &DesktopInputSession,
|
||||
locked: &watch::Receiver<Option<bool>>,
|
||||
allow_locked: bool,
|
||||
wake: W,
|
||||
inhibit: I,
|
||||
) -> Option<AttemptPrep>
|
||||
@@ -102,7 +142,7 @@ where
|
||||
{
|
||||
let current = || !cancelled.load(Ordering::Acquire)
|
||||
&& owner.is_current()
|
||||
&& *locked.borrow() == Some(false);
|
||||
&& attempt_allowed(*locked.borrow(), allow_locked);
|
||||
if !current() { return None; }
|
||||
let wake = wake();
|
||||
if !current() { return None; }
|
||||
@@ -114,7 +154,8 @@ where
|
||||
impl PortalDesktop {
|
||||
pub fn new(screen: Arc<ScreenCapture>) -> Self {
|
||||
Self { state: watch::channel(State { waiting: screen.init_error.is_some(), screen }).0,
|
||||
opening: Arc::new(Mutex::new(())), locked: crate::session_lock::watch_locked() }
|
||||
opening: Arc::new(Mutex::new(())), locked: crate::session_lock::watch_locked(),
|
||||
capture_while_locked: capture_while_locked() }
|
||||
}
|
||||
pub fn begin(&self) {
|
||||
// GNOME closes the Portal session on lock; a cached screen with a dead session
|
||||
@@ -133,10 +174,21 @@ impl PortalDesktop {
|
||||
}
|
||||
pub fn subscribe(&self) -> watch::Receiver<State> { self.state.subscribe() }
|
||||
pub fn lock_state(&self) -> watch::Receiver<Option<bool>> { self.locked.clone() }
|
||||
/// Whether capture may run in this lock state for this desktop. Shares the rule used by
|
||||
/// maintain(), so capture-setting requests do not stall behind a lock the compositor does
|
||||
/// not honor.
|
||||
pub fn capture_allowed(&self, locked: Option<bool>) -> bool {
|
||||
attempt_allowed(locked, self.capture_while_locked)
|
||||
}
|
||||
#[cfg(test)]
|
||||
pub fn with_lock_state(screen: Arc<ScreenCapture>, locked: watch::Receiver<Option<bool>>) -> Self {
|
||||
Self::with_lock_state_and_capture(screen, locked, false)
|
||||
}
|
||||
#[cfg(test)]
|
||||
pub fn with_lock_state_and_capture(screen: Arc<ScreenCapture>, locked: watch::Receiver<Option<bool>>,
|
||||
capture_while_locked: bool) -> Self {
|
||||
Self { state: watch::channel(State { waiting: screen.init_error.is_some(), screen }).0,
|
||||
opening: Arc::new(Mutex::new(())), locked }
|
||||
opening: Arc::new(Mutex::new(())), locked, capture_while_locked }
|
||||
}
|
||||
#[cfg(test)]
|
||||
pub fn publish_test_screen(&self, screen: Arc<ScreenCapture>) {
|
||||
@@ -204,22 +256,27 @@ impl PortalDesktop {
|
||||
let inhibit = Arc::new(inhibit);
|
||||
let open = Arc::new(open);
|
||||
let mut locked = self.locked.clone();
|
||||
let mut previous = None;
|
||||
let allow_locked = self.capture_while_locked;
|
||||
let mut previous: Option<Option<bool>> = None;
|
||||
let mut defer_until_unlock = false;
|
||||
let mut retry_at = Instant::now();
|
||||
loop {
|
||||
if !owner.is_current() { return Ok(()); }
|
||||
let state = *locked.borrow_and_update();
|
||||
if state != Some(false) {
|
||||
if previous == Some(false) { self.pause(&owner); }
|
||||
} else {
|
||||
// A fresh unlocked transition gets an immediate wake/recovery attempt.
|
||||
let force_wake = previous != Some(false);
|
||||
if state == Some(false) { defer_until_unlock = false; }
|
||||
if state != Some(false) && previous == Some(Some(false)) { self.pause(&owner); }
|
||||
if state == Some(true) && previous != Some(Some(true)) && allow_locked {
|
||||
log::info!("Desktop is locked; opening Portal capture for the lock screen");
|
||||
}
|
||||
if attempt_allowed(state, allow_locked) && !defer_until_unlock {
|
||||
// A fresh transition into an attempted state gets an immediate wake/recovery attempt.
|
||||
let force_wake = fresh_state(previous, state);
|
||||
if force_wake { retry_at = Instant::now(); }
|
||||
let mut attempt_locked = locked.clone();
|
||||
let outcome = tokio::select! {
|
||||
biased;
|
||||
_ = wait_for_lock(&mut locked) => AttemptOutcome::Cancelled,
|
||||
outcome = self.portal_attempt(&owner, &mut attempt_locked, retry_at, force_wake, wake.clone(), inhibit.clone(), open.clone()) => outcome,
|
||||
_ = wait_for_lock(&mut locked, allow_locked) => AttemptOutcome::Cancelled,
|
||||
outcome = self.portal_attempt(&owner, &mut attempt_locked, allow_locked, retry_at, force_wake, wake.clone(), inhibit.clone(), open.clone()) => outcome,
|
||||
};
|
||||
match outcome {
|
||||
AttemptOutcome::Ready(screen) => self.publish(&owner, screen),
|
||||
@@ -228,11 +285,12 @@ impl PortalDesktop {
|
||||
log::warn!("Portal desktop recovery deferred: {error}");
|
||||
retry_at = Instant::now() + std::time::Duration::from_secs(5);
|
||||
}
|
||||
AttemptOutcome::Deferred => { defer_until_unlock = true; }
|
||||
AttemptOutcome::Cancelled => {}
|
||||
}
|
||||
if *locked.borrow_and_update() != Some(false) { self.pause(&owner); }
|
||||
if !attempt_allowed(*locked.borrow_and_update(), allow_locked) { self.pause(&owner); }
|
||||
}
|
||||
previous = *locked.borrow_and_update();
|
||||
previous = Some(*locked.borrow_and_update());
|
||||
tokio::select! {
|
||||
_ = locked.changed() => {},
|
||||
_ = tokio::time::sleep(std::time::Duration::from_millis(200)) => {},
|
||||
@@ -241,20 +299,20 @@ impl PortalDesktop {
|
||||
}
|
||||
|
||||
async fn portal_attempt<W, I, O>(&self, owner: &Arc<DesktopInputSession>,
|
||||
locked: &mut watch::Receiver<Option<bool>>, retry_at: Instant, force_wake: bool,
|
||||
locked: &mut watch::Receiver<Option<bool>>, allow_locked: bool, retry_at: Instant, force_wake: bool,
|
||||
wake: Arc<W>, inhibit: Arc<I>, open: Arc<O>) -> AttemptOutcome
|
||||
where
|
||||
W: Fn() -> Result<(), String> + Send + Sync + 'static,
|
||||
I: Fn() -> IdleGuard + Send + Sync + 'static,
|
||||
O: Fn(Arc<ScreenCapture>, Arc<AtomicBool>) -> Result<Arc<ScreenCapture>, PortalError> + Send + Sync + 'static,
|
||||
{
|
||||
if !owner.is_current() || *locked.borrow() != Some(false) || Instant::now() < retry_at {
|
||||
if !owner.is_current() || !attempt_allowed(*locked.borrow(), allow_locked) || Instant::now() < retry_at {
|
||||
return AttemptOutcome::Cancelled;
|
||||
}
|
||||
let gate = self.opening.clone().lock_owned().await;
|
||||
// The state can change while this attempt waits for an earlier worker
|
||||
// to finish rotating the Portal permission token.
|
||||
if !owner.is_current() || *locked.borrow() != Some(false) {
|
||||
if !owner.is_current() || !attempt_allowed(*locked.borrow(), allow_locked) {
|
||||
return AttemptOutcome::Cancelled;
|
||||
}
|
||||
let screen = self.snapshot().screen;
|
||||
@@ -271,6 +329,7 @@ impl PortalDesktop {
|
||||
&prep_cancel,
|
||||
&prep_owner,
|
||||
&prep_locked,
|
||||
allow_locked,
|
||||
|| (*wake)(),
|
||||
|| (*inhibit)(),
|
||||
)).await {
|
||||
@@ -282,7 +341,7 @@ impl PortalDesktop {
|
||||
// Held by the cancellable async helper, not the blocking worker, so a
|
||||
// lock transition releases it while worker cleanup may still be running.
|
||||
let _inhibitor = prep.inhibitor;
|
||||
if !owner.is_current() || *locked.borrow() != Some(false) {
|
||||
if !owner.is_current() || !attempt_allowed(*locked.borrow(), allow_locked) {
|
||||
return AttemptOutcome::Cancelled;
|
||||
}
|
||||
// A new controller can arrive while the cached Portal handle is alive
|
||||
@@ -298,19 +357,25 @@ impl PortalDesktop {
|
||||
}
|
||||
open(screen, worker_cancel)
|
||||
}).await;
|
||||
if !owner.is_current() || *locked.borrow() != Some(false) {
|
||||
if !owner.is_current() || !attempt_allowed(*locked.borrow(), allow_locked) {
|
||||
return AttemptOutcome::Cancelled;
|
||||
}
|
||||
match result {
|
||||
Ok(Err(error)) if defer_consent(&error, *locked.borrow()) => {
|
||||
// The consent dialog opened behind the lock screen cannot be approved here.
|
||||
// Keep this connection alive and ask again after the local unlock.
|
||||
log::info!("Portal consent is behind the lock screen; waiting for the local unlock");
|
||||
AttemptOutcome::Deferred
|
||||
}
|
||||
Ok(result) => classify(result),
|
||||
Err(_) => AttemptOutcome::Terminal("Portal initialization worker failed".into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async fn wait_for_lock(locked: &mut watch::Receiver<Option<bool>>) {
|
||||
async fn wait_for_lock(locked: &mut watch::Receiver<Option<bool>>, allow_locked: bool) {
|
||||
while locked.changed().await.is_ok() {
|
||||
if *locked.borrow_and_update() != Some(false) { return; }
|
||||
if !attempt_allowed(*locked.borrow_and_update(), allow_locked) { return; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -441,19 +506,19 @@ mod tests {
|
||||
let wakes = AtomicUsize::new(0);
|
||||
let inhibitors = AtomicUsize::new(0);
|
||||
let cancelled = AtomicBool::new(true);
|
||||
assert!(prepare_attempt(&cancelled, &owner, &locked,
|
||||
assert!(prepare_attempt(&cancelled, &owner, &locked, false,
|
||||
|| { wakes.fetch_add(1, Ordering::Relaxed); Ok(()) },
|
||||
|| { inhibitors.fetch_add(1, Ordering::Relaxed); IdleGuard::default() }).is_none());
|
||||
assert_eq!(wakes.load(Ordering::Relaxed), 0);
|
||||
cancelled.store(false, Ordering::Release);
|
||||
lock.send(Some(true)).unwrap();
|
||||
assert!(prepare_attempt(&cancelled, &owner, &locked,
|
||||
assert!(prepare_attempt(&cancelled, &owner, &locked, false,
|
||||
|| { wakes.fetch_add(1, Ordering::Relaxed); Ok(()) },
|
||||
|| { inhibitors.fetch_add(1, Ordering::Relaxed); IdleGuard::default() }).is_none());
|
||||
assert_eq!(wakes.load(Ordering::Relaxed), 0);
|
||||
lock.send(Some(false)).unwrap();
|
||||
let locked_during_wake = lock.clone();
|
||||
assert!(prepare_attempt(&cancelled, &owner, &locked,
|
||||
assert!(prepare_attempt(&cancelled, &owner, &locked, false,
|
||||
|| {
|
||||
wakes.fetch_add(1, Ordering::Relaxed);
|
||||
locked_during_wake.send(Some(true)).unwrap();
|
||||
@@ -464,7 +529,7 @@ mod tests {
|
||||
assert_eq!(inhibitors.load(Ordering::Relaxed), 0);
|
||||
lock.send(Some(false)).unwrap();
|
||||
let replacement = input.desktop_session();
|
||||
assert!(prepare_attempt(&cancelled, &owner, &locked,
|
||||
assert!(prepare_attempt(&cancelled, &owner, &locked, false,
|
||||
|| { wakes.fetch_add(1, Ordering::Relaxed); Ok(()) },
|
||||
|| { inhibitors.fetch_add(1, Ordering::Relaxed); IdleGuard::default() }).is_none());
|
||||
assert_eq!(wakes.load(Ordering::Relaxed), 1);
|
||||
@@ -479,6 +544,115 @@ mod tests {
|
||||
drop(guard);
|
||||
assert!(flag.load(Ordering::Acquire));
|
||||
}
|
||||
#[test]
|
||||
fn locked_capture_gate_follows_the_compositor_rule() {
|
||||
assert!(attempt_allowed(Some(false), false));
|
||||
assert!(!attempt_allowed(Some(true), false));
|
||||
assert!(!attempt_allowed(None, false));
|
||||
assert!(attempt_allowed(Some(true), true));
|
||||
assert!(attempt_allowed(None, true));
|
||||
}
|
||||
#[test]
|
||||
fn wake_and_retry_reset_once_per_lock_transition() {
|
||||
assert!(fresh_state(None, Some(true)));
|
||||
assert!(!fresh_state(Some(Some(true)), Some(true)));
|
||||
assert!(fresh_state(Some(Some(true)), Some(false)));
|
||||
assert!(!fresh_state(Some(Some(false)), Some(false)));
|
||||
assert!(fresh_state(Some(Some(true)), None));
|
||||
assert!(!fresh_state(Some(None), None));
|
||||
}
|
||||
#[test]
|
||||
fn consent_failures_are_deferred_only_while_locked() {
|
||||
for code in [4, 5] {
|
||||
assert!(defer_consent(&PortalError { code }, Some(true)));
|
||||
assert!(!defer_consent(&PortalError { code }, Some(false)));
|
||||
assert!(!defer_consent(&PortalError { code }, None));
|
||||
}
|
||||
assert!(!defer_consent(&PortalError { code: 8 }, Some(true)));
|
||||
assert!(!defer_consent(&PortalError { code: 13 }, Some(true)));
|
||||
}
|
||||
#[tokio::test]
|
||||
async fn wait_for_lock_ends_on_a_lock_the_compositor_does_not_honor() {
|
||||
use std::time::Duration;
|
||||
let (lock, mut locked) = watch::channel(Some(false));
|
||||
let mut task = tokio::spawn(async move { wait_for_lock(&mut locked, false).await; });
|
||||
lock.send(Some(true)).unwrap();
|
||||
tokio::time::timeout(Duration::from_secs(1), &mut task).await
|
||||
.expect("lock must end the wait").unwrap();
|
||||
}
|
||||
#[tokio::test]
|
||||
async fn wait_for_lock_ignores_lock_changes_when_capture_is_allowed() {
|
||||
use std::time::Duration;
|
||||
let (lock, mut locked) = watch::channel(Some(false));
|
||||
let mut task = tokio::spawn(async move { wait_for_lock(&mut locked, true).await; });
|
||||
lock.send(Some(true)).unwrap();
|
||||
assert!(tokio::time::timeout(Duration::from_millis(100), &mut task).await.is_err(),
|
||||
"lock cancelled an allowed wait");
|
||||
lock.send(None).unwrap();
|
||||
assert!(tokio::time::timeout(Duration::from_millis(100), &mut task).await.is_err(),
|
||||
"unknown lock cancelled an allowed wait");
|
||||
task.abort();
|
||||
let _ = task.await;
|
||||
}
|
||||
#[test]
|
||||
fn locked_attempt_is_allowed_when_the_compositor_keeps_the_stream() {
|
||||
let input = Arc::new(crate::input::InputInjector::without_desktop());
|
||||
let owner = input.desktop_session();
|
||||
let (lock, locked) = watch::channel(Some(true));
|
||||
let cancelled = AtomicBool::new(false);
|
||||
let wakes = AtomicUsize::new(0);
|
||||
assert!(prepare_attempt(&cancelled, &owner, &locked, true,
|
||||
|| { wakes.fetch_add(1, Ordering::Relaxed); Ok(()) },
|
||||
|| IdleGuard::default()).is_some());
|
||||
lock.send(None).unwrap();
|
||||
assert!(prepare_attempt(&cancelled, &owner, &locked, true,
|
||||
|| { wakes.fetch_add(1, Ordering::Relaxed); Ok(()) },
|
||||
|| IdleGuard::default()).is_some());
|
||||
assert_eq!(wakes.load(Ordering::Relaxed), 2);
|
||||
}
|
||||
#[tokio::test]
|
||||
async fn locked_capture_keeps_the_attempt_running() {
|
||||
use std::time::Duration;
|
||||
let (lock, locked) = watch::channel(Some(false));
|
||||
let host = Arc::new(PortalDesktop::with_lock_state_and_capture(
|
||||
Arc::new(ScreenCapture::unavailable("pending".into())), locked, true));
|
||||
let input = Arc::new(crate::input::InputInjector::without_desktop());
|
||||
let owner = input.desktop_session();
|
||||
let releases = Arc::new(AtomicUsize::new(0));
|
||||
let worker_release = Arc::new(AtomicBool::new(false));
|
||||
let (started, mut started_rx) = tokio::sync::mpsc::unbounded_channel();
|
||||
let task = tokio::spawn({
|
||||
let host = host.clone();
|
||||
let owner = owner.clone();
|
||||
let releases = releases.clone();
|
||||
let worker_release = worker_release.clone();
|
||||
async move {
|
||||
host.maintain_with(owner,
|
||||
|| Ok(()),
|
||||
move || IdleGuard(Some(Inhibitor::Fake(DropSignal(releases.clone())))),
|
||||
move |screen, cancel| {
|
||||
let _ = started.send(());
|
||||
while !worker_release.load(Ordering::Acquire) && !cancel.load(Ordering::Acquire) {
|
||||
std::thread::sleep(Duration::from_millis(1));
|
||||
}
|
||||
if cancel.load(Ordering::Acquire) { return Err(PortalError { code: 13 }); }
|
||||
Ok(screen)
|
||||
}).await
|
||||
}
|
||||
});
|
||||
started_rx.recv().await.unwrap();
|
||||
lock.send(Some(true)).unwrap();
|
||||
tokio::time::sleep(Duration::from_millis(50)).await;
|
||||
assert_eq!(releases.load(Ordering::Relaxed), 0, "lock released a compositor-backed attempt");
|
||||
worker_release.store(true, Ordering::Release);
|
||||
let deadline = tokio::time::Instant::now() + Duration::from_secs(2);
|
||||
while host.snapshot().waiting {
|
||||
assert!(tokio::time::Instant::now() < deadline, "locked attempt did not publish");
|
||||
tokio::task::yield_now().await;
|
||||
}
|
||||
task.abort();
|
||||
let _ = task.await;
|
||||
}
|
||||
#[tokio::test]
|
||||
async fn lock_transition_cancels_blocked_attempt_and_releases_inhibitor() {
|
||||
let (lock, locked) = watch::channel(Some(false));
|
||||
|
||||
@@ -12,7 +12,7 @@ mod record;
|
||||
mod tool;
|
||||
|
||||
pub use mode::Mode;
|
||||
use std::sync::{atomic::{AtomicBool, Ordering}, Mutex};
|
||||
use std::sync::{atomic::{AtomicBool, AtomicU64, Ordering}, Mutex};
|
||||
|
||||
struct Active { mode: Mode, record: Option<record::Record> }
|
||||
struct State { sessions: usize, active: Option<Active> }
|
||||
@@ -25,6 +25,9 @@ static POINTER: Mutex<Option<[f64; 4]>> = Mutex::new(None);
|
||||
/// ends. An auto-enable never overrides it, including an RPC that arrives after the connection
|
||||
/// opens but before `session_started` bumps the counter.
|
||||
static VIEWER_OVERRIDE: AtomicBool = AtomicBool::new(false);
|
||||
/// Bumped when a new first desktop session spawns its auto-enable thread. A reconnect that beats
|
||||
/// the 500 ms poll would otherwise leave the old waiter running for up to five minutes.
|
||||
static AUTO_GENERATION: AtomicU64 = AtomicU64::new(0);
|
||||
/// iOS viewers encode "screen off" as `enable=0, type=3`, and Windows viewers carry every request
|
||||
/// in `type` with `enable=0`; see `protocol::Request::normalize_ios_screen_off` and
|
||||
/// `protocol::Request::normalize_windows`.
|
||||
@@ -182,10 +185,42 @@ fn auto_set(mode: Mode) -> Result<bool, String> {
|
||||
if result.is_err() { if let Err(e) = leave(&mut state) { log::warn!("Privacy rollback failed: {e}"); } }
|
||||
result.map(|_| true)
|
||||
}
|
||||
/// The watch is authoritative while it has a value. A None (the logind monitor lost the session)
|
||||
/// must not fail open: ask logind directly before covering a possibly locked desktop.
|
||||
fn currently_locked() -> bool {
|
||||
let locked = crate::session_lock::watch_locked();
|
||||
let state = *locked.borrow();
|
||||
match state {
|
||||
Some(state) => state,
|
||||
None => crate::session_lock::locked_now() == Some(true),
|
||||
}
|
||||
}
|
||||
/// The capture session and the viewer's CONTROL state need a moment after the peer connects;
|
||||
/// retry while the portal session is still missing, and let the viewer's RPC 7 win if it arrives.
|
||||
fn auto_enable(mode: Mode) {
|
||||
fn auto_enable(mode: Mode, generation: u64) {
|
||||
// A locked desktop is already covered. Switching the share to the virtual output would hide
|
||||
// the lock screen the viewer needs to unlock, so wait for the local unlock first. Bounded:
|
||||
// a viewer that never unlocks, or leaves, must not hold this thread forever.
|
||||
let current = || AUTO_GENERATION.load(Ordering::Acquire) == generation;
|
||||
let deadline = std::time::Instant::now() + std::time::Duration::from_secs(300);
|
||||
while currently_locked() {
|
||||
if !current() { return; }
|
||||
if VIEWER_OVERRIDE.load(Ordering::Relaxed) {
|
||||
log::info!("Privacy auto: skipped, the viewer already chose a mode");
|
||||
return;
|
||||
}
|
||||
if STATE.try_lock().is_ok_and(|state| state.sessions == 0) {
|
||||
log::info!("Privacy auto: skipped, the desktop session ended");
|
||||
return;
|
||||
}
|
||||
if std::time::Instant::now() >= deadline {
|
||||
log::info!("Privacy auto: desktop stayed locked; not covering it");
|
||||
return;
|
||||
}
|
||||
std::thread::sleep(std::time::Duration::from_millis(500));
|
||||
}
|
||||
for attempt in 1..=5 {
|
||||
if !current() { return; }
|
||||
if VIEWER_OVERRIDE.load(Ordering::Relaxed) {
|
||||
log::info!("Privacy auto: skipped, the viewer already chose a mode");
|
||||
return;
|
||||
@@ -215,9 +250,10 @@ pub fn session_started() {
|
||||
let first = STATE.lock().ok().is_some_and(|mut s| { s.sessions += 1; s.sessions == 1 });
|
||||
let Some(mode) = auto else { return };
|
||||
if !first { return; }
|
||||
let generation = AUTO_GENERATION.fetch_add(1, Ordering::AcqRel) + 1;
|
||||
std::thread::spawn(move || {
|
||||
std::thread::sleep(std::time::Duration::from_millis(1500));
|
||||
auto_enable(mode);
|
||||
auto_enable(mode, generation);
|
||||
});
|
||||
}
|
||||
pub fn session_ended() {
|
||||
|
||||
+74
-19
@@ -11,11 +11,15 @@
|
||||
//! (`loginctl unlock-session`, allowed for the session owner), which avoids remote keystrokes
|
||||
//! and gives an exact wrong-password result. The password is never logged or stored.
|
||||
|
||||
use std::process::Command;
|
||||
use std::process::{Command, Stdio};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use std::sync::OnceLock;
|
||||
use std::time::Duration;
|
||||
use tokio::sync::watch;
|
||||
|
||||
mod logind;
|
||||
|
||||
/// Official UnlockResult cases (LockScreenManager).
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum UnlockResult { Success, WrongPassword, NoLoggedInUser, NoPermission, Failed }
|
||||
@@ -29,10 +33,44 @@ extern "C" {
|
||||
fn uu_pam_check(service: *const libc::c_char, user: *const libc::c_char, password: *const libc::c_char) -> libc::c_int;
|
||||
}
|
||||
|
||||
// Resolve once: execvp's unsuccessful PATH candidates are also recorded by auditd.
|
||||
fn loginctl_path() -> Option<&'static Path> {
|
||||
static PATH: OnceLock<Option<PathBuf>> = OnceLock::new();
|
||||
PATH.get_or_init(|| {
|
||||
std::env::var_os("PATH").into_iter().flat_map(|p| std::env::split_paths(&p).collect::<Vec<_>>())
|
||||
.map(|dir| dir.join("loginctl"))
|
||||
.find(|path| path.is_file() && std::ffi::CString::new(path.as_os_str().as_encoded_bytes())
|
||||
.map(|p| unsafe { libc::access(p.as_ptr(), libc::X_OK) == 0 }).unwrap_or(false))
|
||||
.and_then(|path| std::fs::canonicalize(path).ok())
|
||||
}).as_deref()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
static COMMAND_STARTS: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);
|
||||
|
||||
fn bounded_command(path: &Path, args: &[&str], timeout: Duration) -> Option<String> {
|
||||
use std::io::Read;
|
||||
#[cfg(test)]
|
||||
COMMAND_STARTS.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
|
||||
let mut child = Command::new(path).args(args).stdin(Stdio::null()).stdout(Stdio::piped())
|
||||
.stderr(Stdio::null()).spawn().ok()?;
|
||||
let deadline = std::time::Instant::now() + timeout;
|
||||
loop {
|
||||
match child.try_wait() {
|
||||
Ok(Some(status)) => {
|
||||
if !status.success() { return None; }
|
||||
let mut text = String::new();
|
||||
child.stdout.take()?.take(4096).read_to_string(&mut text).ok()?;
|
||||
return Some(text.trim().to_owned());
|
||||
}
|
||||
Ok(None) if std::time::Instant::now() < deadline => std::thread::sleep(Duration::from_millis(10)),
|
||||
_ => { let _ = child.kill(); let _ = child.wait(); return None; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn loginctl(args: &[&str]) -> Option<String> {
|
||||
let out = Command::new("loginctl").args(args).output().ok()?;
|
||||
if !out.status.success() { return None; }
|
||||
Some(String::from_utf8_lossy(&out.stdout).trim().to_string()).filter(|s| !s.is_empty())
|
||||
bounded_command(loginctl_path()?, args, Duration::from_secs(3)).filter(|s| !s.is_empty())
|
||||
}
|
||||
|
||||
/// The logind session that owns this user's graphical display.
|
||||
@@ -44,7 +82,7 @@ fn display_session() -> Option<String> {
|
||||
pub fn locked_now() -> Option<bool> { display_session().as_deref().and_then(session_locked) }
|
||||
|
||||
fn session_locked(session: &str) -> Option<bool> {
|
||||
loginctl(&["show-session", session, "-p", "LockedHint", "--value"]).map(|v| v == "yes")
|
||||
loginctl(&["show-session", session, "-p", "LockedHint", "--value"]).and_then(|v| match v.as_str() { "yes" => Some(true), "no" => Some(false), _ => None })
|
||||
}
|
||||
|
||||
fn user_name() -> Option<String> {
|
||||
@@ -78,30 +116,28 @@ pub fn supported() -> bool {
|
||||
*SUPPORTED.get_or_init(|| pam_available() && display_session().is_some())
|
||||
}
|
||||
|
||||
/// Current lock state (None = unknown), refreshed every second by one background thread.
|
||||
/// Current lock state (None = unknown), shared by all desktop connections.
|
||||
pub fn watch_locked() -> watch::Receiver<Option<bool>> {
|
||||
static STATE: OnceLock<watch::Sender<Option<bool>>> = OnceLock::new();
|
||||
STATE.get_or_init(|| {
|
||||
let (tx, _) = watch::channel(None);
|
||||
let sender = tx.clone();
|
||||
std::thread::Builder::new().name("uu-lock-state".into()).spawn(move || {
|
||||
let mut session = None;
|
||||
loop {
|
||||
if session.is_none() { session = display_session(); }
|
||||
let locked = session.as_deref().and_then(session_locked);
|
||||
if locked.is_none() { session = None; } // session ended or changed: look it up again
|
||||
sender.send_if_modified(|current| if *current != locked {
|
||||
log::info!("Desktop lock state: {}", match locked { Some(true) => "locked", Some(false) => "unlocked", None => "unknown" });
|
||||
if locked == Some(true) { log::info!("Desktop is locked; capture continues while the compositor supplies frames"); }
|
||||
*current = locked; true
|
||||
} else { false });
|
||||
std::thread::sleep(Duration::from_secs(1));
|
||||
}
|
||||
tokio::runtime::Builder::new_current_thread().enable_all().build()
|
||||
.expect("lock monitor runtime").block_on(logind::monitor(sender));
|
||||
}).expect("spawn lock state thread");
|
||||
tx
|
||||
}).subscribe()
|
||||
}
|
||||
|
||||
fn publish_lock_state(sender: &watch::Sender<Option<bool>>, locked: Option<bool>) {
|
||||
sender.send_if_modified(|current| if *current != locked {
|
||||
log::info!("Desktop lock state: {}", match locked { Some(true) => "locked", Some(false) => "unlocked", None => "unknown" });
|
||||
if locked == Some(true) { log::info!("Desktop is locked; capture continues while the compositor supplies frames"); }
|
||||
*current = locked; true
|
||||
} else { false });
|
||||
}
|
||||
|
||||
/// Verifies the session user's password and unlocks the display session. Blocking (PAM may
|
||||
/// delay a failure by seconds); call from spawn_blocking. Consumes and wipes the password.
|
||||
pub fn unlock(password: String) -> UnlockResult {
|
||||
@@ -117,7 +153,7 @@ fn unlock_with(password: &str) -> UnlockResult {
|
||||
let Some(user) = user_name() else { return UnlockResult::NoLoggedInUser };
|
||||
if password.is_empty() || password.contains('\0') { return UnlockResult::WrongPassword; }
|
||||
match pam_check(&user, password) { 0 => {}, 1 => return UnlockResult::WrongPassword, _ => return UnlockResult::Failed }
|
||||
if Command::new("loginctl").args(["unlock-session", &session]).status().map(|s| !s.success()).unwrap_or(true) {
|
||||
if loginctl_path().and_then(|path| bounded_command(path, &["unlock-session", &session], Duration::from_secs(3))).is_none() {
|
||||
return UnlockResult::NoPermission;
|
||||
}
|
||||
if let Err(error) = crate::capture::keep_display_awake() {
|
||||
@@ -204,6 +240,25 @@ pub fn password_from_args(args: &[u8]) -> Option<String> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
#[test]
|
||||
fn unknown_state_is_preserved_and_repeated_states_do_not_notify() {
|
||||
let (tx, mut rx) = watch::channel(Some(true));
|
||||
publish_lock_state(&tx, None);
|
||||
assert_eq!(*rx.borrow_and_update(), None);
|
||||
publish_lock_state(&tx, None);
|
||||
assert!(!rx.has_changed().unwrap());
|
||||
publish_lock_state(&tx, Some(false));
|
||||
assert!(rx.has_changed().unwrap());
|
||||
assert_eq!(*rx.borrow_and_update(), Some(false));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hung_fallback_is_killed_and_reaped() {
|
||||
let start = std::time::Instant::now();
|
||||
assert_eq!(bounded_command(Path::new("/bin/sleep"), &["10"], Duration::from_millis(30)), None);
|
||||
assert!(start.elapsed() < Duration::from_secs(2));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn password_comes_from_the_official_key_field() {
|
||||
assert_eq!(password_from_args(br#"{"key":"p@ss word"}"#).as_deref(), Some("p@ss word"));
|
||||
|
||||
@@ -0,0 +1,208 @@
|
||||
//! logind signals replace per-second process spawning; loginctl is a bounded fallback.
|
||||
use super::{publish_lock_state, Duration};
|
||||
use futures_util::StreamExt;
|
||||
use tokio::sync::watch;
|
||||
use zbus::{Connection, MatchRule, MessageStream, Proxy, proxy::CacheProperties};
|
||||
|
||||
const SERVICE: &str = "org.freedesktop.login1";
|
||||
const ROOT: &str = "/org/freedesktop/login1";
|
||||
const CALL_TIMEOUT: Duration = Duration::from_secs(5);
|
||||
const RETRY: Duration = Duration::from_secs(30);
|
||||
|
||||
async fn locked(connection: &Connection) -> zbus::Result<Option<bool>> {
|
||||
let path = format!("{ROOT}/user/_{}", unsafe { libc::getuid() });
|
||||
let user = zbus::proxy::Builder::<Proxy<'_>>::new(connection).destination(SERVICE)?
|
||||
.path(path)?.interface("org.freedesktop.login1.User")?
|
||||
.cache_properties(CacheProperties::No).build().await?;
|
||||
// No cached property reads: signals, including invalidations, trigger a fresh snapshot.
|
||||
let display: (String, zbus::zvariant::OwnedObjectPath) = user.get_property("Display").await?;
|
||||
if display.0.is_empty() { return Ok(None); }
|
||||
let session = zbus::proxy::Builder::<Proxy<'_>>::new(connection).destination(SERVICE)?
|
||||
.path(display.1)?.interface("org.freedesktop.login1.Session")?
|
||||
.cache_properties(CacheProperties::No).build().await?;
|
||||
session.get_property("LockedHint").await.map(Some)
|
||||
}
|
||||
|
||||
async fn snapshot(connection: &Connection) -> zbus::Result<Option<bool>> {
|
||||
tokio::time::timeout(CALL_TIMEOUT, locked(connection)).await
|
||||
.map_err(|_| zbus::Error::Failure("lock query timed out".into()))?
|
||||
}
|
||||
|
||||
async fn monitor_connection(connection: &Connection, sender: &watch::Sender<Option<bool>>) -> zbus::Result<()> {
|
||||
// Subscribe before reading: any change during the first snapshot stays queued.
|
||||
// Watch all logind signals so User.Display, SessionNew/Removed and invalidated
|
||||
// properties also re-resolve the graphical session instead of trusting a stale path.
|
||||
let rule = MatchRule::builder().msg_type(zbus::message::Type::Signal)
|
||||
.sender(SERVICE)?.path_namespace(ROOT)?.build();
|
||||
let mut signals = tokio::time::timeout(CALL_TIMEOUT, MessageStream::for_match_rule(rule, connection, Some(64))).await
|
||||
.map_err(|_| zbus::Error::Failure("lock subscription timed out".into()))??;
|
||||
publish_lock_state(sender, snapshot(connection).await?);
|
||||
let mut reconcile = tokio::time::interval(RETRY);
|
||||
reconcile.tick().await;
|
||||
loop {
|
||||
tokio::select! {
|
||||
event = signals.next() => { event.ok_or_else(|| zbus::Error::Failure("system bus closed".into()))??; },
|
||||
_ = reconcile.tick() => {},
|
||||
}
|
||||
publish_lock_state(sender, snapshot(connection).await?);
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) async fn monitor(sender: watch::Sender<Option<bool>>) {
|
||||
let mut degraded = false;
|
||||
loop {
|
||||
let result = tokio::time::timeout(CALL_TIMEOUT, async { zbus::connection::Builder::system()?.method_timeout(CALL_TIMEOUT).build().await }).await;
|
||||
if let Ok(Ok(connection)) = result {
|
||||
if !degraded { log::debug!("Desktop lock monitor: logind D-Bus"); }
|
||||
// Recovery is announced only after a valid snapshot, via the state channel.
|
||||
let _ = monitor_connection(&connection, &sender).await;
|
||||
}
|
||||
publish_lock_state(&sender, None);
|
||||
if !degraded { log::warn!("Desktop lock monitor unavailable; retrying D-Bus with bounded loginctl fallback every 30s"); }
|
||||
degraded = true;
|
||||
let fallback = tokio::task::spawn_blocking(super::locked_now).await.ok().flatten();
|
||||
publish_lock_state(&sender, fallback);
|
||||
tokio::time::sleep(RETRY).await;
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::sync::{Arc, Mutex, atomic::{AtomicBool, Ordering}};
|
||||
use zbus::zvariant::{OwnedObjectPath, Value};
|
||||
|
||||
struct User(Arc<Mutex<String>>);
|
||||
#[zbus::interface(name = "org.freedesktop.login1.User")]
|
||||
impl User {
|
||||
#[zbus(property)]
|
||||
fn display(&self) -> (String, OwnedObjectPath) {
|
||||
let id = self.0.lock().unwrap().clone();
|
||||
let path = if id.is_empty() { "/".into() } else { format!("{ROOT}/session/{id}") };
|
||||
(id, OwnedObjectPath::try_from(path).unwrap())
|
||||
}
|
||||
}
|
||||
struct Session { locked: Arc<AtomicBool>, valid: Arc<AtomicBool> }
|
||||
#[zbus::interface(name = "org.freedesktop.login1.Session")]
|
||||
impl Session {
|
||||
#[zbus(property)]
|
||||
fn locked_hint(&self) -> zbus::fdo::Result<bool> {
|
||||
if !self.valid.load(Ordering::SeqCst) { return Err(zbus::fdo::Error::Failed("unavailable".into())); }
|
||||
Ok(self.locked.load(Ordering::SeqCst))
|
||||
}
|
||||
}
|
||||
|
||||
async fn expect(rx: &mut watch::Receiver<Option<bool>>, value: Option<bool>) {
|
||||
tokio::time::timeout(Duration::from_secs(3), async {
|
||||
loop {
|
||||
let current = *rx.borrow_and_update();
|
||||
if current == value { return; }
|
||||
rx.changed().await.unwrap();
|
||||
}
|
||||
}).await.expect("lock state update");
|
||||
}
|
||||
|
||||
async fn invalidated(server: &Connection, path: &str, interface: &str, property: &str) {
|
||||
// An invalidation has no replacement value: the client must re-read it.
|
||||
let changed = std::collections::HashMap::<&str, Value<'_>>::new();
|
||||
server.emit_signal(None::<&str>, path, "org.freedesktop.DBus.Properties", "PropertiesChanged",
|
||||
&(interface, changed, vec![property])).await.unwrap();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[ignore = "isolated D-Bus integration; requires dbus-daemon, never changes the real desktop"]
|
||||
async fn private_bus_tracks_initial_state_invalidation_session_change_and_failure() {
|
||||
use tokio::io::{AsyncBufReadExt, BufReader};
|
||||
let mut daemon = tokio::process::Command::new("dbus-daemon")
|
||||
.args(["--session", "--nofork", "--print-address=1"])
|
||||
.stdout(std::process::Stdio::piped()).stderr(std::process::Stdio::null())
|
||||
.kill_on_drop(true).spawn().unwrap();
|
||||
let mut address = String::new();
|
||||
tokio::time::timeout(Duration::from_secs(3), BufReader::new(daemon.stdout.take().unwrap()).read_line(&mut address)).await.unwrap().unwrap();
|
||||
let address = address.trim();
|
||||
let display = Arc::new(Mutex::new(String::new()));
|
||||
let locked = Arc::new(AtomicBool::new(true));
|
||||
let valid = Arc::new(AtomicBool::new(true));
|
||||
let user_path = format!("{ROOT}/user/_{}", unsafe { libc::getuid() });
|
||||
let server = zbus::connection::Builder::address(address).unwrap().name(SERVICE).unwrap()
|
||||
.serve_at(user_path.clone(), User(display.clone())).unwrap()
|
||||
.serve_at(format!("{ROOT}/session/a"), Session { locked: locked.clone(), valid: valid.clone() }).unwrap()
|
||||
.serve_at(format!("{ROOT}/session/b"), Session { locked: Arc::new(AtomicBool::new(true)), valid: valid.clone() }).unwrap()
|
||||
.build().await.unwrap();
|
||||
let client = zbus::connection::Builder::address(address).unwrap().build().await.unwrap();
|
||||
let (tx, mut rx) = watch::channel(Some(false));
|
||||
let monitor = tokio::spawn(async move {
|
||||
let result = monitor_connection(&client, &tx).await;
|
||||
publish_lock_state(&tx, None);
|
||||
result
|
||||
});
|
||||
expect(&mut rx, None).await;
|
||||
assert!(!monitor.is_finished(), "no graphical session must keep the D-Bus subscription alive");
|
||||
*display.lock().unwrap() = "a".into();
|
||||
invalidated(&server, &user_path, "org.freedesktop.login1.User", "Display").await;
|
||||
expect(&mut rx, Some(true)).await; // login is observed without waiting for the retry timer
|
||||
locked.store(false, Ordering::SeqCst);
|
||||
invalidated(&server, &format!("{ROOT}/session/a"), "org.freedesktop.login1.Session", "LockedHint").await;
|
||||
expect(&mut rx, Some(false)).await;
|
||||
*display.lock().unwrap() = "b".into();
|
||||
invalidated(&server, &user_path, "org.freedesktop.login1.User", "Display").await;
|
||||
expect(&mut rx, Some(true)).await;
|
||||
display.lock().unwrap().clear();
|
||||
invalidated(&server, &user_path, "org.freedesktop.login1.User", "Display").await;
|
||||
expect(&mut rx, None).await;
|
||||
assert!(!monitor.is_finished(), "logout must keep the D-Bus subscription alive");
|
||||
*display.lock().unwrap() = "b".into();
|
||||
invalidated(&server, &user_path, "org.freedesktop.login1.User", "Display").await;
|
||||
expect(&mut rx, Some(true)).await;
|
||||
valid.store(false, Ordering::SeqCst);
|
||||
invalidated(&server, &format!("{ROOT}/session/b"), "org.freedesktop.login1.Session", "LockedHint").await;
|
||||
expect(&mut rx, None).await; // failure must not become unlocked
|
||||
assert!(monitor.await.unwrap().is_err());
|
||||
// A fresh connection must recover after a service/property failure.
|
||||
valid.store(true, Ordering::SeqCst);
|
||||
let client = zbus::connection::Builder::address(address).unwrap().build().await.unwrap();
|
||||
let close = client.clone();
|
||||
let (tx, mut rx) = watch::channel(None);
|
||||
let monitor = tokio::spawn(async move {
|
||||
let result = monitor_connection(&client, &tx).await;
|
||||
publish_lock_state(&tx, None);
|
||||
result
|
||||
});
|
||||
expect(&mut rx, Some(true)).await;
|
||||
close.close().await.unwrap();
|
||||
expect(&mut rx, None).await;
|
||||
assert!(monitor.await.unwrap().is_err());
|
||||
daemon.kill().await.unwrap();
|
||||
daemon.wait().await.unwrap();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[ignore = "manual acceptance: observes a real lock/unlock for up to three minutes"]
|
||||
async fn live_lock_unlock_signals() {
|
||||
let before = super::super::COMMAND_STARTS.load(Ordering::SeqCst);
|
||||
let mut rx = super::super::watch_locked();
|
||||
let start = std::time::Instant::now();
|
||||
tokio::time::timeout(Duration::from_secs(180), async {
|
||||
let mut saw_lock = false;
|
||||
loop {
|
||||
let state = *rx.borrow_and_update();
|
||||
println!("live lock state: {state:?}; elapsed_ms={}", start.elapsed().as_millis());
|
||||
if state == Some(true) { saw_lock = true; }
|
||||
if saw_lock && state == Some(false) { break; }
|
||||
rx.changed().await.unwrap();
|
||||
}
|
||||
}).await.expect("please lock and unlock the desktop during this probe");
|
||||
let started = super::super::COMMAND_STARTS.load(Ordering::SeqCst) - before;
|
||||
println!("lock monitor command starts: {started}");
|
||||
assert_eq!(started, 0, "healthy D-Bus monitoring should not spawn loginctl");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[ignore = "read-only live logind probe; requires an active graphical logind session"]
|
||||
async fn live_logind_snapshot_matches_loginctl_without_changing_lock_state() {
|
||||
let connection = Connection::system().await.unwrap();
|
||||
let dbus = snapshot(&connection).await.unwrap();
|
||||
let command = tokio::task::spawn_blocking(super::super::locked_now).await.unwrap();
|
||||
assert_eq!(dbus, command);
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -67,7 +67,9 @@ pub fn load_font() -> Option<FontVec> {
|
||||
let (path, index) = match std::env::var("UU_VIEWER_FONT") {
|
||||
Ok(p) if !p.is_empty() => (p, 0),
|
||||
_ => {
|
||||
let out = std::process::Command::new("fc-match").args(["-f", "%{file}\t%{index}", "sans-serif:lang=zh-cn"]).output().ok()?;
|
||||
// Request U+63A7 (控, from 控制中心) to prefer a CJK-capable font;
|
||||
// the HUD uses a single font without per-glyph fallback.
|
||||
let out = std::process::Command::new("fc-match").args(["-f", "%{file}\t%{index}", "sans-serif:lang=zh-cn:charset=63a7"]).output().ok()?;
|
||||
let line = String::from_utf8(out.stdout).ok()?;
|
||||
let (file, index) = line.split_once('\t').unwrap_or((line.as_str(), "0"));
|
||||
// fontconfig puts the variable-font named instance in the upper 16 bits; the face is below.
|
||||
|
||||
+1
-1
@@ -712,7 +712,7 @@ impl WebRtcSession {
|
||||
}
|
||||
let live = state.screen.init_error.is_none()
|
||||
&& (cfg!(test) || state.screen.portal.as_ref().is_some_and(|portal| portal.is_alive()))
|
||||
&& *manager.lock_state().borrow() == Some(false);
|
||||
&& manager.capture_allowed(*manager.lock_state().borrow());
|
||||
if live { break Some(state.screen); }
|
||||
tokio::time::sleep(std::time::Duration::from_millis(100)).await;
|
||||
if channel.upgrade().is_none_or(|channel| channel.ready_state() != webrtc::data_channel::data_channel_state::RTCDataChannelState::Open) { return; }
|
||||
|
||||
+18
-1
@@ -83,10 +83,18 @@ pub fn lan_info() -> Option<(String, String, String)> {
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
pub fn lan_info() -> Option<(String, String, String)> { None }
|
||||
|
||||
/// Body of the helper registration request (same address as `inner_ip` and `ip`: this host has one LAN address).
|
||||
fn report_body(mac: &str, ip: &str, subnet_mask: &str) -> serde_json::Value {
|
||||
serde_json::json!({ "mac": mac, "inner_ip": ip, "ip": ip, "subnet_mask": subnet_mask })
|
||||
}
|
||||
|
||||
/// Report this host's LAN identity like the official host after sign-in.
|
||||
/// The server rejects the report (HTTP 422, code 1001) unless `inner_ip` is present; the official macOS
|
||||
/// client sends `inner_ip`, `ip`, `mac` and `subnet_mask`. Verified live: with `inner_ip` the helper is
|
||||
/// accepted (HTTP 200) and the cloud forwards `wake_on_lan` pushes to this host.
|
||||
pub async fn report(auth: &crate::auth::UUAuthClient) {
|
||||
let Some((mac, ip, subnet_mask)) = lan_info() else { log::warn!("WOL helper: no IPv4 default-route interface"); return; };
|
||||
let body = serde_json::json!({ "mac": mac, "ip": ip, "subnet_mask": subnet_mask });
|
||||
let body = report_body(&mac, &ip, &subnet_mask);
|
||||
match auth.post_json_url("https://api-ipv4.nrd.nie.163.com", "/api/v1/device/wake_on_lan/info", &body).await {
|
||||
Ok((status, value)) => log::info!("WOL helper: LAN info reported: status={status} code={:?} turn_on_wol={:?}",
|
||||
value.get("code").and_then(serde_json::Value::as_i64),
|
||||
@@ -108,6 +116,15 @@ mod tests {
|
||||
assert_eq!(&packet[..6], &[0xff; 6]);
|
||||
assert_eq!(&packet[96..], &[1, 2, 3, 4, 5, 6]);
|
||||
}
|
||||
#[test]
|
||||
fn report_body_has_inner_ip() {
|
||||
let body = report_body("aa:bb:cc:dd:ee:01", "192.168.2.29", "255.255.255.0");
|
||||
assert_eq!(body["inner_ip"], "192.168.2.29");
|
||||
assert_eq!(body["ip"], "192.168.2.29");
|
||||
assert_eq!(body["mac"], "aa:bb:cc:dd:ee:01");
|
||||
assert_eq!(body["subnet_mask"], "255.255.255.0");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn directed_broadcast() {
|
||||
assert_eq!(subnet_broadcast("192.168.2.29", "255.255.255.0"), Some(Ipv4Addr::new(192, 168, 2, 255)));
|
||||
|
||||
Reference in new issue
Block a user