From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 118916 invoked by alias); 6 Aug 2019 08:33:07 -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 118906 invoked by uid 89); 6 Aug 2019 08:33:06 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-104.2 required=5.0 tests=AWL,BAYES_00,GOOD_FROM_CORINNA_CYGWIN,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=H*F:D*cygwin.com X-HELO: mout.kundenserver.de Received: from mout.kundenserver.de (HELO mout.kundenserver.de) (212.227.17.13) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 06 Aug 2019 08:33:04 +0000 Received: from calimero.vinschen.de ([24.134.7.25]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1Mlf8e-1idZ6t1wRu-00ijHM for ; Tue, 06 Aug 2019 10:33:01 +0200 Received: by calimero.vinschen.de (Postfix, from userid 500) id DA2DEA806B8; Tue, 6 Aug 2019 10:33:00 +0200 (CEST) Date: Tue, 06 Aug 2019 08:33:00 -0000 From: Corinna Vinschen To: cygwin@cygwin.com Subject: Re: Empty file without "x" permission is successfully executable on Cygwin Message-ID: <20190806083300.GM11632@calimero.vinschen.de> Reply-To: cygwin@cygwin.com Mail-Followup-To: cygwin@cygwin.com References: <7d007c9f-e98d-f497-d706-dbf94bb563f2@towo.net> <319f78d5-fbcd-712a-ba27-137bd1fbd439@cornell.edu> <8378710e-4533-ee50-0e31-7714982eec0d@cornell.edu> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="F+wU6CH2q8RBGewX" Content-Disposition: inline In-Reply-To: <8378710e-4533-ee50-0e31-7714982eec0d@cornell.edu> User-Agent: Mutt/1.11.3 (2019-02-01) X-SW-Source: 2019-08/txt/msg00068.txt.bz2 --F+wU6CH2q8RBGewX Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-length: 2332 On Aug 6 03:19, Ken Brown wrote: > On 8/5/2019 4:39 PM, Ken Brown wrote: > > On 8/5/2019 4:19 PM, Thomas Wolff wrote: > >> > >> Am 05.08.2019 um 22:01 schrieb Ken Brown: > >>> On 8/5/2019 2:18 PM, Lavrentiev, Anton (NIH/NLM/NCBI) [C] via cygwin = wrote: > >>>> Hi, > >>>> > >>>> Please consider the following shell session: > >>>> > >>>> $ cat dummy.c > >>>> #include > >>>> > >>>> int main() > >>>> { > >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 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 show= n above). > >>> I can't reproduce this on my system.=C2=A0 Can you show the permissio= ns and ACL of > >>> dummy? > >>> > >>>> There's more.=C2=A0 If I put some rubbish in a file, Cygwin still tr= ies to execute > >>>> it even if the "x" is not there: > >>>> > >>>> $ rm dummy > >>>> $ echo "1" > dummy > >>>> $ ./dummy > >>>> ./dummy: line 1: 1: command not found > >>> Again I can't reproduce this. > >> I reproduce the behaviour: > >> > echo echo foo > bar > >> > ls -l bar > >> -rw-r--r-- 1 towo None 9=C2=A0 5. Aug 22:18 bar > >> > ./bar > >> foo > >=20 > > You're right. I was careless in my test. Sorry for the noise. >=20 > It look like what's happening is that bash calls execve(), which returns = with=20 > errno ENOEXEC instead of EACCES. >=20 > I'll look at this more tomorrow unless someone beats me to it. Looks like the checks for this scenario are in the wrong order. In av::setup(), the first check is if the file is a valid executable and if so, exec returns ENOEXEC (unless called via exec[vl]p). Only if that fails, av::setup checks the executability of the file(*). Ken, I'll propose a patch on cygwin-patches, please check. Thanks, Corinna (*) Note that the executability test only makes sense on filesystems supporting execute bits. On FAT filesystems, no such check will take place and Cygwin will not encounter EACCES scenarios. --=20 Corinna Vinschen Cygwin Maintainer --F+wU6CH2q8RBGewX Content-Type: application/pgp-signature; name="signature.asc" Content-length: 833 -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAl1JOzwACgkQ9TYGna5E T6C16w/+OU1wA8SRRLW7L0aw3YKwRQu3N1nATbRJRNwIrWGnkUloJLXZVxzEDXwR NnaXm7PC94WOds35UjJu4D+ufzcfBmeI5lRUe37i+KyxIF7cTex77bmp+SJhEYjS XJx58NGrmEqQACbhjWEzgN0Nmw3sB2dHQoYZt1cLx1j+EkX7mFooZvhbSI94RMrp VqxGi9Bo6N8RVPs93JUGdC2WKW/nRwuqLxwf/gqShx7hkvmEdtbJLeyjzOBm/OQB PrtqHHpp2gpgNTeBHqFYn1nl5YDLaGaKQWLrC/Wrx1gDgpAmFGraqWhDLw8gBURO JaBzTIH/cT7zJRfbkWZWd4aKgJv9HJP3L7OzE8STWzvWbUUPIaiPxcf7sLkDCYWf L8GRKb/17wXN+dS0cmfGo8d5H2rUhd4fQZPt7E9Ghz4nAcro79tTZGyMCoalWDZp YlLeTWDfem3GV3Y0d2l35+0K458nZWYe735CL1ZVuk3teW765wvgdEQpJ8lFBSM6 LThJb+Pc2kn3C7Km6tv//4pdb6c/gDjgEvZL4rcCGv7wV3VDaw4iA0Ch/6LVoOB3 4N7XUDLyrvriuVNPKbMgMB6i2+ATflW/5cEoPjLqPkswfkODilr415B3G1dkpVb7 w3gT25La52VgjVlT4aP43P6sOgQG0Z77KaPyvtwRmGKbrkPLZX4= =gcw+ -----END PGP SIGNATURE----- --F+wU6CH2q8RBGewX--