mirror of
https://github.com/bitwarden/directory-connector
synced 2025-12-10 13:23:18 +00:00
settings adjustments to allow sharing with service
This commit is contained in:
@@ -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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -50,11 +50,6 @@ namespace Service
|
||||
{
|
||||
EventLog.DeleteEventSource(_serviceInstaller.ServiceName);
|
||||
}
|
||||
|
||||
if(EventLog.Exists("bitwarden"))
|
||||
{
|
||||
EventLog.Delete("bitwarden");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user