diff options
author | Fabien Villepinte <fabien.villepinte@gmail.com> | 2019-10-05 14:26:33 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-10-08 18:20:13 +0200 |
commit | 8b5c351154284a88152ee3d166a32dc77316a658 (patch) | |
tree | e38e10fe7b65983618ae29a290adea19a97f005d /ext/standard/tests/skipif_root.inc | |
parent | bea832cbf6b7a06ee65b93902233864c1ac9ec98 (diff) | |
download | php-git-8b5c351154284a88152ee3d166a32dc77316a658.tar.gz |
Avoid file clash in root_check skipifs
Extract root check into skipif_root.inc to share this commonly
repeated logic.
Closes GH-4779.
Diffstat (limited to 'ext/standard/tests/skipif_root.inc')
-rw-r--r-- | ext/standard/tests/skipif_root.inc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/ext/standard/tests/skipif_root.inc b/ext/standard/tests/skipif_root.inc new file mode 100644 index 0000000000..d43cae8674 --- /dev/null +++ b/ext/standard/tests/skipif_root.inc @@ -0,0 +1,16 @@ +<?php + +// Skip if being run by root (files are always readable, writeable and executable) +$filename = @tempnam(__DIR__, 'root_check_'); +if (!file_exists($filename)) { + die('WARN Unable to create the "root check" file'); +} + +$isRoot = fileowner($filename) == 0; + +unlink($filename); + +if ($isRoot) { + die('SKIP Cannot be run as root'); +} + |