“Permission Denied” using cygwin in Windows

前端 未结 9 1480
终归单人心
终归单人心 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:43

    -rwx------+ might be the problem. Some hidden acl may forbid x for you. Reset your acl with setfacl then.

    $ cat >/tmp/faclx <<EOF
    user::rwx
    group::r--
    mask:rwx
    other:r--
    EOF
    $ setfacl -f /tmp/faclx /cygdrive/c/Users/michael/Desktop/apps_and_drivers/GPU-Z.0.4.8.exe
    

    Or you need elevated permissions:

    $ cygstart  --action=runas /cygdrive/c/Users/michael/Desktop/apps_and_drivers/GPU-Z.0.4.8.exe
    
    0 讨论(0)
  • 2021-02-01 23:47

    I had this problem, and fixed it by cd to the directory which contains the box I just made (packaged, or, repackaged). Then vagrant box add <file.box> --name <name>. I think the PATHs fvck things up, and cause it to fail. Then double check with vagrant box list. Then I mkdir coolbox; cd coolbox. Then I just vagrant init <name> and it all comes up like magic.

    0 讨论(0)
  • 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
    
    0 讨论(0)
  • 2021-02-01 23:51

    The easiest way to fix this is:

    1. Download Sysinternals ProcMon, start it and let it run for a while.
    2. Exclude all processes that generate noise.
    3. When the log becomes less busy, start your file access attempt.
    4. Search the ProcMon log for "Access Denied" messages.
    5. Investigate. Should be easy to fix.
    0 讨论(0)
  • 2021-02-01 23:53

    I had a similar issue around tee redirection:

    "%CYGWIN_ROOT%\bin\bash.exe" -c "{ cd ""%PWD:\=/%""; CHERE_INVOKING=. ""%CYGWIN_ROOT:\=/%/bin/bash.exe"" -l -i; } 2>&1 | ""%CYGWIN_ROOT:\=/%/bin/tee.exe"" -a ""%PROJECT_LOG_FILE:\=/%"""
    

    This kind of code is required if you want to run a bash shell with login in a specific directory (cd before call to login shell).

    But in mine case it won't work, because of the error: tee: 'standard output': Permission denied

    Update:

    Found a fix here: https://sourceware.org/pipermail/cygwin/2020-December/247185.html

    In Win7,
    1) Start command prompt.
    2) Run chcp 65001
    3) Change the font of command prompt to raster font.
    4) Run c:\cygwin\bin\printf "\xce\b1\n"
    
    This causes the error:
    /usr/bin/printf: write error
    
    What weird is that if the font is other than raster font,
    this error does not occur.
    

    A raster font triggers the console write error (a permission denied in case of piping) under 65001 code page specifically in the Windows 7.

    0 讨论(0)
  • 2021-02-01 23:56

    just change the mode of the scripts using chmod command to make it executable. see man chmod for more details.

    0 讨论(0)
提交回复
热议问题