views:

20

answers:

1

I recently removed my ACL because my professor needed to copy certain files. Now I know I should have just granted his user permissions instead of removing it all using 'setfacl -b .' on my home directory.

So the question is how do I recover or set a new ACL to my home directory using setfacl/getfacl?

+1  A: 

You can't 'recover' what you discarded in the way of ACLs. If you know what you had set previously, you can reinstate those remembered ACLs anew, carefully.

Basic Permissions

On a Unix system, the most important criteria for you are the group and other ones - they are not directly affected by ACLs, but they control the access not governed by ACLs, and you must get them right too. You need to decide what is appropriate in your environment. For many corporate settings, allowing group and others read access on files, execute on programs, and read and search (execute) on directories is appropriate:

chmod 644 file
chmod 755 program
chmod 755 directory

If you are not supposed to let other people borrow your course work, you would nail things down so that group and others are not allowed in at all:

chmod 600 file
chmod 700 program
chmod 700 directory

Or you can mix and match; allow flexibility and open access to your home directory, but restrict people underneath that. In some circumstances, you might allow group or other only execute permission on a directory (and only read on a file). Then other people cannot access the file unless they know its name, and they can only read the file, not modify it or the directory that holds it.

Don't forget to use an appropriate umask setting so files are created with the correct permissions by default. For many people, a umask of 022 is appropriate; neither group members nor others can write to the file or directory, but they can read files or execute programs.

Using ACLs

None of this requires ACLs. If you want to provide controlled access to certain groups or users and not to others, then you need to ensure you have the appropriate base-level permissions set, and you can then effectively add permissions for selected users or groups on the files or directories you choose.

The Solaris 10 man page for setfacl says that the command syntax is:

 setfacl [-r] -s acl_entries file
 setfacl [-r] -md acl_entries file
 setfacl [-r] -f acl_file file

This does not mention the '-b' option mentioned in the question, so you may be using a different platform. Note that the ACL controls was going to be POSIX 1e, but was never actually standardized, so different platforms implement slightly different variants on the commands.

The Solaris 10 man page then goes on to explain how to set the 'acl_entries' part of the description, with a note that the default part can only be applied to a directory, but the default values will be used for files in the directory.

 ACL Entry                     Description
 u[ser]::perms                 File owner permissions.
 g[roup]::perms                File group owner permissions.
 o[ther]:perms                 Permissions for  users  other  than
                               the  file  owner or members of file
                               group owner.
 m[ask]:perms                  The ACL mask. The mask entry  indi-
                               cates   the   maximum   permissions
                               allowed for users (other  than  the
                               owner)  and for groups. The mask is
                               a quick way to  change  permissions
                               on all the users and groups.
 u[ser]:uid:perms              Permissions for  a  specific  user.
                               For  uid,  you can specify either a
                               user name or a numeric UID.
 g[roup]:gid:perms             Permissions for a  specific  group.
                               For  gid,  you can specify either a
                               group name or a numeric GID.
 d[efault]:u[ser]::perms       Default file owner permissions.
 d[efault]:g[roup]::perms      Default file  group  owner  permis-
                               sions.
 d[efault]:o[ther]:perms       Default permissions for users other
                               than  the  file owner or members of
                               the file group owner.
 d[efault]:m[ask]:perms        Default ACL mask.
 d[efault]:u[ser]:uid:perms    Default permissions for a  specific
                               user.  For  uid,  you  can  specify
                               either a user  name  or  a  numeric
                               UID.
 d[efault]:g[roup]:gid:perms   Default permissions for a  specific
                               group.  For  gid,  you  can specify
                               either a group name  or  a  numeric
                               GID.

You will need to decide who, apart from your professor, needs access to files. Maybe your lab partner does; maybe the teaching assistants do; maybe your whole year (but not the years below you - those above you probably already know what you know). But without any more information about your requirements for protection, no-one can help you more. And generally, it is easy to get the ACLs wrong - use sparingly, if at all, and use the standard Unix permissions as your main access control.

And next time, I suggest simply allowing your professor in by adding (not erasing) ACLs - or asking him where he wants you to copy the files to (putting the onus on him to sort out the permissions issues), or copying the files into a directory such as $HOME/tmp/prof.jones with 711 permission on the directory, 644 permissions on the files, and tell him which files are there for him to copy.

Jonathan Leffler