diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2020-07-02 11:56:41 +0200 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2020-07-02 12:23:49 +0200 |
commit | c49fb83c380e7c594e85205eac972df4ed93a114 (patch) | |
tree | a3cb4d09c64bdf6d7227d1e1f3f917471ab1d144 /ext/standard/tests | |
parent | f1bf058d7cbb7eaa62c1850c0d931a2c2ee127db (diff) | |
download | php-git-c49fb83c380e7c594e85205eac972df4ed93a114.tar.gz |
Extract test helper function for SeCreateSymbolicLinkPrivilege check
Diffstat (limited to 'ext/standard/tests')
5 files changed, 14 insertions, 28 deletions
diff --git a/ext/standard/tests/file/bug47767.phpt b/ext/standard/tests/file/bug47767.phpt index 37db3b18fc..a7c4f02e78 100644 --- a/ext/standard/tests/file/bug47767.phpt +++ b/ext/standard/tests/file/bug47767.phpt @@ -7,16 +7,8 @@ Venkat Raman Don if(substr(PHP_OS, 0, 3) != 'WIN' ) { die('skip windows only test'); } -if(PHP_WINDOWS_VERSION_MAJOR < 6) { - die('skip windows version 6.0+ only test'); -} - -$fn = "bug47767.lnk"; -$ret = exec("mklink $fn " . __FILE__ .' 2>&1', $out); -@unlink($fn); -if (strpos($ret, 'privilege')) { - die('skip. SeCreateSymbolicLinkPrivilege not enable for this user.'); -} +include_once __DIR__ . '/windows_links/common.inc'; +skipIfSeCreateSymbolicLinkPrivilegeIsDisabled(__FILE__); ?> --FILE-- <?php diff --git a/ext/standard/tests/file/rename_variation6-win32.phpt b/ext/standard/tests/file/rename_variation6-win32.phpt index 9129bd871e..535e5e723a 100644 --- a/ext/standard/tests/file/rename_variation6-win32.phpt +++ b/ext/standard/tests/file/rename_variation6-win32.phpt @@ -3,13 +3,8 @@ Test rename() function: usage variations-6 --SKIPIF-- <?php if (substr(PHP_OS, 0, 3) != 'WIN') die('skip.. for Windows'); -if (!function_exists("symlink")) die("skip symlinks are not supported"); -$fn = "rename_variation6tmp.lnk"; -$ret = exec("mklink $fn " . __FILE__ .' 2>&1', $out); -@unlink($fn); -if (strpos($ret, 'privilege')) { - die('skip. SeCreateSymbolicLinkPrivilege not enable for this user.'); -} +include_once __DIR__ . '/windows_links/common.inc'; +skipIfSeCreateSymbolicLinkPrivilegeIsDisabled(__FILE__); ?> --FILE-- <?php diff --git a/ext/standard/tests/file/windows_links/bug48746_2.phpt b/ext/standard/tests/file/windows_links/bug48746_2.phpt index 5e34344a73..5f3a016232 100644 --- a/ext/standard/tests/file/windows_links/bug48746_2.phpt +++ b/ext/standard/tests/file/windows_links/bug48746_2.phpt @@ -8,11 +8,7 @@ if(substr(PHP_OS, 0, 3) != 'WIN' ) { die('skip windows only test'); } include_once __DIR__ . '/common.inc'; -$ret = exec('mklink bug48746_tmp.lnk ' . __FILE__ .' 2>&1', $out); -if (strpos($ret, 'privilege')) { - die('skip. SeCreateSymbolicLinkPrivilege not enable for this user.'); -} -unlink('bug48746_tmp.lnk'); +skipIfSeCreateSymbolicLinkPrivilegeIsDisabled(__FILE__); ?> --FILE-- <?php diff --git a/ext/standard/tests/file/windows_links/bug73962.phpt b/ext/standard/tests/file/windows_links/bug73962.phpt index 4f74454849..6aee5e1fa4 100644 --- a/ext/standard/tests/file/windows_links/bug73962.phpt +++ b/ext/standard/tests/file/windows_links/bug73962.phpt @@ -6,11 +6,7 @@ if(substr(PHP_OS, 0, 3) != 'WIN' ) { die('skip windows only test'); } include_once __DIR__ . '/common.inc'; -$ret = exec('mklink bug73962_tmp.lnk ' . __FILE__ .' 2>&1', $out); -if (strpos($ret, 'privilege')) { - die('skip. SeCreateSymbolicLinkPrivilege not enable for this user.'); -} -unlink('bug73962_tmp.lnk'); +skipIfSeCreateSymbolicLinkPrivilegeIsDisabled(__FILE__); ?> --FILE-- <?php diff --git a/ext/standard/tests/file/windows_links/common.inc b/ext/standard/tests/file/windows_links/common.inc index 505368b8b0..caa3758d44 100644 --- a/ext/standard/tests/file/windows_links/common.inc +++ b/ext/standard/tests/file/windows_links/common.inc @@ -20,4 +20,11 @@ function get_mountvol() { return "$sysroot\\System32\\mountvol.exe"; } -?> +function skipIfSeCreateSymbolicLinkPrivilegeIsDisabled(string $filename) { + $ln = "$filename.lnk"; + $ret = exec("mklink $ln " . __FILE__ .' 2>&1', $out); + @unlink($ln); + if (strpos($ret, 'privilege') !== false) { + die('skip SeCreateSymbolicLinkPrivilege not enabled'); + } +} |