diff --git a/src/Composer/Console/Application.php b/src/Composer/Console/Application.php index 1d34df527..7c989098f 100644 --- a/src/Composer/Console/Application.php +++ b/src/Composer/Console/Application.php @@ -217,7 +217,11 @@ class Application extends BaseApplication $needsSudoCheck = !Platform::isWindows() && function_exists('exec') && !Platform::getEnv('COMPOSER_ALLOW_SUPERUSER') - && (ini_get('open_basedir') || !file_exists('/.dockerenv')); + && (ini_get('open_basedir') || ( + !file_exists('/.dockerenv') + && !file_exists('/run/.containerenv') + && !file_exists('/var/run/.containerenv') + )); $isNonAllowedRoot = false; // Clobber sudo credentials if COMPOSER_ALLOW_SUPERUSER is not set before loading plugins diff --git a/src/Composer/Util/Platform.php b/src/Composer/Util/Platform.php index 33ff62056..45060c85c 100644 --- a/src/Composer/Util/Platform.php +++ b/src/Composer/Util/Platform.php @@ -152,7 +152,9 @@ class Platform !ini_get('open_basedir') && is_readable('/proc/version') && false !== stripos((string)Silencer::call('file_get_contents', '/proc/version'), 'microsoft') - && !file_exists('/.dockerenv') // docker running inside WSL should not be seen as WSL + && !file_exists('/.dockerenv') // Docker and Podman running inside WSL should not be seen as WSL + && !file_exists('/run/.containerenv') + && !file_exists('/var/run/.containerenv') ) { return self::$isWindowsSubsystemForLinux = true; }