Skip to content

Commit

Permalink
node/cli: more flexible key/pass cfg
Browse files Browse the repository at this point in the history
  • Loading branch information
valdok committed Jun 14, 2023
1 parent 3e93aeb commit f956d38
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions beam/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,26 +438,30 @@ int main(int argc, char* argv[])
auto& vRes = node.m_Keys.m_vExtraOwners; // alias
assert(vRes.empty());

std::vector<std::string> vPasses;
if (vm.count(cli::MULTI_PASSES))
{
auto vPasses = vm[cli::MULTI_PASSES].as<std::vector<std::string> >();

if (vPasses.size() > vKeys.size())
vPasses.resize(vKeys.size());
vPasses = vm[cli::MULTI_PASSES].as<std::vector<std::string> >();

for (auto& sPass : vPasses)
vRes.push_back(ImportPKeyStrict(vKeys[vRes.size()], Blob(sPass.c_str(), static_cast<uint32_t>(sPass.size()))));
}
vPasses.resize(vKeys.size()); // ignore redundant, add empty for missing

while (vRes.size() < vKeys.size())
{
std::ostringstream osPrompt;
osPrompt << "Enter password for extra key " << vRes.size() << ": ";
auto& sPass = vPasses[vRes.size()];
SecString ssPass;
Blob blob;

SecString pass;
read_password(osPrompt.str().c_str(), pass);
if (sPass.empty())
{
std::ostringstream osPrompt;
osPrompt << "Enter password for extra key " << vRes.size() << ": ";

read_password(osPrompt.str().c_str(), ssPass);
blob = Blob(ssPass.data(), (uint32_t) ssPass.size());
}
else
blob = Blob(sPass.c_str(), (uint32_t) sPass.size());

vRes.push_back(ImportPKeyStrict(vKeys[vRes.size()], Blob(pass.data(), static_cast<uint32_t>(pass.size()))));
vRes.push_back(ImportPKeyStrict(vKeys[vRes.size()], blob));
}
}

Expand Down

0 comments on commit f956d38

Please sign in to comment.