]> andersk Git - openssh.git/blobdiff - sshconnect2.c
- markus@cvs.openbsd.org 2002/06/26 14:51:33
[openssh.git] / sshconnect2.c
index 258d7cf5644e54350ff8552353c15093c6a3974c..215f76ca2e3673f7258d7b36d0499d4194f370b1 100644 (file)
@@ -23,7 +23,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: sshconnect2.c,v 1.101 2002/05/24 08:45:14 markus Exp $");
+RCSID("$OpenBSD: sshconnect2.c,v 1.105 2002/06/23 03:30:17 deraadt Exp $");
 
 #include "ssh.h"
 #include "ssh2.h"
@@ -299,12 +299,14 @@ userauth(Authctxt *authctxt, char *authlist)
                }
        }
 }
+
 void
 input_userauth_error(int type, u_int32_t seq, void *ctxt)
 {
        fatal("input_userauth_error: bad message during authentication: "
           "type %d", type);
 }
+
 void
 input_userauth_banner(int type, u_int32_t seq, void *ctxt)
 {
@@ -316,6 +318,7 @@ input_userauth_banner(int type, u_int32_t seq, void *ctxt)
        xfree(msg);
        xfree(lang);
 }
+
 void
 input_userauth_success(int type, u_int32_t seq, void *ctxt)
 {
@@ -327,6 +330,7 @@ input_userauth_success(int type, u_int32_t seq, void *ctxt)
        clear_auth_state(authctxt);
        authctxt->success = 1;                  /* break out */
 }
+
 void
 input_userauth_failure(int type, u_int32_t seq, void *ctxt)
 {
@@ -375,7 +379,7 @@ input_userauth_pk_ok(int type, u_int32_t seq, void *ctxt)
        }
        packet_check_eom();
 
-       debug("input_userauth_pk_ok: pkalg %s blen %d lastkey %p hint %d",
+       debug("input_userauth_pk_ok: pkalg %s blen %u lastkey %p hint %d",
            pkalg, blen, authctxt->last_key, authctxt->last_key_hint);
 
        do {
@@ -395,7 +399,7 @@ input_userauth_pk_ok(int type, u_int32_t seq, void *ctxt)
                if (key->type != pktype) {
                        error("input_userauth_pk_ok: type mismatch "
                            "for decoded key (received %d, expected %d)",
-                            key->type, pktype);
+                           key->type, pktype);
                        break;
                }
                fp = key_fingerprint(key, SSH_FP_MD5, SSH_FP_HEX);
@@ -463,7 +467,7 @@ userauth_passwd(Authctxt *authctxt)
        packet_add_padding(64);
        packet_send();
 
-       dispatch_set(SSH2_MSG_USERAUTH_PASSWD_CHANGEREQ, 
+       dispatch_set(SSH2_MSG_USERAUTH_PASSWD_CHANGEREQ,
            &input_userauth_passwd_changereq);
 
        return 1;
@@ -495,7 +499,7 @@ input_userauth_passwd_changereq(int type, u_int32_t seqnr, void *ctxt)
        packet_put_cstring(authctxt->service);
        packet_put_cstring(authctxt->method->name);
        packet_put_char(1);                     /* additional info */
-       snprintf(prompt, sizeof(prompt), 
+       snprintf(prompt, sizeof(prompt),
            "Enter %.30s@%.128s's old password: ",
            authctxt->server_user, authctxt->host);
        password = read_passphrase(prompt, 0);
@@ -504,7 +508,7 @@ input_userauth_passwd_changereq(int type, u_int32_t seqnr, void *ctxt)
        xfree(password);
        password = NULL;
        while (password == NULL) {
-               snprintf(prompt, sizeof(prompt), 
+               snprintf(prompt, sizeof(prompt),
                    "Enter %.30s@%.128s's new password: ",
                    authctxt->server_user, authctxt->host);
                password = read_passphrase(prompt, RP_ALLOW_EOF);
@@ -512,7 +516,7 @@ input_userauth_passwd_changereq(int type, u_int32_t seqnr, void *ctxt)
                        /* bail out */
                        return;
                }
-               snprintf(prompt, sizeof(prompt), 
+               snprintf(prompt, sizeof(prompt),
                    "Retype %.30s@%.128s's new password: ",
                    authctxt->server_user, authctxt->host);
                retype = read_passphrase(prompt, 0);
@@ -530,8 +534,8 @@ input_userauth_passwd_changereq(int type, u_int32_t seqnr, void *ctxt)
        xfree(password);
        packet_add_padding(64);
        packet_send();
-       
-       dispatch_set(SSH2_MSG_USERAUTH_PASSWD_CHANGEREQ, 
+
+       dispatch_set(SSH2_MSG_USERAUTH_PASSWD_CHANGEREQ,
            &input_userauth_passwd_changereq);
 }
 
@@ -894,15 +898,13 @@ input_userauth_info_req(int type, u_int32_t seq, void *ctxt)
 }
 
 static int
-ssh_keysign(
-    Key *key,
-    u_char **sigp, u_int *lenp,
+ssh_keysign(Key *key, u_char **sigp, u_int *lenp,
     u_char *data, u_int datalen)
 {
        Buffer b;
        struct stat st;
        pid_t pid;
-       int to[2], from[2], status, version = 1;
+       int to[2], from[2], status, version = 2;
 
        debug("ssh_keysign called");
 
@@ -933,7 +935,9 @@ ssh_keysign(
                close(to[1]);
                if (dup2(to[0], STDIN_FILENO) < 0)
                        fatal("ssh_keysign: dup2: %s", strerror(errno));
-               execlp(_PATH_SSH_KEY_SIGN, _PATH_SSH_KEY_SIGN, (char *) 0);
+               close(from[1]);
+               close(to[0]);
+               execl(_PATH_SSH_KEY_SIGN, _PATH_SSH_KEY_SIGN, (char *) 0);
                fatal("ssh_keysign: exec(%s): %s", _PATH_SSH_KEY_SIGN,
                    strerror(errno));
        }
@@ -941,6 +945,7 @@ ssh_keysign(
        close(to[0]);
 
        buffer_init(&b);
+       buffer_put_int(&b, packet_get_connection_in()); /* send # of socket */
        buffer_put_string(&b, data, datalen);
        msg_send(to[1], version, &b);
 
@@ -952,9 +957,9 @@ ssh_keysign(
        close(from[0]);
        close(to[1]);
 
-        while (waitpid(pid, &status, 0) < 0)
-                if (errno != EINTR)
-                        break;
+       while (waitpid(pid, &status, 0) < 0)
+               if (errno != EINTR)
+                       break;
 
        if (buffer_get_char(&b) != version) {
                error("ssh_keysign: bad version");
@@ -1095,6 +1100,7 @@ authmethod_lookup(const char *name)
 static Authmethod *current = NULL;
 static char *supported = NULL;
 static char *preferred = NULL;
+
 /*
  * Given the authentication method list sent by the server, return the
  * next method we should try.  If the server initially sends a nil list,
This page took 0.060659 seconds and 4 git commands to generate.