arrfab / rpms / glibc

Forked from rpms/glibc 5 years ago
Clone

Blame SOURCES/glibc-rh977870.patch

147e83
commit d755bba40f880c01ced8740a26fecc85534454b9
147e83
Author: Siddhesh Poyarekar <siddhesh@redhat.com>
147e83
Date:   Wed Apr 3 10:56:45 2013 +0530
147e83
147e83
    Preserve errno across _PC_CHOWN_RESTRICTED call on XFS
147e83
    
147e83
    Fix BZ #15305.
147e83
    
147e83
    On kernel versions earlier than 2.6.29, the Linux kernel exported a
147e83
    sysctl called restrict_chown for xfs, which could be used to allow
147e83
    chown to users other than the owner.  2.6.29 removed this support,
147e83
    causing the open_not_cancel_2 to fail and thus modify errno.  The fix
147e83
    is to save and restore errno so that the caller sees it as unmodified.
147e83
    
147e83
    Additionally, since the code to check the sysctl is not useful on
147e83
    newer kernels, we add an ifdef so that in future the code block gets
147e83
    rmeoved completely.
147e83
147e83
diff --git glibc-2.17-c758a686/sysdeps/unix/sysv/linux/kernel-features.h glibc-2.17-c758a686/sysdeps/unix/sysv/linux/kernel-features.h
147e83
index 8fdff7e..ccd4c59 100644
147e83
--- glibc-2.17-c758a686/sysdeps/unix/sysv/linux/kernel-features.h
147e83
+++ glibc-2.17-c758a686/sysdeps/unix/sysv/linux/kernel-features.h
147e83
@@ -221,3 +221,9 @@
147e83
 #if defined __x86_64__ && __LINUX_KERNEL_VERSION >= 0x030100
147e83
 # define __ASSUME_GETCPU_SYSCALL	1
147e83
 #endif
147e83
+
147e83
+/* 2.6.29 removed the XFS restricted_chown sysctl, so it is pointless looking
147e83
+   for it in newer kernels.  */
147e83
+#if __LINUX_KERNEL_VERSION >= 0x02061d
147e83
+# define __ASSUME_XFS_RESTRICTED_CHOWN 1
147e83
+#endif
147e83
diff --git glibc-2.17-c758a686/sysdeps/unix/sysv/linux/pathconf.c glibc-2.17-c758a686/sysdeps/unix/sysv/linux/pathconf.c
147e83
index de91a45..723d234 100644
147e83
--- glibc-2.17-c758a686/sysdeps/unix/sysv/linux/pathconf.c
147e83
+++ glibc-2.17-c758a686/sysdeps/unix/sysv/linux/pathconf.c
147e83
@@ -289,11 +289,16 @@ __statfs_chown_restricted (int result, const struct statfs *fsbuf)
147e83
       return -1;
147e83
     }
147e83
 
147e83
+#if __ASSUME_XFS_RESTRICTED_CHOWN
147e83
+  return 1;
147e83
+#else
147e83
   int fd;
147e83
+  int save_errno;
147e83
   long int retval = 1;
147e83
   switch (fsbuf->f_type)
147e83
     {
147e83
     case XFS_SUPER_MAGIC:
147e83
+      save_errno = errno;
147e83
       /* Read the value from /proc/sys/fs/xfs/restrict_chown.  If we cannot
147e83
 	 read it default to assume the restriction is in place.  */
147e83
       fd = open_not_cancel_2 ("/proc/sys/fs/xfs/restrict_chown", O_RDONLY);
147e83
@@ -306,6 +311,7 @@ __statfs_chown_restricted (int result, const struct statfs *fsbuf)
147e83
 
147e83
 	  close_not_cancel_no_status (fd);
147e83
 	}
147e83
+      __set_errno (save_errno);
147e83
       break;
147e83
 
147e83
     default:
147e83
@@ -313,4 +319,5 @@ __statfs_chown_restricted (int result, const struct statfs *fsbuf)
147e83
     }
147e83
 
147e83
   return retval;
147e83
+#endif
147e83
 }