If I have a directory with default ACL entries assigned to it, but some or all of its descendant files and sub-directories have access or default ACLs that do not agree with those defaults, how do I recursively (re)apply those default ACL entries to all descendants? There is a qualification. I wish to entirely replace all existing descendant ACLs except for the existing execute status of files. The intent otherwise is that all descendants should have the ACLs they would have if newly created in their current location.
Rogach asked "How do I set permissions recursively on a dir (with ACL enabled)?" but was looking to add a new ACL entry recursively rather than (re)applying an existing default ACL. Although not asked for by Rogach, Franklin Piat's answer to that question also offers a solution to my question, but I believe his solution is flawed. Piat suggests this pair of commands:
find . -mindepth 1 -type d| xargs -n 50 setfacl -b --set-file=<(getfacl . | sed -e 's/x$/X/') find . -mindepth 1 -type f| xargs -n 50 setfacl -b --set-file=<(getfacl . | grep -v '^default:' | sed -e 's/x$/X/')
The flaws that I want to fix:
- The current directory's access ACL is being propagated to descendants instead of its default ACL, which is not how I understand ACLs should work.
- The execute bit is cleared for all files (sed is ineffective).
- Typical sudoer policies prevent process substitution from working when root privileges are required. See "closefrom_override" option for sudoers(5).
Ideally I would also only need one command line to accomplish this one task.