[BACK]Return to sshconnect2.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Diff for /src/usr.bin/ssh/sshconnect2.c between version 1.146.2.1 and 1.147

version 1.146.2.1, 2006/09/30 04:06:51 version 1.147, 2006/03/07 09:07:40
Line 1 
Line 1 
 /* $OpenBSD$ */  
 /*  /*
  * Copyright (c) 2000 Markus Friedl.  All rights reserved.   * Copyright (c) 2000 Markus Friedl.  All rights reserved.
  *   *
Line 23 
Line 22 
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.   * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */   */
   
   #include "includes.h"
   RCSID("$OpenBSD$");
   
 #include <sys/types.h>  #include <sys/types.h>
 #include <sys/socket.h>  
 #include <sys/wait.h>  #include <sys/wait.h>
 #include <sys/queue.h>  #include <sys/queue.h>
 #include <sys/stat.h>  #include <sys/stat.h>
   
 #include <errno.h>  
 #include <stdio.h>  
 #include <string.h>  
 #include <signal.h>  
 #include <pwd.h>  
 #include <unistd.h>  
   
 #include "xmalloc.h"  
 #include "ssh.h"  #include "ssh.h"
 #include "ssh2.h"  #include "ssh2.h"
   #include "xmalloc.h"
 #include "buffer.h"  #include "buffer.h"
 #include "packet.h"  #include "packet.h"
 #include "compat.h"  #include "compat.h"
   #include "bufaux.h"
 #include "cipher.h"  #include "cipher.h"
 #include "key.h"  
 #include "kex.h"  #include "kex.h"
 #include "myproposal.h"  #include "myproposal.h"
 #include "sshconnect.h"  #include "sshconnect.h"
Line 58 
Line 52 
 #include "canohost.h"  #include "canohost.h"
 #include "msg.h"  #include "msg.h"
 #include "pathnames.h"  #include "pathnames.h"
 #include "uidswap.h"  
   
 #ifdef GSSAPI  #ifdef GSSAPI
 #include "ssh-gss.h"  #include "ssh-gss.h"
Line 374 
Line 367 
         debug3("input_userauth_banner");          debug3("input_userauth_banner");
         msg = packet_get_string(NULL);          msg = packet_get_string(NULL);
         lang = packet_get_string(NULL);          lang = packet_get_string(NULL);
         if (options.log_level >= SYSLOG_LEVEL_INFO)          if (options.log_level > SYSLOG_LEVEL_QUIET)
                 fprintf(stderr, "%s", msg);                  fprintf(stderr, "%s", msg);
         xfree(msg);          xfree(msg);
         xfree(lang);          xfree(lang);
