1 |
Am 25.03.2010 09:50, schrieb Alan McKinnon: |
2 |
> On Thursday 25 March 2010 10:26:25 Hinko Kocevar wrote: |
3 |
>> Hi, |
4 |
>> |
5 |
>> Where is defined what permissions will the newly created folder/file |
6 |
>> have by default? |
7 |
> |
8 |
> This is done by the umask of the user creating the folder. |
9 |
> |
10 |
> |
11 |
>> |
12 |
>> Eg. When creating a folder I would like it to have permissions right |
13 |
>> after it is created, to void use of chmod/chown afterwards: |
14 |
>> |
15 |
>> drwxrwxr-x 2 hinko users 4096 Mar 25 09:23 folder1 |
16 |
>> |
17 |
>> while now I get only: |
18 |
>> drwxr-xr-x 2 hinko users 4096 Mar 25 09:23 folder1 |
19 |
>> |
20 |
>> That is group should have 'w' set. |
21 |
> |
22 |
> |
23 |
> This is a common misunderstanding about permissions and the Unix philosophy |
24 |
> about them, which is: |
25 |
> |
26 |
> It's up to the user, not the system, to say what permissions he wants on new |
27 |
> filesystem objects. |
28 |
> |
29 |
> Modifing the user's umask is not advised, as this is global. *Every* new file |
30 |
> or dir then ends up with g+w and you probably don't want that. |
31 |
> |
32 |
> You need to use Posix ACLs for this, and your file system and kernel must |
33 |
> support them; you configure it per directory. It's all in man pages and on |
34 |
> google - better start reading. |
35 |
> |
36 |
> Be warned though: you *will* forget you set this, and *will* wonder in future |
37 |
> why g+w is set in various places. "ls" gives precious little clue that an ACL |
38 |
> is in place. |
39 |
> |
40 |
> I find that in real life, a "find -exec chmod" in a cron is a better solution |
41 |
> |
42 |
|
43 |
To avoid ACLs and still have group rw rights on some folders for |
44 |
specific groups, you can make use of the 'user private group' scheme and |
45 |
the setgid bit: [1]. |
46 |
|
47 |
Gentoo uses this scheme per default, although I think the umask setting |
48 |
is different (has to be 002 or 007). |
49 |
|
50 |
What Alan forgot to tell is where to set the umask: /etc/profile. Don't |
51 |
use too strict settings because these are also applied to system |
52 |
accounts. This can easily break your system. |
53 |
|
54 |
[1] |
55 |
http://www.redhat.com/docs/manuals/linux/RHL-7.3-Manual/ref-guide/s1-users-groups-private-groups.html |
56 |
|
57 |
Hope this helps, |
58 |
Florian Philipp |