Skip to content

Commit

Permalink
fixup! Update occ
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Wurst <[email protected]>
  • Loading branch information
ChristophWurst committed Sep 18, 2024
1 parent 77bfa2e commit 0768c99
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions occ
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
#!/usr/bin/env php
<?php

/**
* SPDX-FileCopyrightText: 2014 ownCloud, Inc.
* SPDX-FileCopyrightText: 2014 Olivier Paroz
* SPDX-FileCopyrightText: 2013 Thomas Müller <[email protected]>
* SPDX-License-Identifier: AGPL-3.0-only
*/

// make it possible to run as root
if (posix_getuid() == 0){
// Drop privileges when run as root
if (posix_getuid() === 0){
$configPath = __DIR__ . '/config/config.php';
$fallbackUser = 'www-data';
$guessedUser = match (file_exists($configPath)) {
true => ($ownerUid = fileowner($configPath)) ? posix_getpwuid($ownerUid)['name'] : $fallbackUser,
false => $fallbackUser,
};
$command = implode (' ', $argv);
echo(shell_exec('sudo -u www-data '.$command));
echo(shell_exec("sudo -u $guessedUser php -f " . $command));
exit;
} else {
require_once __DIR__ . '/console.php';
}

require_once __DIR__ . '/console.php';

0 comments on commit 0768c99

Please sign in to comment.