client: New get_password()
I'm going to drop use of getpass(). As a first step, weaken the bond by hiding it in a separate function. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
2ae769bec4
commit
f7ae50261f
1 changed files with 7 additions and 6 deletions
|
@ -29,7 +29,7 @@
|
||||||
* Known contributors to this file:
|
* Known contributors to this file:
|
||||||
* Dave Pare, 1989
|
* Dave Pare, 1989
|
||||||
* Steve McClure, 1998
|
* Steve McClure, 1998
|
||||||
* Markus Armbruster, 2004-2009
|
* Markus Armbruster, 2004-2020
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
@ -45,11 +45,12 @@
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "proto.h"
|
#include "proto.h"
|
||||||
|
|
||||||
#ifndef HAVE_GETPASS
|
|
||||||
#define getpass ersatz_getpass
|
|
||||||
static char *
|
static char *
|
||||||
ersatz_getpass(char *prompt)
|
get_password(const char *prompt)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_GETPASS
|
||||||
|
return getpass(prompt);
|
||||||
|
#else
|
||||||
static char buf[128];
|
static char buf[128];
|
||||||
char *p;
|
char *p;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
@ -75,8 +76,8 @@ ersatz_getpass(char *prompt)
|
||||||
if (p[len - 1] == '\n')
|
if (p[len - 1] == '\n')
|
||||||
p[len - 1] = 0;
|
p[len - 1] = 0;
|
||||||
return p;
|
return p;
|
||||||
|
#endif /* !HAVE_GETPASS */
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
int
|
int
|
||||||
login(int s, char *uname, char *cname, char *cpass,
|
login(int s, char *uname, char *cname, char *cpass,
|
||||||
|
@ -123,7 +124,7 @@ login(int s, char *uname, char *cname, char *cpass,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (cpass == NULL) {
|
if (cpass == NULL) {
|
||||||
cpass = getpass("Your name? ");
|
cpass = get_password("Your name? ");
|
||||||
if (cpass == NULL || *cpass == 0)
|
if (cpass == NULL || *cpass == 0)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue