diff --git a/src/Console/Program.cs b/src/Console/Program.cs index 808f0f56..917560f0 100644 --- a/src/Console/Program.cs +++ b/src/Console/Program.cs @@ -3,6 +3,8 @@ using Bit.Core.Services; using Bit.Core.Utilities; using System; using System.Collections.Generic; +using System.Diagnostics; +using System.IO; using System.Linq; using System.Security; using System.Text; @@ -19,6 +21,9 @@ namespace Bit.Console static void Main(string[] args) { + Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory); + //SetDebugDirectory(); + MainAsync(args).Wait(); } @@ -28,7 +33,6 @@ namespace Bit.Console _usingArgs = args.Length > 0; string selection = null; - Con.ForegroundColor = ConsoleColor.DarkCyan; Con.WriteLine(@" _ _ _ _ | |__ (_) |___ ____ _ _ __ __| | ___ _ __ @@ -815,5 +819,13 @@ namespace Bit.Console return dict; } + + [Conditional("DEBUG")] + private static void SetDebugDirectory() + { + Directory.SetCurrentDirectory(string.Concat( + Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), + "\\bitwarden\\DirectoryConnector")); + } } } diff --git a/src/Core/Models/EncryptedData.cs b/src/Core/Models/EncryptedData.cs index 92e67a2e..41a1d5f4 100644 --- a/src/Core/Models/EncryptedData.cs +++ b/src/Core/Models/EncryptedData.cs @@ -14,14 +14,14 @@ namespace Bit.Core.Models public EncryptedData(byte[] plainValue) { IV = RandomBytes(); - Value = ProtectedData.Protect(plainValue, IV, DataProtectionScope.CurrentUser); + Value = ProtectedData.Protect(plainValue, IV, DataProtectionScope.LocalMachine); } public EncryptedData(string plainValue) { var bytes = Encoding.UTF8.GetBytes(plainValue); IV = RandomBytes(); - Value = ProtectedData.Protect(bytes, IV, DataProtectionScope.CurrentUser); + Value = ProtectedData.Protect(bytes, IV, DataProtectionScope.LocalMachine); } public byte[] Value { get; set; } diff --git a/src/Core/Services/SettingsService.cs b/src/Core/Services/SettingsService.cs index dfabd928..8d0dd33e 100644 --- a/src/Core/Services/SettingsService.cs +++ b/src/Core/Services/SettingsService.cs @@ -14,9 +14,7 @@ namespace Bit.Core.Services { private static SettingsService _instance; private static object _locker = new object(); - private static string _baseStoragePath = string.Concat( - Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), - "\\bitwarden\\DirectoryConnector"); + private static string _baseStoragePath = Directory.GetCurrentDirectory(); private SettingsModel _settings; diff --git a/src/Service/Installer.cs b/src/Service/Installer.cs index cd4f7f07..f12c8655 100644 --- a/src/Service/Installer.cs +++ b/src/Service/Installer.cs @@ -50,11 +50,6 @@ namespace Service { EventLog.DeleteEventSource(_serviceInstaller.ServiceName); } - - if(EventLog.Exists("bitwarden")) - { - EventLog.Delete("bitwarden"); - } } } } diff --git a/src/Service/Service.cs b/src/Service/Service.cs index d2dd2c76..ec7479e6 100644 --- a/src/Service/Service.cs +++ b/src/Service/Service.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; +using System.IO; using System.Linq; using System.ServiceProcess; using System.Text; @@ -21,21 +22,20 @@ namespace Service public Service() { + Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory); + ServiceName = "bitwarden Directory Connector"; _components = new Container(); _eventLog = new EventLog(); _eventLog.Source = ServiceName; - _eventLog.Log = "bitwarden"; + _eventLog.Log = "Application"; - var eventLogSupprot = _eventLog as ISupportInitialize; - eventLogSupprot.BeginInit(); if(!EventLog.SourceExists(_eventLog.Source)) { - EventLog.CreateEventSource(ServiceName, _eventLog.Log); + EventLog.CreateEventSource(_eventLog.Source, _eventLog.Log); } - eventLogSupprot.EndInit(); } protected override void Dispose(bool disposing)