delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2019/08/06/02:23:22

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:message-id:from:reply-to:to:subject
:references:in-reply-to:content-type; q=dns; s=default; b=kGb+A0
R2wypyCEM78IFbaZYzohODWxZoIeSu+lOVprsW1rOaPgJzbYh8fVY+gso9N1t0bu
gQzs1NtbHvWzUuZ5/qbl6+HG7/v5iw1djVo7I4PuprzaM0/3+J+wLaudUXg96jrE
e+wqFgWWikH+ZMvZegM7UPEe7wHkgaxkIXBFU=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:message-id:from:reply-to:to:subject
:references:in-reply-to:content-type; s=default; bh=xpguZRQNt2Sa
VfBgSJhc5yL01F0=; b=Bj29UKf6WAU00ifjiEZAVOOgGR/SVNn4d/QgTqKtStMp
gFLj2f7iSs2AtshtDindc8EGyKkORoBzmAT3n203HKZpl1wux6mWLHSRDH/tniPo
KMG+0IT8KLBdD5JI0ovZHhRfqfpelOPzFoxHVSlVcjKwifEKFqoBgGJDQH4yL3c=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,NORMAL_HTTP_TO_IP,NUMERIC_HTTP_ADDR,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.1 spammy=study, H*F:D*nl
X-HELO: lb2-smtp-cloud9.xs4all.net
Date: Tue, 06 Aug 2019 08:22:25 +0200
Message-ID: <1a3b494cbcf1bdc792b9993836f9d44c@smtp-cloud9.xs4all.net>
From: Houder <houder AT xs4all DOT nl>
Reply-To: cygwin AT cygwin DOT com
To: cygwin AT cygwin DOT com
Subject: Re: Empty file without "x" permission is successfully executable on Cygwin
References: <BL0PR0901MB43081893EE588BDED05886BFA5DA0 AT BL0PR0901MB4308 DOT namprd09 DOT prod DOT outlook DOT com>
In-Reply-to: <BL0PR0901MB43081893EE588BDED05886BFA5DA0@BL0PR0901MB4308.namprd09.prod.outlook.com>
User-Agent: mua.awk 0.99

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019