Description of problem: All local environment changes should be set using files in /etc/profile.d. However if the umask is set in a script in /etc/profile.d, this umask is eclipsed by a umask setting in /etc/bashrc Version-Release number of selected component (if applicable): How reproducible: Create a script in /etc/profile.d setting the umask. Login and see that the actual umask does not match the umask that is set. Steps to Reproduce: 1. echo umask 077 > /etc/profile.d/umask.sh 2. chmod 755 /etc/profile.d/umask.sh 3. login to system Actual results: After login, the umask is not set to 077 Expected results: The umask is set to 077
Not always true ... umask is set in the beginning of /etc/bashrc ... and profile.d scripts are run at the end of /etc/bashrc - unless short option for login shell is provided. That seems to be your case (using su - / su -l / bash -l ... whatever what provides login shell option). Simple bash/su without login shell option will source your umask.sh script and set umask as you want ... Will check why it is done that way...
I can confirm this always happens, the execution process is: Login shell 1- /etc/profile is executed sourcing profile.d scripts 2- ~/.bash_profile is executed that calls ~/.bashrc and then /etc/bashrc 3- /etc/bashrc is executed and set umask 4- /etc/bashrc do not calls profile.d because it is inside: if ! shopt -q login_shell No Login shell 1- /etc/profile is not loaded 2- ~/.bashrc is executed and set umask 3- /etc/bashrc calls profile.d because it checks it is not a login shell So profile.d scripts are called before the default umask on /etc/bashrc when it is a login shell and after it when it is not a login shell This make impossible to set a default umask for a login shell without modifying /etc/bashrc Should not be the default umask be at the start of the /etc/profile? why change the umask each time a new no login shell is spawn? I think non login shells must inherit the default umask or any other umask set by the user in .bash_profile without reverting to the default when running /etc/bashrc NOTE: the exact same steps happens on Fedora releases
(In reply to comment #3) > > NOTE: the exact same steps happens on Fedora releases True only in released Fedora's ... it is already fixed in rawhide since August - http://koji.fedoraproject.org/koji/buildinfo?buildID=189043 ... probably worth of adding into f14, I don't plan update in older Fedoras.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. http://rhn.redhat.com/errata/RHBA-2012-0198.html