You are not logged in.

#1 2010-11-18 23:06:44

XtrmGmr99
Member
Registered: 2009-04-14
Posts: 128

umask question...

I'm just wondering: I know that umask sets the default file permissions for files, however I want to know if there is anyway to set default file permissions for newly created directories.

For example, I want my user to create new directories that anyone can access and modify (777) but I want the new files the user creates to be 755 (read by everyone, written only by user).

Is this possible?

Offline

#2 2010-11-18 23:39:09

bazmonkey
Member
Registered: 2010-11-03
Posts: 21

Re: umask question...

Not really. An old Unix mantra is "everything is a file". When you make a directory, you are making a file whose contents are the identifiers (inodes) of the files it contains. It all gets masked the same.

What you can do depends on why you're doing this. You can directly make directories with specific permissions, with "mkdir -m=MODE dir", but you can't make them.

With access control lists you can set more complicated rules of default permissions wthin directories, but again, it governs the creation of any new object, not just diectories.

Perhaps there is an easier way to go about accomplishing what you want to do.  In your example, for example, giving all directories 777 access means anyone could delete or create any file within any directory. Plus, you're never going to get regular files created with 755 access because the umask/acl only restricts the permissions that files come with. Regular files don't come with the execution bit set (binaries like newly compiled executables do), so the most a regular file will be created with is 666.

A normal umask like 0022 does what it sounds like you're looking for, a "look, but don't touch" sort of control. Users can create what they want in their directories (including 777 directories if that's what you actually want), and everyone else can see those files, but only the user can modify anything that he/she hasn't specifically allowed other users to do so.  If that's not what you want, what do you actually want to accomplish?

Last edited by bazmonkey (2010-11-18 23:49:58)

Offline

#3 2010-11-18 23:52:49

rusty99
Member
Registered: 2009-03-18
Posts: 253

Re: umask question...

You can set it in your shell's rc file for user config, for all users have a look at /etc/login.conf or man login.conf
Not at a linux box right now but I assume it would be cap_mkdb /etc/login.conf after changes are made.

Offline

#4 2010-11-19 00:25:42

bazmonkey
Member
Registered: 2010-11-03
Posts: 21

Re: umask question...

rusty99 wrote:

You can set it in your shell's rc file for user config, for all users have a look at /etc/login.conf or man login.conf
Not at a linux box right now but I assume it would be cap_mkdb /etc/login.conf after changes are made.

To have just directories created with a different umask than files, or to make regular files created with the execution bit set?  How?

Offline

#5 2010-11-19 03:21:19

pseudonomous
Member
Registered: 2008-04-23
Posts: 349

Re: umask question...

As somewhat of an aside:

If you give 777 permissions on a directory, not only will users be able to write any file they want in the directory, they are able to delete files, even if these files are not owned by that user.  They can also remove the directory.   I'm not sure why you want to give directories 777 permissions, but keep these facts in mind.

Offline

#6 2010-11-19 04:43:01

bazmonkey
Member
Registered: 2010-11-03
Posts: 21

Re: umask question...

pseudonomous wrote:

They can also remove the directory.

The directory's parent directory's permissions determine that...

Offline

#7 2010-11-19 05:50:10

pseudonomous
Member
Registered: 2008-04-23
Posts: 349

Re: umask question...

Oops, yes, that's right.  I forgot that I had write permissions anyway in the directory I tested tested this.

Offline

#8 2010-11-19 06:08:44

bazmonkey
Member
Registered: 2010-11-03
Posts: 21

Re: umask question...

pseudonomous wrote:

Oops, yes, that's right.  I forgot that I had write permissions anyway in the directory I tested tested this.

I just took a CS course on shell scripting and that was a question I missed earlier in the semester :-P

Offline

#9 2010-11-19 09:09:04

rusty99
Member
Registered: 2009-03-18
Posts: 253

Re: umask question...

bazmonkey wrote:

To have just directories created with a different umask than files, or to make regular files created with the execution bit set?  How?

Appears I shouldn't answer questons so late at night hmm
I read the OP as just wanting to change default umask, not having diferent umasks for dirs and files.

Offline

Board footer

Powered by FluxBB