]> git.eshelyaron.com Git - emacs.git/commitdiff
Don't report zero errno for inaccessible directory
authorEli Zaretskii <eliz@gnu.org>
Fri, 27 Jan 2017 08:51:53 +0000 (10:51 +0200)
committerEli Zaretskii <eliz@gnu.org>
Fri, 27 Jan 2017 08:51:53 +0000 (10:51 +0200)
* src/fileio.c (Ffile_accessible_directory_p): Report EACCES when
a file handler reports a failure.  (Bug#25419)

src/fileio.c

index ac6d781941126a8d8bfd415790029241328d1c24..8e549a448550cfdc708cc5b7b7d104e51c43a2ab 100644 (file)
@@ -2815,7 +2815,14 @@ really is a readable and searchable directory.  */)
   if (!NILP (handler))
     {
       Lisp_Object r = call2 (handler, Qfile_accessible_directory_p, absname);
-      errno = 0;
+
+      /* This might be a lie (e.g., the directory might not exist, or
+        be a regular file), but at least it does TRT in the "usual"
+        case of an existing directory that is not accessible by the
+        current user, and avoids reporting "Success" for a failed
+        operation.  */
+      if (!EQ (r, Qt))
+       errno = EACCES;
       return r;
     }