]> granicus.if.org Git - php/commitdiff
add PHP_OS_FAMILY constant to determine on which os we are
authorStricted <info@stricted.net>
Wed, 25 Jan 2017 07:34:24 +0000 (08:34 +0100)
committerJoe Watkins <krakjoe@php.net>
Wed, 25 Jan 2017 20:50:14 +0000 (20:50 +0000)
26 files changed:
NEWS
main/main.c
tests/basic/req60524-win.phpt
tests/basic/req60524.phpt
tests/lang/bug38579.phpt
tests/output/sapi_windows_vt100_support_notwindows.phpt
tests/output/sapi_windows_vt100_support_winko_err.phpt
tests/output/sapi_windows_vt100_support_winko_in-err.phpt
tests/output/sapi_windows_vt100_support_winko_in-out-err.phpt
tests/output/sapi_windows_vt100_support_winko_in-out.phpt
tests/output/sapi_windows_vt100_support_winko_out-err.phpt
tests/output/sapi_windows_vt100_support_winko_out.phpt
tests/output/sapi_windows_vt100_support_winok_err.phpt
tests/output/sapi_windows_vt100_support_winok_in-err.phpt
tests/output/sapi_windows_vt100_support_winok_in-out-err.phpt
tests/output/sapi_windows_vt100_support_winok_in-out.phpt
tests/output/sapi_windows_vt100_support_winok_out-err.phpt
tests/output/sapi_windows_vt100_support_winok_out.phpt
tests/security/open_basedir_001.phpt
tests/security/open_basedir_link.phpt
tests/security/open_basedir_linkinfo.phpt
tests/security/open_basedir_mkdir.phpt
tests/security/open_basedir_parse_ini_file.phpt
tests/security/open_basedir_readlink.phpt
tests/security/open_basedir_realpath.phpt
tests/security/open_basedir_symlink.phpt

diff --git a/NEWS b/NEWS
index dbbea3b7eb9d5ae8d5723dea80869f2a34ee602f..7d03c34a926cfa7b52d372a05387db7e0b3d00bb 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -23,6 +23,7 @@ PHP                                                                        NEWS
   . Raised minimum supported Windows versions to Windows 7/Server 2008 R2.
     (Anatol)
   . Fixed bug #73969 (segfault in debug_print_backtrace). (andrewnester)
+  . Added PHP_OS_FAMILY constant to determine on which OS we are. (Jan Altensen)
 
 - BCMath:
   . Fixed bug #46564 (bcmod truncates fractionals). (liborm85)
index 17cf2995ffe43dbd8043ca312f19ddf81b5cb849..ab01757efa4fc449567ce3b30ef3b91c31e19c1a 100644 (file)
@@ -2051,7 +2051,7 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
        zend_utility_functions zuf;
        zend_utility_values zuv;
        int retval = SUCCESS, module_number=0;  /* for REGISTER_INI_ENTRIES() */
-       char *php_os;
+       char *php_os, *php_os_family;
        zend_module_entry *module;
 
 #ifdef PHP_WIN32
@@ -2073,6 +2073,21 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
        php_os = PHP_OS;
 #endif
 
+#if defined(PHP_WIN32)
+       php_os_family = "WIN";
+#elif defined(BSD) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
+       php_os_family = "BSD";
+#elif defined(__APPLE__) || defined(__MACH__)
+       php_os_family = "OSX";
+#elif defined(__sun__)
+       php_os_family = "SOLARIS";
+#elif defined(__linux__)
+       php_os_family = "LINUX";
+#else
+       php_os_family = "unknown";
+#endif
+
+
 #ifdef ZTS
        (void)ts_resource(0);
 #endif
@@ -2153,6 +2168,7 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
 #endif
        REGISTER_MAIN_LONG_CONSTANT("PHP_DEBUG", PHP_DEBUG, CONST_PERSISTENT | CONST_CS);
        REGISTER_MAIN_STRINGL_CONSTANT("PHP_OS", php_os, strlen(php_os), CONST_PERSISTENT | CONST_CS);
