Hi, It seems that Cygwin does not check for executable bit before it allows a script to run, does it?
$ rm abc $ cat <<EOF >abc > #!/bin/sh > echo Hm... > EOF $ ll abc -rw-r--r--+ 1 ibobyr Domain Users Nov 21 4 16:44 abc $ test -x abc && echo Executable Executable $ ./abc Hm... I was able to find some references to a "patch for this [that is] ready" here: http://omgili.com/mailinglist/cygwin/cygwin/com/4A3D15705020506aimcom.html Reply by Corinna Vinschen on Mon, 22 Jun 2009 15:11:44 +0200. For some reason I do not see above mail in the cygwin.com mailing list archive (http://cygwin.com/ml/cygwin/2009-06/index.html). For me the most annoying part is that "test -x" says that I can execute a file that I just did "chmod -x" on. I'm looking at git-svn tests and they assume that "chmod -x abc && test ! -x abc". And it does not hold on Cygwin. Accidentally I posted this on the cygwin-developers mailing list and already got the following reply (along with my answer): On 11/04/2010 05:12 PM, Illia Bobyr wrote: > On 11/4/2010 5:02 PM, Eric Blake wrote: > > On 11/04/2010 03:57 PM, Illia Bobyr wrote: > > > $ ll abc > > > -rw-r--r--+ 1 ibobyr Domain Users Nov 21 4 16:44 abc > > > > See that +? That means there are ACLs in play. > > > > > $ test -x abc&& echo Executable > > > Executable > > > > Likely, one of those ACLs is still making the file executable. > > > > What does 'getfacl abc' say? > > $ getfacl abc > # file: abc > # owner: ibobyr > # group: Domain Users > user::rw- > group::r-- > group:SYSTEM:rwx > group:Administrators:rwx > group:Users:r-x > mask:rwx > other:r-- > > > > $ ./abc > > > Hm... > > One other thing to point out. This will happen on FAT and other > > brain-dead filesystems that lack true execute bits, where chmod -x has > > no effect (since there's no bit to disable), such that cygwin always > > represents the file as executable on those file systems if it has a > > she-bang (well, depending on your mount options). But given that FAT > > also doesn't support ACLs, it's not the problem you are facing. > > I'm on NTFS. So, it is not that one. > "chmod +x" and "chmod -x" do have visible effect: > > $ ll abc > -rw-r--r--+ 1 ibobyr Domain Users Nov 21 4 16:44 abc > > $ chmod +x abc > > $ ll abc > -rwxr-xr-x+ 1 ibobyr Domain Users Nov 21 4 16:44 abc* > > $ chmod -x abc > > $ ll abc > -rw-r--r--+ 1 ibobyr Domain Users Nov 21 4 16:44 abc > > A newly created file is executable even without "chmod +x": > > $ echo "echo Hm... =)" > cba > > $ ./cba > Hm... =) > > > > For me the most annoying part is that "test -x" says that I can execute > > > a file that I just did "chmod -x" on. > > There's more to permissions than just the 9 unix mode bits. You really > > CAN execute the file if test -x says you can; the question should rather > > be why 'chmod -x' didn't remove all execute permissions, and that > > usually boils down to ACL settings.