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: Fri, 16 Dec 2011 14:37:30 -0500 Message-ID: <4EEB9DFA.8040000@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> <83d3bq32gw.fsf@gnu.org> <4EEA0759.5040403@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 1324064316 18932 80.91.229.12 (16 Dec 2011 19:38:36 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 16 Dec 2011 19:38:36 +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 Fri Dec 16 20:38:31 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 1Rbdby-00008Q-6A for geb-bug-gnu-emacs@m.gmane.org; Fri, 16 Dec 2011 20:38:30 +0100 Original-Received: from localhost ([::1]:36780 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rbdbx-0005d1-JG for geb-bug-gnu-emacs@m.gmane.org; Fri, 16 Dec 2011 14:38:29 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:45522) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rbdbu-0005cw-UB for bug-gnu-emacs@gnu.org; Fri, 16 Dec 2011 14:38:27 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rbdbt-0007I2-Td for bug-gnu-emacs@gnu.org; Fri, 16 Dec 2011 14:38:26 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:40481) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rbdbt-0007Hy-Qo for bug-gnu-emacs@gnu.org; Fri, 16 Dec 2011 14:38:25 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1RbddS-0001Q4-9v for bug-gnu-emacs@gnu.org; Fri, 16 Dec 2011 14:40: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: Fri, 16 Dec 2011 19:40: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.13240643615401 (code B ref 10257); Fri, 16 Dec 2011 19:40:02 +0000 Original-Received: (at 10257) by debbugs.gnu.org; 16 Dec 2011 19:39:21 +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 1Rbdcj-0001P1-S1 for submit@debbugs.gnu.org; Fri, 16 Dec 2011 14:39:19 -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 1Rbdcf-0001Oq-So for 10257@debbugs.gnu.org; Fri, 16 Dec 2011 14:39:16 -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 pBGJbYI9015293 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 16 Dec 2011 14:37:35 -0500 (EST) User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0 In-Reply-To: <4EEA0759.5040403@cornell.edu> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Fri, 16 Dec 2011 14:40: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:55022 Archived-At: On 12/15/2011 9:42 AM, Ken Brown wrote: > On 12/14/2011 11:04 PM, Eli Zaretskii wrote: >>> How does the following patch look? >> >> Looks fine to me, if it does the job. > > Thanks. > > It works for me, but I'd like Jari to confirm. Jari has confirmed in private email that it works, but he has proposed making it slightly more permissive and having check_writable return success if either UID or GID is -1. The rationale is the same as before: If euidaccess returns failure but either UID or GID is -1, then the result of euidaccess is unreliable. The revised patch is below. Eli, do you see any problem with this extra permissiveness? Stefan, is it OK to apply the patch to the trunk, or would you rather I wait for 24.2? Ken === modified file 'src/fileio.c' --- src/fileio.c 2011-12-05 08:55:25 +0000 +++ src/fileio.c 2011-12-16 19:32:23 +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 or 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 */ }