Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/updater.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2016-11-28 19:44:06 +0300
committerMorris Jobke <hey@morrisjobke.de>2016-11-28 19:46:01 +0300
commit0c5204c99fff1d7cab6057f553ad3404f4ecbc3a (patch)
treeea1ab8d1dad87bfce8b2484a1e183943e3abc7cb
parent418e9c4509bbfd5100bec748212010b9bc54d84f (diff)
verify that owner of config.php and updater process user are the same1.0.2
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
-rw-r--r--Changelog.md4
-rw-r--r--Makefile2
-rw-r--r--lib/UpdateCommand.php20
3 files changed, 26 insertions, 0 deletions
diff --git a/Changelog.md b/Changelog.md
index 1584bb7..b12907f 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -1,3 +1,7 @@
+# 1.0.2 - 2016-11-28
+
+- CLI: verify that owner of config.php and updater process user are the same
+
# 1.0.1 - 2016-11-25
- CLI: if the instance is not installed the updater exits properly with a exit code of 0
diff --git a/Makefile b/Makefile
index c75bdd2..c97ebf8 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,5 @@
+.PHONY: updater.phar
+
box:
curl -L https://github.com/box-project/box2/releases/download/2.7.4/box-2.7.4.phar -o box
chmod +x box
diff --git a/lib/UpdateCommand.php b/lib/UpdateCommand.php
index 71fdef0..572d1e9 100644
--- a/lib/UpdateCommand.php
+++ b/lib/UpdateCommand.php
@@ -84,6 +84,26 @@ class UpdateCommand extends Command {
return -1;
}
+ if (!function_exists('posix_getuid')) {
+ $output->writeln("The posix extensions are required - see http://php.net/manual/en/book.posix.php");
+ return -1;
+ }
+
+ if($dir = getenv('NEXTCLOUD_CONFIG_DIR')) {
+ $configFileName = rtrim($dir, '/') . '/config.php';
+ } else {
+ $configFileName = $path . '/../config/config.php';
+ }
+ $user = posix_getpwuid(posix_getuid());
+ $configUser = posix_getpwuid(fileowner($configFileName));
+ if ($user['name'] !== $configUser['name']) {
+ $output->writeln("Console has to be executed with the user that owns the file config/config.php");
+ $output->writeln("Current user: " . $user['name']);
+ $output->writeln("Owner of config.php: " . $configUser['name']);
+ $output->writeln("Try adding 'sudo -u " . $configUser['name'] . " ' to the beginning of the command (without the single quotes)");
+ return -1;
+ }
+
// Check if the updater.log can be written to
try {
$this->updater->log('[info] updater cli is executed');