Re: Umask

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jay Paulson wrote:
> Hey thanks for the help!  That's exactly what I was looking for.
> 
> One thing interesting that I noticed though was that one one machine I  
> have the umask is set to 022 when a user logs in.

Is this Fedora? Red Hat? Another Linux? Another Unix-like system? It
really makes a difference.

> However, if a user  
> logs into a different machine the umask is set to 0002 but, if they su  
> to root (something I can't do on the other machine) the umask is set to  
> 0022.  Therefore, I may not have a problem on the second machine.

Yes, that's not surprising. You actually have the clue a little later in
your e-mail:

> Although upon further investigation of the /etc/profile and the  
> /etc/bashrc files I did notice slight differences in them with regards  
> to the umask.
> 
> #Machine 1
> if [ `id -gn` = `id -un` -a `id -u` -gt 99 ]; then
>     umask 002
> else
>     umask 022
> fi
> 
> #Machine 2
> if [ "`id -gn`" = "`id -un`" -a `id -u` -gt 99 ]; then
>     umask 002
> else
>     umask 022
> fi

These are the important lines. Run
id -gn
id -un
id -u
to see what happens: at least on Machine 2 you'll note that you get your
primary group name, your user name, and your numeric user ID
respectively.

The code says that "if your user name is the same as your group name"
(i.e. you've got Red Hat User Private Groups set up) *and* your user ID
is over 99 (which cuts out root and other system accounts), you get
umask 002. Otherwise, you get 022.

> You'll notice the double quotes (") around 'id -gn' and 'id -un' in the  
> if else statement of Machine 2.  I wonder if this has some effect on  
> the umask settings?

It means that the code will still work if you manage to set up group or
user names with spaces in (*seriously* ick!) or you manage to set up
"null" group names or user names, then this code will still work.

It's just better coding practice. Normally, it won't make a scrap of
difference.

You might try the id commands on Machine 1 and see if you can spot
anything different.

Hope this helps,

James.
-- 
James Wilkinson       | Found -- the gene that causes the orchestra to move.
Exeter    Devon    UK |     -- The megahal program, trained on my quote file.
E-mail address: james | 
@westexe.demon.co.uk  | 


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux