public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Empty file without "x" permission is successfully executable on Cygwin
@ 2019-08-05 18:18 Lavrentiev, Anton (NIH/NLM/NCBI) [C] via cygwin
  2019-08-05 20:01 ` Ken Brown
  2019-08-06  6:22 ` Houder
  0 siblings, 2 replies; 17+ messages in thread
From: Lavrentiev, Anton (NIH/NLM/NCBI) [C] via cygwin @ 2019-08-05 18:18 UTC (permalink / raw)
  To: 'cygwin@cygwin.com'

Hi,

Please consider the following shell session:

$ cat dummy.c
#include <stdio.h>

int main()
{
    return 0;
}
$ gcc -o dummy dummy.c
$ mv dummy.exe dummy
$ ./dummy
$ echo $?
0
$ chmod a-x dummy
$ ./dummy
-bash: ./dummy: Permission denied
$ rm dummy
$ touch dummy
$ ./dummy
$ echo $?
0

So Cygwin lets the shell to execute a zero-sized file regardless of the "x" perm
(non-empty files are not executable if they do not have "x", as shown above).

Is that expected?  On Unix, an empty file can only be executed (exit code 0) if there's the "x" permission granted.

There's more.  If I put some rubbish in a file, Cygwin still tries to execute it even if the "x" is not there:

$ rm dummy
$ echo "1" > dummy
$ ./dummy
./dummy: line 1: 1: command not found

So Cygwin knows about "dummy" being a PE32 executable missing the "x" (top of my session), and properly denies the execution
when there's no "x", but still lets all other file contents execute blindly (regardless of "x").  That's very dangerous!

Thanks,
Anton Lavrentiev


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 17+ messages in thread
* Re: Empty file without "x" permission is successfully executable on Cygwin
@ 2019-08-06 19:09 Lavrentiev, Anton (NIH/NLM/NCBI) [C] via cygwin
  2019-08-06 19:35 ` Ken Brown
  2019-08-07  6:12 ` Houder
  0 siblings, 2 replies; 17+ messages in thread
From: Lavrentiev, Anton (NIH/NLM/NCBI) [C] via cygwin @ 2019-08-06 19:09 UTC (permalink / raw)
  To: 'cygwin@cygwin.com'

> zero-sized? Irrelevant.

It is actually very relevant.  Because executing an empty script results in "success" (exit code 0) -- that creates a false-positive.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 17+ messages in thread
* Re: Empty file without "x" permission is successfully executable on Cygwin
@ 2019-08-06 20:39 Lavrentiev, Anton (NIH/NLM/NCBI) [C] via cygwin
  2019-08-06 21:06 ` Vince Rice
  0 siblings, 1 reply; 17+ messages in thread
From: Lavrentiev, Anton (NIH/NLM/NCBI) [C] via cygwin @ 2019-08-06 20:39 UTC (permalink / raw)
  To: Ken Brown; +Cc: 'cygwin@cygwin.com'

> But what's your basis for saying that an empty script shouldn't be executable?

I meant it only in the context of the script file lacking the proper "x" permission.
Of course an empty script _with_ such permissions allowed must be executable, and it will always complete with exit code 0.


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 17+ messages in thread
* Re: Empty file without "x" permission is successfully executable on Cygwin
@ 2019-08-06 21:17 Lavrentiev, Anton (NIH/NLM/NCBI) [C] via cygwin
  2019-08-06 21:43 ` Vince Rice
  0 siblings, 1 reply; 17+ messages in thread
From: Lavrentiev, Anton (NIH/NLM/NCBI) [C] via cygwin @ 2019-08-06 21:17 UTC (permalink / raw)
  To: Vince Rice; +Cc: cygwin

> Which is why, as Ken said, the size is irrelevant.

Which makes your comment irrelevant as well.  Read the thread what I was responding and to whom before trolling.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 17+ messages in thread
* Re: Empty file without "x" permission is successfully executable on Cygwin
@ 2019-08-06 22:28 Lavrentiev, Anton (NIH/NLM/NCBI) [C] via cygwin
  0 siblings, 0 replies; 17+ messages in thread
From: Lavrentiev, Anton (NIH/NLM/NCBI) [C] via cygwin @ 2019-08-06 22:28 UTC (permalink / raw)
  To: Vince Rice; +Cc: 'cygwin@cygwin.com'

> I did read the thread.

Really?

> which you confirmed after the fact.

Oh really?  Then read again:

In my initial post that started the entire thread I wrote:

> On Unix, an empty file can only be executed (exit code 0) if there's the "x" permission granted.

So what's your deal, exactly?


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2019-08-24  5:54 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-05 18:18 Empty file without "x" permission is successfully executable on Cygwin Lavrentiev, Anton (NIH/NLM/NCBI) [C] via cygwin
2019-08-05 20:01 ` Ken Brown
2019-08-05 20:19   ` Thomas Wolff
2019-08-05 20:39     ` Ken Brown
2019-08-06  3:19       ` Ken Brown
2019-08-06  8:33         ` Corinna Vinschen
2019-08-06  9:01           ` Corinna Vinschen
2019-08-06  6:22 ` Houder
2019-08-06 19:09 Lavrentiev, Anton (NIH/NLM/NCBI) [C] via cygwin
2019-08-06 19:35 ` Ken Brown
2019-08-07  6:12 ` Houder
2019-08-24 10:13   ` Houder
2019-08-06 20:39 Lavrentiev, Anton (NIH/NLM/NCBI) [C] via cygwin
2019-08-06 21:06 ` Vince Rice
2019-08-06 21:17 Lavrentiev, Anton (NIH/NLM/NCBI) [C] via cygwin
2019-08-06 21:43 ` Vince Rice
2019-08-06 22:28 Lavrentiev, Anton (NIH/NLM/NCBI) [C] via cygwin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).