BSD 4_4_Lite2 release
[unix-history] / usr / src / lib / libtelnet / read_password.c
index ec56935..4676ed3 100644 (file)
@@ -1,12 +1,38 @@
 /*-
 /*-
- * Copyright (c) 1992 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1992, 1993
+ *     The Regents of the University of California.  All rights reserved.
  *
  *
- * %sccs.include.redist.c%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)read_password.c    5.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)read_password.c    8.3 (Berkeley) 5/30/95";
 #endif /* not lint */
 
 /*
 #endif /* not lint */
 
 /*
@@ -24,6 +50,8 @@ static char sccsid[] = "@(#)read_password.c   5.1 (Berkeley) %G%";
  * echoing.
  */
 
  * echoing.
  */
 
+#if    defined(RSA_ENCPWD) || defined(KRB4_ENCPWD)
+
 #include <stdio.h>
 #include <strings.h>
 #include <sys/ioctl.h>
 #include <stdio.h>
 #include <strings.h>
 #include <sys/ioctl.h>
@@ -48,7 +76,7 @@ local_des_read_pw_string(s,max,prompt,verify)
 {
     int ok = 0;
     char *ptr;
 {
     int ok = 0;
     char *ptr;
-    
+
     jmp_buf old_env;
     struct sgttyb tty_state;
     char key_string[BUFSIZ];
     jmp_buf old_env;
     struct sgttyb tty_state;
     char key_string[BUFSIZ];
@@ -58,12 +86,12 @@ local_des_read_pw_string(s,max,prompt,verify)
     }
 
     /* XXX assume jmp_buf is typedef'ed to an array */
     }
 
     /* XXX assume jmp_buf is typedef'ed to an array */
-    bcopy((char *)old_env, (char *)env, sizeof(env));
+    memmove((char *)env, (char *)old_env, sizeof(env));
     if (setjmp(env))
        goto lose;
 
     /* save terminal state*/
     if (setjmp(env))
        goto lose;
 
     /* save terminal state*/
-    if (ioctl(0,TIOCGETP,(char *)&tty_state) == -1) 
+    if (ioctl(0,TIOCGETP,(char *)&tty_state) == -1)
        return -1;
 /*
     push_signals();
        return -1;
 /*
     push_signals();
@@ -77,7 +105,7 @@ local_des_read_pw_string(s,max,prompt,verify)
        (void) fflush(stdout);
        while (!fgets(s, max, stdin));
 
        (void) fflush(stdout);
        while (!fgets(s, max, stdin));
 
-       if ((ptr = index(s, '\n')))
+       if ((ptr = strchr(s, '\n')))
            *ptr = '\0';
        if (verify) {
            printf("\nVerifying, please re-enter %s",prompt);
            *ptr = '\0';
        if (verify) {
            printf("\nVerifying, please re-enter %s",prompt);
@@ -86,7 +114,7 @@ local_des_read_pw_string(s,max,prompt,verify)
                clearerr(stdin);
                continue;
            }
                clearerr(stdin);
                continue;
            }
-            if ((ptr = index(key_string, '\n')))
+           if ((ptr = strchr(key_string, '\n')))
            *ptr = '\0';
            if (strcmp(s,key_string)) {
                printf("\n\07\07Mismatch - try again\n");
            *ptr = '\0';
            if (strcmp(s,key_string)) {
                printf("\n\07\07Mismatch - try again\n");
@@ -99,7 +127,7 @@ local_des_read_pw_string(s,max,prompt,verify)
 
 lose:
     if (!ok)
 
 lose:
     if (!ok)
-       bzero(s, max);
+       memset(s, 0, max);
     printf("\n");
     /* turn echo back on */
     tty_state.sg_flags |= ECHO;
     printf("\n");
     /* turn echo back on */
     tty_state.sg_flags |= ECHO;
@@ -108,9 +136,10 @@ lose:
 /*
     pop_signals();
 */
 /*
     pop_signals();
 */
-    bcopy((char *)env, (char *)old_env, sizeof(env));
+    memmove((char *)old_env, (char *)env, sizeof(env));
     if (verify)
     if (verify)
-       bzero(key_string, sizeof (key_string));
+       memset(key_string, 0, sizeof (key_string));
     s[max-1] = 0;              /* force termination */
     return !ok;                        /* return nonzero if not okay */
 }
     s[max-1] = 0;              /* force termination */
     return !ok;                        /* return nonzero if not okay */
 }
+#endif /* defined(RSA_ENCPWD) || defined(KRB4_ENCPWD) */