From f5c92834f79dfdf8007daa019f401c5e51a7596f Mon Sep 17 00:00:00 2001 From: Chuyan Zhang Date: Sat, 2 Dec 2023 17:37:57 -0800 Subject: Fix read/write permissions --- ayafs-core/src/utils/permissions.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'ayafs-core/src/utils') 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 { 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 } -- cgit v1.2.3-70-g09d2