diff --git a/angrr/src/utils.rs b/angrr/src/utils.rs index db1a0b2..e1cd68c 100644 --- a/angrr/src/utils.rs +++ b/angrr/src/utils.rs @@ -15,35 +15,23 @@ pub fn validate_store_path, P2: AsRef>( store: P1, target: P2, ) -> Option { + let store = store.as_ref(); let target = target.as_ref(); - match canonicalize_to_store(store, target) { - Ok(path) => Some(path), + match fs::canonicalize(target) { + Ok(path) => { + if path.starts_with(store) { + Some(path) + } else { + None + } + } Err(e) => { - log::warn!("failed to canonicalize {target:?} for validation: {e}"); + log::debug!("failed to canonicalize {target:?} for validation: {e}"); None } } } -pub fn canonicalize_to_store, P2: AsRef>( - store: P1, - path: P2, -) -> anyhow::Result { - let store = store.as_ref(); - let path = path.as_ref(); - if path.starts_with(store) { - Ok(PathBuf::from(path)) - } else { - let metadata = fs::symlink_metadata(path)?; - if metadata.is_symlink() { - let next = fs::read_link(path)?; - canonicalize_to_store(store, next) - } else { - anyhow::bail!("canonicalized to a non-store path") - } - } -} - pub fn discover_users(roots: &[Arc]) -> anyhow::Result> { let uids: BTreeSet<_> = roots.iter().map(|root| root.path_metadata.uid()).collect(); let mut users = Vec::new();