Fix bug #8974 - Kernel oplocks are broken when uid(file) != uid(process).
authorJeremy Allison <jra@samba.org>
Wed, 20 Jun 2012 22:50:00 +0000 (15:50 -0700)
committerKarolin Seeger <kseeger@samba.org>
Sat, 30 Jun 2012 11:44:55 +0000 (13:44 +0200)
Based on a fix from "Etienne Dechamps " <e-t172@akegroup.org>
(cherry picked from commit 0e2fb6c69e971c7502fabe17fa71d1453dda18a6)
(cherry picked from commit 92b1d6b93571facbb07b7d32f169ba32ef6f8e1f)

source3/modules/vfs_default.c
source3/smbd/oplock_linux.c

index 60b85d9730cd2eb3931d81c0fa8c9fcab17bbe32..0a341981740aeef196515424e4cfa0f41926420f 100644 (file)
@@ -1133,11 +1133,6 @@ static int vfswrap_linux_setlease(vfs_handle_struct *handle, files_struct *fsp,
        START_PROFILE(syscall_linux_setlease);
 
 #ifdef HAVE_KERNEL_OPLOCKS_LINUX
-       /* first set the signal handler */
-       if(linux_set_lease_sighandler(fsp->fh->fd) == -1) {
-               return -1;
-       }
-
        result = linux_setlease(fsp->fh->fd, leasetype);
 #else
        errno = ENOSYS;
index c60c74517717da2eea9ae4d7bf007a99734094fa..ff5d5961b7b9dc18f1b89c0672d7dc06efb7122a 100644 (file)
@@ -74,9 +74,22 @@ int linux_setlease(int fd, int leasetype)
 {
        int ret;
 
+       /* First set the signal handler. */
+       if (linux_set_lease_sighandler(fd) == -1) {
+               return -1;
+       }
        ret = fcntl(fd, F_SETLEASE, leasetype);
        if (ret == -1 && errno == EACCES) {
                set_effective_capability(LEASE_CAPABILITY);
+               /*
+                * Bug 8974 - work around Linux kernel bug
+                * https://bugzilla.kernel.org/show_bug.cgi?id=43336.
+                * "fcntl(F_SETLEASE) resets signal number when
+                *  called multiple times"
+                */
+               if (linux_set_lease_sighandler(fd) == -1) {
+                       return -1;
+               }
                ret = fcntl(fd, F_SETLEASE, leasetype);
        }