mturk       2005/06/01 04:22:16

  Modified:    jni/native/src sslcontext.c sslutils.c
  Log:
  Do not set 'stdin' as default BIO for password promt. Use conio for
  WIN32 (curses will be added for posix).
  
  Revision  Changes    Path
  1.8       +1 -11     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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- sslcontext.c      1 Jun 2005 10:45:03 -0000       1.7
  +++ sslcontext.c      1 Jun 2005 11:22:16 -0000       1.8
  @@ -107,13 +107,8 @@
       c->ctx  = ctx;
       c->pool = p;
       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 = SSL_BIO_FLAG_RDONLY;
  -    }
       SSL_CTX_set_options(c->ctx, SSL_OP_ALL);
       if (!(protocol & SSL_PROTOCOL_SSLV2))
           SSL_CTX_set_options(c->ctx, SSL_OP_NO_SSLv2);
  @@ -184,13 +179,8 @@
       c->ctx  = ctx;
       c->pool = p;
       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 = SSL_BIO_FLAG_RDONLY;
  -    }
       SSL_CTX_set_options(c->ctx, SSL_OP_ALL);
       if (!(protocol & SSL_PROTOCOL_SSLV2))
           SSL_CTX_set_options(c->ctx, SSL_OP_NO_SSLv2);
  
  
  
  1.7       +23 -2     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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- sslutils.c        1 Jun 2005 10:45:03 -0000       1.6
  +++ sslutils.c        1 Jun 2005 11:22:16 -0000       1.7
  @@ -104,7 +104,8 @@
   int SSL_password_prompt(tcn_ssl_ctxt_t *c, char *buf, int len)
   {
       int rv = 0;
  -    if (c && c->bio_is) {
  +    *buf = '\0';
  +    if (c->bio_is) {
           if (c->bio_is->flags & SSL_BIO_FLAG_RDONLY) {
               /* Use error BIO in case of stdin */
               BIO_printf(c->bio_os, "Enter password: ");
  @@ -125,6 +126,26 @@
               }
           }
       }
  +    else {
  +#ifdef WIN32
  +        #include <conio.h>
  +        int ch;
  +        BIO_printf(c->bio_os, "Enter password: ");
  +        do {
  +            ch = getch();
  +            if (ch == '\r')
  +                break;
  +            fputc('*', stdout);
  +            buf[rv++] = ch;
  +            if (rv + 1 > len)
  +                continue;
  +        } while (ch != '\n');
  +        buf[rv] = '\0';
  +        fputc('\n', stdout);
  +        fflush(stdout);
  +#endif
  +
  +    }
       return rv;
   }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to