Skip to content

Commit

Permalink
YOLO - Remove the site directory write permissions at the end of the …
Browse files Browse the repository at this point in the history
…scaffold process.
  • Loading branch information
pingers committed Sep 6, 2017
1 parent 017dcaa commit 3b7eaa1
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down Expand Up @@ -169,7 +171,6 @@ public function createSettingsFile()
$shepherdSettings,
FILE_APPEND
);
$this->filesystem->chmod($root . '/sites/default/settings.php', 0444);
}
}

Expand All @@ -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.
*
Expand Down

0 comments on commit 3b7eaa1

Please sign in to comment.