From bb796ec6b9e7eb682c552d32fab8af748cb6c73c Mon Sep 17 00:00:00 2001 From: Warren Date: Mon, 22 Jun 2026 16:25:33 +0800 Subject: [PATCH] Fix smb-server xattr: add root_path field for absolute path storage --- data/auth.sqlite | Bin 73728 -> 73728 bytes vendor/smb-server/src/fs/local.rs | 24 ++++++++++++------------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/data/auth.sqlite b/data/auth.sqlite index 0c58056ee6bbab1d9c6bad6208a24c26ea35de87..ca8463d2ec5caa85d090d358ca747eba8b5061b6 100644 GIT binary patch delta 295 zcmZoTz|wGlWr8&0--$BLjDI&Kw97E+PCh85FquR44%_>yO&k;SH@}i)V+67r>n7+; z{wDW_>HXEsU*wn3PV z{wDW_>EY4MU*ws1h_Uc7BDL?hqLUR%zj|~W<>#Z7AE=d$&5!uH(xnoz|9=a z^K3Hv1)zk20ng@VcjTCv!?_<$W`6(@(dOR#@O7Lpqv2$S|C_)r{r{hzapU$c{EYwk Kc{d{2!T` plus a flag. pub struct LocalFsBackend { root: Arc, + root_path: PathBuf, // Store absolute path for xattr operations read_only: bool, } @@ -50,9 +51,11 @@ impl LocalFsBackend { /// Open `path` as the share root. Errors if the path does not exist or is /// not a directory. pub fn new(path: impl AsRef) -> io::Result { - let dir = Dir::open_ambient_dir(path, ambient_authority())?; + let p = path.as_ref().canonicalize()?; + let dir = Dir::open_ambient_dir(&p, ambient_authority())?; Ok(Self { root: Arc::new(dir), + root_path: p, read_only: false, }) } @@ -431,14 +434,12 @@ impl ShareBackend for LocalFsBackend { async fn get_xattr(&self, path: &SmbPath, name: &str) -> SmbResult> { let rel = to_rel_path(path); - let root = Arc::clone(&self.root); + let root_path = self.root_path.clone(); let xattr_name = name.to_string(); spawn_blocking(move || { - // Get absolute path: dereference Arc first - let full_path = (*root).as_std_path().join(&rel); + let full_path = root_path.join(&rel); - // Use xattr::get which returns Option> match xattr::get(&full_path, &xattr_name) { Ok(Some(data)) => Ok(data), Ok(None) => Err(SmbError::NotFound), @@ -455,12 +456,12 @@ impl ShareBackend for LocalFsBackend { } let rel = to_rel_path(path); - let root = Arc::clone(&self.root); + let root_path = self.root_path.clone(); let xattr_name = name.to_string(); let value = value.to_vec(); spawn_blocking(move || { - let full_path = (*root).as_std_path().join(&rel); + let full_path = root_path.join(&rel); xattr::set(&full_path, &xattr_name, &value) .map_err(|e| SmbError::Io(e.into())) }) @@ -474,11 +475,11 @@ impl ShareBackend for LocalFsBackend { } let rel = to_rel_path(path); - let root = Arc::clone(&self.root); + let root_path = self.root_path.clone(); let xattr_name = name.to_string(); spawn_blocking(move || { - let full_path = (*root).as_std_path().join(&rel); + let full_path = root_path.join(&rel); xattr::remove(&full_path, &xattr_name) .map_err(|e| SmbError::Io(e.into())) }) @@ -488,12 +489,11 @@ impl ShareBackend for LocalFsBackend { async fn list_xattrs(&self, path: &SmbPath) -> SmbResult> { let rel = to_rel_path(path); - let root = Arc::clone(&self.root); + let root_path = self.root_path.clone(); spawn_blocking(move || { - let full_path = (*root).as_std_path().join(&rel); + let full_path = root_path.join(&rel); - // xattr::list returns iterator of OsString let attrs: Vec = xattr::list(&full_path) .map_err(|e| SmbError::Io(e.into()))? .into_iter()