+       REGISTER_MAIN_STRINGL_CONSTANT("PHP_OS_FAMILY", php_os_family, strlen(php_os_family), CONST_PERSISTENT | CONST_CS);
        REGISTER_MAIN_STRINGL_CONSTANT("PHP_SAPI", sapi_module.name, strlen(sapi_module.name), CONST_PERSISTENT | CONST_CS);
        REGISTER_MAIN_STRINGL_CONSTANT("DEFAULT_INCLUDE_PATH", PHP_INCLUDE_PATH, sizeof(PHP_INCLUDE_PATH)-1, CONST_PERSISTENT | CONST_CS);
        REGISTER_MAIN_STRINGL_CONSTANT("PEAR_INSTALL_DIR", PEAR_INSTALLDIR, sizeof(PEAR_INSTALLDIR)-1, CONST_PERSISTENT | CONST_CS);
index b2e7cfdab4d86ef7963feab93c409fb9eb080454..8eb38a528c96f3f495b226044bddec526d3739c9 100644 (file)
@@ -4,7 +4,7 @@ Req #60524 (Specify temporary directory)
 sys_temp_dir=C:\Windows
 --SKIPIF--
 <?php
-if( substr(PHP_OS, 0, 3) != "WIN" )
+if(PHP_OS_FAMILY !== "WIN")
   die('skip Run only on Windows');
 ?>
 --FILE--
index 7cc3edfabf439bf37b2e8d33a720ebd11332cff7..e4999e1a2036c8bca0486c06e2d18748757e1661 100644 (file)
@@ -4,7 +4,7 @@ Req #60524 (Specify temporary directory)
 sys_temp_dir=/path/to/temp/dir
 --SKIPIF--
 <?php
