diff --git a/src/Handler.php b/src/Handler.php index 665c5af..995fe4e 100644 --- a/src/Handler.php +++ b/src/Handler.php @@ -53,6 +53,8 @@ public function onPostCmdEvent(\Composer\Script\Event $event) $this->createSettingsFile(); $event->getIO()->write("Creating services.yml file if not present."); $this->createServicesFile(); + $event->getIO()->write("Removing write permissions on settings files."); + $this->removeWritePermissions(); } /** @@ -169,7 +171,6 @@ public function createSettingsFile() $shepherdSettings, FILE_APPEND ); - $this->filesystem->chmod($root . '/sites/default/settings.php', 0444); } } @@ -182,10 +183,20 @@ public function createServicesFile() if (!$this->filesystem->exists($root . '/sites/default/services.yml') && $this->filesystem->exists($root . '/sites/default/default.services.yml')) { $this->filesystem->copy($root . '/sites/default/default.services.yml', $root . '/sites/default/services.yml'); - $this->filesystem->chmod($root . '/sites/default/services.yml', 0444); } } + /** + * Remove all write permissions on Drupal configuration files and folder. + */ + public function removeWritePermissions() + { + $root = $this->getDrupalRootPath(); + $this->filesystem->chmod($root . '/sites/default/services.yml', 0444); + $this->filesystem->chmod($root . '/sites/default/settings.php', 0444); + $this->filesystem->chmod($root . '/sites/default', 0555); + } + /** * Copy files from origin to destination, optionally overwritting existing. *