Forbid non-CLI access to command-line scripts
authorHypolite Petovan <hypolite@mrpetovan.com>
Mon, 7 Sep 2020 09:51:26 +0000 (05:51 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Mon, 7 Sep 2020 09:51:26 +0000 (05:51 -0400)
bin/auth_ejabberd.php
bin/console.php
bin/daemon.php
bin/testargs.php
bin/wait-for-connection
bin/worker.php

index fa71faf..e921829 100755 (executable)
  *
  */
 
+if (php_sapi_name() !== 'cli') {
+       header($_SERVER["SERVER_PROTOCOL"] . ' 403 Forbidden');
+       exit();
+}
+
 use Dice\Dice;
 use Friendica\App\Mode;
 use Friendica\Util\ExAuth;
index 27522d8..4d5b4c7 100755 (executable)
  *
  */
 
+if (php_sapi_name() !== 'cli') {
+       header($_SERVER["SERVER_PROTOCOL"] . ' 403 Forbidden');
+       exit();
+}
+
 use Dice\Dice;
 use Psr\Log\LoggerInterface;
 
index 596f4de..3fe803d 100755 (executable)
  * This script was taken from http://php.net/manual/en/function.pcntl-fork.php
  */
 
+if (php_sapi_name() !== 'cli') {
+       header($_SERVER["SERVER_PROTOCOL"] . ' 403 Forbidden');
+       exit();
+}
+
 use Dice\Dice;
 use Friendica\Core\Logger;
 use Friendica\Core\Worker;
index b7d7125..9aed353 100644 (file)
  *
  */
 
+if (php_sapi_name() !== 'cli') {
+       header($_SERVER["SERVER_PROTOCOL"] . ' 403 Forbidden');
+       exit();
+}
 
 if (($_SERVER["argc"] > 1) && isset($_SERVER["argv"][1])) {
        echo $_SERVER["argv"][1];
index b6c03a6..de860e9 100755 (executable)
  * Usage: php bin/wait-for-connection {HOST} {PORT} [{TIMEOUT}]
  */
 
+if (php_sapi_name() !== 'cli') {
+       header($_SERVER["SERVER_PROTOCOL"] . ' 403 Forbidden');
+       exit();
+}
+
 $timeout = 60;
 switch ($argc) {
        case 4:
index 1b70a20..833e5b0 100755 (executable)
  * Starts the background processing
  */
 
+if (php_sapi_name() !== 'cli') {
+       header($_SERVER["SERVER_PROTOCOL"] . ' 403 Forbidden');
+       exit();
+}
+
 use Dice\Dice;
 use Friendica\App;
 use Friendica\Core\Update;