2

Possible Duplicate:
How to set default file permissions for all folders/files in a directory?

Say I have default umask, umask1. I would like all files/folders that I create/modify under a specific path

/path/to/foo

to have a different umask, umask2, and keep using umask1 for everything else. Is there a way to have the shell do this automatically for me? If so, how?

Is there a way to do this for everyone else who belongs to the groupID of /path/to/foo?

2 Answers2

2

You need to use default ACLs.

Note that the syntax is a bit different, and is based on the positive permissions, not the negative permissions mask, e.g. rwxr-x--- would be 750 rather than 027.

For example

setfacl -m d:u::7,g::5,o:0 /path/to/foo

or

setfacl -m d:u::rwx,g::r-x,o:- /path/to/foo

will make it so that files and directories created under /path/to/foo are 750 = rwxr-x--- by default.

If you already have some subfolders, you'll want to add the -R flag to set their defaults recursively as well.

If you get an Operation not supported error, you probably don't have ACLs enabled on your file system. The correct answer depends on many things, but if you're on Linux using ext2/ext3/ext4, try

sudo mount -o remount,acl <mount point>

or

sudo tune2fs -o acl <file system>

See also How to set default file permissions for all folders/files in a directory?

Mikel
  • 57,299
  • 15
  • 134
  • 153
2

You can mount the directory with specific permissions and effective umask using bindfs. See http://www.cs.helsinki.fi/u/partel/bindfs_docs/bindfs.1.html.

dartonw
  • 954