summaryrefslogtreecommitdiff
path: root/ayafs-core/src/utils
diff options
context:
space:
mode:
authorChuyan Zhang <me@zcy.moe>2023-12-02 17:37:57 -0800
committerChuyan Zhang <me@zcy.moe>2023-12-02 17:37:57 -0800
commitf5c92834f79dfdf8007daa019f401c5e51a7596f (patch)
tree19a069a86d9131fef9c271543743e50f6ae3c2eb /ayafs-core/src/utils
parent5ad6da0370cd33230922394817cdb4d0b1e19c93 (diff)
downloadmyfs-f5c92834f79dfdf8007daa019f401c5e51a7596f.tar.gz
myfs-f5c92834f79dfdf8007daa019f401c5e51a7596f.zip
Fix read/write permissions
Diffstat (limited to 'ayafs-core/src/utils')
-rw-r--r--ayafs-core/src/utils/permissions.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/ayafs-core/src/utils/permissions.rs b/ayafs-core/src/utils/permissions.rs
index 6773511..53205b5 100644
--- a/ayafs-core/src/utils/permissions.rs
+++ b/ayafs-core/src/utils/permissions.rs
@@ -2,6 +2,7 @@ use crate::disk::inode::InodeMode;
use libc::{F_OK, S_ISGID, S_ISUID, S_IXGRP, X_OK};
use std::fs::File;
use std::io::BufRead;
+use log::debug;
pub(crate) fn get_groups(pid: u32) -> Vec<u32> {
let file = File::open(format!("/proc/{pid}/task/{pid}/status"))
@@ -36,6 +37,8 @@ pub(crate) fn check_access(
mode: InodeMode,
mut mask: i32,
) -> bool {
+ let mask_mem = mask;
+ // true
if mask == F_OK {
return true;
}
@@ -58,5 +61,17 @@ pub(crate) fn check_access(
} else {
mask -= mask & perm;
}
+
+ debug!(
+ "check_access(incoming_uid: {}, incoming_gid: {}, uid: {}, gid: {}, mode: {:#o}, mask: {:#x}) -> {}",
+ incoming_uid,
+ incoming_gid,
+ uid,
+ gid,
+ mode.0,
+ mask_mem,
+ mask == 0,
+ );
+
mask == 0
}