其他分享
首页 > 其他分享> > 是否在sys / stat.h中定义了Mac系统完整性保护?

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

作者:互联网

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

我注意到,与我遇到的大多数Linux标头不同,Darwin不在/sys/stat.h中定义的stat结构中定义其st_mode位.看来,实现此目标的最佳方法是处理现有的sys / stat.h标头,但是,很明显为什么他们不愿意对此公开.有人进一步调查过吗?

编辑

根据Ken Thomases的建议,我的支票应如下所示.查看源代码中的注释似乎看起来应该可以,但是它仍在尝试输入目录,例如:
“ / Users /< USER> / 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 stat的st_flags字段中寻找SF_RESTRICTED标志.该标志实际上是在sys / stat.h中定义的.

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

标签:darwin,c-3,linux,macos
来源: https://codeday.me/bug/20191108/2005666.html