/** * Check ownership/mode/privacy of repository * * @param Project $project The project to work on * * @return boolean true if success */ public function checkCVSMode($project) { $unix_group_name = $project->getUnixName(false); $cvsroot = $GLOBALS['cvs_prefix'] . '/' . $unix_group_name; $is_private = !$project->isPublic() || $project->isCVSPrivate(); if ($is_private) { $perms = fileperms($cvsroot); // 'others' should have no right on the repository if ($perms & 0x4 || $perms & 0x2 || $perms & 0x1 || $perms & 0x200) { $this->log("Restoring privacy on CVS dir: {$cvsroot}", Backend::LOG_WARNING); $this->setCVSPrivacy($project, $is_private); } } // Sometimes, there might be a bad ownership on file (e.g. chmod failed, maintenance done as root...) $files_to_check = array('CVSROOT/loginfo', 'CVSROOT/commitinfo', 'CVSROOT/config'); $need_owner_update = false; foreach ($files_to_check as $file) { if (file_exists($cvsroot . '/' . $file)) { // Get file stat $stat = stat("{$cvsroot}/{$file}"); if ($stat) { if ($stat['uid'] != $this->getHTTPUserUID() || $stat['gid'] != $project->getUnixGID()) { $need_owner_update = true; } } } else { $this->log("File not found in cvsroot: {$cvsroot}/{$file}", Backend::LOG_WARNING); } } if ($need_owner_update) { $this->log("Restoring ownership on CVS dir: {$cvsroot}", Backend::LOG_INFO); $this->changeRepoOwnership($cvsroot, $unix_group_name); $this->system('chmod g+rws ' . $cvsroot); } return true; }