diff --git a/configure.ac b/configure.ac index c6e6d432..fef05085 100644 --- a/configure.ac +++ b/configure.ac @@ -92,7 +92,7 @@ AC_C_CHAR_UNSIGNED ### Checks for library functions -AC_CHECK_FUNCS(getaddrinfo) +AC_CHECK_FUNCS(getaddrinfo getpass) MY_FUNC_MAKECONTEXT diff --git a/src/client/configure.ac b/src/client/configure.ac index 4adf3a12..2dc6a677 100644 --- a/src/client/configure.ac +++ b/src/client/configure.ac @@ -81,7 +81,7 @@ AC_MSG_RESULT([$Windows_res]) ### Checks for library functions. -AC_CHECK_FUNCS(getaddrinfo) +AC_CHECK_FUNCS(getaddrinfo getpass) ### Site configuration diff --git a/src/client/login.c b/src/client/login.c index 9ec9d530..350e6449 100644 --- a/src/client/login.c +++ b/src/client/login.c @@ -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) diff --git a/src/client/sysdep_w32.c b/src/client/sysdep_w32.c index 12cbaee7..a703c228 100644 --- a/src/client/sysdep_w32.c +++ b/src/client/sysdep_w32.c @@ -204,35 +204,6 @@ w32_close_socket(int fd) return result; } -/* - * WIN32 equivalent for getpass - */ -char * -getpass(char *prompt) -{ - static char tmp[128]; - int len; - char *cpass; - DWORD mode; - HANDLE input_handle = GetStdHandle(STD_INPUT_HANDLE); - - if (GetConsoleMode(input_handle, &mode)) - SetConsoleMode(input_handle, mode & ~ENABLE_ECHO_INPUT); - else - printf("Note: This is echoed to the screen\n"); - printf("%s", prompt); - fflush(stdout); - cpass = fgets(tmp, sizeof(tmp), stdin); - if (GetConsoleMode(input_handle, &mode)) - SetConsoleMode(input_handle, mode | ENABLE_ECHO_INPUT); - if (cpass == NULL) - return NULL; - len = strlen(cpass); - if (tmp[len - 1] == '\n') - tmp[len - 1] = 0; - return cpass; -} - /* * POSIX compatible open() replacement */ diff --git a/src/client/sysdep_w32.h b/src/client/sysdep_w32.h index b5f2f719..0d576314 100644 --- a/src/client/sysdep_w32.h +++ b/src/client/sysdep_w32.h @@ -75,7 +75,6 @@ extern int w32_openfd(const char *fname, int oflag, ...); extern int w32_openhandle(const char *fname, int oflag); extern struct passwd *w32_getpw(void); -extern char *getpass(char *prompt); extern void sysdep_init(void); #define recv(sock, buffer, buf_size, flags) \