diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2019-09-18 04:21:19 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2019-09-18 04:21:55 -0700 |
commit | 735940f4551a43f3b4381105dc074cd7d494f2f3 (patch) | |
tree | ac0cf15878e2be0b8e6ebf043c529d5aaa4468b1 /src/fileio.c | |
parent | 94ca934a5c4ef4908fdb7bcd78950bacf9c4ce88 (diff) | |
download | emacs-735940f4551a43f3b4381105dc074cd7d494f2f3.tar.gz emacs-735940f4551a43f3b4381105dc074cd7d494f2f3.tar.bz2 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/fileio.c')
-rw-r--r-- | src/fileio.c | 16 |
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) return file_metadata_errno ("Getting attributes", file, err); } +/* In theory, EACCES errors for predicates like file-readable-p should + be checked further because they may be problems with an ancestor + directory instead of with the file itself, which means that we + don't have reliable info about the requested file. In practice, + though, such errors are common enough that signaling them can be + annoying even if the errors are real (e.g., Bug#37445). So return + nil for EACCES unless compiling with -DPICKY_EACCES, which is off + by default. */ +#ifndef PICKY_EACCES +enum { PICKY_EACCES = false }; +#endif + static Lisp_Object file_test_errno (Lisp_Object file, int err) { + if (!PICKY_EACCES && err == EACCES) + return Qnil; return file_metadata_errno ("Testing file", file, err); } @@ -2745,7 +2759,7 @@ check_file_access (Lisp_Object file, Lisp_Object operation, int amode) return Qt; int err = errno; if (err == EROFS || err == ETXTBSY - || (err == EACCES && amode != F_OK + || (PICKY_EACCES && err == EACCES && amode != F_OK && file_access_p (encoded_file, F_OK))) { errno = err; |