Skip to content

Commit fa2681a

Browse files
committed
Use per-user named pipe names
1 parent c3f0253 commit fa2681a

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

RepostConfirmationCanceler/ProcessCommunicator.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ This Source Code Form is subject to the terms of the Mozilla Public
88
using System;
99
using System.IO;
1010
using System.IO.Pipes;
11+
using System.Security.AccessControl;
12+
using System.Security.Principal;
1113
using System.Text;
1214
using System.Threading;
1315
using System.Threading.Tasks;
@@ -16,15 +18,25 @@ namespace RepostConfirmationCanceler
1618
{
1719
internal static class ProcessCommunicator
1820
{
19-
private const string NAMED_PIPE_NAME = "RepostConfirmationCancelerNamedPipe";
21+
private const string NAMED_PIPE_NAME_BASE = "RepostConfirmationCancelerNamedPipe";
22+
23+
private static string GeneratePipeName()
24+
{
25+
WindowsIdentity user = WindowsIdentity.GetCurrent();
26+
string sid = user.User.Value;
27+
return $"{NAMED_PIPE_NAME_BASE}_{sid}";
28+
}
2029

2130
internal static async void RunNamedPipedServer(RuntimeContext context)
2231
{
32+
PipeSecurity ps = new PipeSecurity();
33+
ps.AddAccessRule(new PipeAccessRule("Everyone", PipeAccessRights.FullControl, AccessControlType.Allow));
34+
2335
context.Logger.Log("Start server");
2436
// FinishTime > DateTime.Nowではなく、trueでも良いが、念のため。
2537
while (!context.IsEndTime)
2638
{
27-
using (var pipeServer = new NamedPipeServerStream(NAMED_PIPE_NAME, PipeDirection.InOut, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous))
39+
using (var pipeServer = new NamedPipeServerStream(GeneratePipeName(), PipeDirection.InOut, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous, 1024, 1024, ps))
2840
{
2941
var cancellationTokenSource = new CancellationTokenSource();
3042
Task waitTask = pipeServer.WaitForConnectionAsync(cancellationTokenSource.Token);
@@ -74,7 +86,7 @@ internal static void SendKeepAliveMessage(RuntimeContext context)
7486
context.Logger.Log("Start to send keep-alive");
7587
try
7688
{
77-
using (var pipeClient = new NamedPipeClientStream(".", NAMED_PIPE_NAME, PipeDirection.Out))
89+
using (var pipeClient = new NamedPipeClientStream(".", GeneratePipeName(), PipeDirection.Out))
7890
{
7991
pipeClient.Connect(1000);
8092
using (var writer = new StreamWriter(pipeClient) { AutoFlush = true })

RepostConfirmationCancelerX64.iss

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
[Setup]
44
AppName=RepostConfirmationCanceler
55
AppVerName=RepostConfirmationCanceler
6-
VersionInfoVersion=1.2.1.0
7-
AppVersion=1.2.1.0
6+
VersionInfoVersion=1.2.2.0
7+
AppVersion=1.2.2.0
88
AppMutex=RepostConfirmationCancelerSetup
99
;DefaultDirName=C:\RepostConfirmationCanceler
1010
DefaultDirName={code:GetProgramFiles}\RepostConfirmationCanceler
@@ -24,15 +24,15 @@ UninstallDisplayIcon={app}\RepostConfirmationCanceler.exe
2424
Root: HKLM; Subkey: "Software\RepostConfirmationCanceler"; Flags: uninsdeletekey
2525
Root: HKLM; Subkey: "Software\RepostConfirmationCanceler"; ValueType: string; ValueName: "Path"; ValueData: "{app}\"
2626
Root: HKLM; Subkey: "Software\RepostConfirmationCanceler"; ValueType: string; ValueName: "ClientType"; ValueData: ""
27-
Root: HKLM; Subkey: "Software\RepostConfirmationCanceler"; ValueType: string; ValueName: "Version"; ValueData: "1.2.1.0"
27+
Root: HKLM; Subkey: "Software\RepostConfirmationCanceler"; ValueType: string; ValueName: "Version"; ValueData: "1.2.2.0"
2828
Root: HKLM; Subkey: "Software\RepostConfirmationCanceler"; ValueType: string; ValueName: "Rulefile"; ValueData: "{app}\RepostConfirmationCanceler.ini"
2929
Root: HKLM; Subkey: "Software\RepostConfirmationCanceler"; ValueType: string; ValueName: "RCAPfile"; ValueData: "{app}\ResourceCap.ini"
3030
Root: HKLM; Subkey: "Software\RepostConfirmationCanceler"; ValueType: string; ValueName: "ExtensionExecfile"; ValueData: "{app}\RepostConfirmationCanceler.exe"
3131

3232
Root: HKLM; Subkey: "Software\WOW6432Node\RepostConfirmationCanceler"; Flags: uninsdeletekey
3333
Root: HKLM; Subkey: "Software\WOW6432Node\RepostConfirmationCanceler"; ValueType: string; ValueName: "Path"; ValueData: "{app}\"
3434
Root: HKLM; Subkey: "Software\WOW6432Node\RepostConfirmationCanceler"; ValueType: string; ValueName: "ClientType"; ValueData: ""
35-
Root: HKLM; Subkey: "Software\WOW6432Node\RepostConfirmationCanceler"; ValueType: string; ValueName: "Version"; ValueData: "1.2.1.0"
35+
Root: HKLM; Subkey: "Software\WOW6432Node\RepostConfirmationCanceler"; ValueType: string; ValueName: "Version"; ValueData: "1.2.2.0"
3636
Root: HKLM; Subkey: "Software\WOW6432Node\RepostConfirmationCanceler"; ValueType: string; ValueName: "Rulefile"; ValueData: "{app}\RepostConfirmationCanceler.ini"
3737
Root: HKLM; Subkey: "Software\WOW6432Node\RepostConfirmationCanceler"; ValueType: string; ValueName: "RCAPfile"; ValueData: "{app}\ResourceCap.ini"
3838
Root: HKLM; Subkey: "Software\WOW6432Node\RepostConfirmationCanceler"; ValueType: string; ValueName: "ExtensionExecfile"; ValueData: "{app}\RepostConfirmationCanceler.exe"

RepostConfirmationCancelerX86.iss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
[Setup]
44
AppName=RepostConfirmationCanceler
55
AppVerName=RepostConfirmationCanceler
6-
VersionInfoVersion=1.2.1.0
7-
AppVersion=1.2.1.0
6+
VersionInfoVersion=1.2.2.0
7+
AppVersion=1.2.2.0
88
AppMutex=RepostConfirmationCancelerSetup
99
;DefaultDirName=C:\RepostConfirmationCanceler
1010
DefaultDirName={code:GetProgramFiles}\RepostConfirmationCanceler
@@ -23,7 +23,7 @@ UninstallDisplayIcon={app}\RepostConfirmationCanceler.exe
2323
Root: HKLM; Subkey: "Software\RepostConfirmationCanceler"; Flags: uninsdeletekey
2424
Root: HKLM; Subkey: "Software\RepostConfirmationCanceler"; ValueType: string; ValueName: "Path"; ValueData: "{app}\"
2525
Root: HKLM; Subkey: "Software\RepostConfirmationCanceler"; ValueType: string; ValueName: "ClientType"; ValueData: ""
26-
Root: HKLM; Subkey: "Software\RepostConfirmationCanceler"; ValueType: string; ValueName: "Version"; ValueData: "1.2.1.0"
26+
Root: HKLM; Subkey: "Software\RepostConfirmationCanceler"; ValueType: string; ValueName: "Version"; ValueData: "1.2.2.0"
2727
Root: HKLM; Subkey: "Software\RepostConfirmationCanceler"; ValueType: string; ValueName: "Rulefile"; ValueData: "{app}\RepostConfirmationCanceler.ini"
2828
Root: HKLM; Subkey: "Software\RepostConfirmationCanceler"; ValueType: string; ValueName: "RCAPfile"; ValueData: "{app}\ResourceCap.ini"
2929
Root: HKLM; Subkey: "Software\RepostConfirmationCanceler"; ValueType: string; ValueName: "ExtensionExecfile"; ValueData: "{app}\RepostConfirmationCanceler.exe"

0 commit comments

Comments
 (0)