Score:1

How to add permissions to windows named pipes using powershell?

ao flag

How can i add permissions for a specific group to read/write from an existent named pipe, using a powershell script?

This is as far as i went:

$AccessRule = New-Object System.IO.Pipes.PipeAccessRule( "Users", "FullControl", "Allow" )
$PipeSecurity = [System.IO.Directory]::GetAccessControl("\\.\pipe\docker_engine")
$PipeSecurity.AddAccessRule($AccessRule) 

throw error

Cannot convert argument "rule", with value: "System.IO.Pipes.PipeAccessRule", for "AddAccessRule" to type "System.Security.AccessControl.FileSystemAccessRule"

Score:0
cn flag
Ben
$account="<DOMAIN>\<USERNAME>"
$npipe = "\\.\pipe\docker_engine"                                                                                 
$dInfo = New-Object "System.IO.DirectoryInfo" -ArgumentList $npipe                                               
$dSec = $dInfo.GetAccessControl()                                                                                 
$fullControl =[System.Security.AccessControl.FileSystemRights]::FullControl                                       
$allow =[System.Security.AccessControl.AccessControlType]::Allow                                                  
$rule = New-Object "System.Security.AccessControl.FileSystemAccessRule" -ArgumentList $account,$fullControl,$allow
$dSec.AddAccessRule($rule)                                                                                        
$dInfo.SetAccessControl($dSec)
Score:0
in flag

while Ben's solution does work, the access-rules are lost whenever the Docker deamon is restarted.

But there's a permanent fix permanent fix in case of Docker:
Create the file %programdata%\docker\config\daemon.json with the following contents:

{
    "group": "Users"
}

This allows all users in the Windows group Users to open the named pipe without admin privileges.

Best Jan


This is the documentation.

-G, --group string | Group for the unix socket (default "docker")

It says "unix socket" but works for the named pipe too.

The default group seems to be docker, but is not created by the deamon. And Docker Desktop creates a group called docker-users.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.