Skip to content

Commit 2406cc7

Browse files
committed
bug #16095 [Console] Add additional ways to detect OS400 platform (johnkary)
This PR was squashed before being merged into the 2.3 branch (closes #16095). Discussion ---------- [Console] Add additional ways to detect OS400 platform | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #16053 | License | MIT | Doc PR | None This PR adds support for detecting the OS400 platform when the PHP function `php_uname()` is disabled. OS400 platform detection was added in #15058 to fix character encoding issues present on OS400. See that PR for more info. This PR fixes regression introduced in #16053, which did not work on the IBM OS400 server I have access to. The constant `PHP_OS` being checked outputs "AIX" on my IBM OS400 server. I can't say for sure if it works on other IBM platforms... but I preserved this check just in case. User @eloigranado [commented here](#15058 (comment)) asking if we could switch to using `PHP_OS` constant instead of `php_uname()` because he claims some admins might "[hide] the exact kernel build from any attacker who discovers a remote PHP code execution vulnerability". I personally don't think we should accommodate this use case, but I was able to find alternate approaches. ### Why use case insensitive string matching stristr() instead of in_array()? Here are the various outputs on my OS400 server: echo PHP_OS; // "AIX" echo getenv('OSTYPE'); // "os400" echo php_uname('s'); // "OS400" So we have various case issues here, and possible blank values on platforms where OSTYPE var doesn't exist or php_uname() is disabled. Concatenating these optional values together delimited by ; then case-insensitive searching the string for "OS400" seemed like a fair compromise. I would've probably done `in_array()` if case wasn't an issue. Commits ------- 96a4071 [Console] Add additional ways to detect OS400 platform
2 parents bd9997e + 96a4071 commit 2406cc7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Symfony/Component/Console/Output/ConsoleOutput.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,13 @@ protected function hasStderrSupport()
125125
*/
126126
private function isRunningOS400()
127127
{
128-
return 'OS400' === PHP_OS;
128+
$checks = array(
129+
function_exists('php_uname') ? php_uname('s') : '',
130+
getenv('OSTYPE'),
131+
PHP_OS,
132+
);
133+
134+
return false !== stristr(implode(';', $checks), 'OS400');
129135
}
130136

131137
/**

0 commit comments

Comments
 (0)