From 2d64a1960d88abbfd7b41ff4c84e065f93fee9b0 Mon Sep 17 00:00:00 2001 From: campbeb Date: Sat, 15 Oct 2016 14:58:04 -0400 Subject: [PATCH] Add user name to IPC channel name Make IPC channel name unique per user to fix access denied problems on multiuser systems. Fixes #1994. May also fix #1462 and #1509 --- ShareX.HelpersLib/ApplicationInstanceManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ShareX.HelpersLib/ApplicationInstanceManager.cs b/ShareX.HelpersLib/ApplicationInstanceManager.cs index 4a1a4d939..0d163843b 100644 --- a/ShareX.HelpersLib/ApplicationInstanceManager.cs +++ b/ShareX.HelpersLib/ApplicationInstanceManager.cs @@ -36,7 +36,7 @@ public class ApplicationInstanceManager : IDisposable { private static readonly string MutexName = "82E6AC09-0FEF-4390-AD9F-0DD3F5561EFC"; private static readonly string AppName = "ShareX"; - private static readonly string EventName = string.Format("{0}-{1}", Environment.MachineName, AppName); + private static readonly string EventName = string.Format("{0}-{1}-{2}", Environment.MachineName, Environment.UserName, AppName); private static readonly string SemaphoreName = string.Format("{0}{1}", EventName, "Semaphore"); public bool IsSingleInstance { get; private set; } @@ -151,7 +151,7 @@ private void UpdateRemoteObject(string uri) IpcClientChannel clientChannel = new IpcClientChannel(); ChannelServices.RegisterChannel(clientChannel, true); - InstanceProxy proxy = Activator.GetObject(typeof(InstanceProxy), string.Format("ipc://{0}{1}/{1}", Environment.MachineName, uri)) as InstanceProxy; + InstanceProxy proxy = Activator.GetObject(typeof(InstanceProxy), string.Format("ipc://{0}{1}{2}/{2}", Environment.MachineName, Environment.UserName, uri)) as InstanceProxy; if (proxy != null) { @@ -163,7 +163,7 @@ private void UpdateRemoteObject(string uri) private void RegisterRemoteType(string uri) { - serverChannel = new IpcServerChannel(Environment.MachineName + uri); + serverChannel = new IpcServerChannel(Environment.MachineName + Environment.UserName + uri); ChannelServices.RegisterChannel(serverChannel, true); RemotingConfiguration.RegisterWellKnownServiceType(typeof(InstanceProxy), uri, WellKnownObjectMode.Singleton);