diff options
author | Florian Weimer <fweimer@redhat.com> | 2020-08-07 22:06:59 +0200 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2020-08-07 22:06:59 +0200 |
commit | 3d3ab573a5f3071992cbc4f57d50d1d29d55bde2 (patch) | |
tree | 83041d7e8a22d4f7f8e5bacdc53e24abf5c72b1d /sysdeps/unix/sysv/linux/faccessat.c | |
parent | 268ed383b57aa136d2e3a40be18a41cadba9e052 (diff) | |
download | glibc-3d3ab573a5f3071992cbc4f57d50d1d29d55bde2.tar.gz glibc-3d3ab573a5f3071992cbc4f57d50d1d29d55bde2.tar.xz glibc-3d3ab573a5f3071992cbc4f57d50d1d29d55bde2.zip |
Linux: Use faccessat2 to implement faccessat (bug 18683)
This provides correct AT_EACCESS handling and also takes Linux security modules into account. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Diffstat (limited to 'sysdeps/unix/sysv/linux/faccessat.c')
-rw-r--r-- | sysdeps/unix/sysv/linux/faccessat.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/sysdeps/unix/sysv/linux/faccessat.c b/sysdeps/unix/sysv/linux/faccessat.c index e4f18ab2db..56cb6dcc8b 100644 --- a/sysdeps/unix/sysv/linux/faccessat.c +++ b/sysdeps/unix/sysv/linux/faccessat.c @@ -30,6 +30,13 @@ int faccessat (int fd, const char *file, int mode, int flag) { + int ret = INLINE_SYSCALL_CALL (faccessat2, fd, file, mode, flag); +#if __ASSUME_FACCESSAT2 + return ret; +#else + if (ret == 0 || errno != ENOSYS) + return ret; + if (flag & ~(AT_SYMLINK_NOFOLLOW | AT_EACCESS)) return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); @@ -41,9 +48,9 @@ faccessat (int fd, const char *file, int mode, int flag) return -1; mode &= (X_OK | W_OK | R_OK); /* Clear any bogus bits. */ -#if R_OK != S_IROTH || W_OK != S_IWOTH || X_OK != S_IXOTH -# error Oops, portability assumptions incorrect. -#endif +# if R_OK != S_IROTH || W_OK != S_IWOTH || X_OK != S_IXOTH +# error Oops, portability assumptions incorrect. +# endif if (mode == F_OK) return 0; /* The file exists. */ @@ -68,4 +75,5 @@ faccessat (int fd, const char *file, int mode, int flag) return 0; return INLINE_SYSCALL_ERROR_RETURN_VALUE (EACCES); +#endif /* !__ASSUME_FACCESSAT2 */ } |