cancel
Showing results for 
Search instead for 
Did you mean: 

umask

 
Highlighted
Frequent Advisor

umask

I have heard many times that the umask is inverted and bitwise anded with the default setting of 666 (files) and 777 (directories).

Does anyone know where these magic numbers of 666 for files and 777 for directories come from or where they are kept?
11 REPLIES 11
Highlighted
Acclaimed Contributor

Re: umask

These numbers are hardcoded into each application that calls creat(2) (possibly indirectly through fopen(3)) or mkdir(2).
Highlighted
Frequent Advisor

Re: umask

So in the application development community it is pretty much standardized that new files will be created with octal mode 666 and new dirs with 777?

Is this really a worldwide standard?

If that's correct there can be exceptions to this rule then...right?
Highlighted
Acclaimed Contributor

Re: umask

> it is pretty much standardized that new files will be created with octal mode 666 and new dirs with 777?

It's rather the creation mode is octal 666 for files and 777 for directories that is supplied to 'creat()' and that the umask is then and'ed to obtain the permissions you see. Thus, a 'umask' of zero (0000) when applied during file creation leaves the permissions as 0666 for a file and 0777 for a directory. These are the values that the shell uses as a standard.

Regards!

...JRF...
Highlighted
Frequent Advisor

Re: umask

My question is related in part to ftp.

I am putting some files into a directory on a server and even though the default umask is 022 the files that are being dumped have 0600 permissions instead of the expected 0644. This is really confusing the heck out of me.

So please help as best as you can.
Highlighted
Acclaimed Contributor

Re: umask

Hi:

You can set a 'defumask' umask in '/etc/ftpd/ftpaccess'. The later configuration file is used when the FTP daemon (as spawned by 'inetd') is invoked with the '-a' switch. See:

http://www.docs.hp.com/en/B2355-60130/ftpaccess.4.html

Regards!

...JRF...


Highlighted
Frequent Advisor

Re: umask

I had thought of looking at the ftpaccess file but I want the umask to apply only to a particular user on the system not everybody.

Is there a way I can specify that particular user?
Highlighted
Frequent Advisor

Re: umask

Besides that defumask is found only on 11iv3 while the sytem I am on is 11iv1.
Highlighted
Acclaimed Contributor

Re: umask

Hi (again):

> Besides that defumask is found only on 11iv3 while the sytem I am on is 11iv1

Well, it always helps to state the release on which you are running at the onset :-)

That said, on 11.23 or 11.31 you could do

class myclass real someuser
defumask 022 myclass

...which would allow you a user-specific 'umask' as desired.

I don't know if this works or not on 11.11. It's not documented in those manpages. If it isn't, I think this leaves you to use 'inetd's default FTP umask '-u nnn' and to after-the-fact change the permissions of the files of the user in question.

Regards!

...JRF...
Highlighted
Acclaimed Contributor

Re: umask

>So in the application development community it is pretty much standardized that new files will be created with octal mode 666 and new dirs with 777?

Yes. But some application may want to be more secure. Though from fopen(3), you don't get a choice.

>If that's correct there can be exceptions to this rule then... right?

Sure. But from your following questions it seems it is umask that is changed, not the default mode parms.