Commit 7cd1a123 authored by Niels Möller's avatar Niels Möller
Browse files

Use C library function getpass().

Rev: src/client_password.c:1.3
parent 59601e35
......@@ -24,6 +24,7 @@
#include "password.h"
#include "format.h"
#include "xalloc.h"
#include "werror.h"
......@@ -36,7 +37,32 @@
#include <errno.h>
#include <termios.h>
#include <pwd.h>
struct lsh_string *read_password(int max_length,
struct lsh_string *prompt, int free)
{
/* NOTE: Ignores max_length; instead getpass()'s limit applies. */
char *password;
prompt = make_cstring(prompt, free);
if (!prompt)
return 0;
/* NOTE: This function uses a static buffer. */
password = getpass(prompt->data);
lsh_string_free(prompt);
if (!password)
return 0;
return format_cstring(password);
}
#if 0
static int echo_on(int fd)
{
struct termios t;
......@@ -127,3 +153,4 @@ struct lsh_string *read_password(int max_length, struct lsh_string *prompt)
return res;
}
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment