[Glibc-bsd-commits] r2652 - trunk/glibc-ports/kfreebsd
Petr Salinger
ps-guest at alioth.debian.org
Mon Jul 20 08:45:09 UTC 2009
Author: ps-guest
Date: 2009-07-20 08:45:08 +0000 (Mon, 20 Jul 2009)
New Revision: 2652
Modified:
trunk/glibc-ports/kfreebsd/Makefile
trunk/glibc-ports/kfreebsd/access.c
trunk/glibc-ports/kfreebsd/faccessat.c
Log:
misc access() fixes
Modified: trunk/glibc-ports/kfreebsd/Makefile
===================================================================
--- trunk/glibc-ports/kfreebsd/Makefile 2009-07-20 08:14:00 UTC (rev 2651)
+++ trunk/glibc-ports/kfreebsd/Makefile 2009-07-20 08:45:08 UTC (rev 2652)
@@ -31,7 +31,7 @@
ifeq ($(subdir),io)
# For <unistd.h>.
-sysdep_routines += sys_access sys_fchownat sys_fexecve sys_getcwd sys_linkat sys_lseek sys_freebsd6_lseek sys_readlinkat sys_symlinkat sys_unlinkat
+sysdep_routines += sys_access sys_faccessat sys_fchownat sys_fexecve sys_getcwd sys_linkat sys_lseek sys_freebsd6_lseek sys_readlinkat sys_symlinkat sys_unlinkat
# For <fcntl.h>.
sysdep_routines += sys_open sys_openat open_2
# For <sys/stat.h>.
Modified: trunk/glibc-ports/kfreebsd/access.c
===================================================================
--- trunk/glibc-ports/kfreebsd/access.c 2009-07-20 08:14:00 UTC (rev 2651)
+++ trunk/glibc-ports/kfreebsd/access.c 2009-07-20 08:45:08 UTC (rev 2652)
@@ -37,48 +37,30 @@
discouraged. This wrapper implements the recommended behaviour.
*/
-extern int __syscall_access (const char *path, mode_t mode);
+extern int __syscall_access (const char *path, int mode);
libc_hidden_proto (__syscall_access)
int
-__access (path, mode)
- const char *path;
- int mode;
+__access (const char *path, int mode)
{
- uid_t uid;
struct stat64 stats;
- uid = __getuid();
-
- if (uid != 0)
+ if ((__getuid() != 0) || !(mode & X_OK))
return __syscall_access (path, mode);
+ /* Althought the super-user can read and write any file,
+ the file-system might be i.e. read-only. Do the check. */
+
+ if (__syscall_access (path, mode))
+ return -1;
+
if (stat64 (path, &stats))
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 (mode == F_OK)
- return 0; /* The file exists. */
-
- /* The super-user can read and write any file, and execute any file
- that anyone can execute. */
- if ((mode & X_OK) == 0 || (stats.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
+ /* The super-user can execute any file that anyone can execute. */
+ if (stats.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))
return 0;
- int granted = (uid == stats.st_uid
- ? (unsigned int) (stats.st_mode & (mode << 6)) >> 6
- : (stats.st_gid == (__getgid ())
- || __group_member (stats.st_gid))
- ? (unsigned int) (stats.st_mode & (mode << 3)) >> 3
- : (stats.st_mode & mode));
-
- if (granted == mode)
- return 0;
-
__set_errno (EACCES);
return -1;
}
Modified: trunk/glibc-ports/kfreebsd/faccessat.c
===================================================================
--- trunk/glibc-ports/kfreebsd/faccessat.c 2009-07-20 08:14:00 UTC (rev 2651)
+++ trunk/glibc-ports/kfreebsd/faccessat.c 2009-07-20 08:45:08 UTC (rev 2652)
@@ -29,8 +29,7 @@
#include <kernel-features.h>
#include <sysdep.h>
-extern int __syscall_faccessat (int fd, const char *path, mode_t mode,
- int flag);
+extern int __syscall_faccessat (int fd, const char *path, int mode, int flag);
libc_hidden_proto (__syscall_faccessat)
int
More information about the Glibc-bsd-commits
mailing list