Match Windows 7 default permissions to Cygwin created file defaults

15

0

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!)?

UmaN

Posted 2013-11-26T09:45:26.097

Reputation: 253

1

@UmaN, I think Casey Crockett's answer would be the solution, yes? It's backed up by this: https://cygwin.com/ml/cygwin/2011-02/msg00121.html

– r_alex_hall – 2016-01-01T20:45:47.963

1For fallback solution, this seems to work:

find ./ -type f -name '*.myExtension' -exec chmod 644 {} ; – UmaN – 2013-11-26T10:01:24.983

1Did you give umask a try? – Werner Henze – 2013-11-26T10:55:46.963

umask is 0022. As stated, creating through the cygwin terminal works just fine. The problem occurs when copying files in windows explorer or creating files through e.g. an IDE when programming. This should somehow have something to do with how Windows cygwin treats Windows permissions on folders I suppose... – UmaN – 2013-11-26T12:31:52.183

4@UmaN: A comment on your comment: there’s no good reason to say find ./ …; find . … works just fine, and if you get in the habit of typing find ./ all the time, one of these days you’re going to type find / -exec rm … (or, equivalently, find /. …) by accident. – Scott – 2013-12-02T22:57:51.833

Answers

2

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.

Casey Crockett

Posted 2013-11-26T09:45:26.097

Reputation: 36

0

It isn't clear what you're trying to achieve here, but if you're trying to make your cygwin git ignore permissions do this:

$ git config --local core.filemode false

stacksharki

Posted 2013-11-26T09:45:26.097

Reputation: 199