Match Windows 7 default permissions to Cygwin created file defaults

I am using cygwin on Windows 7 professional.

When I create new files such as MyNewFile.java it seems to get default permission set to 755. This is not what I want. I want it to be 644 for regular files.

This is very annoying to have to change permissions every time I create new files outside of the cygwin terminal (cp from cygwin terminal works fine and just keeps existing permissions as expected, even creating new files from inside cygwin works).

Alternatively, is there any way in git to auto-change *.myextension files to always have a specific permission?

If not, is there any way to recursively chmod 644 all *.myextension files recursively under a folder (without affecting folder permissions!)?


Solution 1:

You need to change the security of the folder within Windows that cygwin is writing to so that it matches your cygwin configuration.

For instance, with default security, I get:

-rwxr-xr-x 1 400 401    0 Jul 29 14:48 New Text Document.txt

After changing security on the folder in Windows, I get:

-rwxr--r-- 1 400 401    0 Jul 29 14:54 New Text Document 2.txt

I have found that the "Everyone" Windows security entry matches up to "other" in the "user group other" listing in the ls command. Remove "Read & execute", leaving only Read for that one to match. The special CREATOR GROUP security entry matched the "group" part for me. When I disabled "Read & execute" and left only Read enabled, all of the directory listing now matched the security of the cygwin created file.