Skip to content

Commit ffacbaa

Browse files
authored
Added writable_acl_groups option to acl mode in deploy:writable (#3957)
* Added `writable_acl_groups` option to acl mode in `deploy:writable` * Added docs
1 parent 8a2c0cb commit ffacbaa

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

docs/recipe/deploy/writable.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,20 @@ The chmod mode.
9191
```
9292

9393

94+
### writable_acl_groups
95+
[Source](https://github.com/deployphp/deployer/blob/master/recipe/deploy/writable.php#L62)
96+
97+
List of additional groups to give write permission to.
98+
99+
```php title="Default value"
100+
[]
101+
```
102+
94103

95104
## Tasks
96105

97106
### deploy\:writable {#deploy-writable}
98-
[Source](https://github.com/deployphp/deployer/blob/master/recipe/deploy/writable.php#L62)
107+
[Source](https://github.com/deployphp/deployer/blob/master/recipe/deploy/writable.php#L65)
99108

100109
Makes writable dirs.
101110

recipe/deploy/writable.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@
5858
// The chmod mode.
5959
set('writable_chmod_mode', '0755');
6060

61+
// List of additional groups to give write permission to.
62+
set('writable_acl_groups', []);
63+
6164
desc('Makes writable dirs');
6265
task('deploy:writable', function () {
6366
$dirs = join(' ', get('writable_dirs'));
@@ -103,6 +106,13 @@
103106
run("$sudo chmod +a \"$remoteUser allow delete,write,append,file_inherit,directory_inherit\" $dirs");
104107
} elseif (commandExist('setfacl')) {
105108
$setFaclUsers = "-m u:\"$httpUser\":rwX";
109+
$setFaclGroups = "";
110+
foreach (get("writable_acl_groups") as $index => $group) {
111+
if ($index > 0) {
112+
$setFaclGroups .= " ";
113+
}
114+
$setFaclGroups .= "-m g:\"$group\":rwX";
115+
}
106116
// Check if remote user exists, before adding it to setfacl
107117
$remoteUserExists = test("id -u $remoteUser &>/dev/null 2>&1 || exit 0");
108118
if ($remoteUserExists === true) {
@@ -119,13 +129,13 @@
119129
$hasfacl = run("getfacl -p $dir | grep \"^user:$httpUser:.*w\" | wc -l");
120130
// Set ACL for directory if it has not been set before
121131
if (!$hasfacl) {
122-
run("setfacl -L $recursive $setFaclUsers $dir");
123-
run("setfacl -dL $recursive $setFaclUsers $dir");
132+
run("setfacl -L $recursive $setFaclUsers $setFaclGroups $dir");
133+
run("setfacl -dL $recursive $setFaclUsers $setFaclGroups $dir");
124134
}
125135
}
126136
} else {
127-
run("$sudo setfacl -L $recursive $setFaclUsers $dirs");
128-
run("$sudo setfacl -dL $recursive $setFaclUsers $dirs");
137+
run("$sudo setfacl -L $recursive $setFaclUsers $setFaclGroups $dirs");
138+
run("$sudo setfacl -dL $recursive $setFaclUsers $setFaclGroups $dirs");
129139
}
130140
} else {
131141
$alias = currentHost()->getAlias();

0 commit comments

Comments
 (0)