summaryrefslogtreecommitdiff
path: root/passwd
diff options
context:
space:
mode:
authorGuenter Knauf <fuankg@apache.org>2008-06-06 13:49:41 +0000
committerGuenter Knauf <fuankg@apache.org>2008-06-06 13:49:41 +0000
commit03b235647cc3ee81ee5500c91ec8182e56a75644 (patch)
treed8c9574625fc09ad2a3bcc61e8f20156232e8d85 /passwd
parentda585537dc03f9d0d2016be382a9b9b75384ddbb (diff)
downloadapr-03b235647cc3ee81ee5500c91ec8182e56a75644.tar.gz
added usage of threadsafe getpass_r();
enabled HAVE_GETPASS_R for NetWare platform. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@663941 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'passwd')
-rw-r--r--passwd/apr_getpass.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/passwd/apr_getpass.c b/passwd/apr_getpass.c
index a9d60e38a..3deb08fc0 100644
--- a/passwd/apr_getpass.c
+++ b/passwd/apr_getpass.c
@@ -70,7 +70,7 @@
#define ERR_OVERFLOW 5
-#if !defined(HAVE_GETPASS) && !defined(HAVE_GETPASSPHRASE)
+#if !defined(HAVE_GETPASS) && !defined(HAVE_GETPASSPHRASE) && !defined(HAVE_GETPASS_R)
/* MPE, Win32, NetWare and BeOS all lack a native getpass() */
@@ -202,7 +202,7 @@ static char *get_password(const char *prompt)
#endif /* no getchar or _getch */
-#endif /* no getpass */
+#endif /* no getpass or getpassphrase or getpass_r */
/*
* Use the OS getpass() routine (or our own) to obtain a password from
@@ -221,6 +221,11 @@ static char *get_password(const char *prompt)
APR_DECLARE(apr_status_t) apr_password_get(const char *prompt, char *pwbuf, apr_size_t *bufsiz)
{
+ apr_status_t rv = APR_SUCCESS;
+#if defined(HAVE_GETPASS_R)
+ if (getpass_r(prompt, pwbuf, *bufsiz) == NULL)
+ return APR_EINVAL;
+#else
#if defined(HAVE_GETPASSPHRASE)
char *pw_got = getpassphrase(prompt);
#elif defined(HAVE_GETPASS)
@@ -228,7 +233,6 @@ APR_DECLARE(apr_status_t) apr_password_get(const char *prompt, char *pwbuf, apr_
#else /* use the replacement implementation above */
char *pw_got = get_password(prompt);
#endif
- apr_status_t rv = APR_SUCCESS;
if (!pw_got)
return APR_EINVAL;
@@ -237,5 +241,6 @@ APR_DECLARE(apr_status_t) apr_password_get(const char *prompt, char *pwbuf, apr_
}
apr_cpystrn(pwbuf, pw_got, *bufsiz);
memset(pw_got, 0, strlen(pw_got));
+#endif /* HAVE_GETPASS_R */
return rv;
}