Problem/Motivation

Following recent security advisories it may be a good idea to allow (and encourage) sites to disable the installer from settings.php where it cannot be undone without editing code.

Steps to reproduce

Proposed resolution

Add an installer_access killswitch to settings.php similar to update_free_access.
Set to TRUE in default.settings.php.
Rewrite to FALSE at the end of the installer.
Add a status report message to warn the site owner if it is TRUE.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3641632

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

longwave created an issue. See original summary.

catch’s picture

I'm wondering if we should consider supporting a timestamp here, write it at the beginning of the installer and then only allow a certain window to complete the install (one day? 2 hours?).

We would still use true/false for manually enabling and disabling it but if we use a timestamp that would help to protect against incomplete installs a bit more since at least there'd be a time limit.

longwave’s picture

Status: Active » Needs review

Parts of this MR were assisted by Claude Code. Specifically I would not have thought to invalidate the opcache before writing settings.php, and this might be the cause of some weird bugs people have seen immediately after install in some cases?

alexpott’s picture

I've been considering as non-settings.php kill switch for some reasons:

  • Automation - it's harder to automate changing values in settings.php.
  • It's PHP - you make this setting the result of business logic (footgun)
  • The depths of includes of settings.something.php make me wish for something better
  • Opcache fun

I was thinking about an empty drupal/ui-installer composer project that we could use as a flag to enable the installer. This obviously does not scale to other problems - and we already have the update access setting - so at least the settings.php solution as precedence on its side.

Reading the code I think this approach is okay. I wish we didn't have to make the file writable again in install_finished(). One possible improvement is that when installing with the non-interactive installer we should disable the interactive installer much earlier - in the initial write to settings.php by the installer.

Also the setting only disables the interactive installer so probably should be labelled along those lines.

alexpott’s picture

alexpott’s picture

So the test fails reveal 2 things... this change means that in order to use the interactive installer settings.php must be writable - before it was possible to create a settings php that the webserver couldn't write with everything set up and then use the interactive installer. This change breaks that capability. Which feels a bit dodgy.

Also this change breaks #2122693: Installer does not work on a completely empty settings.php - which might be acceptable - but it is a behaviour change.

catch’s picture

Also this change breaks #2122693: Installer does not work on a completely empty settings.php - which might be acceptable - but it is a behaviour change.

I think that's OK assuming we add this in 12.0/11.5, we can put it in the release notes.

this change means that in order to use the interactive installer settings.php must be writable - before it was possible to create a settings php that the webserver couldn't write with everything set up and then use the interactive installer.

I think we can still support that if we add timestamp support and if the installer is not writable, leave the timestamp as-is. If it's writable, set it to FALSE.

longwave’s picture

Fixed the tests for both cases, implemented the timestamp idea (using the same settings key), and renamed everything to "interactive installer" for clarity, all assisted by Claude Code.

longwave’s picture

Addressed the feedback.