public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Houder <houder@xs4all.nl>
To: cygwin@cygwin.com
Subject: Re: Empty file without "x" permission is successfully executable on Cygwin
Date: Tue, 06 Aug 2019 06:22:00 -0000	[thread overview]
Message-ID: <1a3b494cbcf1bdc792b9993836f9d44c@smtp-cloud9.xs4all.net> (raw)
In-Reply-To: <BL0PR0901MB43081893EE588BDED05886BFA5DA0@BL0PR0901MB4308.namprd09.prod.outlook.com>

On Mon, 5 Aug 2019 18:18:52, Lavrentiev, Anton (NIH/NLM/NCBI) [C] via cygwin"  wrote:
> 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 ...

zero-sized? Irrelevant.
[snip]

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

Yes, Cygwin != Linux.

64-@@ echo date > dummy
64-@@ ls -l dummy
-rw-r--r-- 1 Henri None 5 Aug  6 08:01 dummy
64-@@ ./dummy
Tue Aug  6 08:01:19 CEST 2019
64-@@ dash
$ ./dummy
Tue Aug  6 08:01:38 CEST 2019 <==== (execution by /bin/sh)

$ mv /bin/sh /bin/OOS
$ ls -l /bin/sh.exe
ls: cannot access '/bin/sh.exe': No such file or directory
$ ./dummy
dash: 4: ./dummy: not found <==== attempted to execute "script" using /bin/sh

Also study:

    https://stackoverflow.com/questions/7268437/bash-script-execution-with-and-without-shebang-in-linux-and-bsd

    ( Bash script execution with and without shebang in Linux and BSD )

and

    http://www.faqs.org/faqs/unix-faq/faq/part3/section-16.html

Henri


--
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

  parent reply	other threads:[~2019-08-06  6:22 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-05 18:18 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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1a3b494cbcf1bdc792b9993836f9d44c@smtp-cloud9.xs4all.net \
    --to=houder@xs4all.nl \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).