Skip to content

Commit 5e45f60

Browse files
authored
Remove chown and local user handling (#96)
* Remove chown and local user handling * Deprecate buildSetFilesOwner
1 parent c108679 commit 5e45f60

File tree

1 file changed

+12
-21
lines changed

1 file changed

+12
-21
lines changed

RoboFileBase.php

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
abstract class RoboFileBase extends \Robo\Tasks {
1414

1515
protected $drush_cmd;
16-
protected $local_user;
1716

1817
protected $drush_bin = "bin/drush";
1918
protected $composer_bin = "composer";
@@ -42,14 +41,11 @@ abstract class RoboFileBase extends \Robo\Tasks {
4241
protected $php_enable_module_command = 'phpenmod -v ALL';
4342
protected $php_disable_module_command = 'phpdismod -v ALL';
4443

45-
protected $web_server_user = 'www-data';
46-
4744
protected $application_root = "/code/web";
4845
protected $file_public_path = '/shared/public';
4946
protected $file_private_path = '/shared/private';
5047
protected $file_temp_path = '/shared/tmp';
5148
protected $services_yml = "web/sites/default/services.yml";
52-
protected $settings_php = "web/sites/default/settings.php";
5349

5450
protected $config = [];
5551

@@ -89,7 +85,6 @@ abstract class RoboFileBase extends \Robo\Tasks {
8985
*/
9086
public function __construct() {
9187
$this->drush_cmd = $this->drush_bin;
92-
$this->local_user = $this->getLocalUser();
9388

9489
// Read config from env vars.
9590
$environment_config = $this->readConfigFromEnv();
@@ -153,11 +148,11 @@ public function build() {
153148
$this->devXdebugDisable();
154149
$this->devComposerValidate();
155150
$this->buildMake();
156-
$this->buildSetFilesOwner();
151+
$this->ensureDirectories();
157152
$this->buildInstall();
158153
$this->configImportPlus();
159154
$this->devCacheRebuild();
160-
$this->buildSetFilesOwner();
155+
$this->ensureDirectories();
161156
$this->devXdebugEnable();
162157
$this->say('Total build duration: ' . date_diff(new DateTime(), $start)->format('%im %Ss'));
163158
}
@@ -198,20 +193,27 @@ public function buildMake($flags = '') {
198193
/**
199194
* Set the owner and group of all files in the files dir to the web user.
200195
*/
201-
public function buildSetFilesOwner() {
196+
public function ensureDirectories() {
202197
$publicDir = getenv('PUBLIC_DIR') ?: $this->file_public_path;
203198
$privateDir = getenv('PRIVATE_DIR') ?: $this->file_private_path;
204199
$tmpDir = getenv('TMP_DIR') ?: $this->file_temp_path;
205200
foreach ([$publicDir, $privateDir, $tmpDir] as $path) {
206201
$this->say("Ensuring all directories exist.");
207202
$this->_exec("mkdir -p $path");
208-
$this->say("Setting files directory owner.");
209-
$this->_exec("chown $this->web_server_user:$this->local_user -R $path");
210203
$this->say("Setting directory permissions.");
211204
$this->setPermissions($path, '0775');
212205
}
213206
}
214207

208+
/**
209+
* Set the owner and group of all files in the files dir to the web user.
210+
*
211+
* @deprecated Use ::ensureDirectories instead.
212+
*/
213+
public function buildSetFilesOwner() {
214+
$this->ensureDirectories();
215+
}
216+
215217
/**
216218
* Clean config and files, then install Drupal and module dependencies.
217219
*/
@@ -652,17 +654,6 @@ protected function setPermissions($file, $permission) {
652654
}
653655
}
654656

655-
/**
656-
* Return the name of the local user.
657-
*
658-
* @return string
659-
* Returns the current user.
660-
*/
661-
protected function getLocalUser() {
662-
$user = posix_getpwuid(posix_getuid());
663-
return $user['name'];
664-
}
665-
666657
/**
667658
* Helper function to check whether a task has completed successfully.
668659
*

0 commit comments

Comments
 (0)