Chmod: copy permissions (with extended permissions) from one file to another

chmod

I've got a ZFS filesystem that's shared via CIFS. Somehow, the permissions have got all messed up, to the point where the ownership is all correct but a whole bunch of files have 0000 permissions.

The files which work correctly look like this:

-rwx------+  1 guest other 3.8M 2011-05-10 14:58 Presentation.ppt

How do I copy that permissions set and apply it across the rest of the files on the filesystem?

Update

Thanks for the responses – the problem I have is that a file with 700 permissions for some reason doesn't have the delete permission, when viewed from windows:

Setting the permission gives the '+' on the file.

Best Answer

You can view extended permissions with:

$ /usr/bin/ls -V Presentation.ppt

This could look like:

$ /usr/bin/ls -V Presentation.ppt
   -rw-r--r--+  1 root     staff          0 Feb  3 14:13 file.1
        user:lp:rw------------:------:allow
         owner@:--x-----------:------:deny
         owner@:rw-p---A-W-Co-:------:allow
     user:marks:r-------------:------:deny
         group@:-wxp----------:------:deny
         group@:r-------------:------:allow
      everyone@:-wxp---A-W-Co-:------:deny
      everyone@:r-----a-R-c--s:------:allow

You could then apply this set of ACL settings recursively to your share:

$ /usr/bin/chmod -R A=\
    user:lp:rw------------:------:allow, \
    owner@:--x-----------:------:deny, \
    owner@:rw-p---A-W-Co-:------:allow, \
    user:marks:r-------------:------:deny, \
    group@:-wxp----------:------:deny, \
    group@:r-------------:------:allow, \
    everyone@:-wxp---A-W-Co-:------:deny, \
    everyone@:r-----a-R-c--s:------:allow, \
    /mnt/share