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

[Bug]: occ maintenance:install fails on read-only htdocs directory #42286

Closed
5 of 8 tasks
Tracked by #2641
Pilzinsel64 opened this issue Dec 14, 2023 · 7 comments · Fixed by #42298
Closed
5 of 8 tasks
Tracked by #2641

[Bug]: occ maintenance:install fails on read-only htdocs directory #42286

Pilzinsel64 opened this issue Dec 14, 2023 · 7 comments · Fixed by #42298
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap 27-feedback bug

Comments

@Pilzinsel64
Copy link

Pilzinsel64 commented Dec 14, 2023

⚠️ This issue respects the following points: ⚠️

Bug description

Since Nextcloud 27.1.5 and Nextcloud 28.0.0 the occ command for manual install requires write-access to the htdocs directory. This were not the case before and allowed Nextcloud to be deployed via the SNAP environment.

Ref: nextcloud-snap/nextcloud-snap#2631 (comment)

This prevents us from updating our snap packges at the moment as the snap environment is read-only for security reasons.

Is there a workaround for this to execute manual install without the need for write-access?

Steps to reproduce

  1. Create a read-only webspace.
  2. Install Nextcloud 27.1.5 or 28.0.0 there.
  3. Execute the installation process via the command occ maintenance:install.
  4. The command will fail because it requires write-access to the htdocs direcotry.

Expected behavior

Do not require write-access on occ maintenance:install or at least try-catch and skip the steps that would write to the htdocs directory, so the command will execute successfully - like in v27.1.4 and earlier.

Installation method

Community SNAP package

Nextcloud Server version

27

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.1

Web server

Apache (supported)

Database engine version

MySQL

Is this bug present after an update or on a fresh install?

Fresh Nextcloud Server install

Are you using the Nextcloud Server Encryption module?

None

What user-backends are you using?

  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other

Configuration report

No response

List of activated Apps

No response

Nextcloud Signing status

No response

Nextcloud Logs

No response

Additional info

No response

@Pilzinsel64 Pilzinsel64 added 0. Needs triage Pending check for reproducibility or if it fits our roadmap bug labels Dec 14, 2023
@Pilzinsel64 Pilzinsel64 changed the title [Bug]: occ maintenance:install requires write-access to its htdocs directory [Bug]: occ maintenance:install fails on read-only htdocs directory Dec 14, 2023
@joshtrichards
Copy link
Member

The first error in the linked issue is the result of a recently added check to make sure there's enough disk space available before writing out the config.php. This is important since avoids truncating the existing config.php. It was added in #41544 and the code is as follows:

if ($content !== '') {
// Never write file back if disk space should be too low
if (function_exists('disk_free_space')) {
$df = disk_free_space(\OC::$SERVERROOT);
$size = strlen($content) + 10240;
if ($df !== false && $df < (float)$size) {
throw new \Exception(\OC::$SERVERROOT . " does not have enough space for writing the htaccess file! Not writing it back!");
}
}
//suppress errors in case we don't have permissions for it
return (bool)@file_put_contents($setupHelper->pathToHtaccess(), $htaccessContent . $content . "\n");
}

As for occ maintenance:install I don't see anything significant that's changed lately in regards to write related behavior. The only change made for NC28 was increased verbosity. Which might help you uncover what's going on if you activate it.

The code for the command is here:

https://github.com/nextcloud/server/blob/master/core/Command/Maintenance/Install.php

@solracsf
Copy link
Member

Problem is at line 568.
To handle these (SNAP) cases, it should just return false, but it actually throws.
@szaimen any objections here?

@szaimen
Copy link
Contributor

szaimen commented Dec 14, 2023

I think we should rather chevk if the dir is read only and then return false...

@kyrofa
Copy link
Member

kyrofa commented Dec 14, 2023

Yes, the snap is a squashfs image, which is by definition 100% full and read-only.

@kyrofa
Copy link
Member

kyrofa commented Dec 14, 2023

The first error in the linked issue is the result of a recently added check to make sure there's enough disk space available before writing out the config.php

Remember that config.php could be held entirely out of the webroot. Read-only webroots are not uncommon.

@solracsf
Copy link
Member

PR at #42298

@kyrofa
Copy link
Member

kyrofa commented Dec 15, 2023

Thank you, @solracsf!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap 27-feedback bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants