X-Recipient: archive-cygwin@delorie.com
X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 	tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_PASS
X-Spam-Check-By: sourceware.org
MIME-Version: 1.0
In-Reply-To: <20090810164057.GV3204@calimero.vinschen.de>
References: <e2480c70908100619m906f5dfj794823f22c7604bc@mail.gmail.com> 	 <20090810132515.GP3204@calimero.vinschen.de> 	 <e2480c70908100911j520101cftbaf4dc3eb08b109e@mail.gmail.com> 	 <20090810164057.GV3204@calimero.vinschen.de>
Date: Tue, 11 Aug 2009 02:01:54 +0200
Message-ID: <6910a60908101701m77bcb1b3x55e48d028bf35ef0@mail.gmail.com>
Subject: Re: Perl bug (was Re: [1.7] cygwin allows writing to readonly files)
From: Reini Urban <rurban@x-ray.at>
To: cygwin@cygwin.com
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-IsSubscribed: yes
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
Precedence: bulk
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com

2009/8/10 Corinna Vinschen:
> On Aug 10 20:11, Alexey Borzenkov wrote:
>> On Mon, Aug 10, 2009 at 5:25 PM, Corinna
>> Vinschen<corinna-cygwin@cygwin.com> wrote:
>> > That's a bug in your testsuite. =A0I assume you're running the tests as
>> > administrator, right? =A0Administrators have the right to write to all
>> > files, even R/O files, according to POSIX rules. =A0Your test would fa=
il
>> > on Linux as well, if you're running it as root.
>>
>> Well, it's not my testsuite, but yes, I'm running under administrator
>> account. But it makes me wonder, how does it work? Do you change ACLs
>> temporarily?
>
> No. =A0It's a "user privileges" thingy. =A0See
> http://msdn.microsoft.com/en-us/library/aa379306%28VS.85%29.aspx
>
> The SE_BACKUP_NAME and SE_RESTORE_NAME privileges are in the
> administrator's user token, but they are not enabled by default. =A0Cygwin
> just enables them at startup time, if they are available in the user
> token. =A0Therefore, a Cygwin process has the usual POSIX-like permissions
> for admin users. =A0It's no magic which isn't available to any other
> native Win32 application.
>
>> Anyway, it means there is a bug in perl, because on Linux:
>>
>> root@kitsu:~# touch test.txt
>> root@kitsu:~# chmod 0444 test.txt
>> root@kitsu:~# perl -e 'print "writable\n" if -w "test.txt"'
>> writable
>>
>> On Cygwin 1.7 perl thinks that the file is not writable.
>
> Indeed. =A0Checking with strace I found that the test is the same on Linux
> and Cygwin. =A0In both cases perl uses stat(), and the returned permissio=
ns
> are the same (0444). =A0Further experimenting shows that perl has a
> hardcoded uid =3D=3D 0 test which must obviously fail on Cygwin. =A0If I =
change
> the user's uid to 0, the string "writable" is printed by the above comman=
d.
>
> That's a bug in perl. =A0There are other OSes out there which have
> root-like permissions for non-0 uids. =A0Perl should use the access()
> function to check for read/write/execute permissions, which always
> returns the correct result independent of the uid of the current user.

Thanks.
I'll carry it along to p5p, but it will definitely not appear in
upstream 5.10.1
because this gate is already closed.
Even a horrible performance problem with
File::Spec::Cygwin::case_tolerant was not fixed.

But I work on a fix to be included in blead and in my cygwin package.
--=20
Reini Urban

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

