unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Ken Brown <kbrown@cornell.edu>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 10257@debbugs.gnu.org, jari.aalto@cante.net
Subject: bug#10257: 23.3.1 Cygwin: network drives - file is write protected (false positive)
Date: Fri, 16 Dec 2011 14:37:30 -0500	[thread overview]
Message-ID: <4EEB9DFA.8040000@cornell.edu> (raw)
In-Reply-To: <4EEA0759.5040403@cornell.edu>

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 */
  }






  reply	other threads:[~2011-12-16 19:37 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-09 18:23 bug#10257: 23.3.1 Cygwin: network drives - file is write protected (false positive) Jari Aalto
2011-12-09 20:33 ` Ken Brown
2011-12-10  9:58   ` jaalto
2011-12-13 12:18     ` Ken Brown
2011-12-13 14:00       ` jari
2011-12-13 14:43         ` Eli Zaretskii
2011-12-13 15:12           ` Ken Brown
2011-12-13 19:27             ` Stefan Monnier
2011-12-13 20:16               ` Ken Brown
2011-12-14  2:54                 ` Stefan Monnier
2011-12-14  3:27                   ` Ken Brown
2011-12-14  8:01                     ` Jari Aalto
2011-12-14  8:35                       ` Eli Zaretskii
2011-12-14 12:24                         ` Ken Brown
2011-12-14 12:55                           ` Ken Brown
2011-12-14 13:10                             ` Eli Zaretskii
2011-12-14 14:19                               ` Ken Brown
2011-12-14 14:47                                 ` jari
2011-12-14 17:30                                 ` Eli Zaretskii
2011-12-14 17:57                                   ` Ken Brown
2011-12-15  2:43                                     ` Ken Brown
2011-12-15  2:53                                       ` Ken Brown
2011-12-15  3:19                                         ` Ken Brown
2011-12-15  4:04                                       ` Eli Zaretskii
2011-12-15 14:42                                         ` Ken Brown
2011-12-16 19:37                                           ` Ken Brown [this message]
2011-12-16 19:46                                             ` Eli Zaretskii
2011-12-16 23:15                                             ` Stefan Monnier
2011-12-17 17:08                                               ` Ken Brown
2011-12-14 14:15                             ` jari
2011-12-14 14:29                               ` Ken Brown
2011-12-14 14:43                                 ` jari
2011-12-14 17:21                                 ` Eli Zaretskii
2011-12-14 17:23             ` Richard Stallman
2011-12-13 16:26           ` jari
2011-12-13 16:52             ` Ken Brown
2011-12-13 17:48               ` jari
2011-12-13 17:48             ` Eli Zaretskii
2011-12-13 18:05               ` jari
2011-12-13 18:36                 ` Eli Zaretskii
2011-12-15 14:44           ` Jason Rumney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4EEB9DFA.8040000@cornell.edu \
    --to=kbrown@cornell.edu \
    --cc=10257@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=jari.aalto@cante.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).