]> granicus.if.org Git - php/commitdiff
Improve privilege check in pcntl_setpriority() test
authorNikita Popov <nikita.ppv@gmail.com>
Wed, 5 Aug 2020 07:58:34 +0000 (09:58 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Wed, 5 Aug 2020 10:09:10 +0000 (12:09 +0200)
We need CAP_SYS_NICE privileges, which might not be available
just because we're running as root (Docker...)

ext/pcntl/tests/pcntl_setpriority_basic.phpt

index 235b0ec9ceb015f710ca58ac3a0d799cfa23a758..0c92245e1ed3e5de45cb58a591713c348e7f87fa 100644 (file)
@@ -11,8 +11,8 @@ if (!extension_loaded('pcntl')) {
 if (!function_exists('pcntl_setpriority')) {
     die('skip pcntl_setpriority doesn\'t exist');
 }
-if (!function_exists('posix_getuid') || posix_getuid() !== 0) {
-    die('skip this functions needs to run with superuser');
+if (@pcntl_setpriority(-5) === false && pcntl_get_last_error() == PCNTL_EACCES) {
+    die('skip this function needs to run with CAP_SYS_NICE privileges');
 }
 ?>
 --FILE--