[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.35 and 1.36

version 1.35, 2015/04/27 13:41:45 version 1.36, 2015/04/27 13:52:17
Line 186 
Line 186 
         }          }
         if (magicfp == NULL)          if (magicfp == NULL)
                 err(1, "%s", magicpath);                  err(1, "%s", magicpath);
           setvbuf(magicfp, NULL, _IOLBF, 0); /* stops stdio calling fstat */
   
         parent = getpid();          parent = getpid();
         if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, pair) != 0)          if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, pair) != 0)
                 err(1, "socketpair");                  err(1, "socketpair");
         switch (pid = fork()) {          pid = sandbox_fork(FILE_USER);
         case 0:          if (pid == 0) {
                 close(pair[0]);                  close(pair[0]);
                 child(pair[1], parent, argc, argv);                  child(pair[1], parent, argc, argv);
         case -1:  
                 err(1, "fork");  
         }          }
         close(pair[1]);          close(pair[1]);
   
Line 329 
Line 328 
         struct input_file        inf;          struct input_file        inf;
         int                      i, idx;          int                      i, idx;
         size_t                   len, width = 0;          size_t                   len, width = 0;
         struct passwd           *pw;  
   
         if (geteuid() == 0) {  
                 pw = getpwnam(FILE_USER);  
                 if (pw == NULL)  
                         errx(1, "unknown user %s", FILE_USER);  
                 if (setgroups(1, &pw->pw_gid) != 0)  
                         err(1, "setgroups");  
                 if (setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) != 0)  
                         err(1, "setresgid");  
                 if (setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid) != 0)  
                         err(1, "setresuid");  
         }  
   
         m = magic_load(magicfp, magicpath, cflag || Wflag);          m = magic_load(magicfp, magicpath, cflag || Wflag);
         if (cflag) {          if (cflag) {

Legend:
Removed from v.1.35  
changed lines
  Added in v.1.36