summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-12-17 15:45:32 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2015-12-17 15:45:32 +0100
commita9ad5c7b6bbbdce1994fd60884c2be5468971ccf (patch)
tree5cff805f8cbc6441dae920a5edad79762af4679d
parent1285b780860fe782efe845f364e590a8e47bb564 (diff)
parentb8ceae68d5e9ff46daf4daf2ce13bcc94cafa7f8 (diff)
downloadnextcloud-server-a9ad5c7b6bbbdce1994fd60884c2be5468971ccf.tar.gz
nextcloud-server-a9ad5c7b6bbbdce1994fd60884c2be5468971ccf.zip
Merge pull request #21251 from owncloud/make-occ-more-error-proof
occ command can only be called from ownCloud root directory
-rw-r--r--console.php10
1 files changed, 10 insertions, 0 deletions
diff --git a/console.php b/console.php
index 8bfbabf2a03..ab845aced50 100644
--- a/console.php
+++ b/console.php
@@ -64,6 +64,16 @@ try {
}
}
+ $oldWorkingDir = getcwd();
+ if ($oldWorkingDir === false) {
+ echo "This script can be run from the ownCloud root directory only." . PHP_EOL;
+ echo "Can't determine current working dir - the script will continue to work but be aware of the above fact." . PHP_EOL;
+ } else if ($oldWorkingDir !== __DIR__ && !chdir(__DIR__)) {
+ echo "This script can be run from the ownCloud root directory only." . PHP_EOL;
+ echo "Can't change to ownCloud root diretory." . PHP_EOL;
+ exit(1);
+ }
+
$application = new Application(\OC::$server->getConfig());
$application->loadCommands(new ConsoleOutput());
$application->run();