1824721 Members
3988 Online
109674 Solutions
New Discussion юеВ

default umask

 
SOLVED
Go to solution
Anthony O'Connor
Occasional Advisor

default umask

Where is the default umask set on HP-UX?
13 REPLIES 13
James R. Ferguson
Acclaimed Contributor

Re: default umask

Hi Anthony:

It's not, other than "000". You should establish the default you want in /etc/profile and/or in $HOME/.profile.

Regards!

...JRF...
Vincent Farrugia
Honored Contributor

Re: default umask

Hi,

Why do you need that? Typing

umask

or

umask -S

displays the mask for you. I don't know why you need to know where it is stored in HP/UX... any more information please?

Vince
Tape Drives RULE!!!
Sanjay_6
Honored Contributor

Re: default umask

Uday_S_Ankolekar
Honored Contributor

Re: default umask

Hi,

umask is set in /etc/profile. That umask can then be overridden by setting it again in the user's .profile. Finally, you can override that at the command line using the umask command (though it will only be changed for that process).

-USA..
Good Luck..
Roger Baptiste
Honored Contributor

Re: default umask


It's been a long time since i did a fresh O/S install, but iirr, the default is nothing i.e 000.

You would need to set it system wide in /etc/profile- > umask xyz

and to override it for individual users, you set it in their .profile file.

HTH
raj
Take it easy.
Anthony O'Connor
Occasional Advisor

Re: default umask

Thanks for the quick replies...

I know I can set it in profiles or on command line. But the default 000 must be set somewhere on the system, before being over ridden by the value in /etc/profile or $HOME/.profile.

The default on trusted systems is 077 (or 07077 to be precise) where is this configured for example?
Bernie Vande Griend
Respected Contributor

Re: default umask

The default is definitely 000 as it is not set.

It is a good practice to set it to 002 or 022 in /etc/profile so that files are not wide open by default for all users, then set it individually per user in their .profile if they something different. Actually what you set it to depends on your situation. I've seen this set to 077 as well so only the user could access his/her files.
Ye who thinks he has a lot to say, probably shouldn't.
Roger Baptiste
Honored Contributor

Re: default umask

<>

umask is a shell environment variable and like
any variable if it is not set, it has no value and is taken as 000. When a file
is created it's default permissions as per
the open system call would be 777; this
is subtracted from the umask setting and the resulting permission will be the actuall file permission setting. So, if the umask is not set, the permission will always be 777.

<>

I think , when you make a system trusted,
it adds the umask entry to the /etc/profile file!!


HTH
raj
Take it easy.
Anthony O'Connor
Occasional Advisor

Re: default umask


>umask is a shell environment variable and
>like any variable if it is not set, it has no
>value and is taken as 000.

If it was an unset shell variable it would have a null value such as " ", rather than "000". Wouldn't it?

>I think , when you make a system trusted,
>it adds the umask entry to the /etc/profile
>file!!

No, it doesn't!!

Re: default umask

Each process that runs on a system has its own file mode creation mask, which is usually inherited from its parent processes environment. Anyone who logs in via the network thro inetd gets the umask defined in /sbin/init.d/inetd. Any other services started on the box get the umask defined in /sbin/rc, as for root logins at the console? Well I'm not sure where init (which is the parent process of the getty) gets its mask from (if anywhere) - Perhaps its hard coded into the kernel...

I am an HPE Employee
Accept or Kudo
Roger Baptiste
Honored Contributor

Re: default umask

>umask is a shell environment variable and
>like any variable if it is not set, it has no
>value and is taken as 000.

<<>>

No. This value is slightly different from the usual shell variable settings. As far as i know, that's because the file creation system calls, invoke umask system call to get the current umask setting.
THe umask system call is always sucessful
i.e, it no value is set it returns 0 and if the umask is set, it returns the umask value. So either case, the output is either a 0 or a umask value.


>I think , when you make a system trusted,
>it adds the umask entry to the /etc/profile
>file!!

<>

Umm, intresting. I need to look into my trusted systems. Will post back , if i find something.

-raj
Take it easy.
Bill Hassell
Honored Contributor

Re: default umask

Yep, it's true. umask's default setting is 07077 for Trusted Systems...which is not correct and is fixed with PHKL_23226. This patch changes the default umask on Trusted System environments to 077.

It is a very good idea to set umask explicitly in /etc/profile AND /etc/csh.login so you know exactly what each user will get. Similarly, set umask for ftpd in /etc/inetd.conf.

Finally, when writing scripts for cron or other batch operations, never assume that umask is safe...set it at the beginning of the script. umask 077 is best for anything run by root. Then in your script, loosen the permissions on specific files when needed.


Bill Hassell, sysadmin
Wodisch
Honored Contributor
Solution

Re: default umask

Hello Anthony,

"umask" is kernel parameter (and has always been ;-). There is a shell-builtin command "umask", of course, but this is only useful for *changing* it, the original value comes from the kernel, or - in rare cases, like "ftpd" - from the daemon's setup.
For shells it might be fine to set it "/etc/profile" and "/etc/cshrc", but what about CDE (X-Windows) and other daemons?
So, you might consider setting "umask" in each daemon's rc-script prior to starting the daemon process. To not influence something else enclose everything in parentheses like here:
( umask 027; /usr/lib/lpsched && echo ...; )
( umask 077; /usr/sbin/inetd -k; )

Some rc-scripts already do this, like "inetd", "net", and "syslogd", but other not (like "lp", "cron").

Just my ???0.02,
Wodisc