On Thu, Sep 23, 2010 at 09:33:48AM -0500, Kent Yoder wrote:
> > I was hoping we could make this simpler (and more standardized) if we
> > simply use getpass(3), without worrying about echoing stars or
> > anything else.
> > 
> > Even if getpass() is marked as obsolete, the idea behind it is
> > sufficiently simple to implement it by our own if needed.
> 
>   Yeah, I avoided it as soon as I saw the manpage, but not echoing
> anything makes this patch even simpler, all we'll need to do is 
> count-- when we see backspace or delete.

Here's patch without echoing:

diff --git a/usr/sbin/pkcsconf/pkcsconf.c b/usr/sbin/pkcsconf/pkcsconf.c
index f94ecfa..79e8313 100755
--- a/usr/sbin/pkcsconf/pkcsconf.c
+++ b/usr/sbin/pkcsconf/pkcsconf.c
@@ -647,20 +647,16 @@ int get_pin(CK_CHAR **pin)
        /* Turn off echoing to the terminal when getting the password */
        echo(FALSE);
        /* Get each character and print out a '*' for each input */
-       for (count = 0; (c != LINE_FEED) && (count < PIN_SIZE); count++) {
+       for (count = 0; (c != LINE_FEED) && (count < PIN_SIZE);) {
                buff[count] = getc(stdin);
                c = buff[count];
                if (c == BACK_SPACE || c == DELETE) {
-                       printf("\nBackspace and delete character not allowed. "
-                              "Please retry entering your PIN.\n");
-                       rc = -EINVAL;
-                       echo(TRUE);
-                       fflush(stdout);
-                       goto out;
+                       if (count)
+                               count--;
+                       continue;
                }
-               if ((c != LINE_FEED))
-                       printf("*");
                fflush(stdout);
+               count++;
        }
        echo(TRUE);
        /* After we get the password go to the next line */

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Opencryptoki-tech mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opencryptoki-tech

Reply via email to