]> granicus.if.org Git - sudo/commitdiff
added convex c2 support
authorTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 7 Jul 1994 00:05:51 +0000 (00:05 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 7 Jul 1994 00:05:51 +0000 (00:05 +0000)
check.c

diff --git a/check.c b/check.c
index 246765f45b48045e6a86a48a2d2db1e417573115..9c3b61dc0ad297e0f511a88d5ca0a5b8c22ed49b 100644 (file)
--- a/check.c
+++ b/check.c
@@ -63,7 +63,10 @@ static char rcsid[] = "$Id$";
 #ifdef __svr4__
 #include <shadow.h>
 #endif /* __svr4__ */
-
+#if defined(__convex__) && defined(HAVE_C2_SECURITY)
+#include <sys/security.h>
+#include <prot.h>
+#endif /* __convex__ && HAVE_C2_SECURITY */
 
 
 /*
@@ -225,18 +228,23 @@ static void check_passwd()
 #ifdef __svr4__
     struct spwd *spw_ent;
 #endif /* __svr4__ */
-#if defined (hpux) && defined(HAVE_C2_SECURITY)
+#if defined (__hpux) && defined(HAVE_C2_SECURITY)
     struct s_passwd *spw_ent;
-#endif /* hpux && HAVE_C2_SECURITY */
+#endif /* __hpux && HAVE_C2_SECURITY */
+#if defined (__convex__) && defined(HAVE_C2_SECURITY)
+    char salt[2];              /* Need the salt to perform the encryption */
+    register int i;
+    struct pr_passwd *secure_pw_ent;
+#endif /* __convex__ && HAVE_C2_SECURITY */
     char *encrypted;           /* this comes from /etc/passwd  */
     char *pass;                        /* this is what gets entered    */
     register int counter = TRIES_FOR_PASSWORD;
 
     /* some os's need to be root to get at shadow password */
     be_root();
-#if defined (hpux) && defined(HAVE_C2_SECURITY)
+#if defined (__hpux) && defined(HAVE_C2_SECURITY)
     spw_ent = getspwuid(uid);
-#endif /* hpux && HAVE_C2_SECURITY */
+#endif /* __hpux && HAVE_C2_SECURITY */
     pw_ent = getpwuid(uid);
     be_user();
     if (pw_ent == NULL) {
@@ -257,11 +265,23 @@ static void check_passwd()
     }
     encrypted = spw_ent -> sp_pwdp;
 #else
-#if defined (hpux) && defined(HAVE_C2_SECURITY)
+#if defined (__convex__) && defined(HAVE_C2_SECURITY)
+    be_root();
+    secure_pw_ent = getprpwnam(pw_ent->pw_name);
+    be_user();
+    if (secure_pw_ent == (struct pr_passwd *)NULL) {
+       (void) sprintf(user, "%u", uid);
+       log_error(GLOBAL_NO_AUTH_ENT);
+       inform_user(GLOBAL_NO_AUTH_ENT);
+       exit(1);
+    }
+    encrypted = secure_pw_ent->ufld.fd_encrypt;
+#endif /* __convex__ && HAVE_C2_SECURITY */
+#if defined (__hpux) && defined(HAVE_C2_SECURITY)
     if (spw_ent && spw_ent -> pw_passwd)
        encrypted = spw_ent -> pw_passwd;
     else
-#endif /* hpux && HAVE_C2_SECURITY */
+#endif /* __hpux && HAVE_C2_SECURITY */
        encrypted = pw_ent -> pw_passwd;
 #endif /* __svr4__ */
 
@@ -276,8 +296,15 @@ static void check_passwd()
 #endif /* USE_GETPASS */
        if (!pass || *pass == '\0')
            exit(0);
+#if defined (__convex__) && defined(HAVE_C2_SECURITY)
+       strncpy(salt, secure_pw_ent->ufld.fd_encrypt, 2);
+       i = AUTH_SALT_SIZE + AUTH_CIPHERTEXT_SEG_CHARS;
+       if (strncmp(encrypted, crypt(pass, salt), i) == 0)
+           return;           /* if the passwd is correct return() */
+#else
        if (!strcmp(encrypted, (char *) crypt(pass, encrypted)))
            return;             /* if the passwd is correct return() */
+#endif /* __convex__ && HAVE_C2_SECURITY */
        --counter;              /* otherwise, try again  */
 #ifdef USE_INSULTS
        (void) fprintf(stderr, "%s\n", INSULT);