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