From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ken Brown Newsgroups: gmane.emacs.bugs Subject: bug#10257: 23.3.1 Cygwin: network drives - file is write protected (false positive) Date: Wed, 14 Dec 2011 21:53:15 -0500 Message-ID: <4EE9611B.7080605@cornell.edu> References: <87aa71mwng.fsf@picasso.cante.net> <4EE270AA.2080702@cornell.edu> <20111210095858.GA19881@cante.cante.net> <4EE742B0.1080703@cornell.edu> <20111213140042.GA22678@picasso.cante.net> <4EE76B6E.7070904@cornell.edu> <4EE7B2A9.6060308@cornell.edu> <4EE8178F.5040004@cornell.edu> <87liqf1t04.fsf@picasso.cante.net> <4EE89590.2040503@cornell.edu> <4EE89CAB.8080301@cornell.edu> <4EE8B064.8080803@cornell.edu> <83fwgn2h8a.fsf@gnu.org> <4EE8E376.7080309@cornell.edu> <4EE95EBB.5040504@cornell.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1323917624 18120 80.91.229.12 (15 Dec 2011 02:53:44 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 15 Dec 2011 02:53:44 +0000 (UTC) Cc: 10257@debbugs.gnu.org, jari.aalto@cante.net To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Dec 15 03:53:39 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Rb1Rz-0001MI-L2 for geb-bug-gnu-emacs@m.gmane.org; Thu, 15 Dec 2011 03:53:39 +0100 Original-Received: from localhost ([::1]:35256 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rb1Rz-0007Oo-A4 for geb-bug-gnu-emacs@m.gmane.org; Wed, 14 Dec 2011 21:53:39 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:42245) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rb1Rw-0007Oc-T6 for bug-gnu-emacs@gnu.org; Wed, 14 Dec 2011 21:53:37 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rb1Rv-0001gC-V6 for bug-gnu-emacs@gnu.org; Wed, 14 Dec 2011 21:53:36 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:37845) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rb1Rv-0001g8-SL for bug-gnu-emacs@gnu.org; Wed, 14 Dec 2011 21:53:35 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1Rb1TK-0008BL-Ar for bug-gnu-emacs@gnu.org; Wed, 14 Dec 2011 21:55:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Ken Brown Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 15 Dec 2011 02:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 10257 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 10257-submit@debbugs.gnu.org id=B10257.132391769231434 (code B ref 10257); Thu, 15 Dec 2011 02:55:02 +0000 Original-Received: (at 10257) by debbugs.gnu.org; 15 Dec 2011 02:54:52 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Rb1TA-0008Ax-Ks for submit@debbugs.gnu.org; Wed, 14 Dec 2011 21:54:52 -0500 Original-Received: from granite1.mail.cornell.edu ([128.253.83.141] helo=authusersmtp.mail.cornell.edu) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Rb1T8-0008Aq-I6 for 10257@debbugs.gnu.org; Wed, 14 Dec 2011 21:54:51 -0500 Original-Received: from [192.168.1.3] (cpe-67-249-194-47.twcny.res.rr.com [67.249.194.47]) (authenticated bits=0) by authusersmtp.mail.cornell.edu (8.14.4/8.12.10) with ESMTP id pBF2rKGY012397 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 14 Dec 2011 21:53:22 -0500 (EST) User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0 In-Reply-To: <4EE95EBB.5040504@cornell.edu> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Wed, 14 Dec 2011 21:55:02 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:54973 Archived-At: On 12/14/2011 9:43 PM, Ken Brown wrote: > On 12/14/2011 12:57 PM, Ken Brown wrote: >> On 12/14/2011 12:30 PM, Eli Zaretskii wrote: >>> "Such cases" are those where UID and GID are returned as -1 (I think), >>> see the original report where Jari shows the result of >>> file-attributes. >> >> OK, I could certainly change check_writable to return success if >> euidaccess returns failure and UID and GID are both -1. I'll make a >> patch when I get a chance and let Jari test it. > > How does the following patch look? > > === modified file 'src/fileio.c' > --- src/fileio.c 2011-12-05 08:55:25 +0000 > +++ src/fileio.c 2011-12-15 02:17:01 +0000 > @@ -2416,15 +2416,27 @@ > return (st.st_mode & S_IWRITE || S_ISDIR (st.st_mode)); > #else /* not MSDOS */ > #ifdef HAVE_EUIDACCESS > - return (euidaccess (filename, 2) >= 0); > -#else > + int res = (euidaccess (filename, 2) >= 0); > +#ifdef CYGWIN > + /* euidaccess may have returned failure because Cygwin couldn't > + determine the file's UID and GID; if so, we return success. */ > + if (!res) > + { > + struct stat st; > + if (stat (filename, &st) < 0) > + return 0; > + res = (st.st_uid == -1 && st.st_gid == -1); > + } > +#endif /* CYGWIN */ > + return res; > +#else /* not HAVE_EUIDACCESS */ > /* Access isn't quite right because it uses the real uid > and we really want to test with the effective uid. > But Unix doesn't give us a right way to do it. > Opening with O_WRONLY could work for an ordinary file, > but would lose for directories. */ > return (access (filename, 2) >= 0); > -#endif > +#endif /* not HAVE_EUIDACCESS */ > #endif /* not MSDOS */ > } Sorry, this isn't quite right. I think it's too lenient. As long as I've called stat, I should at least check that stat shows the file to be writable, as in the MSDOS port. I'll send a revised patch. Ken