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

Diff for /src/usr.bin/ssh/auth-rhosts.c between version 1.41 and 1.42

version 1.41, 2006/08/03 03:34:41 version 1.42, 2008/06/13 04:40:22
Line 17 
Line 17 
 #include <sys/types.h>  #include <sys/types.h>
 #include <sys/stat.h>  #include <sys/stat.h>
   
   #include <fcntl.h>
 #include <netgroup.h>  #include <netgroup.h>
 #include <pwd.h>  #include <pwd.h>
 #include <stdio.h>  #include <stdio.h>
Line 33 
Line 34 
 #include "key.h"  #include "key.h"
 #include "hostfile.h"  #include "hostfile.h"
 #include "auth.h"  #include "auth.h"
   #include "misc.h"
   
 /* import */  /* import */
 extern ServerOptions options;  extern ServerOptions options;
Line 51 
Line 53 
 {  {
         FILE *f;          FILE *f;
         char buf[1024]; /* Must not be larger than host, user, dummy below. */          char buf[1024]; /* Must not be larger than host, user, dummy below. */
           int fd;
           struct stat st;
   
         /* Open the .rhosts file, deny if unreadable */          /* Open the .rhosts file, deny if unreadable */
         f = fopen(filename, "r");          if ((fd = open(filename, O_RDONLY|O_NONBLOCK)) == -1)
         if (!f)  
                 return 0;                  return 0;
           if (fstat(fd, &st) == -1) {
                   close(fd);
                   return 0;
           }
           if (!S_ISREG(st.st_mode)) {
                   logit("User %s hosts file %s is not a regular file",
                       server_user, filename);
                   close(fd);
                   return 0;
           }
           unset_nonblock(fd);
           if ((f = fdopen(fd, "r")) == NULL) {
                   close(fd);
                   return 0;
           }
         while (fgets(buf, sizeof(buf), f)) {          while (fgets(buf, sizeof(buf), f)) {
                 /* All three must be at least as big as buf to avoid overflows. */                  /* All three must be at least as big as buf to avoid overflows. */
                 char hostbuf[1024], userbuf[1024], dummy[1024], *host, *user, *cp;                  char hostbuf[1024], userbuf[1024], dummy[1024], *host, *user, *cp;

Legend:
Removed from v.1.41  
changed lines
  Added in v.1.42