Skip to content

Commit 53d6d4b

Browse files
author
Hidde Boomsma
committed
bug symfony#14246 [Filesystem] dumpFile() negates default file permissions
1 parent 5931ef7 commit 53d6d4b

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/Symfony/Component/Filesystem/Filesystem.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,12 +522,16 @@ public function dumpFile($filename, $content)
522522
throw new IOException(sprintf('Unable to write to the "%s" directory.', $dir), 0, null, $dir);
523523
}
524524

525+
// Will create a temp file with 0600 access rights
526+
// when the filesystem supports chmod.
525527
$tmpFile = $this->tempnam($dir, basename($filename));
526528

527529
if (false === @file_put_contents($tmpFile, $content)) {
528530
throw new IOException(sprintf('Failed to write file "%s".', $filename), 0, null, $filename);
529531
}
530532

533+
// Ignore for filesystems that do not support umask
534+
@chmod($tmpFile, 0666);
531535
$this->rename($tmpFile, $filename, true);
532536
}
533537

src/Symfony/Component/Filesystem/Tests/FilesystemTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,7 @@ public function testDumpFile()
10761076

10771077
// skip mode check on Windows
10781078
if ('\\' !== DIRECTORY_SEPARATOR) {
1079-
$this->assertFilePermissions(600, $filename);
1079+
$this->assertFilePermissions(666, $filename);
10801080
}
10811081
}
10821082

0 commit comments

Comments
 (0)