Saturday, May 18, 2024
 Popular · Latest · Hot · Upcoming
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 3181  / 3 Years ago, mon, august 16, 2021, 4:43:08

Well, I have a WSL2 with Ubuntu 20.04.3 LTS on it. It is intended for web-development purposes, so nginx, php and other related apps are installed there. No GUI.


So when I start it with wsl from Windows PowerShell, I always have to go to the project root and set correct folder permissions:


sudo chown -R $USER:www-data /var/www/html/project_root/all_required_folders

It works fine until I restart WSL, then after boot, permissions are being reset back and I have to set them once again.


I know that I can add these commands to run after boot, but I am curious about the reason, because I did not experienced this before (unless I moved to clean system from HDD to SSD, but I don't think this might be the reason).


Honestly, I don't think this issue comes from nginx, I guess somewhere esle?


Have to note, that not all folder group is being reset, only some of them, somehow. And these are usually /node_modules, /storage and /bootstrap (Yes, I'm running Laravel).


So, why this happens? It does not reset folder permissions - only owner & group.


More From » 20.04

 Answers
2

Usually we do suspect the metadata support for drvfs filesystems when this type of "permissions or ownership" issue occurs (as noted in the existing answer).


However, in this case I don't believe that's what you are seeing, for multiple reasons:



  • First, the metadata option is only applicable to Windows drive mounts. Unless there's a symlink in your /var/www/... path that you didn't mention, that doesn't appear to be the case here.



  • But more than that, if that's the problem you were having, then chown wouldn't work at all. Without metadata support, the files and directories on the Windows drive are always owned by the default user. A chown would simply have no effect.



  • And you mention that permissions are not reset, so I'm assuming you have been able to set some non-default permissions. This also wouldn't be possible on a Windows drive without the metadata option.




So with that ruled out (I believe), I'd look at two other possible culprits:



  • My next "normal" suspicion (if this wasn't a web app) would be something in your shell startup. However, I don't see that being the case here. It's easy to eliminate startup config by running with wsl -e bash --noprofile --norc if you'd like to test it.



  • But what I really think you are seeing here is something like this. It's really "normal behavior" -- The web-server, running as www-data, is creating files/directories. These files are naturally owned by the user/process that created them. I don't think that ownership is being reset when WSL restarts. I think they are just being written with that ownership in the first place.


    If that's causing issues for your development, then add your user to the www-data group with sudo usermod -aG www-data $USER. Or see the linked answer for additional options.




[#993] Tuesday, August 17, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
lowovey

Total Points: 287
Total Questions: 98
Total Answers: 117

Location: Bosnia and Herzegovina
Member since Thu, Jan 14, 2021
3 Years ago
lowovey questions
Fri, Nov 4, 22, 22:59, 2 Years ago
Sat, Nov 27, 21, 01:22, 3 Years ago
Thu, Jan 6, 22, 15:14, 2 Years ago
;