From: Gunnar Beutner Date: Thu, 15 Feb 2018 14:48:53 +0000 (+0100) Subject: Properly escape strings in ApiUserCommand::Run X-Git-Tag: v2.9.0~155^2~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f4403daef88ad7bb44bbb8f8f184626d9d3d128f;p=icinga2 Properly escape strings in ApiUserCommand::Run --- diff --git a/lib/cli/apiusercommand.cpp b/lib/cli/apiusercommand.cpp index 8c20f5568..fc1ae6bc3 100644 --- a/lib/cli/apiusercommand.cpp +++ b/lib/cli/apiusercommand.cpp @@ -20,6 +20,7 @@ #include "cli/apiusercommand.hpp" #include "base/logger.hpp" #include "base/tlsutility.hpp" +#include "base/configwriter.hpp" #include "remote/apiuser.hpp" #include @@ -81,9 +82,16 @@ int ApiUserCommand::Run(const boost::program_options::variables_map& vm, const s if (vm.count("oneline")) std::cout << '"' << hashedPassword << "\"\n"; else { - std::cout - << "object ApiUser \"" << user << "\" {\n" - << " password_hash =\"" << hashedPassword << "\"\n" + std::cout << "object ApiUser "; + + ConfigWriter::EmitString(std::cout, user); + + std::cout << "{\n" + << " password_hash = "; + + ConfigWriter::EmitString(std::cout, hashedPassword); + + std::cout << "\n" << " // client_cn = \"\"\n" << "\n" << " permissions = [ \"*\" ]\n"