Hi, I've just introduced getpass_r() in apr_getpass.c, and ifdef'd with HAVE_GETPASS_R; I need this on NetWare platform where the existing stuff doesnt work properly. Since getpass_r() should be threadsafe I thought it might be useful for other platforms too; if not then let me know and I will ifdef with the NETWARE macro. Please review my changes.
Thanks, Guen. > Author: fuankg > Date: Fri Jun 6 06:49:41 2008 > New Revision: 663941 > URL: http://svn.apache.org/viewvc?rev=663941&view=rev > Log: > added usage of threadsafe getpass_r(); > enabled HAVE_GETPASS_R for NetWare platform. > Modified: > apr/apr/trunk/include/arch/netware/apr_private.h > apr/apr/trunk/passwd/apr_getpass.c > Modified: apr/apr/trunk/include/arch/netware/apr_private.h > URL: http://svn.apache.org/viewvc/apr/apr/trunk/include/arch/netware/apr_p > rivate.h?rev=663941&r1=663940&r2=663941&view=diff > ========================================================================== > ==== > --- apr/apr/trunk/include/arch/netware/apr_private.h (original) > +++ apr/apr/trunk/include/arch/netware/apr_private.h Fri Jun 6 06:49:41 > 2008 > @@ -70,6 +70,15 @@ > #define HAVE_WRITEV 1 > +#define HAVE_GETPASS_R 1 > +/* > + * check for older NDKs which have only the getpassword() function. > + */ > +#include <ndkvers.h> > +#if (CURRENT_NDK_THRESHOLD < 709060000) > +#define getpass_r getpassword > +#endif > + > /* 64-bit integer conversion function */ > #define APR_INT64_STRFN strtoll > Modified: apr/apr/trunk/passwd/apr_getpass.c > URL: http://svn.apache.org/viewvc/apr/apr/trunk/passwd/apr_getpass.c?rev=6 > 63941&r1=663940&r2=663941&view=diff > ========================================================================== > ==== > --- apr/apr/trunk/passwd/apr_getpass.c (original) > +++ apr/apr/trunk/passwd/apr_getpass.c Fri Jun 6 06:49:41 2008 > @@ -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 @@ > #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 @@ > 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 @@ > #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_cpystrn(pwbuf, pw_got, *bufsiz); > memset(pw_got, 0, strlen(pw_got)); > +#endif /* HAVE_GETPASS_R */ > return rv; > }
