mirror of
https://github.com/znc/znc.git
synced 2026-07-04 17:01:23 +02:00
Use termios instead of deprecated getpass().
Fix build on cygwin
(cherry picked from commit f3762e8b05)
This commit is contained in:
+1
-1
@@ -240,7 +240,7 @@ if test "$POLL" = "yes"; then
|
||||
fi
|
||||
|
||||
AC_CHECK_LIB( gnugetopt, getopt_long,)
|
||||
AC_CHECK_FUNCS([lstat getopt_long getpassphrase])
|
||||
AC_CHECK_FUNCS([lstat getopt_long getpassphrase tcsetattr])
|
||||
|
||||
# ----- Check for dlopen
|
||||
|
||||
|
||||
@@ -31,6 +31,10 @@
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
|
||||
#ifdef HAVE_TCSETATTR
|
||||
#include <termios.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ICU
|
||||
#include <unicode/ucnv.h>
|
||||
#include <unicode/errorcode.h>
|
||||
@@ -197,12 +201,29 @@ CString CUtils::SaltedSHA256Hash(const CString& sPass, const CString& sSalt) {
|
||||
}
|
||||
|
||||
CString CUtils::GetPass(const CString& sPrompt) {
|
||||
#ifdef HAVE_TCSETATTR
|
||||
// Disable echo
|
||||
struct termios t;
|
||||
tcgetattr(1, &t);
|
||||
struct termios t2 = t;
|
||||
t2.c_lflag &= ~ECHO;
|
||||
tcsetattr(1, TCSANOW, &t2);
|
||||
// Read pass
|
||||
CString r;
|
||||
GetInput(sPrompt, r);
|
||||
// Restore echo and go to new line
|
||||
tcsetattr(1, TCSANOW, &t);
|
||||
fprintf(stdout, "\n");
|
||||
fflush(stdout);
|
||||
return r;
|
||||
#else
|
||||
PrintPrompt(sPrompt);
|
||||
#ifdef HAVE_GETPASSPHRASE
|
||||
return getpassphrase("");
|
||||
#else
|
||||
return getpass("");
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
bool CUtils::GetBoolInput(const CString& sPrompt, bool bDefault) {
|
||||
|
||||
Reference in New Issue
Block a user