cygwin sets file permission to 000

Cygwin

Cygwin Problem Overview


I have a folder /cygwin/d/myfolder/ And everytime I save files there, from cygwin if i do an ls -la I see that the files are given permission 000. That actually causes me quite a bit of problem as I rsync this folder to my server and none of the files are accessible. How can I get the files to automatically get a reasonable permission?

Cygwin Solutions


Solution 1 - Cygwin

Have a read through the answers at this link: http://cygwin.1069669.n5.nabble.com/vim-and-file-permissions-on-Windows-7-td61390.html

The solution there worked for me also:

Edit /etc/fstab and add this line at the end of the file:

none /cygdrive cygdrive binary,noacl,posix=0,user 0 0

Then close all Cygwin processes, open a new terminal and ls -l on your files again.

Explanation: By default, Cygwin uses the filesystem's access control lists (ACLs) to implement real POSIX permissions. Some Windows-native program or process may create or modify the ACLs such that Cygwin computes the POSIX permissions as 000. With the noacl mount option, Cygwin ignores filesystem ACLs and only fakes a subset of permission bits based on the DOS readonly attribute.

Solution 2 - Cygwin

Check to make sure that your umask is set correctly with the umask command. If your umask is say 0777 that subtracts from the permissions of new files and will end up with 000 permissions. There's probably several other possibilities to consider beyond that.

If your id is not set up correctly in /etc/passwd and /etc/group that can also cause ls to show unexpected results. Check the permissions of the folder. Also check the Windows permissions with the getfacl command. Maybe also check the mount command.

Solution 3 - Cygwin

In above answer, solution was proposed:

> Edit /etc/fstab and add this line at the end of the file: > > none /cygdrive cygdrive binary,noacl,posix=0,user 0 0

And in that answer there was this comment:

> When I try this, all my files are -rw-r--r-- no matter what chmod() I do. I can't mark the files as executable; it just reverts to 0644. (umask==0022)

I had this same problem, but it manifested in inability to execute DOS batch files (*.bat) when running Cygwin ksh or mksh. I stumbled across this website: http://pipeline.lbl.gov/code/3rd_party/licenses.win/cygwin-doc-1.4/html/faq/ which contains this helpful advice:

> Note that you can use mount -x to force Cygwin to treat all files under the mount point as executable. This can be used for individual files as well as directories. Then Cygwin will not bother to read files to determine whether they are executable.

So then cross-referencing with this page - https://cygwin.com/cygwin-ug-net/using.html#mount-table - with its advice:

> cygexec - Treat all files below mount point as cygwin executables.

I added cygexec to fourth field of my fstab. This did it. My .bat is now executable inside ksh/mksh, which is necessary since I'm running a Jenkins job that calls a Korn shell stack 3 files deep, that I have no modifiable control over. I just needed the .bat to run!

Update: the solution above wasn't quite what I needed, on further testing. It resulted in some executables such as javac and cl to behave oddly (the utilities would print their usage and exit). I think what I needed instead of 'cygexec' was just 'exec'. As the same page notes:

> exec - Treat all files below mount point as executable.

Solution 4 - Cygwin

On my Win7 PC files were usually ----------+ 1 David None 69120 Jun 17 13:17 mydoc.txt

I tried all of above no luck Turned out I still had some old historical mount entries in my .zshrc I deleted these and Bob's your Uncle problem gone away!

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser391986View Question on Stackoverflow
Solution 1 - CygwinEd RandallView Answer on Stackoverflow
Solution 2 - CygwinjoemooneyView Answer on Stackoverflow
Solution 3 - CygwinBernard AssafView Answer on Stackoverflow
Solution 4 - CygwinzzapperView Answer on Stackoverflow