gpt4 book ai didi

c - sys/stat.h 中是否定义了 Mac 系统完整性保护

转载 作者:太空狗 更新时间:2023-10-29 11:06:44 35 4
gpt4 key购买 nike

我在 Internet 上进行了一些搜索,但没有找到以编程方式确定给定文件是否已打开完整性检测的好方法。

我注意到,与我遇到的大多数 linux header 不同,Darwin 没有在/sys/stat.h 中定义的 stat 结构中定义它们的 st_mode 位。实现这个的最好方法似乎是处理现有的 sys/stat.h header ,但是,很明显他们不想公开它的原因。有人对此进行了更多调查吗?

编辑

根据 Ken Thomases 建议我的 if 检查看起来像这样。查看源代码中的注释似乎应该可以工作,但是它仍在尝试输入目录,例如:“/Users/ /Library/IdentityServices”导致段错误。仅供引用,我已经使用和不使用预处理器 IFDEF 语句对其进行了测试。

if(
(entry->d_type == DT_DIR)
&& ((fileStat.st_flags & SF_RESTRICTED) == 0)
&& (((fileStat.st_mode & 5) == 5)
|| (((fileStat.st_mode & 40) == 40)
&& (fileStat.st_gid == userHomeStat.st_uid))
|| (((fileStat.st_mode & 320) == 320)
&& (fileStat.st_uid == userHomeStat.st_uid))))
{
std::cout<< "Decending into --> " << fullPath.c_str() <<std::endl;
packIndexFrom((fullPath).c_str());
}

编辑

https://developer.apple.com/library/archive/documentation/Security/Conceptual/System_Integrity_Protection_Guide/FileSystemProtections/FileSystemProtections.html#//apple_ref/doc/uid/TP40016462-CH2-SW1

我在 Apple 的网站上找到了这个。这似乎表明我挂断电话的 $HOME/Library 区域受到某种类型的限制,开发人员具有独占的 r/w 访问权限。不幸的是,没有解决我的问题。

编辑

Dans-MBP:tmp mreff555$ cd ~/Library/IdentityServices/
Dans-MBP:IdentityServices mreff555$ pwd
/Users/mreff555/Library/IdentityServices
Dans-MBP:IdentityServices mreff555$ ls
ls: .: Operation not permitted
Dans-MBP:IdentityServices mreff555$

Dans-MBP:IdentityServices mreff555$ ls -ldO ~/Library/IdentityServices
drwxr-xr-x 9 mreff555 staff - 288 Apr 14 10:04 /Users/mreff555/Library/IdentityServices

最佳答案

有些标志与模式标志分开。您正在 struct statst_flags 字段中寻找 SF_RESTRICTED 标志。事实上,该标志是在 sys/stat.h 中定义的。

模式标志(例如 S_IRUSR)在 sys/_types/_s_ifmt.h 中定义,它间接包含在 sys/stat.h 中。

关于c - sys/stat.h 中是否定义了 Mac 系统完整性保护,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55769643/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com