You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# The default umask is now handled by pam_umask.
# See pam_umask(8) and /etc/login.defs.
And, indeed /etc/profile has UMASK> > 022, but:
simon@QOF:~$ umask
0000
The effect of this is that new files are created with 666 and dirs with 777 permissions:
simon@QOF:~$ touch file
simon@QOF:~$ mkdir dir
simon@QOF:~$ ll -d file dir
drwxrwxrwx 2 simon simon 0 May 12 22:54 dir/
-rw-rw-rw- 1 simon simon 0 May 12 22:54 file
This mostly isn't a real problem since UoW doesn't have to care about multiple users, it largely shows up as ls showing dirs with an ugly green background, but it could freak out some tools, similar to ssh wanting 600 on your private keys.
Simplest fix would probably be to dump a umask 022 in /etc/profile, but it seems there's a bunch of stuff in that /etc/login.defs
Easy workaound is to add a umask to your ~/.bashrc
Reacted by Joel Roller, strawman49, Shawn Lee, Cyriac Kandoth, Michael Hansen, Carl Patenaude-Poulin, David Tagatac, Nickolas Burr, Hugh Bellamy, Andrei Bîscă and 36 more
May be somewhat related to #167 , /etc/profile is supposed to be read if bash is a login shell - but even bash.exe --login doesn't seem to use pam_umask
Simon Buchan (@simonbuchan) Thanks for reporting this. I think there are a couple things going on here. I verified that when bash.exe --login is launched /bin/bash does read from /etc/profile. I dumped my default /etc/profile and noticed a comment that:
# The default umask is now handled by pam_umask.
# See pam_umask(8) and /etc/login.defs.
When you run "bash.exe --login" that translates into "/bin/bash --login". We don't run the /bin/login binary and I'm assuming that's what normally sets up pam_umask. Did you try adding a new umask to value to your /etc/profile? It should work (when using bash.exe --login).
Yep, umask in both /etc/profile and ~/.profile run with both bash.exe --login and bash -c "bash --login".
Interestingly, if I revert the umask command and do bash.exe -c "sudo login" then umask is 0002 - no idea where that is coming from!
Please ensure umask is never 0000 no matter how bash is started.
I understand users can set umask to saner defaults in their own bashrc files but it means whatever directories and files auto-installed by scripts after WSL setup and user first bash run till the bad umask was discovered now have to be changed to sane defaults. This is exacerbated in git-based repos because git will track the change of perms to saner defaults as a (needless) change thereby status of git repo becomes dirty which simply put is both: confusing and annoying.
Reacted by bogen, Carl Patenaude-Poulin, Matthew Buckett, Andrew Tang, sitedyno, Luke Rewega, Jean Jordaan, Nándor Előd Fekete, Anton Rudeshko, James Pike and 9 more
This also causes problems for zsh (compinit/compaudit). If you use a tool like antigen the directory permissions will throw shell errors when compinit/compaudit (command completion) is loaded.
Essentially any tool that performs basic checking for "other" write/read permissions will fail.
For anyone else trying to use dropbox, careful with symlinks to the windows /mnt/c/.... You'll likely run into a lot of problems. Unfortunately, dropbox for linux doesn't work yet either (because of the /proc/vmstat issue: #1071 ).
Hello, It's very strange. If I run ./configure, I found that the Makefile in the dir and sub dir only has permission rw no x. So some middle product didn't output, ./configure is right, but can't do make.
/usr/bin/m4: m4_esyscmd subprocess failed: Operation not permitted
/usr/bin/m4:configure.ac:489: cannot run command `./scripts/version.sh': Operation not permitted
# Note: Bash on Windows does not currently apply umask properly.
if [ "$(umask)" = "0000" ]; then
> umask 022
fi
Ben Hillis (@benhillis): if you have time to entertain my curiosity - is there a particular reason you don't run /bin/login?
Reacted by Mateusz Czapliński, William Chen, Jean Jordaan, Vladimir Shkoda, Anton Rudeshko, Jake Brinkmann, berney, Chris, John Nguyen, lobabob and 4 more
LilRed - good question. Historically there have been a couple of reasons. When we first released /bin/bash worked but other shells (zsh for example) didn't work very well and we didn't want users to set their default shell to something that didn't work and get into a bad state. There's also potential strangeness around running bash.exe and zsh being launched.
That being said, running login would actually make a lot of things simpler for us. Currently our init daemon has to do many of the things that /bin/login normally does. We're doing some design for the next release of Windows and I'll take a look at this and see if it would make sense to potentially switch things over now.
If you'd like to play around with using login there's a way you can use it now.
With /bin/login I do get umask returning 002, which is probably "good enough" to close this, but it's still not getting the "correct" default value 022 from /etc/login.defs line 151, which may be a thing.
Ben's login(1)musing can fight another day a new issue/ask for wsl.exe --login or somesuch. This one deemed fixinbound last June with the umask configurable in wsl.conf. Applicable in both WSL1 and WSL2.
I just updated to 1909 and this problem is still there.
Right; it looks like Ben's fix shipped in 18945. 18945 > 18363 (aka 1909 aka 19H2). Which is to say, it appears a number of issues that were addressed in spring/summer 2019 never made it into the November 2019 Windows 10 release. [Or, at least on best evidence.] I'll bounce the tag on this one, but to be honest I'm hoping the fine-grained fixed-in tags die this spring in favour of whatever version is cited in the issue (presupposing they're cited). Here, 18945.
Activity
simonbuchan commentedon May 13, 2016
May be somewhat related to #167 ,
/etc/profileis supposed to be read if bash is a login shell - but evenbash.exe --logindoesn't seem to usepam_umaskbenhillis commentedon May 13, 2016
Simon Buchan (@simonbuchan) Thanks for reporting this. I think there are a couple things going on here. I verified that when bash.exe --login is launched /bin/bash does read from /etc/profile. I dumped my default /etc/profile and noticed a comment that:
When you run "bash.exe --login" that translates into "/bin/bash --login". We don't run the /bin/login binary and I'm assuming that's what normally sets up pam_umask. Did you try adding a new umask to value to your /etc/profile? It should work (when using bash.exe --login).
simonbuchan commentedon May 13, 2016
Yep,
umaskin both/etc/profileand~/.profilerun with bothbash.exe --loginandbash -c "bash --login".Interestingly, if I revert the
umaskcommand and dobash.exe -c "sudo login"thenumaskis0002- no idea where that is coming from!0xMF commentedon May 26, 2016
Please ensure umask is never 0000 no matter how bash is started.
I understand users can set umask to saner defaults in their own bashrc files but it means whatever directories and files auto-installed by scripts after WSL setup and user first bash run till the bad umask was discovered now have to be changed to sane defaults. This is exacerbated in git-based repos because git will track the change of perms to saner defaults as a (needless) change thereby status of git repo becomes dirty which simply put is both: confusing and annoying.
simonbuchan commentedon May 26, 2016
Mark Fernandes (@0xMF) don't worry, git only tracks +x, and the .bashrc changes are mentioned as a workaround
neurogenesis commentedon Oct 16, 2016
This also causes problems for zsh (compinit/compaudit). If you use a tool like antigen the directory permissions will throw shell errors when compinit/compaudit (command completion) is loaded.
Essentially any tool that performs basic checking for "other" write/read permissions will fail.
For anyone else trying to use dropbox, careful with symlinks to the windows
/mnt/c/.... You'll likely run into a lot of problems. Unfortunately, dropbox for linux doesn't work yet either (because of the /proc/vmstat issue: #1071 ).zhangxj5 commentedon Oct 23, 2016
Hello, It's very strange. If I run ./configure, I found that the Makefile in the dir and sub dir only has permission rw no x. So some middle product didn't output, ./configure is right, but can't do make.
It's a big problem.
zhangxj5 commentedon Oct 24, 2016
/usr/bin/m4: m4_esyscmd subprocess failed: Operation not permitted
/usr/bin/m4:configure.ac:489: cannot run command `./scripts/version.sh': Operation not permitted
carlpaten commentedon Dec 1, 2016
I have put this in my
~/.profilein the meantime:Ben Hillis (@benhillis): if you have time to entertain my curiosity - is there a particular reason you don't run /bin/login?
benhillis commentedon Dec 1, 2016
LilRed - good question. Historically there have been a couple of reasons. When we first released /bin/bash worked but other shells (zsh for example) didn't work very well and we didn't want users to set their default shell to something that didn't work and get into a bad state. There's also potential strangeness around running bash.exe and zsh being launched.
That being said, running login would actually make a lot of things simpler for us. Currently our init daemon has to do many of the things that /bin/login normally does. We're doing some design for the next release of Windows and I'll take a look at this and see if it would make sense to potentially switch things over now.
If you'd like to play around with using login there's a way you can use it now.
lxrun.exe /setdefaultuser root
bash.exe -c "/bin/login -f username"
carlpaten commentedon Dec 1, 2016
This is fantastic, thanks for the insight. I will change my Bash shortcut to this and report back if I hit any issues.
simonbuchan commentedon Dec 1, 2016
With
/bin/loginI do getumaskreturning002, which is probably "good enough" to close this, but it's still not getting the "correct" default value022from/etc/login.defsline151, which may be a thing.Also it seems to start faster?!
simonbuchan commentedon Dec 1, 2016
One thing to be aware of is it doesn't extend PATH with the windows path.
38 remaining items
itolosa commentedon Jan 17, 2020
My workaround was:
"wsl.exe -u root -- /bin/login -f username"sudo usermod -s /bin/zsh usernameUsing that, default umask is set to 0002
If you want to use umask 022 you have two options:
therealkenc commentedon Jan 17, 2020
Ben's
login(1)musing can fight another day a new issue/ask forwsl.exe --loginor somesuch. This one deemed fixinbound last June with theumaskconfigurable inwsl.conf. Applicable in both WSL1 and WSL2.mohd-akram commentedon Jan 26, 2020
I just updated to 1909 and this problem is still there.
Quick hack fix for microsoft/WSL#352
Ifiht commentedon Feb 6, 2020
Confirming that with 1909 and a fresh install of Ubuntu. 000 is still the default umask.
Twanislas commentedon Feb 6, 2020
This is how I workaround it in my dotfiles, if it helps anyone ;)
therealkenc commentedon Feb 6, 2020
Right; it looks like Ben's fix shipped in 18945. 18945 > 18363 (aka 1909 aka 19H2). Which is to say, it appears a number of issues that were addressed in spring/summer 2019 never made it into the November 2019 Windows 10 release. [Or, at least on best evidence.] I'll bounce the tag on this one, but to be honest I'm hoping the fine-grained fixed-in tags die this spring in favour of whatever version is cited in the issue (presupposing they're cited). Here, 18945.
Alex6357 commentedon Apr 7, 2024
It seems that pam modules are (partly) still not functioning. MOTD is not correctly shown. #1966