]> andersk Git - openssh.git/blobdiff - auth-skey.c
- Prevent typedefs from being compiled more than once. Report from
[openssh.git] / auth-skey.c
index d54f3d556803a9389a3ab2c59fb6b4bda88b9c15..8f4779820d1cd39768f1820128fe2c027ce9a136 100644 (file)
@@ -1,14 +1,49 @@
 #include "includes.h"
 
 #ifdef SKEY
-
 RCSID("$Id$");
 
 #include "ssh.h"
-#include <sha1.h>
+#include "packet.h"
+
+#ifdef HAVE_OPENSSL
+#include <openssl/sha1.h>
+#endif
+#ifdef HAVE_SSL
+#include <ssl/sha1.h>
+#endif
 
 /* from %OpenBSD: skeylogin.c,v 1.32 1999/08/16 14:46:56 millert Exp % */
 
+/* 
+ * try skey authentication,
+ * return 1 on success, 0 on failure, -1 if skey is not available 
+ */
+
+int 
+auth_skey_password(struct passwd * pw, const char *password)
+{
+       if (strncasecmp(password, "s/key", 5) == 0) {
+               char *skeyinfo = skey_keyinfo(pw->pw_name);
+               if (skeyinfo == NULL) {
+                       debug("generating fake skeyinfo for %.100s.",
+                           pw->pw_name);
+                       skeyinfo = skey_fake_keyinfo(pw->pw_name);
+               }
+               if (skeyinfo != NULL)
+                       packet_send_debug(skeyinfo);
+               /* Try again. */
+               return 0;
+       } else if (skey_haskey(pw->pw_name) == 0 &&
+                  skey_passcheck(pw->pw_name, (char *) password) != -1) {
+               /* Authentication succeeded. */
+               return 1;
+       }
+       /* Fall back to ordinary passwd authentication. */
+       return -1;
+}
+
+/* from %OpenBSD: skeylogin.c,v 1.32 1999/08/16 14:46:56 millert Exp % */
 
 #define ROUND(x)   (((x)[0] << 24) + (((x)[1]) << 16) + (((x)[2]) << 8) + \
                    ((x)[3]))
@@ -79,6 +114,7 @@ skey_fake_keyinfo(char *username)
                    SEEK_SET) != -1 && read(fd, hseed,
                    SKEY_MAX_SEED_LEN) == SKEY_MAX_SEED_LEN) {
                        close(fd);
+                       fd = -1;
                        secret = hseed;
                        secretlen = SKEY_MAX_SEED_LEN;
                        flg = 0;
@@ -88,6 +124,8 @@ skey_fake_keyinfo(char *username)
                        secretlen = strlen(secret);
                        flg = 0;
                }
+               if (fd != -1)
+                       close(fd);
        }
 
        /* Put that in your pipe and smoke it */
This page took 0.085966 seconds and 4 git commands to generate.