Skip to content
Permalink
Browse files

Fix installer.

Permissions should be applied recursively to the /tmp directory.
  • Loading branch information...
markstory committed Sep 4, 2013
1 parent 2b2ee2f commit 86111d715fd6d6e598ed7d78c9ea8cc0ae7a3347
Showing with 24 additions and 11 deletions.
  1. +24 −11 App/App/Console/Installer.php
@@ -64,20 +64,33 @@ public static function createAppConfig($dir, $io) {
* @return void
*/
public static function setTmpPermissions($dir, $io) {
$worldWritable = bindec('0110000000');
$walker = function ($dir, $perms) use ($io, &$walker) {
$files = array_diff(scandir($dir), ['.', '..']);
foreach ($files as $file) {
$path = $dir . '/' . $file;
if (!is_dir($path)) {
continue;
}
// Get current permissions in decimal format so we can bitmask it.
$currentPerms = octdec(substr(sprintf('%o', fileperms($dir . '/tmp')), -4));
// Get current permissions in decimal format so we can bitmask it.
$currentPerms = octdec(substr(sprintf('%o', fileperms($path)), -4));
if (($currentPerms & $perms) == $perms) {
continue;
}
if (($currentPerms & $worldWritable) != $worldWritable) {
$io->write('Attempting to set permissions on tmp/');
$result = chmod('./tmp', $currentPerms | $worldWritable);
if ($result) {
$io->write('Permissions set on tmp/');
} else {
$io->write('Failed to set permissions on tmp/ you must do it yourself.');
$res = chmod($path, $currentPerms | $perms);
if ($res) {
$io->write('Permissions set on ' . $path);
} else {
$io->write('Failed to set permissions on ' . $path);
}
$walker($path, $perms);
}
}
};
$worldWritable = bindec('0110000000');
$walker($dir . '/tmp', $worldWritable);
}
}

0 comments on commit 86111d7

Please sign in to comment.
You can’t perform that action at this time.