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

Diff for /src/usr.bin/ssh/auth2-pubkey.c between version 1.15 and 1.16

version 1.15, 2006/08/03 03:34:41 version 1.16, 2008/06/13 04:40:22
Line 27 
Line 27 
 #include <sys/types.h>  #include <sys/types.h>
 #include <sys/stat.h>  #include <sys/stat.h>
   
   #include <fcntl.h>
 #include <pwd.h>  #include <pwd.h>
 #include <stdio.h>  #include <stdio.h>
 #include <stdarg.h>  #include <stdarg.h>
Line 175 
Line 176 
 user_key_allowed2(struct passwd *pw, Key *key, char *file)  user_key_allowed2(struct passwd *pw, Key *key, char *file)
 {  {
         char line[SSH_MAX_PUBKEY_BYTES];          char line[SSH_MAX_PUBKEY_BYTES];
         int found_key = 0;          int found_key = 0, fd;
         FILE *f;          FILE *f;
         u_long linenum = 0;          u_long linenum = 0;
         struct stat st;          struct stat st;
Line 187 
Line 188 
   
         debug("trying public key file %s", file);          debug("trying public key file %s", file);
   
         /* Fail quietly if file does not exist */          /*
         if (stat(file, &st) < 0) {           * Open the file containing the authorized keys
                 /* Restore the privileged uid. */           * Fail quietly if file does not exist
            */
           if ((fd = open(file, O_RDONLY|O_NONBLOCK)) == -1) {
                 restore_uid();                  restore_uid();
                 return 0;                  return 0;
         }          }
         /* Open the file containing the authorized keys. */          if (fstat(fd, &st) < 0) {
         f = fopen(file, "r");                  close(fd);
         if (!f) {                  restore_uid();
                 /* Restore the privileged uid. */                  return 0;
           }
           if (!S_ISREG(st.st_mode)) {
                   logit("User %s authorized keys %s is not a regular file",
                       pw->pw_name, file);
                   close(fd);
                   restore_uid();
                   return 0;
           }
           unset_nonblock(fd);
           if ((f = fdopen(fd, "r")) == NULL) {
                   close(fd);
                 restore_uid();                  restore_uid();
                 return 0;                  return 0;
         }          }

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16