π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Preserve existing CLI home permissions and clarify missing keys
Manav Rathi00784b90b154
diff --git a/rust/apps/cli-next/src/home.rs b/rust/apps/cli-next/src/home.rsindex 59ea6ab107..a796188d33 100644--- a/rust/apps/cli-next/src/home.rs+++ b/rust/apps/cli-next/src/home.rs@@ -50,16 +50,13 @@ pub fn application_home() -> Result<PathBuf> {pub fn create(path: &Path) -> io::Result<()> {#[cfg(unix)]- use std::os::unix::fs::{DirBuilderExt, PermissionsExt};+ use std::os::unix::fs::DirBuilderExt;let mut builder = fs::DirBuilder::new();builder.recursive(true);#[cfg(unix)]builder.mode(0o700);- builder.create(path)?;- #[cfg(unix)]- fs::set_permissions(path, fs::Permissions::from_mode(0o700))?;- Ok(())+ builder.create(path)}pub fn lock_account(id: Uuid, create: bool) -> Result<LockedAccountHome> {diff --git a/rust/apps/cli-next/src/vault.rs b/rust/apps/cli-next/src/vault.rsindex 2edac84f27..faeb22b3d2 100644--- a/rust/apps/cli-next/src/vault.rs+++ b/rust/apps/cli-next/src/vault.rs@@ -300,6 +300,11 @@ fn load_key(fn keyring_error(error: keyring::Error, exists: bool) -> anyhow::Error {let reason = match error {+ keyring::Error::NoEntry if exists => {+ return anyhow::anyhow!(+ "no saved vault key for this CLI home; if you moved the directory, restore its previous location or supply the original ENTE_CLI_VAULT_KEY"+ );+ }keyring::Error::NoEntry => "the vault key is missing".to_owned(),keyring::Error::NoStorageAccess(error) => {format!("access to system secret storage was denied: {error}")diff --git a/rust/apps/cli-next/tests/cli/main.rs b/rust/apps/cli-next/tests/cli/main.rsindex 1366c20c1b..53a2bdeb58 100644--- a/rust/apps/cli-next/tests/cli/main.rs+++ b/rust/apps/cli-next/tests/cli/main.rs@@ -332,7 +332,7 @@ fn deleted_collections_are_filtered_before_decryption() {#[cfg(unix)]#[test]-fn reading_an_existing_vault_does_not_change_its_directory() {+fn accessing_an_existing_vault_preserves_directory_permissions() {use std::os::unix::fs::PermissionsExt;let home = TestHome::new();@@ -344,6 +344,13 @@ fn reading_an_existing_vault_does_not_change_its_directory() {assert_eq!(success(result).stdout, b"--8=\n");assert_eq!(mode, 0o500, "read changed the CLI home permissions");assert_eq!(fs::read_dir(home.dir.path()).unwrap().count(), 1);++ fs::set_permissions(home.dir.path(), fs::Permissions::from_mode(0o755)).unwrap();+ success(home.run(&["account", "switch", "fixture"]));+ assert_eq!(+ fs::metadata(home.dir.path()).unwrap().permissions().mode() & 0o777,+ 0o755+ );}#[test]