From: Jean Flach Date: Tue, 20 Feb 2018 08:45:55 +0000 (+0100) Subject: Fix crash in api user command X-Git-Tag: v2.8.3~27^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=08eb3ef99122b72238c6f7e54015ed5604b39050;p=icinga2 Fix crash in api user command Missing backport in support/2.8 fixes #6178 --- diff --git a/lib/cli/apiusercommand.cpp b/lib/cli/apiusercommand.cpp index 188691ae0..5bd77ab89 100644 --- a/lib/cli/apiusercommand.cpp +++ b/lib/cli/apiusercommand.cpp @@ -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& 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(); + } if (!vm.count("password")) { Log(LogCritical, "cli", "Password (--password) must be specified."); return 1; } - passwd = vm["passwd"].as(); + passwd = vm["password"].as(); salt = vm.count("salt") ? String(vm["salt"].as()) : 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::cout << "{\n" << " password_hash = ";