]> granicus.if.org Git - icinga2/commitdiff
Properly escape strings in ApiUserCommand::Run
authorGunnar Beutner <gunnar.beutner@icinga.com>
Thu, 15 Feb 2018 14:48:53 +0000 (15:48 +0100)
committerJean Flach <jean-marcel.flach@icinga.com>
Fri, 16 Feb 2018 10:46:43 +0000 (11:46 +0100)
lib/cli/apiusercommand.cpp

index 8c20f55686bb165f9411be2dbd3c9b6ee48195f4..fc1ae6bc3f709528e69abfe7b88af12315e66eb5 100644 (file)
@@ -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 <iostream>
 
@@ -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"