Operating System - HP-UX
1820098 Members
3603 Online
109608 Solutions
New Discussion юеВ

Re: how to set umask for group

 
SOLVED
Go to solution
Scott Van Kalken
Esteemed Contributor

how to set umask for group

Does anyone know how to set a umask for a group?

I remember somewhere reading that it's easy to do, but can't for the life of me remember how.

Thanks in advance
6 REPLIES 6
James R. Ferguson
Acclaimed Contributor

Re: how to set umask for group

Hi:

I believe you are looking for 'setprivgrp' [although setting the 'umask' isn't a direct option]. See the man (1M) pages for 'setprivgrp'.

Regards!

...JRF...
Jeff Schussele
Honored Contributor

Re: how to set umask for group

Hi Scott,

I don't see any way to do this to any *other* user or group from a command because the umask command itself only works on the current shell.

I suspect you'd have to search the passwd file for all primary members (group file for secondary members) of a group & extract the home dir & edit the .profile (.login) file within that home dir - setting the umask there.

Then the mask will apply upon next login.

Rgds,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Michael Tully
Honored Contributor

Re: how to set umask for group

Hi Scott,

I don't see a perfect solution for you. One thing to consider would be to set up a skeleton profile for each group that you intend using and have the umask set that way. I would of course still keep the the umask setting in /etc/profile just in case.

As Jeff mentioned, the umask is set by each users shell.

Cheers
Michael
Anyone for a Mutiny ?
James R. Ferguson
Acclaimed Contributor
Solution

Re: how to set umask for group

Hi (again) Scott:

You asked specifically about 'umask'. My answer above using 'setprivgrp' is predicated on the fact that if you confer the ablity to 'chown' then you confer ability to change permission bits ('chmod'), too.

Regards!

...JRF...
Keith Clark
Valued Contributor

Re: how to set umask for group

Hi Scott,

Are you just trying to have new files created in a directory retain the directories group id? If so, you would chmod g+s /mydir. This will not change the group of existing files, so you may have to chgrp -R mygrp /mydir.

As far as affecting the umask of all members of a group, you could try to implement a shared .profile or .cshrc that sets the umask (and other things) for everyone belonging to a particular group. For example:

MYGRP=mygrp
if [ -n "`groups | grep $MYGRP`" ]
then
echo "Sourcing central .profile for group $MYGRP"
. /nfsmnt/mygrp/mygrp.profile
fi

and /nfsmnt/mygrp/.profile is on an nfs mounted directory and contains the umask 007 command and what ever else is specific to your group.

HTH,

Keith
Tom Danzig
Honored Contributor

Re: how to set umask for group

How about something like the following in /etc/profile (assuming GID 20 is the group in question and the use ksh or sh):

if [[ `id -g` -eq 20 ]]
then
umask 022
else
umask 077
fi