WSL: mkdir command has wrong permissions
- A brief description
The default mkdir setting creates a folder with Read, Write, Execute permissions for Owner, Group and World (0777).
On other systems, mkdir creates a folder with Read, Write, Execute permissions for Owner and Read permissions for Group and World (0755).
This caused test failures running the https://github.com/apple/swift-llbuild project (part of Swift.org)
# command stderr:
/mnt/c/Users/hughb/Documents/GitHub-WSL/swift-llbuild/tests/BuildSystem/Build/mkdir.llbuild:15:22: error: expected string not found in input
# CHECK-PERMISSIONS: 0755
^
/mnt/c/Users/hughb/Documents/GitHub-WSL/build/tests/BuildSystem/Build/Output/mkdir.llbuild.tmp.permissions:1:1: note: scanning from here
0777
^
- Expected results
drwxr-xr-x 2 root root 0 Mar 23 16:35 foo
- Actual results (with terminal output if applicable)
drwxrwxrwx 2 root root 0 Mar 23 16:35 foo
- Your Windows build number
14393.953
- Steps / All commands required to reproduce the error from a brand new installation
mkdir foo
ls -l
- Strace of the failing command
N/A
- Required packages and commands to install
N/A
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Reactions: 9
- Comments: 20 (3 by maintainers)
Yeah there’s a couple unrelated things going on here making it confusing. One is file permissions on DrvFs (
/mnt/c), which are now supported in WSL as of Insider 17063 and Spring Creators real soon now. If the drive isn’t mounted with the ‘metadata’ feature, directories are going to take on the permissions of the mount regardless of yourumask.The other is the default
umask, which is still0000(causing a 777mkdir). That is #352 and is still open. There are work-arounds over there, the easiest being to set theumaskin your.profile/.bashrc/.zshrc/.whateverrc.@jakegt1 it is also 777 in ~/ by bash.exe see https://github.com/Microsoft/BashOnWindows/issues/1803
This thread was really confusing. It seems several people redirected here from other threads (though not OP) and I are experiencing the issue that even in /home/our_username, mkdir still makes with 777 permissions. umask returns 0000. Was there ever a clear answer to this @therealkenc ?
I think what everyone wants to know at this point is WHERE to set
umask 022so that WSL stops creating directories with777instead of755.The improper settings BREAK things like oh-my-zsh, antigen, and other zsh stuff.
An after-the-fact solution would be to run a
compauditthenfind $COMMON_PATH_OF_THOSE_DIRECTORIES -type d -exec chmod 0755 {} \;Overall, it would be nice if WSL had the
umask 022mask enabled by default and simple “put that in [insert file name here].”Because the next problem after that would be finding out why
nice(5)denies permissions to do things. It could be for the same reason. (Follow up: It’s issue #1887. Just need to addunsetopt BG_NICEnear the beginning of~/.zshrc.)The default umask on Ubuntu is 0222 (http://askubuntu.com/questions/44542/what-is-umask-and-how-does-it-work)
Manually setting
umaskon the command lineUnfortunately,
mkdiron WSL seems to ignore anyumaskyou set:Manually passing the mode on the command line
Unfortunately,
mkdiron WSL seems to ignore any-mparameter you pass: