Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

fix(cua-spacesd): build on Windows again (geteuid is Unix-only) (#4462)

ddupont27e226144cb2
diff --git a/libs/cua-spacesd/crates/cua-spacesd-server/src/services/volume.rs b/libs/cua-spacesd/crates/cua-spacesd-server/src/services/volume.rs
index a07d74738b..99d29defc5 100644
--- a/libs/cua-spacesd/crates/cua-spacesd-server/src/services/volume.rs
+++ b/libs/cua-spacesd/crates/cua-spacesd-server/src/services/volume.rs
@@ -330,8 +330,7 @@ async fn clear_stale_mounts() {
tracing::warn!(path = %p, "clearing a stale volume mount left by a previous daemon");
let r = if cfg!(target_os = "linux") {
// Lazy: a dead FUSE/NFS mount may refuse a plain unmount.
- // SAFETY: geteuid never fails.
- let root = unsafe { libc::geteuid() } == 0;
+ let root = running_as_root();
if root {
run("umount", &["-l", &p]).await
} else {
@@ -806,6 +805,18 @@ pub async fn volume_ws(
})
}
+/// Whether this process runs as root (always false off Unix).
+#[cfg(unix)]
+fn running_as_root() -> bool {
+ // SAFETY: geteuid never fails.
+ unsafe { libc::geteuid() == 0 }
+}
+
+#[cfg(not(unix))]
+fn running_as_root() -> bool {
+ false
+}
+
#[cfg(test)]
mod tests {
use super::*;