add legacy euidaccess function and eaccess alias for it
authorRich Felker <dalias@aerifal.cx>
Sat, 3 Aug 2013 06:15:45 +0000 (02:15 -0400)
committerRich Felker <dalias@aerifal.cx>
Sat, 3 Aug 2013 06:15:45 +0000 (02:15 -0400)
this is mainly for ABI compat purposes.

src/legacy/euidaccess.c [new file with mode: 0644]

diff --git a/src/legacy/euidaccess.c b/src/legacy/euidaccess.c
new file mode 100644 (file)
index 0000000..f37a4ec
--- /dev/null
@@ -0,0 +1,18 @@
+#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);
+}
+
+weak_alias(euidaccess, eaccess);