summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2013-07-31 16:32:20 -0700
committerJeremy Allison <jra@samba.org>2013-07-31 17:07:58 -0700
commit1af8b0792913d3f280b5da0802e04df063f9f59e (patch)
treeeebf26bfb2c6a88ef5842c7777e6d00a42173d76 /source3
parent63db0694c45b1ce59b9232f0690226fce39f9c28 (diff)
downloadsamba-1af8b0792913d3f280b5da0802e04df063f9f59e.tar.gz
samba-1af8b0792913d3f280b5da0802e04df063f9f59e.tar.bz2
samba-1af8b0792913d3f280b5da0802e04df063f9f59e.zip
Wrap setting leases in become_root()/unbecome_root() to ensure correct delivery of signals.
Remove workaround for Linux kernel bug https://bugzilla.kernel.org/show_bug.cgi?id=43336 as we don't need to set capabilities when we're already root. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Simo Sorce <idra@samba.org>
Diffstat (limited to 'source3')
-rw-r--r--source3/smbd/oplock_linux.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/source3/smbd/oplock_linux.c b/source3/smbd/oplock_linux.c
index 7fa9b7cb2c..dd772bf6cb 100644
--- a/source3/smbd/oplock_linux.c
+++ b/source3/smbd/oplock_linux.c
@@ -75,26 +75,33 @@ int linux_set_lease_sighandler(int fd)
int linux_setlease(int fd, int leasetype)
{
int ret;
+ int saved_errno;
+
+ /*
+ * Ensure the lease owner is root to allow
+ * correct delivery of lease-break signals.
+ */
+
+ become_root();
/* First set the signal handler. */
if (linux_set_lease_sighandler(fd) == -1) {
- return -1;
+ saved_errno = errno;
+ ret = -1;
+ goto out;
}
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);
+ if (ret == -1) {
+ saved_errno = errno;
}
+ out:
+
+ unbecome_root();
+
+ if (ret == -1) {
+ errno = saved_errno;
+ }
return ret;
}