Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't add remote user to setfacl command, if it doesn't exist as an os user #2822

Merged
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions recipe/deploy/writable.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@
run("$sudo chmod +a \"$httpUser allow delete,write,append,file_inherit,directory_inherit\" $dirs");
run("$sudo chmod +a \"$remoteUser allow delete,write,append,file_inherit,directory_inherit\" $dirs");
} elseif (commandExist('setfacl')) {
$setFaclUsers = "-m u:\"$httpUser\":rwX";
// Check if remote user exists, before adding it to setfacl
$remoteUserId = run("id -u $remoteUser &>/dev/null 2>&1 || exit 0");
ElAberino marked this conversation as resolved.
Show resolved Hide resolved
if (!empty($remoteUserId)) {
$setFaclUsers .= " -m u:$remoteUser:rwX";
}
if (empty($sudo)) {
// When running without sudo, exception may be thrown
// if executing setfacl on files created by http user (in directory that has been setfacl before).
Expand All @@ -117,13 +123,13 @@
$hasfacl = run("getfacl -p $dir | grep \"^user:$httpUser:.*w\" | wc -l");
// Set ACL for directory if it has not been set before
if (!$hasfacl) {
run("setfacl -L $recursive -m u:\"$httpUser\":rwX -m u:$remoteUser:rwX $dir");
run("setfacl -dL $recursive -m u:\"$httpUser\":rwX -m u:$remoteUser:rwX $dir");
run("setfacl -L $recursive $setFaclUsers $dir");
run("setfacl -dL $recursive $setFaclUsers $dir");
}
}
} else {
run("$sudo setfacl -L $recursive -m u:\"$httpUser\":rwX -m u:$remoteUser:rwX $dirs");
run("$sudo setfacl -dL $recursive -m u:\"$httpUser\":rwX -m u:$remoteUser:rwX $dirs");
run("$sudo setfacl -L $recursive $setFaclUsers $dirs");
run("$sudo setfacl -dL $recursive $setFaclUsers $dirs");
}
} else {
$alias = currentHost()->getAlias();
Expand Down