diff --git a/src/gui/src/MainWindow.cpp b/src/gui/src/MainWindow.cpp index ccb5c196..55052efe 100644 --- a/src/gui/src/MainWindow.cpp +++ b/src/gui/src/MainWindow.cpp @@ -442,7 +442,7 @@ void MainWindow::checkFingerprint(const QString& line) barrier::string::from_hex(fingerprintRegex.cap(2).toStdString()) }; - auto db_path = DataDirectories::trusted_servers_ssl_fingerprints_path(); + auto db_path = barrier::DataDirectories::trusted_servers_ssl_fingerprints_path(); // We compare only SHA256 fingerprints, but show both SHA1 and SHA256 so that the users can // still verify fingerprints on old Barrier servers. This way the only time when we are exposed @@ -564,7 +564,7 @@ void MainWindow::startBarrier() // launched the process (e.g. when launched with elevation). setting the // profile dir on launch ensures it uses the same profile dir is used // no matter how its relaunched. - args << "--profile-dir" << QString::fromStdString("\"" + DataDirectories::profile() + "\""); + args << "--profile-dir" << QString::fromStdString("\"" + barrier::DataDirectories::profile() + "\""); #endif if ((barrierType() == barrierClient && !clientArgs(args, app)) @@ -1020,7 +1020,7 @@ void MainWindow::updateSSLFingerprint() return; } - auto local_path = DataDirectories::local_ssl_fingerprints_path(); + auto local_path = barrier::DataDirectories::local_ssl_fingerprints_path(); if (!QFile::exists(QString::fromStdString(local_path))) { return; } diff --git a/src/gui/src/SslCertificate.cpp b/src/gui/src/SslCertificate.cpp index 57fb5f1b..910e0a8d 100644 --- a/src/gui/src/SslCertificate.cpp +++ b/src/gui/src/SslCertificate.cpp @@ -38,7 +38,7 @@ static const char kSslDir[] = "SSL"; SslCertificate::SslCertificate(QObject *parent) : QObject(parent) { - m_ProfileDir = DataDirectories::profile(); + m_ProfileDir = barrier::DataDirectories::profile(); if (m_ProfileDir.empty()) { emit error(tr("Failed to get profile directory.")); } @@ -73,7 +73,7 @@ void SslCertificate::generateCertificate() void SslCertificate::generateFingerprint(const std::string& cert_path) { try { - auto local_path = DataDirectories::local_ssl_fingerprints_path(); + auto local_path = barrier::DataDirectories::local_ssl_fingerprints_path(); barrier::FingerprintDatabase db; db.add_trusted(barrier::get_pem_file_cert_fingerprint(cert_path, barrier::FingerprintType::SHA1)); diff --git a/src/lib/barrier/App.cpp b/src/lib/barrier/App.cpp index dd0e6197..9216470a 100644 --- a/src/lib/barrier/App.cpp +++ b/src/lib/barrier/App.cpp @@ -164,7 +164,7 @@ App::initApp(int argc, const char** argv) // parse command line parseArgs(argc, argv); - DataDirectories::profile(argsBase().m_profileDirectory.u8string()); + barrier::DataDirectories::profile(argsBase().m_profileDirectory.u8string()); // set log filter if (!CLOG->setFilter(argsBase().m_logFilter)) { diff --git a/src/lib/barrier/ServerApp.cpp b/src/lib/barrier/ServerApp.cpp index 3ecfd912..d11f960e 100644 --- a/src/lib/barrier/ServerApp.cpp +++ b/src/lib/barrier/ServerApp.cpp @@ -130,11 +130,11 @@ ServerApp::help() // refer to custom profile directory even if not saved yet barrier::fs::path profile_path = argsBase().m_profileDirectory; if (profile_path.empty()) { - profile_path = barrier::fs::u8path(DataDirectories::profile()); + profile_path = barrier::fs::u8path(barrier::DataDirectories::profile()); } auto usr_config_path = (profile_path / barrier::fs::u8path(USR_CONFIG_NAME)).u8string(); - auto sys_config_path = (barrier::fs::u8path(DataDirectories::systemconfig()) / + auto sys_config_path = (barrier::fs::u8path(barrier::DataDirectories::systemconfig()) / barrier::fs::u8path(SYS_CONFIG_NAME)).u8string(); std::ostringstream buffer; @@ -197,7 +197,7 @@ ServerApp::loadConfig() // load the default configuration if no explicit file given else { - auto path = barrier::fs::u8path(DataDirectories::profile()); + auto path = barrier::fs::u8path(barrier::DataDirectories::profile()); if (!path.empty()) { // complete path path /= barrier::fs::u8path(USR_CONFIG_NAME); @@ -210,7 +210,7 @@ ServerApp::loadConfig() } if (!loaded) { // try the system-wide config file - path = barrier::fs::u8path(DataDirectories::systemconfig()); + path = barrier::fs::u8path(barrier::DataDirectories::systemconfig()); if (!path.empty()) { path /= barrier::fs::u8path(SYS_CONFIG_NAME); if (loadConfig(path.u8string())) { diff --git a/src/lib/barrier/win32/DaemonApp.cpp b/src/lib/barrier/win32/DaemonApp.cpp index 88e6b4ef..a3638d86 100644 --- a/src/lib/barrier/win32/DaemonApp.cpp +++ b/src/lib/barrier/win32/DaemonApp.cpp @@ -245,7 +245,7 @@ DaemonApp::logFilename() { string logFilename = ARCH->setting("LogFilename"); if (logFilename.empty()) - logFilename = DataDirectories::global() + "\\" + LOG_FILENAME; + logFilename = barrier::DataDirectories::global() + "\\" + LOG_FILENAME; MSWindowsUtil::createDirectory(logFilename, true); return logFilename; } diff --git a/src/lib/common/DataDirectories.h b/src/lib/common/DataDirectories.h index 4489ac24..5b7b0f51 100644 --- a/src/lib/common/DataDirectories.h +++ b/src/lib/common/DataDirectories.h @@ -15,10 +15,13 @@ * along with this program. If not, see . */ -#pragma once +#ifndef BARRIER_LIB_COMMON_DATA_DIRECTORIES_H +#define BARRIER_LIB_COMMON_DATA_DIRECTORIES_H #include +namespace barrier { + class DataDirectories { public: @@ -40,3 +43,7 @@ private: static std::string _global; static std::string _systemconfig; }; + +} // namespace barrier + +#endif diff --git a/src/lib/common/DataDirectories_static.cpp b/src/lib/common/DataDirectories_static.cpp index 5e28e055..5c3615eb 100644 --- a/src/lib/common/DataDirectories_static.cpp +++ b/src/lib/common/DataDirectories_static.cpp @@ -17,7 +17,8 @@ #include "DataDirectories.h" -// static member +namespace barrier { + std::string DataDirectories::_profile; std::string DataDirectories::_global; std::string DataDirectories::_systemconfig; @@ -46,3 +47,5 @@ std::string DataDirectories::trusted_clients_ssl_fingerprints_path() { return ssl_fingerprints_path() + "/" + kFingerprintsTrustedClientsFilename; } + +} // namespace barrier diff --git a/src/lib/common/unix/DataDirectories.cpp b/src/lib/common/unix/DataDirectories.cpp index 608db05c..ee4947c6 100644 --- a/src/lib/common/unix/DataDirectories.cpp +++ b/src/lib/common/unix/DataDirectories.cpp @@ -22,6 +22,8 @@ #include // getpwuid(_r) #include // getpwuid(_r) +namespace barrier { + const std::string ProfileSubdir = "/barrier"; static std::string pw_dir(struct passwd* pwentp) @@ -112,3 +114,5 @@ const std::string& DataDirectories::systemconfig(const std::string& path) _systemconfig = path; return _systemconfig; } + +} // namespace barrier diff --git a/src/lib/common/win32/DataDirectories.cpp b/src/lib/common/win32/DataDirectories.cpp index 32bc2136..0eeb6a20 100644 --- a/src/lib/common/win32/DataDirectories.cpp +++ b/src/lib/common/win32/DataDirectories.cpp @@ -20,6 +20,8 @@ #include +namespace barrier { + std::string known_folder_path(const KNOWNFOLDERID& id) { std::string path; @@ -71,3 +73,5 @@ const std::string& DataDirectories::systemconfig(const std::string& path) _systemconfig = path; return _systemconfig; } + +} // namespace barrier diff --git a/src/lib/net/SecureListenSocket.cpp b/src/lib/net/SecureListenSocket.cpp index 2a9f84cb..bfaa4be0 100644 --- a/src/lib/net/SecureListenSocket.cpp +++ b/src/lib/net/SecureListenSocket.cpp @@ -56,7 +56,7 @@ SecureListenSocket::accept() } std::string certificateFilename = barrier::string::sprintf("%s/%s/%s", - DataDirectories::profile().c_str(), + barrier::DataDirectories::profile().c_str(), s_certificateDir, s_certificateFilename); diff --git a/src/lib/net/SecureSocket.cpp b/src/lib/net/SecureSocket.cpp index 9ac674d6..1a190381 100644 --- a/src/lib/net/SecureSocket.cpp +++ b/src/lib/net/SecureSocket.cpp @@ -674,7 +674,7 @@ SecureSocket::verifyCertFingerprint() barrier::format_ssl_fingerprint(fingerprint_sha1.data).c_str(), barrier::format_ssl_fingerprint(fingerprint_sha256.data).c_str())); - auto fingerprint_db_path = DataDirectories::trusted_servers_ssl_fingerprints_path(); + auto fingerprint_db_path = barrier::DataDirectories::trusted_servers_ssl_fingerprints_path(); // Provide debug hint as to what file is being used to verify fingerprint trust LOG((CLOG_NOTE "fingerprint_db_path: %s", fingerprint_db_path.c_str())); diff --git a/src/lib/platform/MSWindowsHook.cpp b/src/lib/platform/MSWindowsHook.cpp index b10d5c63..fce9020f 100644 --- a/src/lib/platform/MSWindowsHook.cpp +++ b/src/lib/platform/MSWindowsHook.cpp @@ -574,7 +574,7 @@ MSWindowsHook::install() g_fakeServerInput = false; // setup immune keys - g_immuneKeysPath = DataDirectories::profile() + "\\ImmuneKeys.txt"; + g_immuneKeysPath = barrier::DataDirectories::profile() + "\\ImmuneKeys.txt"; g_immuneKeys = immune_keys_list(); LOG((CLOG_DEBUG "Found %u immune keys in %s", g_immuneKeys.size(), g_immuneKeysPath.c_str()));