Skip to content

Commit 07cbc6c

Browse files
f-trycuaclaude
andauthored
fix(cua-driver): pass CUA_DRIVER_RS_ENABLE_WAYLAND through to embedded hosts (trycua#4877)
The embedded host builds the daemon environment from an allowlist, and CUA_DRIVER_RS_ENABLE_WAYLAND was not on it. A host such as an Electron app could never turn on the native Wayland backend: the opt-in was dropped silently. Allow it, and test inheritance, an explicit host opt-in, and an explicit opt-out winning over an inherited opt-in. Ported from T3 Code's Linux patch to Cua Driver 0.34.0 (pingdotgg/t3code#16975, MIT, Copyright (c) 2026 T3 Tools Inc.); credited in THIRD_PARTY_NOTICES.md. Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 97ef165 commit 07cbc6c

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

‎libs/cua-driver/rust/THIRD_PARTY_NOTICES.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ the items listed.
1818
| [yabai](https://github.com/koekeishiya/yabai) | Copyright (c) 2019 Åsmund Vikane | `crates/platform-macos/src/input/skylight.rs` (`activate_without_raise`) | The focus-without-raise SkyLight event-record sequence |
1919
| [QuickJS-ng](https://github.com/quickjs-ng/quickjs) | Copyright (c) 2017-2026 Fabrice Bellard; (c) 2017-2024 Charlie Gordon; (c) 2023-2026 Ben Noordhuis; (c) 2023-2026 Saúl Ibarra Corretgé | `crates/cua-driver-core/src/script_tool/` (compiled in through rquickjs-sys) | The JavaScript engine behind the experimental `run_script` tool |
2020
| [rquickjs](https://github.com/DelSkayn/rquickjs) | Copyright (c) 2020 Mees Delzenne; (c) 2025 Rquickjs Contributors | `crates/cua-driver-core/src/script_tool/` | Rust bindings to QuickJS-ng |
21+
| [T3 Code](https://github.com/pingdotgg/t3code) | Copyright (c) 2026 T3 Tools Inc. | `crates/cua-driver-sdk/src/embedded.rs` (`allowed_environment_name` and its test) | Linux fixes ported from T3 Code's patch to Cua Driver 0.34.0 ([pingdotgg/t3code#16975](https://github.com/pingdotgg/t3code/pull/16975), `patches/cua-driver-linux/0.34.0.patch`): the `CUA_DRIVER_RS_ENABLE_WAYLAND` embedded-host pass-through |
2122

2223
## MIT License
2324

‎libs/cua-driver/rust/crates/cua-driver-sdk/src/embedded.rs‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,7 @@ pub(crate) fn allowed_environment_name(name: &str) -> bool {
860860
| "PROGRAMDATA"
861861
| "DISPLAY"
862862
| "WAYLAND_DISPLAY"
863+
| "CUA_DRIVER_RS_ENABLE_WAYLAND"
863864
| "XDG_RUNTIME_DIR"
864865
| "XDG_SESSION_TYPE"
865866
| "DBUS_SESSION_BUS_ADDRESS"
@@ -1306,6 +1307,41 @@ mod tests {
13061307
.any(|variable| variable.value == "forged-lock"));
13071308
}
13081309

1310+
#[test]
1311+
fn wayland_backend_opt_in_reaches_embedded_driver() {
1312+
let name = "CUA_DRIVER_RS_ENABLE_WAYLAND";
1313+
assert!(allowed_environment_name(name));
1314+
let inherited = [(name.to_owned(), "1".to_owned())];
1315+
let values = merge_safe_environment(inherited.clone(), &[]);
1316+
assert!(values
1317+
.iter()
1318+
.any(|variable| variable.name == name && variable.value == "1"));
1319+
1320+
// Hosts can opt in without changing their own process environment.
1321+
let enabled = EmbeddedEnvironmentVariable {
1322+
name: name.into(),
1323+
value: "1".into(),
1324+
};
1325+
let values = merge_safe_environment(std::iter::empty(), &[enabled]);
1326+
assert!(values
1327+
.iter()
1328+
.any(|variable| variable.name == name && variable.value == "1"));
1329+
1330+
// An explicit opt-out still wins over the inherited opt-in.
1331+
let disabled = EmbeddedEnvironmentVariable {
1332+
name: name.into(),
1333+
value: "0".into(),
1334+
};
1335+
let values = merge_safe_environment(inherited, &[disabled]);
1336+
assert!(values
1337+
.iter()
1338+
.any(|variable| variable.name == name && variable.value == "0"));
1339+
assert!(!allowed_environment_name("LD_PRELOAD"));
1340+
assert!(!allowed_environment_name(
1341+
"CUA_DRIVER_DANGEROUSLY_BYPASS_APPROVALS"
1342+
));
1343+
}
1344+
13091345
#[test]
13101346
fn interactive_linux_session_environment_is_inherited() {
13111347
let values = merge_safe_environment(

0 commit comments

Comments
 (0)