Skip to content

Commit 8d5347f

Browse files
committed
projects: check folder weird permissions (-x)
1 parent c978370 commit 8d5347f

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

include/git/projectlist/ProjectListDirectory.class.php

+12-5
Original file line numberDiff line numberDiff line change
@@ -132,25 +132,32 @@ private function RecurseDir($dir)
132132

133133
$this->Log(sprintf('Searching directory %1$s', $dir));
134134

135+
if (!GitPHP_Util::IsWindows() && (fileperms($dir) & 0111) == 0) {
136+
$this->Log(sprintf('Folder %1$s is protected... mode %2$o', $dir, fileperms($dir)));
137+
}
138+
135139
if ($dh = opendir($dir)) {
136140
$trimlen = strlen(GitPHP_Util::AddSlash($this->projectRoot)) + 1;
137141
while (($file = readdir($dh)) !== false) {
138142
$fullPath = $dir . '/' . $file;
139-
140143
if (!GitPHP_Util::IsDir($fullPath) || $file == '.' || $file == '..')
141144
continue;
142-
143-
elseif ( $this->repoSupport and $file == '.repo' )
145+
elseif ($this->repoSupport && $file == '.repo')
144146
; // check subfolders
145-
146-
elseif ( substr($file,-4) != '.git') {
147+
elseif (substr($file,-4) != '.git') {
147148
// working copy repositories (git clone)
148149
if ( !$this->bareOnly && GitPHP_Util::IsDir($fullPath . '/.git') )
149150
$fullPath .= '/.git';
150151
elseif ($this->curlevel >= $this->sublevels or substr($file,0,1) == '.')
151152
continue;
152153
}
153154

155+
// check +x access on .git folder
156+
if (!GitPHP_Util::IsWindows() && (fileperms($fullPath.'/.') & 0111) == 0) {
157+
$this->Log(sprintf('Folder %1$s is protected... mode %2$o',
158+
$fullPath, fileperms($fullPath)));
159+
}
160+
154161
if (is_file($fullPath . '/HEAD') || is_file($fullPath . '/ORIG_HEAD')) {
155162
$projectPath = substr($fullPath, $trimlen);
156163
if (!isset($this->projects[$projectPath])) {

0 commit comments

Comments
 (0)