c++ - 如何创建 NULL/空 DACL?

标签 c++ security winapi dacl

我需要向所有人授予我正在创建的命名管道的访问权限。我知道这样做的方法是创建一个 NULL/空 DACL 并将其传递给 CreateNamedPipe

如何创建 NULL DACL?有人告诉我,这与为 LPSECURITY_ATTRIBUTES 传递 NULL 指针不同。

最佳答案

像这样:

SECURITY_DESCRIPTOR SD;
InitializeSecurityDescriptor(&SD, SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorDacl(&SD, TRUE, NULL, FALSE);

为了简洁起见,我省略了错误检查。你不会那样做。

然后当您调用 CreateNamedPipe 时,您可以像这样设置安全属性记录:

SA.nLength = sizeof(SA);
SA.lpSecurityDescriptor = &SD;
SA.bInheritHandle = TRUE;

SetSecurityDescriptorDacl 的文档指出:

When the pDacl parameter does not point to a DACL and the bDaclPresent flag is TRUE, a NULL DACL is specified. All access is allowed. You should not use a NULL DACL with an object because any user can change the DACL and owner of the security descriptor. This will interfere with use of the object.

所以,上面是怎么做的,但是文档确实强调你不应该这样做。

关于c++ - 如何创建 NULL/空 DACL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14502450/

相关文章:

c++ - 如何比较 vector ?

ios - Objc 中的 SecRandomCopyBytes 提供程序(SHA1PRNG 或 NativePRNG)类型?

java - 生成和保护礼品卡代码

security - 是否可以在网络级别严格限制前端和后端 Azure IaaS VM 之间的入口和导出流量?

c++ - 获取正在运行的程序的属性

c++ - 为什么这个 Windows 消息循环不处理快捷键/tab 键?

c++ - 在 C++ 中使用 flexlexer 重载 yylex()

c++ - 错误 : Cannot add two pointers

c++ - C++ 中的多元正态密度函数

C# 如何关闭特定显示器?