diff options
author | Günther Deschner <gd@samba.org> | 2008-05-28 13:20:16 +0200 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2008-05-28 13:22:52 +0200 |
commit | 611072fc1cd94e6c9d56ce910fd13f007f6ecb84 (patch) | |
tree | bf09fa76bfc8f3f148777ed6fde08e89f21b1c78 /source3 | |
parent | 87c15f5a57c4c7e35ac87fa1c90faeeac7c86250 (diff) | |
download | samba-611072fc1cd94e6c9d56ce910fd13f007f6ecb84.tar.gz samba-611072fc1cd94e6c9d56ce910fd13f007f6ecb84.tar.bz2 samba-611072fc1cd94e6c9d56ce910fd13f007f6ecb84.zip |
Fix Bug #5285. (libcap header mismatch)
Can someone with gpfs available test this ? The only codepath using this
function is the modules/gpfs.c module. The fix resolves at least the build
issues Samba has with recent kernel / libcap versions by using the portable
cap_get_proc()/cap_set_proc() interface (instead of using capget/capset).
Guenther
(This used to be commit 177955141247a4eb56ba0d82dc1add7f52175c40)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/include/smb.h | 3 | ||||
-rw-r--r-- | source3/lib/system.c | 5 | ||||
-rw-r--r-- | source3/smbd/oplock_linux.c | 48 |
3 files changed, 9 insertions, 47 deletions
diff --git a/source3/include/smb.h b/source3/include/smb.h index e7860b7903..76cc389a10 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -1709,7 +1709,8 @@ minimum length == 18. enum smbd_capability { KERNEL_OPLOCK_CAPABILITY, - DMAPI_ACCESS_CAPABILITY + DMAPI_ACCESS_CAPABILITY, + LEASE_CAPABILITY }; /* if a kernel does support oplocks then a structure of the following diff --git a/source3/lib/system.c b/source3/lib/system.c index fa50955ef6..eabb6d6dc4 100644 --- a/source3/lib/system.c +++ b/source3/lib/system.c @@ -733,6 +733,11 @@ static bool set_process_capability(enum smbd_capability capability, cap_vals[num_cap_vals++] = CAP_MKNOD; #endif break; + case LEASE_CAPABILITY: +#ifdef CAP_LEASE + cap_vals[num_cap_vals++] = CAP_LEASE; +#endif + break; } SMB_ASSERT(num_cap_vals <= ARRAY_SIZE(cap_vals)); diff --git a/source3/smbd/oplock_linux.c b/source3/smbd/oplock_linux.c index fa7cb42bc6..08df228f8f 100644 --- a/source3/smbd/oplock_linux.c +++ b/source3/smbd/oplock_linux.c @@ -22,22 +22,6 @@ #if HAVE_KERNEL_OPLOCKS_LINUX -/* these can be removed when they are in glibc headers */ -struct cap_user_header { - uint32 version; - int pid; -} header; -struct cap_user_data { - uint32 effective; - uint32 permitted; - uint32 inheritable; -} data; - -extern int capget(struct cap_user_header * hdrp, - struct cap_user_data * datap); -extern int capset(struct cap_user_header * hdrp, - const struct cap_user_data * datap); - static SIG_ATOMIC_T signals_received; #define FD_PENDING_SIZE 100 static SIG_ATOMIC_T fd_pending_array[FD_PENDING_SIZE]; @@ -75,40 +59,12 @@ static void signal_handler(int sig, siginfo_t *info, void *unused) sys_select_signal(RT_SIGNAL_LEASE); } -/**************************************************************************** - Try to gain a linux capability. -****************************************************************************/ - -static void set_capability(unsigned capability) -{ -#ifndef _LINUX_CAPABILITY_VERSION -#define _LINUX_CAPABILITY_VERSION 0x19980330 -#endif - header.version = _LINUX_CAPABILITY_VERSION; - header.pid = 0; - - if (capget(&header, &data) == -1) { - DEBUG(3,("Unable to get kernel capabilities (%s)\n", - strerror(errno))); - return; - } - - if (0 == (data.effective & (1<<capability))) { - data.effective |= (1<<capability); - - if (capset(&header, &data) == -1) { - DEBUG(3,("Unable to set %d capability (%s)\n", - capability, strerror(errno))); - } - } -} - /* * public function to get linux lease capability. Needed by some VFS modules (eg. gpfs.c) */ void linux_set_lease_capability(void) { - set_capability(CAP_LEASE); + set_effective_capability(LEASE_CAPABILITY); } /* @@ -136,7 +92,7 @@ int linux_setlease(int fd, int leasetype) ret = fcntl(fd, F_SETLEASE, leasetype); if (ret == -1 && errno == EACCES) { - set_capability(CAP_LEASE); + set_effective_capability(LEASE_CAPABILITY); ret = fcntl(fd, F_SETLEASE, leasetype); } |