microsoft / microsoft/WSL

Recognize Windows executable and script by file extension

Open
#4,778 2 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
C++
Stars
33.7k
Forks
1.8k
Avg merge
3d 17h
Merged PRs (30d)
116

Description

Problem

Linux does not recognize Windows executable and script files ( and its extension) on mounted Windows filesystem without --x--x--x file mode bits.
But WSL doe not set execute bit automatically only for Windows executable and script files.
So if user set fmask=000 for automount option, then all Windows files are regarded as executable, regardless it is really Windows executable or plain data (mode = -rwxrwrwx), which I don't want.
And if fmask is set to 111 (fmask=111), then all window executables (.exe) files are regarded as non-executable data and if I try to run write.exe, then bash issues permission denied. error and refuse to run it. User have to set the execute bit manually to run it. Here is my wsl.conf

# /etc/wsl.conf 
[automount]
enabled	= true 
options	= "metadata,umask=022,fmask=111"
[interop]
enabled	= true

Solution

Implement something similar to %PATHEXT% Windows environment variable so that WSL will recognize Windows exe files extension and set default execute bit by extension. For example, if [interop] section of /etc/wsl.conf have "executables" attribute that lists extensions of Windows executable files. For example, executables="exe sh py", then all files with .exe or .sh or .py file extension on mounted Windows file system will have default execute bit set (rwxrwxrwx) and masked by fmask bits. All other files with extensions not listed in the attribute will have default execute bit unset (rw-rw-rw)

So If user sets fmask=011, then write.exe file have rwxr--r-- permission mode bits. and all other data files (like data.txt with non-executable extension ) will have rw-r--r-- permission mode. User can set execute bit manually (regardless of file extension) by chmod +x file.script .

Alternate Solution

Windows file meta data or ACL(access control list) may have execute permission bit for any (and all) WSL user. But it may be bit too much.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how /etc/wsl.conf handles the [automount] and [interop] sections, then locate where mounted Windows file modes and extension matching are decided. Done means configured executable extensions receive the default execute bit subject to fmask, while other files do not and chmod can still override the result.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.