delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2011/07/21/08:43:34

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-1.1 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD
X-Spam-Check-By: sourceware.org
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: AhsEAKIcKE7QB6CdkWdsb2JhbABUhEqUFI4PfRQBAQEBFBIUJYh8qyORBYErhAQwXwSHVZApFYtW
MIME-Version: 1.0
Subject: RE: [ -w filename ] returns true when permissions are -r--r--r--
Date: Thu, 21 Jul 2011 07:43:10 -0500
Message-ID: <2BF01EB27B56CC478AD6E5A0A28931F202EC7114@A1DAL1SWPES19MB.ams.acs-inc.net>
In-Reply-To: <4E271C9E.3060408@redhat.com>
References: <4E271C9E DOT 3060408 AT redhat DOT com>
From: "Nellis, Kenneth" <Kenneth DOT Nellis AT acs-inc DOT com>
To: <cygwin AT cygwin DOT com>
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT 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
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id p6LChUsx025690

> From: Eric Blake
> On 07/20/2011 12:05 PM, Reid Thompson wrote:
> > Is this broken?  Or a known windows/cygwin discrepancy?  Or am I
> missing
> > something with my posix/windows file permissions settings
> 
> If you are running as an administrator, that might explain it.  Admins
> can alter any file regardless of permissions, in which case [ -w is
> telling you the truth that under your current uid, you can indeed write
> to the file.
> 
> This is a feature of access(file,W_OK), and not a bug.

FWIW, I'm not running as administrator and I'm running 1.7.9, and I'm
seeing the same thing:

$ touch afile
$ chmod 444 afile
$ ls -l
total 0
-r--r--r-- 1 knellis knellis 0 Jul 21 08:36 afile
$ [ -w afile ] && echo writable || echo not writable
writable
$ echo abc >> afile
$ cat afile
abc
$ ls -l
total 1
-r--r--r-- 1 knellis knellis 4 Jul 21 08:37 afile
$

--Ken Nellis

- Raw text -


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