From 47af739e4755d0b9453f584d9dfbdac9d34c3b21 Mon Sep 17 00:00:00 2001 From: "J. King" Date: Sun, 6 Jun 2021 19:14:37 -0400 Subject: [PATCH] Catch more PID path failures --- lib/CLI.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/CLI.php b/lib/CLI.php index 825441e2..38614a63 100644 --- a/lib/CLI.php +++ b/lib/CLI.php @@ -330,11 +330,15 @@ USAGE_TEXT; protected function resolvePID(string $pidfile): string { $dir = dirname($pidfile); $file = basename($pidfile); - if ($base = @realpath($dir)) { + if (!strlen($file)) { + throw new \Exception("Specified PID file location must be a regular file"); + } elseif ($base = @realpath($dir)) { $out = "$base/$file"; if (file_exists($out)) { if (!is_writable($out)) { throw new \Exception("PID file is not writable"); + } elseif (!is_file($out)) { + throw new \Exception("Specified PID file location must be a regular file"); } } elseif (!is_writable($base)) { throw new \Exception("Cannot create PID file");