php-src/ext/standard/tests/skipif_root.inc
Fabien Villepinte 8b5c351154 Avoid file clash in root_check skipifs
Extract root check into skipif_root.inc to share this commonly
repeated logic.

Closes GH-4779.
2019-10-08 18:20:13 +02:00

17 lines
341 B
PHP

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