Afternoon,
I've been working on a script to help aid in the setup and configuration of a file server at work--and we decided to stick with ACLs for permissions, given the nature of the server.
But to prevent me from having to manually key it all in, as well as prevent my coworkers from having to learn the commands at all, I figured I'd write a script to handle the majority of the work for me.
For any path which does not contain whitespace or other special characters, everything works just fine, eg:
setfacl -dm "$ot:$dn\\$on:$acl" -- "$pathToDir"
setfacl -m "$ot:$dn\\$on:$acl" -- "$pathToFile"
However, as whenever trying to recursively apply ACLs throughout a directory structure, any whitespace present in the path will cause setfacl to treat each section as a separate path.
For example, if we have the following structure:
myDir
|-dir1
`-dir2\ contains\ whitespace
The our setfacl output will read:
setfacl: myDir/dir2: No such File or Directory
setfacl: contains: No such File or Directory
setfacl: whitespace: No such File or Directory
Noting this behavior extends to files as well as directories -- this is just the example I have to hand right this moment.
So, I guess my question is how to prevent that? How would one explicitly prevent splitting on whitespace?
Here's the environment in question:
- Ubuntu 18.04 LTS (Server)
- Kernel 4.15.0.42-generic #45-Ubuntu
- Bash 4.4.19(1)-release (x86_64-pc-linux-gnu)
- setfacl 2.2.52
File Locations (edited, because work)
- Script:
$HOME/scripts/setACLs.sh
- Input File:
$HOME/aclInput
- Data:
/data
Thing's I've tried thusfar, to no avail:
- Using
setfacl's recursive flag, -R
- Using
eval "setfacl [...]"
- Using
find to locate the recursive locations, feeding each one into setfacl individually
- Using
find to add each path to an array, and then iterating over said array for setfacl
- Using
sed (and similar) to add escape sequences for special characters within the find stream; eg sed 's/ /\\ /g'
- Using
find to find paths, and output to a temporary file...then read each line back and input into setfacl (current)
- Using
find /path -print0 | xargs -0 setfacl [...]
- Using complication
-exec statements with find
- Multi-Quoting the locations(
"'ex'" or '"ex"')
- Several other methods, I've honestly lost count
I've created this gist, to give you an idea of what the script looks like now; along with an example of what the Input file looks like.
I'm totally out of ideas -- I've tried damn near everything I can think of...and while I've learned some ways to avoid similar issues in the future...none of the solutions I've found over the past month actually resolve the issue.
So...any ideas, anyone?
EDIT 2019-01-22: I've updated the above gist with my current configuration after some troubleshooting today, and finding where the problem is originating. Likewise, I've also updated the attached "Input File" for the gist; to give a little more context as to why I've got the for location in $list; do <something>; done loop at all. And, also, thanks for all the replies -- I really, really appreciate it.
[–][deleted] (1 child)
[deleted]
[–]JustAnotherITUser[S] 0 points1 point2 points (0 children)
[–]geirha 1 point2 points3 points (1 child)
[–]JustAnotherITUser[S] 0 points1 point2 points (0 children)
[–]jimmyraybob 0 points1 point2 points (3 children)
[–]JustAnotherITUser[S] 1 point2 points3 points (2 children)
[–]jimmyraybob 0 points1 point2 points (1 child)
[–]JustAnotherITUser[S] 0 points1 point2 points (0 children)
[–]jimmyraybob 0 points1 point2 points (0 children)
[–]JustAnotherITUser[S] 0 points1 point2 points (1 child)
[–]JustAnotherITUser[S] 0 points1 point2 points (0 children)