[Glibc-bsd-commits] r3743 - branches/squeeze/glibc-ports/kfreebsd

Petr Salinger ps-guest at alioth.debian.org
Tue Oct 18 07:02:22 UTC 2011


Author: ps-guest
Date: 2011-10-18 07:02:22 +0000 (Tue, 18 Oct 2011)
New Revision: 3743

Modified:
   branches/squeeze/glibc-ports/kfreebsd/faccessat.c
   branches/squeeze/glibc-ports/kfreebsd/sa_len.c
Log:
merge faccessat fix and minimal sa_len fix


Modified: branches/squeeze/glibc-ports/kfreebsd/faccessat.c
===================================================================
--- branches/squeeze/glibc-ports/kfreebsd/faccessat.c	2011-10-18 06:53:37 UTC (rev 3742)
+++ branches/squeeze/glibc-ports/kfreebsd/faccessat.c	2011-10-18 07:02:22 UTC (rev 3743)
@@ -32,6 +32,16 @@
 extern int __syscall_faccessat (int fd, const char *path, int mode, int flag);
 libc_hidden_proto (__syscall_faccessat)
 
+/*
+   The FreeBSD kernel do not test file access correctly when the 
+   process' real user ID is superuser. In particular, they always return
+   zero when testing execute permissions without regard to whether the 
+   file is executable.
+
+   While this behaviour conforms to POSIX.1-2008, it is explicitely 
+   discouraged. This wrapper implements the recommended behaviour.
+ */
+
 int
 faccessat (fd, file, mode, flag)
      int fd;
@@ -49,7 +59,24 @@
 	__have_atfcts = -1;
       else
 # endif
+      {
+        if ((result == 0) && (mode & X_OK))
+        {
+          uid_t uid = (flag & AT_EACCESS) ? __geteuid () : __getuid ();
+          if (uid == 0)
+          {
+            struct stat64 stats;
+            if (fstatat64 (fd, file, &stats, flag & AT_SYMLINK_NOFOLLOW))
+              return -1;
+            if ((stats.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) == 0)
+            {
+              __set_errno (EACCES);
+              return -1;
+	    }
+          }
+	}
 	return result;
+      }	
     }
 
 #ifndef __ASSUME_ATFCTS

Modified: branches/squeeze/glibc-ports/kfreebsd/sa_len.c
===================================================================
--- branches/squeeze/glibc-ports/kfreebsd/sa_len.c	2011-10-18 06:53:37 UTC (rev 3742)
+++ branches/squeeze/glibc-ports/kfreebsd/sa_len.c	2011-10-18 07:02:22 UTC (rev 3743)
@@ -37,7 +37,7 @@
     case AF_IPX:
       return sizeof (struct sockaddr_ipx);
     case AF_LOCAL:
-      return sizeof (struct sockaddr_un);
+      return sizeof (struct sockaddr_un) - 4;
     }
   return 0;
 }




More information about the Glibc-bsd-commits mailing list