WSL icon indicating copy to clipboard operation
WSL copied to clipboard

Permission masks are ignored for new directories/files in DrvFs filesystem with WSL2 Ubuntu 20.04 (but work fine with WSL2 Ubuntu 18.04)

Open ailiop opened this issue 6 years ago • 2 comments

Environment

Windows build number: 10.0.19041.388
Your Distribution version: Ubuntu 20.04.1 LTS
Linux version 4.19.104-microsoft-standard
WSL 2

Steps to reproduce

$ cd /mnt/d
$ mkdir foo
$ touch bar
$ ls -l
[...]
-rwxrwxrwx 1 ailiop ailiop   0 Aug  7 13:21  bar
drwxrwxrwx 1 ailiop ailiop 512 Aug  7 13:21  foo
$ umask
0022

$ cat /etc/wsl.conf
[automount]
enabled = true
root = /mnt/
options = "metadata,umask=22,fmask=11"
mountFsTab = false

[network]
generateHosts = true
generateResolvConf = true

Expected behavior

Permissions for directories and files created via WSL2 Ubuntu 20.04 should be set by default according to the umask and fmask settings in /etc/wsl.conf.

In the above example, the ls -l command should yield:

$ ls -l
-rw-r--r-- 1 ailiop ailiop   0 Aug  7 13:27  bar
drwxr-xr-x 1 ailiop ailiop 512 Aug  7 13:27  foo

Actual behavior

Directories and files that are created via WSL2 Ubuntu 20.04 in DrvFs-automounted drives always have all permissions set (777 / rwx).

(However, directories and files that are created in the WSL2 Ubuntu 20.04 filesystem, e.g. under ~/, have the expected Linux-default permissions.)

Additional info

This issue does not affect WSL2 Ubuntu 18.04

Surprisingly, if I try the same steps as above (see Steps to reproduce) in WSL2 Ubuntu 18.04, everything works as expected. That is, bar and foo in the example are created with permissions 755 and 744, respectively.

Relevant distribution version: Ubuntu 18.04.5 LTS

Installed WSL2 distributions

PowerShell output:

> wsl --list --all --verbose
  NAME            STATE           VERSION
* Ubuntu-18.04    Running         2
  Ubuntu          Running         2

Setting umask in ~/.bashrc does not help

I saw #352 and tried setting umask in my ~/.bashrc, but nothing changed. (Plus, that would not explain why things work as expected with WSL2 Ubuntu 18.04.)

ailiop avatar Aug 07 '20 17:08 ailiop

Cannot repro perceived 18.04 vs 20.04 difference here. WAG no wsl.exe --shutdown to make your wsl.conf changes take.

image

therealkenc avatar Aug 07 '20 18:08 therealkenc

Alright, this is embarrassing: I was sure I had actually rebooted since editing /etc/wsl.conf, but apparently I was wrong...

Shutting down WSL fixed my issue. Thank you and sorry for the unnecessary post.

ailiop avatar Aug 07 '20 18:08 ailiop