Exemple #1
0
 static function GetExpectedPerms_file($file)
 {
     if (!FileSystem::HasFunctions()) {
         return '666';
     }
     //if user id's match
     $puid = posix_geteuid();
     $suid = FileSystem::file_uid($file);
     if ($suid !== false && $puid == $suid) {
         return '644';
     }
     //if group id's match
     $pgid = posix_getegid();
     $sgid = FileSystem::file_group($file);
     if ($sgid !== false && $pgid == $sgid) {
         return '664';
     }
     //if user is a member of group
     $snam = FileSystem::file_owner($file);
     $pmem = FileSystem::process_members();
     if (in_array($suid, $pmem) || in_array($snam, $pmem)) {
         return '664';
     }
     return '666';
 }
Exemple #2
0
 function CheckFile($path, $type = 'dir')
 {
     $current = '?';
     $expected = '777';
     $euid = '?';
     if (FileSystem::HasFunctions()) {
         $current = @substr(decoct(@fileperms($path)), -3);
         if ($type == 'file') {
             $expected = FileSystem::getExpectedPerms_file($path);
         } else {
             $expected = FileSystem::getExpectedPerms($path);
         }
         if (FileSystem::perm_compare($expected, $current)) {
             $this->passed_count++;
             return;
         }
         $euid = FileSystem::file_uid($path);
     } elseif (gp_is_writable($path)) {
         $this->passed_count++;
         return;
     }
     $this->failed_count++;
     if ($this->failed_count > $this->show_failed_max) {
         return;
     }
     echo '<tr><td>';
     echo substr($path, $this->check_dir_len);
     echo '</td><td>';
     echo $current;
     echo '</td><td>';
     echo $expected;
     echo '</td><td>';
     echo $euid;
     echo '</td><td>';
     echo $this->euid;
     echo '</td></tr>';
 }