I'd like to clone all the ZFS ACLs from one file to another.
With POSIX ACLs this can be done by piping the output of getfacl
to setfacl
.
Is there an easy and quick way to do this with the NFSv4 style ACLs in ZFS? I know I can read off the output of ls -lV
and then enter it as part of a chmod
, but I can't seem to find a functional equivalent to the POSIX way of copying ACLs.
Best Answer
Instead of using
ls -lV
you can usels -lv
which can be fed in to a script to convert it to a sequence ofchmod
commands to duplicate the ACLs.E.g. if the ACl looks like this:
It should be turned in to the following sequence of
chmod
commands:I recently found myself in a situation where a script like the one described above would have been useful, so here's a little Bash script I made (can also be sourced to the shell and run as a function) to print the list of chmod commands necessary to copy the ZFS ACLs from one file to another:
Here are a couple example usages and their output for file1 from above:
If we like, we can even evaluate these chmods directly, if both files are accessible on this host and we wish to copy the ACLs from file1 to file2 immediately: