]> granicus.if.org Git - icinga2/commitdiff
Fix crash in api user command 6179/head
authorJean Flach <jean-marcel.flach@icinga.com>
Tue, 20 Feb 2018 08:45:55 +0000 (09:45 +0100)
committerMichael Friedrich <michael.friedrich@icinga.com>
Fri, 23 Mar 2018 11:13:41 +0000 (12:13 +0100)
Missing backport in support/2.8

fixes #6178

lib/cli/apiusercommand.cpp

index 188691ae0dd8efd8c4bd213e700e9758d2ae539d..5bd77ab8912c504178aaf58f2d725c268e6703ef 100644 (file)
@@ -56,19 +56,18 @@ void ApiUserCommand::InitParameters(boost::program_options::options_description&
  */
 int ApiUserCommand::Run(const boost::program_options::variables_map& vm, const std::vector<std::string>& ap) const
 {
-       String user, passwd, salt;
+       String passwd, salt;
        if (!vm.count("user") && !vm.count("oneline")) {
                Log(LogCritical, "cli", "Username (--user) must be specified.");
                return 1;
-       } else
-               user = vm["user"].as<std::string>();
+       }
 
        if (!vm.count("password")) {
                Log(LogCritical, "cli", "Password (--password) must be specified.");
                return 1;
        }
 
-       passwd = vm["passwd"].as<std::string>();
+       passwd = vm["password"].as<std::string>();
        salt = vm.count("salt") ? String(vm["salt"].as<std::string>()) : RandomString(8);
 
        if (salt.FindFirstOf('$') != String::NPos) {
@@ -83,11 +82,11 @@ int ApiUserCommand::Run(const boost::program_options::variables_map& vm, const s
        }
 
        if (vm.count("oneline"))
-               std::cout << '"' << hashedPassword << "\"\n";
+               std::cout << hashedPassword << std::endl;
        else {
                std::cout << "object ApiUser ";
 
-               ConfigWriter::EmitString(std::cout, user);
+               ConfigWriter::EmitString(std::cout, vm["user"].as<std::string>());
 
                std::cout << "{\n"
                        << "  password_hash = ";