-if (substr(PHP_OS, 0, 3) == 'WIN') {
+if(PHP_OS_FAMILY === "WIN") {
     die('skip non-windows only test');
 }
 ?>
index 445296c222599cc208271ffc99a485fb558c9eb2..3c96e7f50fe6bd93dae600800906eaa00131c8b3 100644 (file)
@@ -2,7 +2,7 @@
 Bug #38579 (include_once() may include the same file twice)
 --SKIPIF--
 <?php
-if (substr(PHP_OS, 0, 3) != 'WIN') {
+if(PHP_OS_FAMILY !== "WIN") {
     die('skip only for Windows');
 }
 ?>
index 5ff382350a513a216ef3ff692e50189da9167bed..d1afa4d9a3f37db967713461e5ce589a5853fb1a 100644 (file)
@@ -2,7 +2,7 @@
 Test that sapi_windows_vt100_support exists only on Windows
 --SKIPIF--
 <?php
-if (stripos(PHP_OS, 'WIN') === 0) {
+if(PHP_OS_FAMILY === "WIN") {
     echo "skip Only for not Windows systems";
 }
 ?>
index 4357c741afaf91ee890bd645d0cdb2b4dec8402b..9c85a207257c2682a4ba3a2630c78148f4b42bc4 100644 (file)
@@ -5,7 +5,7 @@ Test sapi_windows_vt100_support on older Windows versions with redirected STDERR
 if (getenv("SKIP_IO_CAPTURE_TESTS")) {
        die("skip I/O capture test");
 }
-if (stripos(PHP_OS, 'WIN') !== 0) {
+if(PHP_OS_FAMILY !== "WIN") {
     echo "skip Only for Windows systems";
 } elseif (version_compare(
     PHP_WINDOWS_VERSION_MAJOR.'.'.PHP_WINDOWS_VERSION_MINOR.'.'.PHP_WINDOWS_VERSION_BUILD,
index fd508eedaea46fba3798b0ac5d495fb6da242f3b..595b5c401f1c8e4cedf8d54952bc17e370ce6c3c 100644 (file)
@@ -5,7 +5,7 @@ Test sapi_windows_vt100_support on older Windows versions with redirected STDIN/
 if (getenv("SKIP_IO_CAPTURE_TESTS")) {
        die("skip I/O capture test");
 }
-if (stripos(PHP_OS, 'WIN') !== 0) {
+if(PHP_OS_FAMILY !== "WIN") {
     echo "skip Only for Windows systems";
 } elseif (version_compare(
     PHP_WINDOWS_VERSION_MAJOR.'.'.PHP_WINDOWS_VERSION_MINOR.'.'.PHP_WINDOWS_VERSION_BUILD,
index 4af527f3d2dd317251b1421ea087e666553175c0..44fae220ff7e5fbd2e6af08c48e49107eec389f2 100644 (file)
@@ -5,7 +5,7 @@ Test sapi_windows_vt100_support on older Windows versions with redirected STDIN/
 if (getenv("SKIP_IO_CAPTURE_TESTS")) {
        die("skip I/O capture test");
 }
-if (stripos(PHP_OS, 'WIN') !== 0) {
+if(PHP_OS_FAMILY !== "WIN") {
     echo "skip Only for Windows systems";
 } elseif (version_compare(
     PHP_WINDOWS_VERSION_MAJOR.'.'.PHP_WINDOWS_VERSION_MINOR.'.'.PHP_WINDOWS_VERSION_BUILD,
index 18b64acaa66e1ab16406b28f6ba9b8b883474d2f..322e7ad2297c3e40c11b822d29672c5f7d487a97 100644 (file)
@@ -5,7 +5,7 @@ Test sapi_windows_vt100_support on older Windows versions with redirected STDIN/
 if (getenv("SKIP_IO_CAPTURE_TESTS")) {
        die("skip I/O capture test");
 }
-if (stripos(PHP_OS, 'WIN') !== 0) {
+if(PHP_OS_FAMILY !== "WIN") {
     echo "skip Only for Windows systems";
 } elseif (version_compare(
     PHP_WINDOWS_VERSION_MAJOR.'.'.PHP_WINDOWS_VERSION_MINOR.'.'.PHP_WINDOWS_VERSION_BUILD,
index 4fdf2dd5f9a3db8b4364a9d4f17b1eac92c77ca2..e61652c13fbe6e5c0b56fcc0c570129b7f9106ad 100644 (file)
@@ -5,7 +5,7 @@ Test sapi_windows_vt100_support on older Windows versions with redirected STDOUT
 if (getenv("SKIP_IO_CAPTURE_TESTS")) {
        die("skip I/O capture test");
 }
-if (stripos(PHP_OS, 'WIN') !== 0) {
+if(PHP_OS_FAMILY !== "WIN") {
     echo "skip Only for Windows systems";
 } elseif (version_compare(
     PHP_WINDOWS_VERSION_MAJOR.'.'.PHP_WINDOWS_VERSION_MINOR.'.'.PHP_WINDOWS_VERSION_BUILD,
index 500cabcf9d71acfe70b62eee219f918f2d937785..21966c8f648802f101bdd8110a80e9d3426c3260 100644 (file)
@@ -5,7 +5,7 @@ Test sapi_windows_vt100_support on older Windows versions with redirected STDOUT
 if (getenv("SKIP_IO_CAPTURE_TESTS")) {
        die("skip I/O capture test");
 }
-if (stripos(PHP_OS, 'WIN') !== 0) {
+if(PHP_OS_FAMILY !== "WIN") {
     echo "skip Only for Windows systems";
 } elseif (version_compare(
     PHP_WINDOWS_VERSION_MAJOR.'.'.PHP_WINDOWS_VERSION_MINOR.'.'.PHP_WINDOWS_VERSION_BUILD,
index 31138916619310950f5f6d383e0545bb245465f0..26da5564b3ff0d93a69df904260c484cd08f1013 100644 (file)
@@ -5,7 +5,7 @@ Test sapi_windows_vt100_support on newer Windows versions with redirected STDERR
 if (getenv("SKIP_IO_CAPTURE_TESTS")) {
        die("skip I/O capture test");
 }
-if (stripos(PHP_OS, 'WIN') !== 0) {
+if(PHP_OS_FAMILY !== "WIN") {
     echo "skip Only for Windows systems";
 } elseif (version_compare(
     PHP_WINDOWS_VERSION_MAJOR.'.'.PHP_WINDOWS_VERSION_MINOR.'.'.PHP_WINDOWS_VERSION_BUILD,
index 4ca743fb46f9971ed2c6be6dc29ce3c0fdcefe49..646e169d9bfecb735be82bf840a2e4ec30ca6d2a 100644 (file)
@@ -5,7 +5,7 @@ Test sapi_windows_vt100_support on newer Windows versions with redirected STDIN/
 if (getenv("SKIP_IO_CAPTURE_TESTS")) {
        die("skip I/O capture test");
 }
-if (stripos(PHP_OS, 'WIN') !== 0) {
+if(PHP_OS_FAMILY !== "WIN") {
     echo "skip Only for Windows systems";
 } elseif (version_compare(
     PHP_WINDOWS_VERSION_MAJOR.'.'.PHP_WINDOWS_VERSION_MINOR.'.'.PHP_WINDOWS_VERSION_BUILD,
index a8d938014074feed865c7de548cb4d7fc2e4d9ff..d277128095b3240ee5c7ab3f3bb1394225dd4c59 100644 (file)
@@ -5,7 +5,7 @@ Test sapi_windows_vt100_support on newer Windows versions with redirected STDIN/
 if (getenv("SKIP_IO_CAPTURE_TESTS")) {
        die("skip I/O capture test");
 }
-if (stripos(PHP_OS, 'WIN') !== 0) {
+if(PHP_OS_FAMILY !== "WIN") {
     echo "skip Only for Windows systems";
 } elseif (version_compare(
     PHP_WINDOWS_VERSION_MAJOR.'.'.PHP_WINDOWS_VERSION_MINOR.'.'.PHP_WINDOWS_VERSION_BUILD,
index 17f90e5f55039c4c136675e61bb068be77db18b0..1dd889aa053d36c206775ff7664598f1477dcd0b 100644 (file)
@@ -5,7 +5,7 @@ Test sapi_windows_vt100_support on newer Windows versions with redirected STDIN/
 if (getenv("SKIP_IO_CAPTURE_TESTS")) {
        die("skip I/O capture test");
 }
-if (stripos(PHP_OS, 'WIN') !== 0) {
+if(PHP_OS_FAMILY !== "WIN") {
     echo "skip Only for Windows systems";
 } elseif (version_compare(
     PHP_WINDOWS_VERSION_MAJOR.'.'.PHP_WINDOWS_VERSION_MINOR.'.'.PHP_WINDOWS_VERSION_BUILD,
index 03e7d2c5ec52f427dd8df5484e77c5acc2ccb576..e31b6881790dddf88d164d28fbbdd0428dd06aa9 100644 (file)
@@ -5,7 +5,7 @@ Test sapi_windows_vt100_support on newer Windows versions with redirected STDOUT
 if (getenv("SKIP_IO_CAPTURE_TESTS")) {
        die("skip I/O capture test");
 }
-if (stripos(PHP_OS, 'WIN') !== 0) {
+if(PHP_OS_FAMILY !== "WIN") {
     echo "skip Only for Windows systems";
 } elseif (version_compare(
     PHP_WINDOWS_VERSION_MAJOR.'.'.PHP_WINDOWS_VERSION_MINOR.'.'.PHP_WINDOWS_VERSION_BUILD,
index 784a12d02cf0d8e0899036cae1315116a85a5d3d..5379ac2059996fab8da685877e0749f0ce40e534 100644 (file)
@@ -5,7 +5,7 @@ Test sapi_windows_vt100_support on newer Windows versions with redirected STDOUT
 if (getenv("SKIP_IO_CAPTURE_TESTS")) {
        die("skip I/O capture test");
 }
-if (stripos(PHP_OS, 'WIN') !== 0) {
+if(PHP_OS_FAMILY !== "WIN") {
     echo "skip Only for Windows systems";
 } elseif (version_compare(
     PHP_WINDOWS_VERSION_MAJOR.'.'.PHP_WINDOWS_VERSION_MINOR.'.'.PHP_WINDOWS_VERSION_BUILD,
index 9ea955994255be340d539172c19144b0a28da61e..7b198df843807cd6f35d16d6c2584f0f930c6d4b 100644 (file)
@@ -2,7 +2,7 @@
 openbase_dir runtime tightning
 --SKIPIF--
 <?php
-if (substr(PHP_OS, 0, 3) == 'WIN') {
+if(PHP_OS_FAMILY === "WIN") {
        die('skip.. only for unix');
 }
 if (!is_dir("/usr/local/bin")) {
index 82f97d6b0922577e9a9a314127eb8aef7278d78a..e03b23eb6082eb47a736b1916a4aea202d6c998b 100644 (file)
@@ -2,7 +2,7 @@
 Test open_basedir configuration
 --SKIPIF--
 <?php
-if (substr(PHP_OS, 0, 3) == 'WIN') {
+if(PHP_OS_FAMILY === "WIN") {
     die('skip no links on Windows');
 }
 ?>
index 55cf2c2f4be745da38d028741884fbb5868946d7..0f2b941e3ca6819095044a59fe2021e2476f3d16 100644 (file)
@@ -2,7 +2,7 @@
 Test open_basedir configuration
 --SKIPIF--
 <?php
-if (substr(PHP_OS, 0, 3) == 'WIN') {
+if(PHP_OS_FAMILY === "WIN") {
     die('skip no symlinks on Windows');
 }
 ?>
index 9c32d408a2927080385d2b5340c63b28998cf214..fba0dfbc0a9a1ac08d26ee42b4c5e6aafc936995 100644 (file)
@@ -2,7 +2,7 @@
 Test open_basedir configuration
 --SKIPIF--
 <?php
-if (substr(PHP_OS, 0, 3) != 'WIN') {
+if(PHP_OS_FAMILY !== "WIN") {
     die('skip Windows only variation');
 }
 ?>
index d69adeb5e13ce14ab0a326e0102ebc55d23df890..5dec5f83a7e92897830a8116eb0bb99790e1f827 100644 (file)
@@ -4,7 +4,7 @@ Test open_basedir configuration
 open_basedir=.
 --SKIPIF--
 <?php
-if (substr(PHP_OS, 0, 3) != 'WIN') {
+if(PHP_OS_FAMILY !== "WIN") {
     die('skip Windows only variation');
 }
 ?>
index 33720bbf1b60f43a6cc633dac04a8e24c807412a..16c638a30745151f4a8247c5f29062ee0d9a759f 100644 (file)
@@ -2,7 +2,7 @@
 Test open_basedir configuration
 --SKIPIF--
 <?php
-if (substr(PHP_OS, 0, 3) == 'WIN') {
+if(PHP_OS_FAMILY === "WIN") {
     die('skip no symlinks on Windows');
 }
 ?>
index 8cae890e99ce9f722e3cc3bd396c1f9695f6a33c..c44215aa47f46965bf1bc5676bce0b8e0819aed2 100644 (file)
@@ -2,7 +2,7 @@
 Test open_basedir configuration
 --SKIPIF--
 <?php
-if (substr(PHP_OS, 0, 3) != 'WIN') {
+if(PHP_OS_FAMILY !== "WIN") {
     die('skip only run on Windows');
 }
 ?>
index cdc8e7bcc476a36b6c0032b28493a73cbbdd6a54..fe138cf9566afd8afd825393d12666e94ae6f3d4 100644 (file)
@@ -2,7 +2,7 @@
 Test open_basedir configuration
 --SKIPIF--
 <?php
-if (substr(PHP_OS, 0, 3) == 'WIN') {
+if(PHP_OS_FAMILY === "WIN") {
     die('skip no symlinks on Windows');
 }
 ?>