Community
    • Login

    Notepad++ resets file permission bits for WSL files on save

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    18 Posts 7 Posters 1.2k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      anno73
      last edited by

      Out of curiosity, I also tried VSCode. The bits did not change upon save. The script stayed executable.

      xomxX 1 Reply Last reply Reply Quote 0
      • xomxX
        xomx @anno73
        last edited by

        @anno73

        Thanks for the details and the ls -l test. Now I see where the problem is (probably - I did not have time to setup a WSL test & debug that in N++ yet).

        The problem is really in what I already stated (a possibility that N++ uses in this case incorrectly the CREATE_ALWAYS file saving disposition parameter somehow instead of the TRUNCATE one). My mistake was in the wrong assumption, how the storage of such WSL Linux permissions is implemented on the Windows side in NTFS - I thought it would be the NTFS Alternate Data Streams (this is already covered in the N++ file saving code) but it is implemented via the Extended Attributes (ref.).

        So the fix should be easy - adding one more pre-check for the FILE_ATTRIBUTE_EA. I will see what I can do but please be patient, nowadays I have almost no free time…

        A 1 Reply Last reply Reply Quote 5
        • A
          anno73 @xomx
          last edited by

          @xomx

          Thanks for having a look at the issue.

          I just remembered, I am using 32bit version of npp. So I tested the 64bit version too: There it works as expected. Executable bit is there after saving the file. Hope this gives you some more hints.

          xomxX 1 Reply Last reply Reply Quote 3
          • xomxX
            xomx @anno73
            last edited by

            @anno73 said in Notepad++ resets file permission bits for WSL files on save:

            Hope this gives you some more hints.

            Actually, now it is more confusing to me ;-)
            So maybe my EA theory is wrong.

            I still cannot debug the issue because my current WSL installation just seems to have all gates up for the NTFS file-permissions (every file has all the permissions and the chmod cannot change anything, I probably have the NTFS drive mounted differently than you or setup somehow without the EA…)

            A 1 Reply Last reply Reply Quote 1
            • A
              anno73 @xomx
              last edited by anno73

              @xomx

              LOL

              I have following entries in my /etc/fstab:

              C:\     /mnt/c  drvfs   rw,noatime,uid=1000,gid=1000,umask=22,fmask=111,metadata,case=off
              D:\     /mnt/d  drvfs   rw,noatime,uid=1000,gid=1000,umask=22,fmask=111,metadata,case=off
              

              and this is /etc/wsl.conf:

              [boot]
              systemd = true
              
              [automount]
              enabled = true
              options = "metadata,umask=22,fmask=111"
              
              [network]
              generateResolvConf = true
              
              [interop]
              enabled = true
              

              I am not sure if anything else affects the file system mount logic in wsl.

              xomxX 1 Reply Last reply Reply Quote 2
              • xomxX
                xomx @anno73
                last edited by

                @anno73

                Thanks, with the updated wsl.conf, it is ok now.

                But I cannot reproduce your problem, my N++ (both 64- and 32-bit) does not mangle/delete the EA set by the chmod on save:

                npp-WSL-chmod-test.png

                I am even able to see, what the chmod +x command really does on the NTFS drive (EA) and the N++ does not change this:

                npp-EA-WSL.png

                Liming TieuL A 2 Replies Last reply Reply Quote 2
                • Liming TieuL
                  Liming Tieu @xomx
                  last edited by PeterJones

                  @xomx
                  I’m not sure if this helps.
                  I’m getting the same problem with the 64bit version of NPP version 8.5.7, when using NPP in windows to edit a file on a RHEL linux server over SSH (via mobaxterm).
                  Instead of the execute permissions being removed, rather NPP is saving all files with 644 permissions.
                  Which means no execute permissions in this case.
                  eg.

                  chmod 750 test.sh
                  -rwxr-x--- test.sh
                  

                  when script is saved test.sh becomes

                  -rw-r--r-- test.sh
                  
                  xomxX 1 Reply Last reply Reply Quote 0
                  • xomxX
                    xomx @Liming Tieu
                    last edited by

                    @Liming-Tieu said in Notepad++ resets file permission bits for WSL files on save:

                    I’m getting the same problem with the 64bit version of NPP version 8.5.7

                    If you can, please 1st upgrade to the latest upcoming v8.7.5 (in the current v8.7.4 is a critical regression, it will be replaced by v8.7.5 soon). Why - there are many fixes which are related to this area, specifically - the next version from the yours (v8.5.8) fixed the overwriting of some NTFS metadata (“Fix saving files losing Alternate Data Stream issue. (Fix #1498, #8451, #8013)”).

                    (here you will find a convenient overview of all the changes in N++ versions: https://github.com/notepad-plus-plus/notepad-plus-plus/wiki/Changes )

                    Then please report back here, if your problem persists.

                    1 Reply Last reply Reply Quote 4
                    • A
                      anno73 @xomx
                      last edited by

                      @xomx thank you for your effort!

                      As a last try, I have updated WSL in windows command shell (wsl --update) and since then the issue does not occur any more.

                      > wsl.exe --version
                      WSL version: 2.3.26.0
                      Kernel version: 5.15.167.4-1
                      WSLg version: 1.0.65
                      MSRDC version: 1.2.5620
                      Direct3D version: 1.611.1-81528511
                      DXCore version: 10.0.26100.1-240331-1435.ge-release
                      Windows version: 10.0.19045.5371
                      
                      xomxX 1 Reply Last reply Reply Quote 2
                      • xomxX
                        xomx @anno73
                        last edited by

                        @anno73 said in Notepad++ resets file permission bits for WSL files on save:

                        (wsl --update) and since then the issue does not occur any more.

                        This could mean that the WSL team fixed this stuff somehow in some newer versions (as I installed WSL for testing some time after you, I had probably such a newer version installed, so my ok N++ test corresponds to your current one).

                        Still - I am curious how this works (there has to be probably some watch-dog guard of these NTFS EA for the drives/folders mounted from within the WSL (?)).

                        1 Reply Last reply Reply Quote 2
                        • First post
                          Last post
                        The Community of users of the Notepad++ text editor.
                        Powered by NodeBB | Contributors