Line 505 
Line 498 
   
         /* Check to see if the mechanism is usable before we offer it */          /* Check to see if the mechanism is usable before we offer it */
         while (mech < gss_supported->count && !ok) {          while (mech < gss_supported->count && !ok) {
                   if (gssctxt)
                           ssh_gssapi_delete_ctx(&gssctxt);
                   ssh_gssapi_build_ctx(&gssctxt);
                   ssh_gssapi_set_oid(gssctxt, &gss_supported->elements[mech]);
   
                 /* My DER encoding requires length<128 */                  /* My DER encoding requires length<128 */
                 if (gss_supported->elements[mech].length < 128 &&                  if (gss_supported->elements[mech].length < 128 &&
                     ssh_gssapi_check_mechanism(&gssctxt,                      !GSS_ERROR(ssh_gssapi_import_name(gssctxt,
                     &gss_supported->elements[mech], authctxt->host)) {                      authctxt->host))) {
                         ok = 1; /* Mechanism works */                          ok = 1; /* Mechanism works */
                 } else {                  } else {
                         mech++;                          mech++;
Line 762 
Line 760 
  * parse PASSWD_CHANGEREQ, prompt user and send SSH2_MSG_USERAUTH_REQUEST   * parse PASSWD_CHANGEREQ, prompt user and send SSH2_MSG_USERAUTH_REQUEST
  */   */
 void  void
 input_userauth_passwd_changereq(int type, u_int32_t seqnr, void *ctxt)  input_userauth_passwd_changereq(int type, uint32_t seqnr, void *ctxt)
 {  {
         Authctxt *authctxt = ctxt;          Authctxt *authctxt = ctxt;
         char *info, *lang, *password = NULL, *retype = NULL;          char *info, *lang, *password = NULL, *retype = NULL;
Line 969 
Line 967 
 {  {
         Key *private;          Key *private;
         char prompt[300], *passphrase;          char prompt[300], *passphrase;
         int perm_ok, quit, i;          int quit, i;
         struct stat st;          struct stat st;
   
         if (stat(filename, &st) < 0) {          if (stat(filename, &st) < 0) {
                 debug3("no such identity: %s", filename);                  debug3("no such identity: %s", filename);
                 return NULL;                  return NULL;
         }          }
         private = key_load_private_type(KEY_UNSPEC, filename, "", NULL, &perm_ok);          private = key_load_private_type(KEY_UNSPEC, filename, "", NULL);
         if (!perm_ok)  
                 return NULL;  
         if (private == NULL) {          if (private == NULL) {
                 if (options.batch_mode)                  if (options.batch_mode)
                         return NULL;                          return NULL;
Line 987 
Line 983 
                 for (i = 0; i < options.number_of_password_prompts; i++) {                  for (i = 0; i < options.number_of_password_prompts; i++) {
                         passphrase = read_passphrase(prompt, 0);                          passphrase = read_passphrase(prompt, 0);
                         if (strcmp(passphrase, "") != 0) {                          if (strcmp(passphrase, "") != 0) {
                                 private = key_load_private_type(KEY_UNSPEC,                                  private = key_load_private_type(KEY_UNSPEC, filename,
                                     filename, passphrase, NULL, NULL);                                      passphrase, NULL);
                                 quit = 0;                                  quit = 0;
                         } else {                          } else {
                                 debug2("no passphrase given, try next key");                                  debug2("no passphrase given, try next key");
Line 1031 
Line 1027 
                 if (key && key->type == KEY_RSA1)                  if (key && key->type == KEY_RSA1)
                         continue;                          continue;
                 options.identity_keys[i] = NULL;                  options.identity_keys[i] = NULL;
                 id = xcalloc(1, sizeof(*id));                  id = xmalloc(sizeof(*id));
                   memset(id, 0, sizeof(*id));
                 id->key = key;                  id->key = key;
                 id->filename = xstrdup(options.identity_files[i]);                  id->filename = xstrdup(options.identity_files[i]);
                 TAILQ_INSERT_TAIL(&files, id, next);                  TAILQ_INSERT_TAIL(&files, id, next);
Line 1055 
Line 1052 
                                 }                                  }
                         }                          }
                         if (!found && !options.identities_only) {                          if (!found && !options.identities_only) {
                                 id = xcalloc(1, sizeof(*id));                                  id = xmalloc(sizeof(*id));
                                   memset(id, 0, sizeof(*id));
                                 id->key = key;                                  id->key = key;
                                 id->filename = comment;                                  id->filename = comment;
                                 id->ac = ac;                                  id->ac = ac;
Line 1251 
Line 1249 
                 return -1;                  return -1;
         }          }
         if (pid == 0) {          if (pid == 0) {
                 permanently_drop_suid(getuid());                  seteuid(getuid());
                   setuid(getuid());
                 close(from[0]);                  close(from[0]);
                 if (dup2(from[1], STDOUT_FILENO) < 0)                  if (dup2(from[1], STDOUT_FILENO) < 0)
                         fatal("ssh_keysign: dup2: %s", strerror(errno));                          fatal("ssh_keysign: dup2: %s", strerror(errno));
Line 1331 
Line 1330 
         if (p == NULL) {          if (p == NULL) {
                 error("userauth_hostbased: cannot get local ipaddr/name");                  error("userauth_hostbased: cannot get local ipaddr/name");
                 key_free(private);                  key_free(private);
                 xfree(blob);  
                 return 0;                  return 0;
         }          }
         len = strlen(p) + 2;          len = strlen(p) + 2;
         xasprintf(&chost, "%s.", p);          chost = xmalloc(len);
           strlcpy(chost, p, len);
           strlcat(chost, ".", len);
         debug2("userauth_hostbased: chost %s", chost);          debug2("userauth_hostbased: chost %s", chost);
         xfree(p);          xfree(p);
   
Line 1368 
Line 1368 
                 error("key_sign failed");                  error("key_sign failed");
                 xfree(chost);                  xfree(chost);
                 xfree(pkalg);                  xfree(pkalg);
                 xfree(blob);  
                 return 0;                  return 0;
         }          }
         packet_start(SSH2_MSG_USERAUTH_REQUEST);          packet_start(SSH2_MSG_USERAUTH_REQUEST);
Line 1384 
Line 1383 
         xfree(signature);          xfree(signature);
         xfree(chost);          xfree(chost);
         xfree(pkalg);          xfree(pkalg);
         xfree(blob);  
   
         packet_send();          packet_send();
         return 1;          return 1;

Legend:
Removed from v.1.146.2.1  
changed lines
  Added in v.1.147