소스 검색

Code cleanup and ensure checked file is unique.

Niels Keurentjes 9 년 전
부모
커밋
43eb471ec2
1개의 변경된 파일2개의 추가작업 그리고 3개의 파일을 삭제
  1. 2 3
      src/Composer/Console/Application.php

+ 2 - 3
src/Composer/Console/Application.php

@@ -150,9 +150,8 @@ class Application extends BaseApplication
 
 
             // Check system temp folder for usability as it can cause weird runtime issues otherwise
             // Check system temp folder for usability as it can cause weird runtime issues otherwise
             Silencer::call(function() {
             Silencer::call(function() {
-                $tempfile = sys_get_temp_dir() . '/tempchk.tmp';
-                $usable = file_put_contents($tempfile, __FILE__) && (file_get_contents($tempfile) == __FILE__) && unlink($tempfile);
-                if (!$usable || file_exists($tempfile)) {
+                $tempfile = sys_get_temp_dir() . '/temp-' . md5(microtime());
+                if (!(file_put_contents($tempfile, __FILE__) && (file_get_contents($tempfile) == __FILE__) && unlink($tempfile) && !file_exists($tempfile))) {
                     throw new \RuntimeException(sprintf('PHP temp directory "%s" does not exist or is not writable to Composer - check sys_temp_dir in your php.ini', sys_get_temp_dir()));
                     throw new \RuntimeException(sprintf('PHP temp directory "%s" does not exist or is not writable to Composer - check sys_temp_dir in your php.ini', sys_get_temp_dir()));
                 }
                 }
             });
             });