Only modify pipe ACL when running as admin
This commit is contained in:
committed by
Paul Chote
parent
0c319e88c3
commit
b61b7b5431
@@ -51,9 +51,18 @@ namespace OpenRA.Utility
|
|||||||
if (args.Length > 1 && args[1] == "--pipe")
|
if (args.Length > 1 && args[1] == "--pipe")
|
||||||
{
|
{
|
||||||
piping = true;
|
piping = true;
|
||||||
var ps = new PipeSecurity();
|
NamedPipeServerStream pipe;
|
||||||
ps.AddAccessRule(new PipeAccessRule("EVERYONE", PipeAccessRights.FullControl, System.Security.AccessControl.AccessControlType.Allow));
|
var id = WindowsIdentity.GetCurrent();
|
||||||
NamedPipeServerStream pipe = new NamedPipeServerStream("OpenRA.Utility", PipeDirection.Out, 1, PipeTransmissionMode.Byte, PipeOptions.None, 1024, 1024, ps);
|
var principal = new WindowsPrincipal(id);
|
||||||
|
if (principal.IsInRole(WindowsBuiltInRole.Administrator))
|
||||||
|
{
|
||||||
|
var ps = new PipeSecurity();
|
||||||
|
ps.AddAccessRule(new PipeAccessRule("EVERYONE", PipeAccessRights.FullControl, System.Security.AccessControl.AccessControlType.Allow));
|
||||||
|
pipe = new NamedPipeServerStream("OpenRA.Utility", PipeDirection.Out, 1, PipeTransmissionMode.Byte, PipeOptions.None, 1024, 1024, ps);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
pipe = new NamedPipeServerStream("OpenRA.Utility", PipeDirection.Out);
|
||||||
|
|
||||||
pipe.WaitForConnection();
|
pipe.WaitForConnection();
|
||||||
Console.SetOut(new StreamWriter(pipe) { AutoFlush = true });
|
Console.SetOut(new StreamWriter(pipe) { AutoFlush = true });
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user