From 01a78a4d3aa58fc3cadf8cc17a112421e730e3b0 Mon Sep 17 00:00:00 2001 From: albertony <12441419+albertony@users.noreply.github.com> Date: Sat, 5 Dec 2020 01:09:41 +0100 Subject: [PATCH 1/2] Do not store path to ImmuneKeys.txt before --profile-dir is considered --- src/lib/platform/MSWindowsHook.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib/platform/MSWindowsHook.cpp b/src/lib/platform/MSWindowsHook.cpp index b9b97404..9600d6b0 100644 --- a/src/lib/platform/MSWindowsHook.cpp +++ b/src/lib/platform/MSWindowsHook.cpp @@ -56,14 +56,13 @@ static BYTE g_deadKeyState[256] = { 0 }; static BYTE g_keyState[256] = { 0 }; static bool g_fakeServerInput = false; static std::vector g_immuneKeys; - -static const std::string ImmuneKeysPath = DataDirectories::profile() + "\\ImmuneKeys.txt"; +static std::string g_immuneKeysPath; static std::vector immune_keys_list() { std::vector keys; std::string badLine; - if (!ImmuneKeysReader::get_list(ImmuneKeysPath.c_str(), keys, badLine)) + if (!ImmuneKeysReader::get_list(g_immuneKeysPath.c_str(), keys, badLine)) LOG((CLOG_ERR "Reading immune keys stopped at: %s", badLine.c_str())); return keys; } @@ -575,8 +574,9 @@ MSWindowsHook::install() g_fakeServerInput = false; // setup immune keys + g_immuneKeysPath = DataDirectories::profile() + "\\ImmuneKeys.txt"; g_immuneKeys = immune_keys_list(); - LOG((CLOG_DEBUG "Found %u immune keys in %s", g_immuneKeys.size(), ImmuneKeysPath.c_str())); + LOG((CLOG_DEBUG "Found %u immune keys in %s", g_immuneKeys.size(), g_immuneKeysPath.c_str())); #if NO_GRAB_KEYBOARD // we only need the mouse hook @@ -638,4 +638,4 @@ void MSWindowsHook::uninstallScreenSaver() { g_hkMessage.unset(); -} \ No newline at end of file +} From 87c5f874e45948ea621eae9d9d895c894dc6807c Mon Sep 17 00:00:00 2001 From: albertony <12441419+albertony@users.noreply.github.com> Date: Sat, 5 Dec 2020 01:12:19 +0100 Subject: [PATCH 2/2] Include --profile-dir in help text --- src/lib/barrier/App.h | 4 ++-- src/lib/barrier/ServerApp.cpp | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/lib/barrier/App.h b/src/lib/barrier/App.h index 8040da86..b5cce7e8 100644 --- a/src/lib/barrier/App.h +++ b/src/lib/barrier/App.h @@ -166,8 +166,8 @@ private: " -l --log write log messages to file.\n" \ " --no-tray disable the system tray icon.\n" \ " --enable-drag-drop enable file drag & drop.\n" \ - " --enable-crypto enable the crypto (ssl) plugin.\n" - + " --enable-crypto enable the crypto (ssl) plugin.\n" \ + " --profile-dir use named profile directory instead.\n" #define HELP_COMMON_INFO_2 \ " -h, --help display this help and exit.\n" \ " --version display version information and exit.\n" diff --git a/src/lib/barrier/ServerApp.cpp b/src/lib/barrier/ServerApp.cpp index 18cf9358..ed064f87 100644 --- a/src/lib/barrier/ServerApp.cpp +++ b/src/lib/barrier/ServerApp.cpp @@ -128,6 +128,12 @@ ServerApp::help() # define WINAPI_INFO "" #endif + // refer to custom profile directory even if not saved yet + String profilePath = argsBase().m_profileDirectory; + if (profilePath.empty()) { + profilePath = DataDirectories::profile(); + } + std::ostringstream buffer; buffer << "Start the barrier server component." << std::endl << std::endl @@ -150,7 +156,7 @@ ServerApp::help() << std::endl << "If no configuration file pathname is provided then the first of the" << std::endl << "following to load successfully sets the configuration:" << std::endl - << " " << PathUtilities::concat(DataDirectories::profile(), USR_CONFIG_NAME) << std::endl + << " " << PathUtilities::concat(profilePath, USR_CONFIG_NAME) << std::endl << " " << PathUtilities::concat(DataDirectories::systemconfig(), SYS_CONFIG_NAME) << std::endl; LOG((CLOG_PRINT "%s", buffer.str().c_str()));