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

Diff for /src/usr.bin/file/file.c between version 1.31 and 1.32

version 1.31, 2015/04/24 17:10:50 version 1.32, 2015/04/24 17:34:57
Line 137 
Line 137 
         } else if (argc == 0)          } else if (argc == 0)
                 usage();                  usage();
   
         home = getenv("HOME");          f = NULL;
         if (home == NULL || *home == '\0') {          if (geteuid() != 0 && !issetugid()) {
                 pw = getpwuid(getuid());                  home = getenv("HOME");
                 if (pw != NULL)                  if (home == NULL || *home == '\0') {
                         home = pw->pw_dir;                          pw = getpwuid(getuid());
                 else                          if (pw != NULL)
                         home = NULL;                                  home = pw->pw_dir;
                           else
                                   home = NULL;
                   }
                   if (home != NULL) {
                           xasprintf(&path, "%s/.magic", home);
                           f = fopen(path, "r");
                           if (f == NULL && errno != ENOENT)
                                   err(1, "%s", path);
                           if (f == NULL)
                                   free(path);
                   }
         }          }
         if (home != NULL) {  
                 xasprintf(&path, "%s/.magic", home);  
                 f = fopen(path, "r");  
                 if (f == NULL && errno != ENOENT)  
                         err(1, "%s", path);  
                 if (f == NULL)  
                         free(path);  
         } else  
                 f = NULL;  
         if (f == NULL) {          if (f == NULL) {
                 path = xstrdup("/etc/magic");                  path = xstrdup("/etc/magic");
                 f = fopen(path, "r");                  f = fopen(path, "r");

Legend:
Removed from v.1.31  
changed lines
  Added in v.1.32