Replace missing getpass()
getpass() is traditional Unix, but has been withdrawn from POSIX. As such, it may be missing. Check for that, and provide ersatz. It's not a real replacement, because it doesn't do the special magic getpass() is supposed to do: read from /dev/tty without echo. This bypasses our existing getpass() for Windows. In contrast to the portable getpass(), the Windows one tries to turn off echo, but that doesn't work for me (MinGW & Wine). Remove it.
This commit is contained in:
parent
b65395d6f4
commit
8c3b8d107d
5 changed files with 24 additions and 32 deletions
|
@ -44,6 +44,28 @@
|
|||
#include "misc.h"
|
||||
#include "proto.h"
|
||||
|
||||
#ifndef HAVE_GETPASS
|
||||
#define getpass ersatz_getpass
|
||||
static char *
|
||||
ersatz_getpass(char *prompt)
|
||||
{
|
||||
static char buf[128];
|
||||
char *p;
|
||||
size_t len;
|
||||
|
||||
printf("Note: your input is echoed to the screen\n");
|
||||
printf("Your name? ");
|
||||
fflush(stdout);
|
||||
p = fgets(buf, sizeof(buf), stdin);
|
||||
if (!p)
|
||||
return NULL;
|
||||
len = strlen(p);
|
||||
if (p[len - 1] == '\n')
|
||||
p[len - 1] = 0;
|
||||
return p;
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
login(int s, char *uname, char *cname, char *cpass,
|
||||
int kill_proc, int utf8)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue