collapse euidaccess to a call to faccessat
authorRich Felker <dalias@aerifal.cx>
Sat, 3 Aug 2013 06:28:35 +0000 (02:28 -0400)
committerRich Felker <dalias@aerifal.cx>
Sat, 3 Aug 2013 06:28:35 +0000 (02:28 -0400)
it turns out Linux is buggy for faccessat, just like fchmodat: the
kernel does not actually take a flags argument. so we're going to have
to emulate it there.

src/legacy/euidaccess.c

index f37a4ec..47b464d 100644 (file)
@@ -1,18 +1,10 @@
 #include <unistd.h>
 #include <fcntl.h>
-#include <errno.h>
-#include "syscall.h"
 #include "libc.h"
 
 int euidaccess(const char *filename, int amode)
 {
-       int ret = __syscall(SYS_faccessat, AT_FDCWD, filename, amode, AT_EACCESS);
-       if (ret != -ENOSYS) return __syscall_ret(ret);
-
-       if (getuid() == geteuid() && getgid() == getegid())
-               return syscall(SYS_access, filename, amode);
-
-       return __syscall_ret(-ENOSYS);
+       return faccessat(AT_FDCWD, filename, amode, AT_EACCESS);
 }
 
 weak_alias(euidaccess, eaccess);