Imported Upstream version 1.8.6p8
[debian/sudo] / plugins / sudoers / auth / secureware.c
index 221889d5d8c240de8f9abd42b5c0c15bdc0afb22..33411752e3b4a281cf196600e1790d945b246244 100644 (file)
 #include "sudo_auth.h"
 
 int
-secureware_init(struct passwd *pw, char **promptp, sudo_auth *auth)
+sudo_secureware_init(struct passwd *pw, sudo_auth *auth)
 {
 #ifdef __alpha
     extern int crypt_type;
+    debug_decl(sudo_secureware_init, SUDO_DEBUG_AUTH)
 
     if (crypt_type == INT_MAX)
-       return AUTH_FAILURE;                    /* no shadow */
+       debug_return_int(AUTH_FAILURE);                 /* no shadow */
+#else
+    debug_decl(secureware_init, SUDO_DEBUG_AUTH)
 #endif
     sudo_setspent();
     auth->data = sudo_getepw(pw);
     sudo_endspent();
-    return AUTH_SUCCESS;
+    debug_return_int(AUTH_SUCCESS);
 }
 
 int
-secureware_verify(struct passwd *pw, char *pass, sudo_auth *auth)
+sudo_secureware_verify(struct passwd *pw, char *pass, sudo_auth *auth)
 {
     char *pw_epasswd = auth->data;
+    char *epass = NULL;
+    debug_decl(sudo_secureware_verify, SUDO_DEBUG_AUTH)
 #ifdef __alpha
-    extern int crypt_type;
+    {
+       extern int crypt_type;
 
-#  ifdef HAVE_DISPCRYPT
-    if (strcmp(pw_epasswd, dispcrypt(pass, pw_epasswd, crypt_type)) == 0)
-       return AUTH_SUCCESS;
-#  else
-    if (crypt_type == AUTH_CRYPT_BIGCRYPT) {
-       if (strcmp(pw_epasswd, bigcrypt(pass, pw_epasswd)) == 0)
-           return AUTH_SUCCESS;
-    } else if (crypt_type == AUTH_CRYPT_CRYPT16) {
-       if (strcmp(pw_epasswd, crypt(pass, pw_epasswd)) == 0)
-           return AUTH_SUCCESS;
+# ifdef HAVE_DISPCRYPT
+       epass = dispcrypt(pass, pw_epasswd, crypt_type);
+# else
+       if (crypt_type == AUTH_CRYPT_BIGCRYPT)
+           epass = bigcrypt(pass, pw_epasswd);
+       else if (crypt_type == AUTH_CRYPT_CRYPT16)
+           epass = crypt(pass, pw_epasswd);
     }
-#  endif /* HAVE_DISPCRYPT */
+# endif /* HAVE_DISPCRYPT */
 #elif defined(HAVE_BIGCRYPT)
-    if (strcmp(pw_epasswd, bigcrypt(pass, pw_epasswd)) == 0)
-       return AUTH_SUCCESS;
+    epass = bigcrypt(pass, pw_epasswd);
 #endif /* __alpha */
 
-       return AUTH_FAILURE;
+    if (epass != NULL && strcmp(pw_epasswd, epass) == 0)
+       debug_return_int(AUTH_SUCCESS);
+    debug_return_int(AUTH_FAILURE);
 }
 
 int
-secureware_cleanup(pw, auth)
+sudo_secureware_cleanup(pw, auth)
     struct passwd *pw;
     sudo_auth *auth;
 {
     char *pw_epasswd = auth->data;
+    debug_decl(sudo_secureware_cleanup, SUDO_DEBUG_AUTH)
 
     if (pw_epasswd != NULL) {
        zero_bytes(pw_epasswd, strlen(pw_epasswd));
        efree(pw_epasswd);
     }
-    return AUTH_SUCCESS;
+    debug_return_int(AUTH_SUCCESS);
 }