From 6b4733fee2a67debce943746dbe5e7d3aae96285 Mon Sep 17 00:00:00 2001
From: jurgenhaas <juergen.haas@lakedrops.com>
Date: Thu, 7 Sep 2023 19:22:04 +0200
Subject: [PATCH] composer/plugin/docker4drupal#63 Ensure setting files are
 writeable and set them read-only afterwards

---
 src/Handler.php | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/Handler.php b/src/Handler.php
index 978e531..275608a 100644
--- a/src/Handler.php
+++ b/src/Handler.php
@@ -139,10 +139,13 @@ class Handler extends BaseHandler {
       $file = $projectRoot . '/settings/default/' . $template;
       $link = $webRoot . '/sites/default/' . $template;
       $rendered = $this->config->render($template, file_get_contents($pluginRoot . '/templates/' . $template . '.twig'));
+      if (file_exists($file)) {
+        $fs->chmod($file, 0664);
+      }
       file_put_contents($file, $rendered);
       $rel = substr($fs->makePathRelative($file, $projectRoot . '/' . $link), 3, -1);
       $fs->symlink($rel, $link);
-      $fs->chmod($file, 0664);
+      $fs->chmod($file, 0444);
       if ($this->config->readValue('chg-acl')) {
         $fs->chgrp($file, $this->config->readValue('webserver-groupname'));
       }
-- 
GitLab