Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

94 changes: 0 additions & 94 deletions apps/app/src/lib/markdown-performance.ts

This file was deleted.

53 changes: 8 additions & 45 deletions apps/cli/src/desktop_node.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! App-private durable Node provisioning. This command is intentionally hidden from the public
//! CLI surface; the Electron main process is its only caller.
//! CLI surface; the native desktop host is its only caller.
use anyhow::{Context, Result, ensure};
use clap::{Args, Subcommand};
use semver::Version;
Expand Down Expand Up @@ -52,7 +52,7 @@ fn public_failure(error: anyhow::Error) -> anyhow::Error {

#[derive(Args)]
pub struct DesktopNode {
/// Absolute Electron profile directory trusted by the App.
/// Absolute desktop profile directory trusted by the App.
#[arg(long, value_parser = absolute_path)]
profile_dir: PathBuf,
/// Existing Node identity to preserve. Required for every mutation.
Expand Down Expand Up @@ -175,26 +175,6 @@ fn canonical_profile(path: &Path) -> Result<PathBuf> {
Ok(profile)
}

/// Runs before Chromium and preferences use the App-owned directory, without creating a Node.
pub(crate) fn prepare_profile(path: &Path) -> Result<()> {
ensure!(path.is_absolute(), "Desktop profile path must be absolute");
match fs::symlink_metadata(path) {
Ok(metadata) => ensure!(
metadata.is_dir() && !metadata.file_type().is_symlink(),
"Desktop profile must be a real directory"
),
Err(error) if error.kind() == io::ErrorKind::NotFound => fs::create_dir_all(path)?,
Err(error) => return Err(error.into()),
}
ensure!(
privatefs::owner_of(path)? == privatefs::current_account()?,
"Desktop profile belongs to another account"
);
privatefs::restrict_dir(path)?;
canonical_profile(path)?;
Ok(())
}

fn data_dir(profile: &Path) -> Result<PathBuf> {
let data = profile.join("node");
let canonical =
Expand Down Expand Up @@ -1312,38 +1292,21 @@ mod tests {
}

#[test]
fn profile_preparation_is_private_idempotent_and_creates_no_node() {
fn canonical_profile_rejects_a_non_private_directory() {
let root = temp("profile-permissions");
let profile = root.join("Desktop 数据");
fs::create_dir(&profile).unwrap();
fs::write(
profile.join("preferences.json"),
b"keep existing preferences",
)
.unwrap();
#[cfg(unix)]
{
use std::os::unix::fs::PermissionsExt as _;
fs::set_permissions(&profile, fs::Permissions::from_mode(0o755)).unwrap();
assert!(canonical_profile(&profile).is_err());
}
for _ in 0..2 {
prepare_profile(&profile).unwrap();
assert!(privatefs::is_private(&profile).unwrap());
assert_eq!(
fs::read(profile.join("preferences.json")).unwrap(),
b"keep existing preferences"
);
assert!(!profile.join("node").exists());
}
let fresh = root.join("fresh");
prepare_profile(&fresh).unwrap();
assert!(privatefs::is_private(&fresh).unwrap());
assert!(fs::read_dir(&fresh).unwrap().next().is_none());
let file = root.join("not-a-profile");
fs::write(&file, b"preserve").unwrap();
assert!(prepare_profile(&file).is_err());
assert_eq!(fs::read(file).unwrap(), b"preserve");
privatefs::restrict_dir(&profile).unwrap();
assert_eq!(
canonical_profile(&profile).unwrap(),
fs::canonicalize(&profile).unwrap()
);
fs::remove_dir_all(root).unwrap();
}

Expand Down
11 changes: 0 additions & 11 deletions apps/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,6 @@ enum Action {
/// Internal Desktop managed Node provisioning interface.
#[command(hide = true)]
DesktopNode(crate::desktop_node::DesktopNode),
/// Prepare only the Electron profile's current-user filesystem permissions.
#[command(hide = true)]
DesktopProfile {
#[arg(long)]
profile_dir: PathBuf,
},
/// Call a local tool with JSON arguments.
Tool {
/// Tool name.
Expand Down Expand Up @@ -881,11 +875,6 @@ async fn main() -> Result<()> {
Some(Action::Service(options)) => crate::service::run(options).await,
Some(Action::Update(options)) => crate::update::run(options).await,
Some(Action::DesktopNode(options)) => crate::desktop_node::run(options).await,
Some(Action::DesktopProfile { profile_dir }) => {
crate::desktop_node::prepare_profile(&profile_dir)?;
println!("{}", json!({"ok": true}));
Ok(())
}
}
}

Expand Down
1 change: 0 additions & 1 deletion apps/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ vibeface-protocol.workspace = true
vibeface-bridge.workspace = true
vibeface-control.workspace = true
vibeface-secure = { path = "../../crates/secure" }
vibeface-secure-ffi = { path = "../../crates/secure-ffi" }
vibeface-delivery = { path = "../../crates/delivery" }
zeroize = { version = "1", features = ["derive"] }

Expand Down
Loading