This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Empty file without "x" permission is successfully executable on Cygwin
- From: "Lavrentiev, Anton (NIH/NLM/NCBI) [C] via cygwin" <cygwin at cygwin dot com>
- To: "'cygwin at cygwin dot com'" <cygwin at cygwin dot com>
- Date: Mon, 5 Aug 2019 18:18:52 +0000
- Subject: Empty file without "x" permission is successfully executable on Cygwin
- Arc-authentication-results: i=1; mx.microsoft.com 1;spf=pass smtp.mailfrom=ncbi.nlm.nih.gov;dmarc=pass action=none header.from=ncbi.nlm.nih.gov;dkim=pass header.d=ncbi.nlm.nih.gov;arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YQbz/I6LMTZluGWgZLPMlYMEFeuBfGWkvLy9yRKlWug=; b=bGtZOKvZwAnsXb10vXVhqZaMggSt3pPbL6xIRGi5ghA0WJoWnO/uSv7tGnhItt1V93BzoqQacWFBCnHggva+QBI8dt6/AnESpICqe3ua/oRISs3D1TLDOakuBi7wqvg5R7E17970/cmUV/L3qD8emaL9ybZ8oi9A08ikX9af2LczUTo4aOlnIivGIC5oD0PcJW8w15R9nfTmIoLlKVw5Pb5zdNw07pbNM3PB8xmcoTDdfMipWYBwPOc22HPKdxSmKTk2jYsgT+tK7fv/BTrRFnRNfgsWT8proKXutSYQ9oixYrK4E3E2HvKEYFop8HhBLAP1W2l3wGO2URVqOKbDNw==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O8Jqm3S+Sdey2Mh2PmndnMRuBXFDzYMqcEU8typkv2JTGpA92q8plHk2mt3xnDZSq5myVckxSkL8ve3ixHaJXcWdCCWL+LhnFBaMEMrWjKdTQGF6vBI0NdeG92O72BNfs9BR0vsZ0EkU/ssYDi2h0R+VVg4LbKsfBMAqiOZZkDBUAkeBFJDTvjIf8CEX9z8gqvboSmIW8RXoTThYfFxztZLKLmZoysmZjgQQzVxsAKqdqntHppw4chUPAHEoCcPUAjt0PmEcn9vodegxN4elDNYqf8Fed14sBxf01TRO0YgODZ5BTReqz/4rtnxzk2AsYLeKlVPWi2LTlcD18cdLNg==
- Ironport-sdr: BHjT0iPWYNgv4NsUTXTdbUQgAC3yTlStRhS5Ih4Cmr/nmh83L1caXUUsPsOV5K/DxCRAyp8T41 LMJQUU+4ooDQ==
- Reply-to: "Lavrentiev, Anton (NIH/NLM/NCBI) [C]" <lavr at ncbi dot nlm dot nih dot gov>
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