views:

419

answers:

3

Are there any ways in OS X to clone the permissions of one folder to another. Just to be clear, I don't want to copy the entire folder, just the permissions and then set them on another folder. I think this type of thing could be achieved on Linux/UNIX using the setfacl/getfacl commands, but I'm unsure on how to do this with OS X.

Thanks

+1  A: 

I presume you Googled and found at least:

And this web page also seems to cover some important information (such as fsaclctl).

Jonathan Leffler
`fsaclctl` is for turning acls on or off on a filesystem, rather than controlling the acl status of a particular folder. In 10.4, I believe, acl support was available but off by default, so this command came in handy. In 10.5, of course acls are on by default, so it still comes in handy for turning the damn things off.
Telemachus
I use chmod all the time, the problem is that I need an automated process to clone the permissions from a source directory to a target directory. Chmod is easy to use manually, but for an automated process it may be a bit hard.
macatomy
@PCWiz: you can easily put a series of `chmod` commands (which you've tested to perfection) into a Bash script and run that as needed.
Telemachus
You can use `ls -lde` to get the acls to begin with, by the way.
Telemachus
A: 

What I ended up doing was creating an Objective C method (I was planning on using this in a Cocoa app anyways) that finds out the permissions of a file using a perl script, then uses chmod/chown to apply those permissions.

macatomy
+1  A: 

Tested on Mac OS X v10.5.7, in bash:

chown $(stat -f%u:%g "$srcdir") "$dstdir" # Copy owner and group
chmod $(stat -f%Mp%Lp "$srcdir") "$dstdir" # Copy the mode bits
(ls -lde "$srcdir"  | tail +2 | sed 's/^ [0-9]*: //'; echo) | chmod -E  "$dstdir" # Copy the ACL

Notes: These operations (esp. changing ownership) are likely to require root access; sprinkle with sudo for best results. Also, that odd echo command on the last line is there to prevent an error if srcdir doesn't have any ACL entries attached (chmod -E can cope with blank lines, but not a completely empty input).

Gordon Davisson