Extract test helper function for SeCreateSymbolicLinkPrivilege check

This commit is contained in:
Christoph M. Becker 2020-07-02 11:56:41 +02:00
parent f1bf058d7c
commit c49fb83c38
6 changed files with 16 additions and 34 deletions

View file

@ -3,12 +3,8 @@ Bug #68825 (Exception in DirectoryIterator::getLinkTarget())
--SKIPIF--
<?php
if (PHP_OS_FAMILY === 'Windows') {
$fn = "bug68825.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__ . '/../../standard/tests/file/windows_links/common.inc';
skipIfSeCreateSymbolicLinkPrivilegeIsDisabled(__FILE__);
}
?>
--FILE--

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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');
}
}