From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 99090 invoked by alias); 6 Aug 2019 06:22:33 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 99083 invoked by uid 89); 6 Aug 2019 06:22:32 -0000 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 Received: from lb2-smtp-cloud9.xs4all.net (HELO lb2-smtp-cloud9.xs4all.net) (194.109.24.26) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 06 Aug 2019 06:22:30 +0000 Received: from tmp.JA6CQSI9LV ([83.162.234.136]) by smtp-cloud9.xs4all.net with ESMTPSA id usrYhbPwwAffAusrZh2Uz3; Tue, 06 Aug 2019 08:22:25 +0200 Date: Tue, 06 Aug 2019 06:22:00 -0000 Message-ID: <1a3b494cbcf1bdc792b9993836f9d44c@smtp-cloud9.xs4all.net> From: Houder Reply-To: cygwin@cygwin.com To: cygwin@cygwin.com Subject: Re: Empty file without "x" permission is successfully executable on Cygwin References: In-Reply-to: Content-Type: text/plain; charset=UTF-8; format=fixed User-Agent: mua.awk 0.99 X-SW-Source: 2019-08/txt/msg00067.txt.bz2 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 > > 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