refactor: move peerCert option to coreArgs
This commit is contained in:
parent
cfd580fb21
commit
cfedfc2c1e
8 changed files with 39 additions and 26 deletions
|
|
@ -37,8 +37,6 @@ bool ArgParser::parseServerArgs(deskflow::ServerArgs &args, int argc, const char
|
||||||
} else if (isArg(i, argc, argv, "-c", "--config", 1)) {
|
} else if (isArg(i, argc, argv, "-c", "--config", 1)) {
|
||||||
// save configuration file path
|
// save configuration file path
|
||||||
args.m_configFile = argv[++i];
|
args.m_configFile = argv[++i];
|
||||||
} else if (isArg(i, argc, argv, nullptr, "--disable-client-cert-check")) {
|
|
||||||
args.m_chkPeerCert = false;
|
|
||||||
} else {
|
} else {
|
||||||
LOG_CRIT("%s: unrecognized option `%s'" BYE, "deskflow-core", argv[i], "deskflow-core");
|
LOG_CRIT("%s: unrecognized option `%s'" BYE, "deskflow-core", argv[i], "deskflow-core");
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,13 @@ void CoreArgParser::parse()
|
||||||
(m_parser.value(CoreArgs::useHooksOption) == "1"));
|
(m_parser.value(CoreArgs::useHooksOption) == "1"));
|
||||||
Settings::setValue(Settings::Core::UseHooks, value);
|
Settings::setValue(Settings::Core::UseHooks, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_parser.isSet(CoreArgs::peerCheckOption)) {
|
||||||
|
bool value =
|
||||||
|
((m_parser.value(CoreArgs::peerCheckOption).toLower() == "true") ||
|
||||||
|
(m_parser.value(CoreArgs::peerCheckOption) == "1"));
|
||||||
|
Settings::setValue(Settings::Security::CheckPeers, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[[noreturn]] void CoreArgParser::showHelpText() const
|
[[noreturn]] void CoreArgParser::showHelpText() const
|
||||||
|
|
|
||||||
|
|
@ -58,20 +58,13 @@ struct CoreArgs
|
||||||
inline static const auto useHooksOption =
|
inline static const auto useHooksOption =
|
||||||
QCommandLineOption("useHooks", "Sets if hooks are used for windows desks", "value");
|
QCommandLineOption("useHooks", "Sets if hooks are used for windows desks", "value");
|
||||||
|
|
||||||
inline static const auto options = {
|
// Server Options
|
||||||
helpOption,
|
inline static const auto peerCheckOption = QCommandLineOption(
|
||||||
versionOption,
|
"peerCertCheck", "Server Mode: Enable client SSL certificate checking (default: true)", "value"
|
||||||
configOption,
|
);
|
||||||
interfaceOption,
|
|
||||||
portOption,
|
inline static const auto options = {helpOption, versionOption, configOption, interfaceOption,
|
||||||
nameOption,
|
portOption, nameOption, logLevelOption, logFileOption,
|
||||||
logLevelOption,
|
secureOption, tlsCertOption, preventSleepOption, restartOption,
|
||||||
logFileOption,
|
displayOption, useHooksOption, peerCheckOption};
|
||||||
secureOption,
|
|
||||||
tlsCertOption,
|
|
||||||
preventSleepOption,
|
|
||||||
restartOption,
|
|
||||||
displayOption,
|
|
||||||
useHooksOption
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -107,8 +107,6 @@ void ServerApp::help()
|
||||||
help << "\n\nServer Mode:\n\n"
|
help << "\n\nServer Mode:\n\n"
|
||||||
<< "Usage: " << kAppId << "-core server \n"
|
<< "Usage: " << kAppId << "-core server \n"
|
||||||
<< " -c, --config <pathname> path of the configuration file\n"
|
<< " -c, --config <pathname> path of the configuration file\n"
|
||||||
<< " --disable-client-cert-check disable client SSL certificate \n"
|
|
||||||
" checking (deprecated)\n"
|
|
||||||
<< s_helpVersionArgs << "\n"
|
<< s_helpVersionArgs << "\n"
|
||||||
<< s_helpNoWayland;
|
<< s_helpNoWayland;
|
||||||
|
|
||||||
|
|
@ -507,7 +505,7 @@ ClientListener *ServerApp::openClientListener(const NetworkAddress &address)
|
||||||
using enum SecurityLevel;
|
using enum SecurityLevel;
|
||||||
auto securityLevel = PlainText;
|
auto securityLevel = PlainText;
|
||||||
if (Settings::value(Settings::Security::TlsEnabled).toBool()) {
|
if (Settings::value(Settings::Security::TlsEnabled).toBool()) {
|
||||||
if (args().m_chkPeerCert) {
|
if (Settings::value(Settings::Security::CheckPeers).toBool()) {
|
||||||
securityLevel = PeerAuth;
|
securityLevel = PeerAuth;
|
||||||
} else {
|
} else {
|
||||||
securityLevel = Encrypted;
|
securityLevel = Encrypted;
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,6 @@ public:
|
||||||
public:
|
public:
|
||||||
std::string m_configFile = "";
|
std::string m_configFile = "";
|
||||||
std::shared_ptr<Config> m_config;
|
std::shared_ptr<Config> m_config;
|
||||||
bool m_chkPeerCert = true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace deskflow
|
} // namespace deskflow
|
||||||
|
|
|
||||||
|
|
@ -459,10 +459,6 @@ bool CoreProcess::addServerArgs(QStringList &args)
|
||||||
args << "--log" << Settings::value(Settings::Log::File).toString();
|
args << "--log" << Settings::value(Settings::Log::File).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Settings::value(Settings::Security::CheckPeers).toBool()) {
|
|
||||||
args << "--disable-client-cert-check";
|
|
||||||
}
|
|
||||||
|
|
||||||
QString configFilename = persistServerConfig();
|
QString configFilename = persistServerConfig();
|
||||||
if (configFilename.isEmpty()) {
|
if (configFilename.isEmpty()) {
|
||||||
qFatal("config file name empty for server args");
|
qFatal("config file name empty for server args");
|
||||||
|
|
|
||||||
|
|
@ -290,6 +290,26 @@ void CoreArgParserTests::hookOptions_true()
|
||||||
QVERIFY(Settings::value(Settings::Core::UseHooks).toBool());
|
QVERIFY(Settings::value(Settings::Core::UseHooks).toBool());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CoreArgParserTests::server_peerCheck_false()
|
||||||
|
{
|
||||||
|
QStringList args = {"stub", "server", "--peerCertCheck", "false"};
|
||||||
|
|
||||||
|
CoreArgParser parser(args);
|
||||||
|
parser.parse();
|
||||||
|
|
||||||
|
QVERIFY(!Settings::value(Settings::Security::CheckPeers).toBool());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CoreArgParserTests::server_peerCheck_true()
|
||||||
|
{
|
||||||
|
QStringList args = {"stub", "server", "--peerCertCheck", "true"};
|
||||||
|
|
||||||
|
CoreArgParser parser(args);
|
||||||
|
parser.parse();
|
||||||
|
|
||||||
|
QVERIFY(Settings::value(Settings::Security::CheckPeers).toBool());
|
||||||
|
}
|
||||||
|
|
||||||
void CoreArgParserTests::preventSleep_true()
|
void CoreArgParserTests::preventSleep_true()
|
||||||
{
|
{
|
||||||
QStringList args = {"stub", "client", "--prevent-sleep", "true"};
|
QStringList args = {"stub", "client", "--prevent-sleep", "true"};
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,8 @@ private Q_SLOTS:
|
||||||
void restartShortOption_true();
|
void restartShortOption_true();
|
||||||
void hookOptions_false();
|
void hookOptions_false();
|
||||||
void hookOptions_true();
|
void hookOptions_true();
|
||||||
|
void server_peerCheck_false();
|
||||||
|
void server_peerCheck_true();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
inline static const QString m_settingsPath = QStringLiteral("tmp/test");
|
inline static const QString m_settingsPath = QStringLiteral("tmp/test");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue