Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permission denied for 'occ' #260

Open
solracsf opened this issue Dec 21, 2019 · 2 comments · May be fixed by #595
Open

Permission denied for 'occ' #260

solracsf opened this issue Dec 21, 2019 · 2 comments · May be fixed by #595
Assignees
Labels
3. to review bug feature: upgrade Note: In `server` but called by updater. Also see `feature: installs and updates` in server

Comments

@solracsf
Copy link
Member

solracsf commented Dec 21, 2019

When executing sudo -u www-data php updater.phar, process can't be finished correctly because of permissions.

  • occ upgrade can't be executed
  • Maintenance mode isn't disabled (even if script states that it has been disabled, see 2 last lines of output below)
sudo -u www-data php -f updater.phar
Nextcloud Updater - version: v16.0.3-3-ga0c2b25 dirty

Current version is 17.0.1.

Update to Nextcloud 17.0.2 available. (channel: "stable")
Following file will be downloaded automatically: https://download.nextcloud.com/server/releases/nextcloud-17.0.2.zip
Open changelog ↗

Steps that will be executed:
[ ] Check for expected files
[ ] Check for write permissions
[ ] Create backup
[ ] Downloading
[ ] Verify integrity
[ ] Extracting
[ ] Enable maintenance mode
[ ] Replace entry points
[ ] Delete old files
[ ] Move new files in place
[ ] Done

Continue update? [y/N] y

Info: Pressing Ctrl-C will finish the currently running step and then stops the updater.

[✔] Check for expected files
[✔] Check for write permissions
[✔] Create backup
[✔] Downloading
[✔] Verify integrity
[✔] Extracting
[✔] Enable maintenance mode
[✔] Replace entry points
[✔] Delete old files
[✔] Move new files in place
[✔] Done

Update of code successful.

Should the "occ upgrade" command be executed? [Y/n] Y
sh: 1: ./occ: Permission denied

Keep maintenance mode active? [y/N] N
sh: 1: ./occ: Permission denied

Maintenance mode is disabled

Answering no to the first and executing sudo -u www-data php occ upgrade followed by sudo -u www-data php occ maintenance:mode --off is fine, but it should be executed inside the first command.

Everything goes fine if sudo -u www-data php ./updater/updater.phar

@joshtrichards joshtrichards added the feature: upgrade Note: In `server` but called by updater. Also see `feature: installs and updates` in server label Sep 20, 2023
@SKJoy
Copy link

SKJoy commented Oct 8, 2023

Do you mean only the php ./updater/updater.phar is good enough?

@joshtrichards
Copy link
Member

We should be checking the return values from both the system() calls and using them to report the proper status:

chdir($path . '/..');
chmod('occ', 0755); # TODO do this in the updater
system(PHP_BINARY . ' ./occ upgrade -v', $returnValue);
$output->writeln('');
if ($input->isInteractive()) {
/** @var QuestionHelper */
$helper = $this->getHelper('question');
$question = new ConfirmationQuestion($this->checkTexts[11] . ' [y/N] ', false);
if ($helper->ask($input, $output, $question)) {
$output->writeln('Maintenance mode kept active');
$this->updater->log('[info] updater finished - maintenance mode kept active');
return $returnValue;
}
} else {
$this->updater->log('[info] updater run in non-interactive mode - disabling maintenance mode');
$output->writeln('Updater run in non-interactive mode - will disable maintenance mode now.');
}
try {
system(PHP_BINARY . ' ./occ maintenance:mode --off', $returnValueMaintenanceMode);
$this->updater->log('[info] maintenance mode is disabled - return code: ' . $returnValueMaintenanceMode);
$output->writeln('');
$output->writeln('Maintenance mode is disabled');
} catch (\Exception $e) {
$this->updater->log('[info] maintenance mode can not be disabled');
$this->updater->logException($e);
$output->writeln('');
$output->writeln('Maintenance mode can not be disabled');
}
return $returnValue;
} else {

Right now we capture them but don't use them to detect failure. 🤦

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review bug feature: upgrade Note: In `server` but called by updater. Also see `feature: installs and updates` in server
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants