From 525a6d2c4fcd4a319e196ede0513275f6b07eb2c Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Fri, 27 Jan 2017 10:51:53 +0200 Subject: [PATCH] Don't report zero errno for inaccessible directory * src/fileio.c (Ffile_accessible_directory_p): Report EACCES when a file handler reports a failure. (Bug#25419) --- src/fileio.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/fileio.c b/src/fileio.c index ac6d7819411..8e549a44855 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -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; } -- 2.11.4.GIT