From aef7c36099eda4bbce8a2203df3ca6665df47234 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Fri, 28 Apr 2006 15:20:23 +0000 Subject: [PATCH] add getpass for Win32 git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2985 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/console/console.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/bacula/src/console/console.c b/bacula/src/console/console.c index 9f20f6de0a..3d70727185 100644 --- a/bacula/src/console/console.c +++ b/bacula/src/console/console.c @@ -288,17 +288,29 @@ static void read_and_process_input(FILE *input, BSOCK *UA_sock) /* * Call-back for reading a passphrase for an encrypted PEM file - * This function uses getpass(), which uses a static buffer and is NOT thread-safe. + * This function uses getpass(), + * which uses a static buffer and is NOT thread-safe. */ static int tls_pem_callback(char *buf, int size, const void *userdata) { #ifdef HAVE_TLS - const char *prompt = (const char *) userdata; +# ifdef HAVE_MINGW + const char *prompt = (const char *)userdata; + sendit(prompt) + if (win32_cgets(buf, size) == NULL) { + buf[0] = 0; + return 0; + } else { + return strlen(buf); + } +# else + const char *prompt = (const char *)userdata; char *passwd; passwd = getpass(prompt); bstrncpy(buf, passwd, size); - return (strlen(buf)); + return strlen(buf); +# endif #else buf[0] = 0; return 0; -- 2.39.5