lib/common: Move DataDirectories to barrier namespace
This commit is contained in:
parent
677612d342
commit
298980fa86
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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())) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -15,10 +15,13 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#ifndef BARRIER_LIB_COMMON_DATA_DIRECTORIES_H
|
||||
#define BARRIER_LIB_COMMON_DATA_DIRECTORIES_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace barrier {
|
||||
|
||||
class DataDirectories
|
||||
{
|
||||
public:
|
||||
|
@ -40,3 +43,7 @@ private:
|
|||
static std::string _global;
|
||||
static std::string _systemconfig;
|
||||
};
|
||||
|
||||
} // namespace barrier
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#include <sys/types.h> // getpwuid(_r)
|
||||
#include <pwd.h> // 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
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
#include <Shlobj.h>
|
||||
|
||||
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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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()));
|
||||
|
|
|
@ -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()));
|
||||
|
||||
|
|
Loading…
Reference in New Issue