mturk 2005/06/01 02:05:08
Modified: jni/native/include ssl_private.h
jni/native/src sslcontext.c sslutils.c
Log:
Rename BIO struct members and strip any CRLF from the prompted password.
Revision Changes Path
1.7 +3 -3
jakarta-tomcat-connectors/jni/native/include/ssl_private.h
Index: ssl_private.h
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-connectors/jni/native/include/ssl_private.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ssl_private.h 1 Jun 2005 08:19:39 -0000 1.6
+++ ssl_private.h 1 Jun 2005 09:05:08 -0000 1.7
@@ -110,8 +110,8 @@
struct tcn_ssl_ctxt {
apr_pool_t *pool;
SSL_CTX *ctx;
- BIO *bio_err;
- BIO *pprompt;
+ BIO *bio_os;
+ BIO *bio_is;
unsigned char vhost_id[MD5_DIGEST_LENGTH];
int protocol;
1.6 +29 -29 jakarta-tomcat-connectors/jni/native/src/sslcontext.c
Index: sslcontext.c
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jni/native/src/sslcontext.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- sslcontext.c 1 Jun 2005 08:19:39 -0000 1.5
+++ sslcontext.c 1 Jun 2005 09:05:08 -0000 1.6
@@ -57,12 +57,12 @@
sk_X509_INFO_pop_free(c->pk.c.certs, X509_INFO_free);
c->pk.c.certs = NULL;
}
- if (c->pprompt)
- BIO_free(c->pprompt);
- c->pprompt = NULL;
- if (c->bio_err)
- BIO_free(c->bio_err);
- c->bio_err = NULL;
+ if (c->bio_is)
+ BIO_free(c->bio_is);
+ c->bio_is = NULL;
+ if (c->bio_os)
+ BIO_free(c->bio_os);
+ c->bio_os = NULL;
}
return APR_SUCCESS;
}
@@ -105,13 +105,13 @@
c->mode = 1;
c->ctx = ctx;
c->pool = p;
- c->bio_err = BIO_new(BIO_s_file());
- c->pprompt = BIO_new(BIO_s_file());
- if (c->bio_err != NULL)
- BIO_set_fp(c->bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
- if (c->pprompt != NULL) {
- BIO_set_fp(c->bio_err, stdin, BIO_NOCLOSE | BIO_FP_TEXT);
- c->pprompt->flags = BIO_FLAGS_MEM_RDONLY;
+ c->bio_os = BIO_new(BIO_s_file());
+ c->bio_is = BIO_new(BIO_s_file());
+ if (c->bio_os != NULL)
+ BIO_set_fp(c->bio_os, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
+ if (c->bio_is != NULL) {
+ BIO_set_fp(c->bio_is, stdin, BIO_NOCLOSE | BIO_FP_TEXT);
+ c->bio_is->flags = BIO_FLAGS_MEM_RDONLY;
}
SSL_CTX_set_options(c->ctx, SSL_OP_ALL);
if (!(protocol & SSL_PROTOCOL_SSLV2))
@@ -182,13 +182,13 @@
c->mode = 0;
c->ctx = ctx;
c->pool = p;
- c->bio_err = BIO_new(BIO_s_file());
- c->pprompt = BIO_new(BIO_s_file());
- if (c->bio_err != NULL)
- BIO_set_fp(c->bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
- if (c->pprompt != NULL) {
- BIO_set_fp(c->bio_err, stdin, BIO_NOCLOSE | BIO_FP_TEXT);
- c->pprompt->flags = BIO_FLAGS_MEM_RDONLY;
+ c->bio_os = BIO_new(BIO_s_file());
+ c->bio_is = BIO_new(BIO_s_file());
+ if (c->bio_os != NULL)
+ BIO_set_fp(c->bio_os, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
+ if (c->bio_is != NULL) {
+ BIO_set_fp(c->bio_is, stdin, BIO_NOCLOSE | BIO_FP_TEXT);
+ c->bio_is->flags = BIO_FLAGS_MEM_RDONLY;
}
SSL_CTX_set_options(c->ctx, SSL_OP_ALL);
if (!(protocol & SSL_PROTOCOL_SSLV2))
@@ -249,26 +249,26 @@
jlong bio)
{
tcn_ssl_ctxt_t *c = J2P(ctx, tcn_ssl_ctxt_t *);
- BIO *bio_err = J2P(bio, BIO *);
+ BIO *bio_os = J2P(bio, BIO *);
UNREFERENCED_STDARGS;
TCN_ASSERT(ctx != 0);
- if (c->bio_err && c->bio_err != bio_err)
- BIO_free(c->bio_err);
- c->bio_err = bio_err;
+ if (c->bio_os && c->bio_os != bio_os)
+ BIO_free(c->bio_os);
+ c->bio_os = bio_os;
}
TCN_IMPLEMENT_CALL(void, SSLContext, setPPromptBIO)(TCN_STDARGS, jlong ctx,
jlong bio)
{
tcn_ssl_ctxt_t *c = J2P(ctx, tcn_ssl_ctxt_t *);
- BIO *pprompt = J2P(bio, BIO *);
+ BIO *bio_is = J2P(bio, BIO *);
UNREFERENCED_STDARGS;
TCN_ASSERT(ctx != 0);
- if (c->pprompt && c->pprompt != pprompt)
- BIO_free(c->pprompt);
- c->pprompt = pprompt;
+ if (c->bio_is && c->bio_is != bio_is)
+ BIO_free(c->bio_is);
+ c->bio_is = bio_is;
}
1.5 +20 -6 jakarta-tomcat-connectors/jni/native/src/sslutils.c
Index: sslutils.c
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/jni/native/src/sslutils.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- sslutils.c 1 Jun 2005 08:19:39 -0000 1.4
+++ sslutils.c 1 Jun 2005 09:05:08 -0000 1.5
@@ -100,16 +100,30 @@
return APR_SUCCESS;
}
-/* Simple password prompting */
+/* Simple echo password prompting */
int SSL_password_prompt(tcn_ssl_ctxt_t *c, char *buf, int len)
{
int rv = 0;
- if (c && c->pprompt) {
- if (c->pprompt->flags & BIO_FLAGS_MEM_RDONLY) {
+ if (c && c->bio_is) {
+ if (c->bio_is->flags & BIO_FLAGS_MEM_RDONLY) {
/* Use error BIO in case of stdin */
- BIO_printf(c->bio_err, "Enter password: ");
+ BIO_printf(c->bio_os, "Enter password: ");
+ }
+ rv = BIO_gets(c->bio_is, buf, len);
+ if (rv > 0) {
+ /* Remove LF chars */
+ char *r = strchr(buf, '\n');
+ if (r) {
+ *r = '\0';
+ rv--;
+ }
+ /* Remove CR chars */
+ r = strchr(buf, '\r');
+ if (r) {
+ *r = '\0';
+ rv--;
+ }
}
- rv = BIO_gets(c->pprompt, buf, len);
}
return rv;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]