aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2019-09-18 04:21:19 -0700
committerPaul Eggert2019-09-18 04:21:55 -0700
commit735940f4551a43f3b4381105dc074cd7d494f2f3 (patch)
treeac0cf15878e2be0b8e6ebf043c529d5aaa4468b1 /src
parent94ca934a5c4ef4908fdb7bcd78950bacf9c4ce88 (diff)
downloademacs-735940f4551a43f3b4381105dc074cd7d494f2f3.tar.gz
emacs-735940f4551a43f3b4381105dc074cd7d494f2f3.zip
Be less picky about EACCES in file test predicates
Problem reported by Tino Calancha (Bug#37445) and others. * src/fileio.c (PICKY_EACCES): New constant, false by default. (file_test_errno): Ignore EACCES if not picky. (check_file_access): Investigate EACCES problems further if picky.
Diffstat (limited to 'src')
-rw-r--r--src/fileio.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/fileio.c b/src/fileio.c
index 0977516f019..58bc6b7ee8c 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -253,9 +253,23 @@ file_attribute_errno (Lisp_Object file, int err)
253 return file_metadata_errno ("Getting attributes", file, err); 253 return file_metadata_errno ("Getting attributes", file, err);
254} 254}
255 255
256/* In theory, EACCES errors for predicates like file-readable-p should
257 be checked further because they may be problems with an ancestor
258 directory instead of with the file itself, which means that we
259 don't have reliable info about the requested file. In practice,
260 though, such errors are common enough that signaling them can be
261 annoying even if the errors are real (e.g., Bug#37445). So return
262 nil for EACCES unless compiling with -DPICKY_EACCES, which is off
263 by default. */
264#ifndef PICKY_EACCES
265enum { PICKY_EACCES = false };
266#endif
267
256static Lisp_Object 268static Lisp_Object
257file_test_errno (Lisp_Object file, int err) 269file_test_errno (Lisp_Object file, int err)
258{ 270{
271 if (!PICKY_EACCES && err == EACCES)
272 return Qnil;
259 return file_metadata_errno ("Testing file", file, err); 273 return file_metadata_errno ("Testing file", file, err);
260} 274}
261 275
@@ -2745,7 +2759,7 @@ check_file_access (Lisp_Object file, Lisp_Object operation, int amode)
2745 return Qt; 2759 return Qt;
2746 int err = errno; 2760 int err = errno;
2747 if (err == EROFS || err == ETXTBSY 2761 if (err == EROFS || err == ETXTBSY
2748 || (err == EACCES && amode != F_OK 2762 || (PICKY_EACCES && err == EACCES && amode != F_OK
2749 && file_access_p (encoded_file, F_OK))) 2763 && file_access_p (encoded_file, F_OK)))
2750 { 2764 {
2751 errno = err; 2765 errno = err;