Mercurial > gnulib
view doc/posix-functions/faccessat.texi @ 39152:abd3b4b846c4
faccessat: port to macOS (Bug#29231)
macOS faccessat has the same bug that lstat does: if the file
name ends in '/' it ignores the trailing slash.
Problem reported for Emacs by Vincent Zhang.
* doc/posix-functions/faccessat.texi (faccessat): Document this.
* lib/faccessat.c (_GL_INCLUDING_UNISTD_H): Define and undef
around the initial includes. Include errno.h, string.h, sys/stat.h.
(orig_faccessat) [HAVE_FACCESSAT]: New function.
Include "unistd.h" after defining it.
(rpl_faccessat) [HAVE_FACCESSAT]: New implementation.
* lib/unistd.in.h (faccessat) [REPLACE_FACCESSAT]:
Handle in the usual way.
* m4/faccessat.m4 (gl_FUNC_FACCESSAT): Replace faccessat if
lstat dereferences symlinks, since faccessat is likely to
have the same problem.
* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Default REPLACE_ACCESSAT.
* modules/faccessat (Depends-on): Add fstatat.
Depend if REPLACE_FACCESSAT is 1, too.
(configure.ac): Link if REPLACE_FACCESSAT is 1.
* modules/faccessat-tests (Depends-on): Add symlink.
* modules/unistd (unistd.h): Substitute REPLACE_FACCESSAT.
* tests/test-faccessat.c (main): Test for the bug.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Sat, 11 Nov 2017 22:33:38 -0800 |
parents | bfa05cb8159c |
children | 0f6b0bb3cee9 |
line wrap: on
line source
@node faccessat @section @code{faccessat} @findex faccessat POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/faccessat.html} Gnulib module: faccessat Portability problems fixed by Gnulib: @itemize @item This function is missing on some platforms: glibc 2.3.6, macOS 10.12, FreeBSD 7.4, NetBSD 6.1.5, OpenBSD 4.9, Minix 3.1.8, AIX 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x, mingw, MSVC 14, Interix 3.5, BeOS. @item On some platforms, @code{faccessat (dfd, "file/", amode, flag)} succeeds instead of failing when @file{file} is not a directory. macOS 10.13. @end itemize Portability problems not fixed by Gnulib: @itemize @item The replacement does not always take ACLs into account. @item The replacement is not safe to be used in libraries. @item The replacement is not multithread-safe. @item The replacement does not support the @code{AT_SYMLINK_NOFOLLOW} flag, which is supported by GNU @code{faccessat}. @end itemize Other problems of this function: @itemize @item There is an inherent race between calling this function and performing some action based on the results; you should think twice before trusting this function, especially in a set-uid or set-gid program. @end itemize