mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-24 22:24:44 +02:00
parent
5bbc8cacbd
commit
f1a1dfb26e
@ -502,9 +502,8 @@ static String UnameHelper(char type)
|
|||||||
pclose(fp);
|
pclose(fp);
|
||||||
|
|
||||||
String result = msgbuf.str();
|
String result = msgbuf.str();
|
||||||
result.Trim();
|
|
||||||
|
|
||||||
return result;
|
return result.Trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ReleaseHelper(std::string &result)
|
int ReleaseHelper(std::string &result)
|
||||||
|
@ -271,23 +271,20 @@ int NodeUtility::GenerateNodeIcingaConfig(const std::vector<std::string>& endpoi
|
|||||||
Dictionary::Ptr my_master_endpoint = new Dictionary();
|
Dictionary::Ptr my_master_endpoint = new Dictionary();
|
||||||
|
|
||||||
if (tokens.size() > 1) {
|
if (tokens.size() > 1) {
|
||||||
String host = tokens[1];
|
String host = tokens[1].Trim();
|
||||||
host.Trim();
|
|
||||||
|
|
||||||
if (!host.IsEmpty())
|
if (!host.IsEmpty())
|
||||||
my_master_endpoint->Set("host", host);
|
my_master_endpoint->Set("host", host);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tokens.size() > 2) {
|
if (tokens.size() > 2) {
|
||||||
String port = tokens[2];
|
String port = tokens[2].Trim();
|
||||||
port.Trim();
|
|
||||||
|
|
||||||
if (!port.IsEmpty())
|
if (!port.IsEmpty())
|
||||||
my_master_endpoint->Set("port", port);
|
my_master_endpoint->Set("port", port);
|
||||||
}
|
}
|
||||||
|
|
||||||
String cn = tokens[0];
|
String cn = tokens[0].Trim();
|
||||||
cn.Trim();
|
|
||||||
my_master_endpoint->Set("__name", cn);
|
my_master_endpoint->Set("__name", cn);
|
||||||
my_master_endpoint->Set("__type", "Endpoint");
|
my_master_endpoint->Set("__type", "Endpoint");
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ int NodeWizardCommand::Run(const boost::program_options::variables_map& vm, cons
|
|||||||
answer = Utility::GetFQDN();
|
answer = Utility::GetFQDN();
|
||||||
|
|
||||||
String cn = answer;
|
String cn = answer;
|
||||||
cn.Trim();
|
cn = cn.Trim();
|
||||||
|
|
||||||
std::cout << ConsoleColorTag(Console_Bold) << "Please specifiy the local zone name" << ConsoleColorTag(Console_Normal) << " [" << cn << "]: ";
|
std::cout << ConsoleColorTag(Console_Bold) << "Please specifiy the local zone name" << ConsoleColorTag(Console_Normal) << " [" << cn << "]: ";
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ int NodeWizardCommand::Run(const boost::program_options::variables_map& vm, cons
|
|||||||
answer = cn;
|
answer = cn;
|
||||||
|
|
||||||
String local_zone = answer;
|
String local_zone = answer;
|
||||||
local_zone.Trim();
|
local_zone = local_zone.Trim();
|
||||||
|
|
||||||
std::vector<std::string> endpoints;
|
std::vector<std::string> endpoints;
|
||||||
|
|
||||||
@ -159,7 +159,7 @@ wizard_endpoint_loop_start:
|
|||||||
}
|
}
|
||||||
|
|
||||||
endpoint_buffer = answer;
|
endpoint_buffer = answer;
|
||||||
endpoint_buffer.Trim();
|
endpoint_buffer = endpoint_buffer.Trim();
|
||||||
|
|
||||||
std::cout << "Do you want to establish a connection to the master " << ConsoleColorTag(Console_Bold) << "from this node?" << ConsoleColorTag(Console_Normal) << " [Y/n]: ";
|
std::cout << "Do you want to establish a connection to the master " << ConsoleColorTag(Console_Bold) << "from this node?" << ConsoleColorTag(Console_Normal) << " [Y/n]: ";
|
||||||
|
|
||||||
@ -183,7 +183,8 @@ wizard_endpoint_loop_start:
|
|||||||
}
|
}
|
||||||
|
|
||||||
String tmp = answer;
|
String tmp = answer;
|
||||||
tmp.Trim();
|
tmp = tmp.Trim();
|
||||||
|
|
||||||
endpoint_buffer += "," + tmp;
|
endpoint_buffer += "," + tmp;
|
||||||
master_endpoint_name = tmp; //store the endpoint name for later
|
master_endpoint_name = tmp; //store the endpoint name for later
|
||||||
|
|
||||||
@ -197,8 +198,7 @@ wizard_endpoint_loop_start:
|
|||||||
else
|
else
|
||||||
tmp = "5665";
|
tmp = "5665";
|
||||||
|
|
||||||
tmp.Trim();
|
endpoint_buffer += "," + tmp.Trim();
|
||||||
endpoint_buffer += "," + tmp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
endpoints.push_back(endpoint_buffer);
|
endpoints.push_back(endpoint_buffer);
|
||||||
@ -228,7 +228,7 @@ wizard_master_host:
|
|||||||
goto wizard_master_host;
|
goto wizard_master_host;
|
||||||
|
|
||||||
String master_host = answer;
|
String master_host = answer;
|
||||||
master_host.Trim();
|
master_host = master_host.Trim();
|
||||||
|
|
||||||
std::cout << ConsoleColorTag(Console_Bold) << "Port" << ConsoleColorTag(Console_Normal) << " [5665]: ";
|
std::cout << ConsoleColorTag(Console_Bold) << "Port" << ConsoleColorTag(Console_Normal) << " [5665]: ";
|
||||||
|
|
||||||
@ -239,7 +239,7 @@ wizard_master_host:
|
|||||||
answer = "5665";
|
answer = "5665";
|
||||||
|
|
||||||
String master_port = answer;
|
String master_port = answer;
|
||||||
master_port.Trim();
|
master_port = master_port.Trim();
|
||||||
|
|
||||||
/* workaround for fetching the master cert */
|
/* workaround for fetching the master cert */
|
||||||
String pki_path = PkiUtility::GetPkiPath();
|
String pki_path = PkiUtility::GetPkiPath();
|
||||||
@ -306,7 +306,7 @@ wizard_ticket:
|
|||||||
goto wizard_ticket;
|
goto wizard_ticket;
|
||||||
|
|
||||||
String ticket = answer;
|
String ticket = answer;
|
||||||
ticket.Trim();
|
ticket = ticket.Trim();
|
||||||
|
|
||||||
Log(LogInformation, "cli")
|
Log(LogInformation, "cli")
|
||||||
<< "Processing self-signed certificate request. Ticket '" << ticket << "'.\n";
|
<< "Processing self-signed certificate request. Ticket '" << ticket << "'.\n";
|
||||||
@ -339,7 +339,7 @@ wizard_ticket:
|
|||||||
boost::algorithm::to_lower(answer);
|
boost::algorithm::to_lower(answer);
|
||||||
|
|
||||||
String bind_host = answer;
|
String bind_host = answer;
|
||||||
bind_host.Trim();
|
bind_host = bind_host.Trim();
|
||||||
|
|
||||||
std::cout << "Bind Port []: ";
|
std::cout << "Bind Port []: ";
|
||||||
|
|
||||||
@ -347,7 +347,7 @@ wizard_ticket:
|
|||||||
boost::algorithm::to_lower(answer);
|
boost::algorithm::to_lower(answer);
|
||||||
|
|
||||||
String bind_port = answer;
|
String bind_port = answer;
|
||||||
bind_port.Trim();
|
bind_port = bind_port.Trim();
|
||||||
|
|
||||||
std::cout << ConsoleColorTag(Console_Bold) << "Accept config from master?" << ConsoleColorTag(Console_Normal) << " [y/N]: ";
|
std::cout << ConsoleColorTag(Console_Bold) << "Accept config from master?" << ConsoleColorTag(Console_Normal) << " [y/N]: ";
|
||||||
std::getline(std::cin, answer);
|
std::getline(std::cin, answer);
|
||||||
@ -449,7 +449,7 @@ wizard_ticket:
|
|||||||
answer = Utility::GetFQDN();
|
answer = Utility::GetFQDN();
|
||||||
|
|
||||||
String cn = answer;
|
String cn = answer;
|
||||||
cn.Trim();
|
cn = cn.Trim();
|
||||||
|
|
||||||
/* check whether the user wants to generate a new certificate or not */
|
/* check whether the user wants to generate a new certificate or not */
|
||||||
String existing_path = PkiUtility::GetPkiPath() + "/" + cn + ".crt";
|
String existing_path = PkiUtility::GetPkiPath() + "/" + cn + ".crt";
|
||||||
@ -481,7 +481,7 @@ wizard_ticket:
|
|||||||
boost::algorithm::to_lower(answer);
|
boost::algorithm::to_lower(answer);
|
||||||
|
|
||||||
String bind_host = answer;
|
String bind_host = answer;
|
||||||
bind_host.Trim();
|
bind_host = bind_host.Trim();
|
||||||
|
|
||||||
std::cout << ConsoleColorTag(Console_Bold) << "Bind Port" << ConsoleColorTag(Console_Normal) << " []: ";
|
std::cout << ConsoleColorTag(Console_Bold) << "Bind Port" << ConsoleColorTag(Console_Normal) << " []: ";
|
||||||
|
|
||||||
@ -489,7 +489,7 @@ wizard_ticket:
|
|||||||
boost::algorithm::to_lower(answer);
|
boost::algorithm::to_lower(answer);
|
||||||
|
|
||||||
String bind_port = answer;
|
String bind_port = answer;
|
||||||
bind_port.Trim();
|
bind_port = bind_port.Trim();
|
||||||
|
|
||||||
/* api feature is always enabled, check above */
|
/* api feature is always enabled, check above */
|
||||||
String apipath = FeatureUtility::GetFeaturesAvailablePath() + "/api.conf";
|
String apipath = FeatureUtility::GetFeaturesAvailablePath() + "/api.conf";
|
||||||
|
@ -269,8 +269,7 @@ void LegacyTimePeriod::ParseTimeRange(const String& timerange, tm *begin, tm *en
|
|||||||
size_t pos = def.FindFirstOf('/');
|
size_t pos = def.FindFirstOf('/');
|
||||||
|
|
||||||
if (pos != String::NPos) {
|
if (pos != String::NPos) {
|
||||||
String strStride = def.SubStr(pos + 1);
|
String strStride = def.SubStr(pos + 1).Trim();
|
||||||
strStride.Trim();
|
|
||||||
*stride = Convert::ToLong(strStride);
|
*stride = Convert::ToLong(strStride);
|
||||||
|
|
||||||
/* Remove the stride parameter from the definition. */
|
/* Remove the stride parameter from the definition. */
|
||||||
@ -283,11 +282,9 @@ void LegacyTimePeriod::ParseTimeRange(const String& timerange, tm *begin, tm *en
|
|||||||
pos = def.Find("- ");
|
pos = def.Find("- ");
|
||||||
|
|
||||||
if (pos != String::NPos) {
|
if (pos != String::NPos) {
|
||||||
String first = def.SubStr(0, pos);
|
String first = def.SubStr(0, pos).Trim();
|
||||||
first.Trim();
|
|
||||||
|
|
||||||
String second = def.SubStr(pos + 1);
|
String second = def.SubStr(pos + 1).Trim();
|
||||||
second.Trim();
|
|
||||||
|
|
||||||
ParseTimeSpec(first, begin, NULL, reference);
|
ParseTimeSpec(first, begin, NULL, reference);
|
||||||
|
|
||||||
|
@ -136,11 +136,8 @@ Dictionary::Ptr LivestatusLogUtility::GetAttributes(const String& text)
|
|||||||
size_t colon = text.FindFirstOf(':');
|
size_t colon = text.FindFirstOf(':');
|
||||||
size_t colon_offset = colon - 13;
|
size_t colon_offset = colon - 13;
|
||||||
|
|
||||||
String type = String(text.SubStr(13, colon_offset));
|
String type = String(text.SubStr(13, colon_offset)).Trim();
|
||||||
String options = String(text.SubStr(colon + 1));
|
String options = String(text.SubStr(colon + 1)).Trim();
|
||||||
|
|
||||||
type.Trim();
|
|
||||||
options.Trim();
|
|
||||||
|
|
||||||
bag->Set("type", type);
|
bag->Set("type", type);
|
||||||
bag->Set("options", options);
|
bag->Set("options", options);
|
||||||
|
@ -154,9 +154,7 @@ LivestatusQuery::LivestatusQuery(const std::vector<String>& lines, const String&
|
|||||||
|
|
||||||
//OutputFormat:json or OutputFormat: json
|
//OutputFormat:json or OutputFormat: json
|
||||||
if (line.GetLength() > col_index + 1)
|
if (line.GetLength() > col_index + 1)
|
||||||
params = line.SubStr(col_index + 1);
|
params = line.SubStr(col_index + 1).Trim();
|
||||||
|
|
||||||
params.Trim();
|
|
||||||
|
|
||||||
if (header == "ResponseHeader")
|
if (header == "ResponseHeader")
|
||||||
m_ResponseHeader = params;
|
m_ResponseHeader = params;
|
||||||
|
@ -67,8 +67,8 @@ void PluginCheckTask::ProcessFinishedHandler(const Checkable::Ptr& checkable, co
|
|||||||
<< pr.ExitStatus << ", output: " << pr.Output;
|
<< pr.ExitStatus << ", output: " << pr.Output;
|
||||||
}
|
}
|
||||||
|
|
||||||
String output = pr.Output;
|
String output = pr.Output.Trim();
|
||||||
output.Trim();
|
|
||||||
std::pair<String, String> co = PluginUtility::ParseCheckOutput(output);
|
std::pair<String, String> co = PluginUtility::ParseCheckOutput(output);
|
||||||
cr->SetCommand(commandLine);
|
cr->SetCommand(commandLine);
|
||||||
cr->SetOutput(co.first);
|
cr->SetOutput(co.first);
|
||||||
|
@ -243,14 +243,13 @@ String ConfigModuleUtility::GetActiveStage(const String& moduleName)
|
|||||||
|
|
||||||
String stage;
|
String stage;
|
||||||
std::getline(fp, stage.GetData());
|
std::getline(fp, stage.GetData());
|
||||||
stage.Trim();
|
|
||||||
|
|
||||||
fp.close();
|
fp.close();
|
||||||
|
|
||||||
if (fp.fail())
|
if (fp.fail())
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
return stage;
|
return stage.Trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -82,11 +82,9 @@ bool HttpRequest::Parse(const Stream::Ptr& stream, StreamReadContext& src, bool
|
|||||||
String::SizeType pos = line.FindFirstOf(":");
|
String::SizeType pos = line.FindFirstOf(":");
|
||||||
if (pos == String::NPos)
|
if (pos == String::NPos)
|
||||||
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid HTTP request"));
|
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid HTTP request"));
|
||||||
String key = line.SubStr(0, pos);
|
String key = line.SubStr(0, pos).ToLower().Trim();
|
||||||
boost::algorithm::to_lower(key);
|
|
||||||
key.Trim();
|
String value = line.SubStr(pos + 1).Trim();
|
||||||
String value = line.SubStr(pos + 1);
|
|
||||||
value.Trim();
|
|
||||||
Headers->Set(key, value);
|
Headers->Set(key, value);
|
||||||
|
|
||||||
if (key == "x-http-method-override")
|
if (key == "x-http-method-override")
|
||||||
|
@ -63,20 +63,16 @@ BOOST_AUTO_TEST_CASE(append)
|
|||||||
BOOST_AUTO_TEST_CASE(trim)
|
BOOST_AUTO_TEST_CASE(trim)
|
||||||
{
|
{
|
||||||
String s1 = "hello";
|
String s1 = "hello";
|
||||||
s1.Trim();
|
BOOST_CHECK(s1.Trim() == "hello");
|
||||||
BOOST_CHECK(s1 == "hello");
|
|
||||||
|
|
||||||
String s2 = " hello";
|
String s2 = " hello";
|
||||||
s2.Trim();
|
BOOST_CHECK(s2.Trim() == "hello");
|
||||||
BOOST_CHECK(s2 == "hello");
|
|
||||||
|
|
||||||
String s3 = "hello ";
|
String s3 = "hello ";
|
||||||
s3.Trim();
|
BOOST_CHECK(s3.Trim() == "hello");
|
||||||
BOOST_CHECK(s3 == "hello");
|
|
||||||
|
|
||||||
String s4 = " hello ";
|
String s4 = " hello ";
|
||||||
s4.Trim();
|
BOOST_CHECK(s4.Trim() == "hello");
|
||||||
BOOST_CHECK(s4 == "hello");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(contains)
|
BOOST_AUTO_TEST_CASE(contains)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user