mirror of
https://github.com/narrrl/proton-drive-linux.git
synced 2026-11-03 16:41:26 +01:00
implemented shared id permissions
This commit is contained in:
1 parent
7de667b386
commit
551e14b644
8 files changed
+1329
-90
No files matched your search
@@ -173,6 +173,61 @@ pub(crate) struct State {
|
||||
}
|
||||
|
||||
impl State {
|
||||
/// Whether `uid` names an owned node currently reachable from this mount's
|
||||
/// root. Resident entries can outlive their dentries for open-handle and
|
||||
/// access-revocation semantics, so `by_uid` membership alone is not proof
|
||||
/// that a control-socket operation may address the node.
|
||||
pub(crate) fn owns_visible_uid(&self, uid: &NodeUid) -> bool {
|
||||
let Some(root) = self.entries.get(&crate::ROOT_INO) else {
|
||||
return false;
|
||||
};
|
||||
if uid.volume_id != root.uid.volume_id {
|
||||
return false;
|
||||
}
|
||||
|
||||
let Some(&target) = self.by_uid.get(uid) else {
|
||||
return false;
|
||||
};
|
||||
let mut current = target;
|
||||
let mut seen = HashSet::new();
|
||||
loop {
|
||||
if !seen.insert(current) {
|
||||
return false;
|
||||
}
|
||||
let Some(entry) = self.entries.get(¤t) else {
|
||||
return false;
|
||||
};
|
||||
if entry.uid.volume_id != root.uid.volume_id
|
||||
|| entry.unlinked
|
||||
|| entry.node.trashed
|
||||
|| entry.uid != entry.node.uid
|
||||
|| self.by_uid.get(&entry.uid) != Some(¤t)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if current == crate::ROOT_INO {
|
||||
return true;
|
||||
}
|
||||
|
||||
let parent = entry.parent;
|
||||
if parent == 0 || parent == current {
|
||||
return false;
|
||||
}
|
||||
let Some(parent_entry) = self.entries.get(&parent) else {
|
||||
return false;
|
||||
};
|
||||
if entry.node.parent_uid.as_ref() != Some(&parent_entry.uid)
|
||||
|| self
|
||||
.children
|
||||
.get(&parent)
|
||||
.is_some_and(|children| !children.contains(¤t))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
current = parent;
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn require_writable(&self, ino: u64) -> Result<(), fuser::Errno> {
|
||||
match self.entries.get(&ino) {
|
||||
Some(entry) if entry.writable() => Ok(()),
|
||||
|
||||
Reference in new issue
Block a user