“Permission Denied” using cygwin in Windows

前端 未结 9 1499
终归单人心
终归单人心 2021-02-01 23:19

Background: I am trying to write a [.bat] file so I can double click it and a bash script will get invoked. The bash script will start up a few window

9条回答
  •  长情又很酷
    2021-02-01 23:49

    • Check the mount table with cat /proc/mounts or mount and make sure that every mount point out of /, /usr/bin, /usr/lib has a noacl flag. If it's missing, correct /etc/fstab and reboot. (Rebooting synced up the noacl flag of the root mount point for me, and I do not know if the same can be achieved without rebooting).

    • Check for a NULL SID record and other strange records in the output of icacls against the file. They appear added on writing by the POSIX ACL translation layer in Cygwin (using "noacl" in /etc/fstab allows disabling that, but the damage will have already been done).

      Resetting the Windows ACL just on the file may not be enough if the containing parents had the NULL SID record. One has to run

      icacls c:\cygwin64 /reset /t /l /c
      

      from Command Prompt to remove the extraneous records from the Windows ACL in each file and directory.

    Update Other commands reset the ownership, remove default ACLs and show ACLs of a known binary before and after the changes:

    set croot=c:\cygwin64
    icacls %croot%\bin\ls.exe
    %croot%\bin\getfacl /bin/ls
    takeown /F %croot% /R /D Y > nul
    icacls %croot% /reset /T /C /L /Q
    icacls %croot%\bin\ls.exe
    
    %croot%\bin\getfacl /bin/setfacl
    %croot%\bin\getfacl /bin/find
    %croot%\bin\setfacl -bk /bin/find
    %croot%\bin\find -P / -xdev -exec /bin/setfacl -bk "{}" +
    
    icacls %croot%\bin\ls.exe
    %croot%\bin\getfacl /bin/ls
    

提交回复
热议问题