1

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"

Miguel
  • 541
  • 4
  • 7
  • 17

2 Answers2

0
$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)
Ben
  • 1
0

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.