|
|
@ -42,12 +42,10 @@
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_READLINE
|
|
|
|
|
|
|
|
#include "readline_buffer.h"
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "memwipe.h"
|
|
|
|
#include "memwipe.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define EOT 0x4
|
|
|
|
|
|
|
|
|
|
|
|
namespace
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#if defined(_WIN32)
|
|
|
|
#if defined(_WIN32)
|
|
|
@ -134,7 +132,7 @@ namespace
|
|
|
|
while (aPass.size() < tools::password_container::max_password_size)
|
|
|
|
while (aPass.size() < tools::password_container::max_password_size)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int ch = getch();
|
|
|
|
int ch = getch();
|
|
|
|
if (EOF == ch)
|
|
|
|
if (EOF == ch || ch == EOT)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -229,13 +227,20 @@ namespace tools
|
|
|
|
m_password.clear();
|
|
|
|
m_password.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::atomic<bool> password_container::is_prompting(false);
|
|
|
|
|
|
|
|
|
|
|
|
boost::optional<password_container> password_container::prompt(const bool verify, const char *message)
|
|
|
|
boost::optional<password_container> password_container::prompt(const bool verify, const char *message)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
is_prompting = true;
|
|
|
|
password_container pass1{};
|
|
|
|
password_container pass1{};
|
|
|
|
password_container pass2{};
|
|
|
|
password_container pass2{};
|
|
|
|
if (is_cin_tty() ? read_from_tty(verify, message, pass1.m_password, pass2.m_password) : read_from_file(pass1.m_password))
|
|
|
|
if (is_cin_tty() ? read_from_tty(verify, message, pass1.m_password, pass2.m_password) : read_from_file(pass1.m_password))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
is_prompting = false;
|
|
|
|
return {std::move(pass1)};
|
|
|
|
return {std::move(pass1)};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
is_prompting = false;
|
|
|
|
return boost::none;
|
|
|
|
return boost::none;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|