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)
committerJeremy Allison <jra@samba.org>
Thu, 21 Jun 2012 19:53:58 +0000 (21:53 +0200)
Based on a fix from "Etienne Dechamps " <e-t172@akegroup.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Thu Jun 21 21:53:58 CEST 2012 on sn-devel-104

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

index b387cce109fdcbe640f427f82de8e51cae0c8c85..eb3e343495fce5d1c2b7f8cf60e764c53a859414 100644 (file)
@@ -1573,11 +1573,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 190578e0ccb6d86cd9757344931f86a0597124ca..7fa9b7cb2ca7c0de3f8419ac306dc2e23d67c6cb 100644 (file)
@@ -76,9 +76,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);
        }