Cygwin mkdir makes directory I don't have permissions to

9

2

Using latest version of cygwin64 in Windows 10. I have managed to get a directory foo that has something strange about its permissions. I'm not quite sure how this happened but here are the symptoms:

$ cd /f/temp/foo
$ ls -lad .
drwxrwx---+ 1 Mm None 0 Jun 16 14:03 .
$ mkdir bar
$ ls -lad bar
d---rwx---+ 1 Mm None 0 Jun 16 14:17 .
$ cd bar
Permission denied
$ umask
0022

This doesn't happen for other directories, e.g. /f/temp/ok. Using ls switches I cannot see any difference between f/temp/ok and /f/temp/foo.

If I do chmod 775 bar then I can enter bar, but then making a directory under bar has the same problem. So this problem is stopping me doing git init in /f/temp/foo. Doing chown -R Mm * in the parent makes no difference.

My question is: What is causing this problem and what is the proper fix?

There are some differences visible with icacls but I'm not sure how to interpret them:

$ cd /f/temp
$ icacls ok  >ok.txt
$ icacls foo >foo.txt
$ diff -b ok.txt foo.txt
1c1
< ok NULL SID:(DENY)(Rc,S,REA,WEA,X,DC)
---
> foo NULL SID:(DENY)(Rc,S,REA,WEA,X,DC)
3c3
<   DESKTOP-AO2AIEC\None:(RX)
---
>    DESKTOP-AO2AIEC\None:(Rc,S,RA)
8c8
<   Everyone:(RX)
---
>    Everyone:(Rc,S,RA)
10,11c10,12
<   CREATOR OWNER:(OI)(CI)(IO)(F)
<   CREATOR GROUP:(OI)(CI)(IO)(RX)
---
>    CREATOR OWNER:(OI)(CI)(IO)(DENY)(S,RD,WD,AD,REA,WEA,X,DC)
>    CREATOR OWNER:(OI)(CI)(IO)(D,Rc,WDAC,WO,RA,WA)
>    CREATOR GROUP:(OI)(CI)(IO)(Rc,S,RA)
16c17
<   Everyone:(OI)(CI)(IO)(RX)
---
>    Everyone:(OI)(CI)(IO)(Rc,S,RA)

I have got a workaround for now: make another directory under /f/temp, then use cp -r to copy all the files out of foo into the new directory, then delete foo and rename the new directory. If I use cp -a instead of cp -r the problem persists.

M.M

Posted 2016-06-16T02:28:07.973

Reputation: 332

1try setfacl -b foo – matzeri – 2016-06-16T12:25:51.660

@matzeri that seemed to work - if you can write up an answer with an explanation i'll vote and accept – M.M – 2016-06-22T05:08:51.377

Answers

10

The excess of DENY showed by icacls can be caused by the recent changes in cygwin dll (between 2.3 and current 2.5) . It took some round to be right and could have left files or directory with puzzling ACL.

To sanitize the ACLs, a -b switch was added to setfacl

setfacl -b foo

For reference https://cygwin.com/cygwin-ug-net/ov-new.html#ov-new2.4s

matzeri

Posted 2016-06-16T02:28:07.973

Reputation: 1 662

1The problem originated when I unzipped some files that were created by someone with a different version of cygwin, so that explanation makes sense – M.M – 2016-06-23T01:00:34.370