SECURITY_ATTRIBUTES 实现最低权限总结

SetSecurityDescriptorDacl函数可以用来设置DACL中的信息。如果一个DACL已经在security descriptor中存在,那么此DACL将被替换。
值得注意的是MSDN中的Remarks中有这样的描述:
There is an important difference between an empty and a nonexistent DACL.
1.When a DACL is empty, it contains no access control entries (ACEs); therefore, no access rights are explicitly granted.As a result, access to the object is implicitly denied.

2.When an object has no DACL (when the pDacl parameter is NULL), no protection is assigned to the object, and all access requests are granted. To help maintain security, restrict access by using a DACL.

根据上面的描述,为了在多进程间实现最低权限访问安全对象,只需把参数三设置为NULL,其实相当于将object的安全级别降到了最低,
所 有的访问请求都将成功。(要想使用第三、四两个参数,那么参数二需要设置为TRUE;如果参数二设置为FALSE,那么参数三、四被忽略).下面的代码将 创建一个比everyone更开放(域用户和everyone都可以访问----everyone权限只包含本地所有用户,不包含域用户)的访问列表:

    1. SECURITY_ATTRIBUTES sa;
    2. SECURITY_DESCRIPTOR sd;
    3. InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION);
    4. SetSecurityDescriptorDacl(&sd, TRUE, NULL, FALSE);
    5. sa.nLength = sizeof(SECURITY_ATTRIBUTES);
    6. sa.bInheritHandle = TRUE;
    7. sa.lpSecurityDescriptor = &sd;
    8. utilStartedEvt = CreateEvent(&sa,FALSE,FALSE,L"Global\\utilStarted")
      【转】:https://blog.csdn.net/lixiangminghate/article/details/79529920
       

posted on   lydstory  阅读(197)  评论(0编辑  收藏  举报

编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

点击右上角即可分享
微信分享提示