Przeglądaj źródła

Merge pull request #6956 from wsandin/master

Fix for issue 6602 - warning when running composer as another user
Jordi Boggiano 7 lat temu
rodzic
commit
0161a63a0a
1 zmienionych plików z 9 dodań i 0 usunięć
  1. 9 0
      src/Composer/Command/SelfUpdateCommand.php

+ 9 - 0
src/Composer/Command/SelfUpdateCommand.php

@@ -107,6 +107,15 @@ EOT
             throw new FilesystemException('Composer update failed: the "'.$tmpDir.'" directory used to download the temp file could not be written');
         }
 
+        // check if composer is running as the same user that owns the directory root, only if POSIX is defined and callable
+        if (function_exists('posix_getpwuid') && function_exists('posix_geteuid')) {
+            $composeUser = posix_getpwuid(posix_geteuid());
+            $homeOwner = posix_getpwuid(fileowner($home));
+            if ($composeUser !== $homeOwner) {
+                $io->writeError('<warning>You are running composer as "'.$composeUser.'", while "'.$home.'" is owned by "'.$homeOwner.'"</warning>');
+            }
+        }
+
         if ($input->getOption('rollback')) {
             return $this->rollback($output, $rollbackDir, $localFilename);
         }