-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] Add additional ways to detect OS400 platform #16095
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This reverts commit 40e0dc8. This commit led to a regression on the OS400 platform, where the constant PHP_OS returns "AIX" not "OS400".
$checks = array( | ||
function_exists('php_uname') ? php_uname('s') : '', | ||
getenv('OSTYPE'), | ||
defined('PHP_OS') ? PHP_OS : '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check can be omitted IMO, we can be sure that the PHP_OS
constant exists.
d86678b
to
e397379
Compare
@dosten Thank you for the quick review. I have made the changes you suggested. |
@johnkary Thank you for the review. On http://www.volubis.fr/php/ibmdemo/showsource.php?filename=checkauth.inc I found this check: // If we report the OS as AIX or OS400, assume we're running under PASE
$isPase = (PHP_OS == "AIX" || PHP_OS == "OS400"); Should we do it similarly here? |
@xabbuh Thank you for the reference link. According to php_uname() docs I'm not an IBM expert, nor do I admin IBM servers. I can only offer evidence from the 1 server I have access to. PHP_OS constant returns "AIX" on that server. Maybe AIX is the deciding factor when we should redirect output, instead of OS400? I'm willing to rework the PR if others think that is a better approach. |
Thank you @johnkary. |
…hnkary) 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
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 asking if we could switch to using
PHP_OS
constant instead ofphp_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:
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.