如何创建一个NULL /空DACL? [英] How do I create a NULL/empty DACL?

查看:191
本文介绍了如何创建一个NULL /空DACL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要授予我创建的命名管道的每个人的访问权限。我理解的方法是创建一个NULL /空DACL,并将其传递给 CreateNamedPipe

I need to grant access to everyone for a named pipe I'm creating. I understand the way to do it is to create a NULL/empty DACL and pass it to CreateNamedPipe.

我创建一个NULL DACL?我被告知,它不一样为传递一个NULL指针 LPSECURITY_ATTRIBUTES

How do I create a NULL DACL? I was told that it is not the same as passing a NULL pointer for LPSECURITY_ATTRIBUTES.

推荐答案

像这样:

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

为了简洁,省略了错误检查。

I omitted error checking for the sake of brevity. You would not do that.

然后当您调用 CreateNamedPipe 时,您可以设置安全属性记录,如下所示:

Then when you call CreateNamedPipe you can set up the security attributes record like this:

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

SetSecurityDescriptorDacl 的文档说明:


当pDacl参数不指向DACL且bDaclPresent标志为TRUE时,指定NULL DACL。允许所有访问。您不应该对对象使用NULL DACL,因为任何用户都可以更改安全描述符的DACL和所有者。这将干扰对象的使用。

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.

因此,上面是如何做到的,但文档确实强调你应该不这样做。

So, the above is how to do it, but the documentation does stress that you should not do so.

这篇关于如何创建一个NULL /空DACL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