Fix Bug #5285. (libcap header mismatch)
authorGünther Deschner <gd@samba.org>
Wed, 28 May 2008 11:20:16 +0000 (13:20 +0200)
committerGünther Deschner <gd@samba.org>
Wed, 28 May 2008 11:45:55 +0000 (13:45 +0200)
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

source/include/smb.h
source/lib/system.c
source/smbd/oplock_linux.c

index 46afcde7c631c19a7a44ba96718416ef1f8d60d7..13e91623a4bb8b3cd8dd6d010fd26b5ac998cad1 100644 (file)
@@ -1710,7 +1710,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
index b23aa048466ed76be46b51dd9ab608504a5cb503..de5f55276e6257dcbaec13822b1fc2b0e6c21be2 100644 (file)
@@ -774,6 +774,11 @@ static BOOL set_process_capability(enum smbd_capability capability,
 #elif CAP_MKNOD
                        /* Linux has CAP_MKNOD for DMAPI access. */
                        cap_vals[num_cap_vals++] = CAP_MKNOD;
+#endif
+                       break;
+               case LEASE_CAPABILITY:
+#ifdef CAP_LEASE
+                       cap_vals[num_cap_vals++] = CAP_LEASE;
 #endif
                        break;
        }
index 14db98cde6cdb4a8892ad25258145f07775d2561..c6c11a77a9cadfc55cf65688fddccaf4923c3140 100644 (file)
 
 #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];
@@ -76,32 +60,6 @@ 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;
-       }
-
-       data.effective |= (1<<capability);
-
-       if (capset(&header, &data) == -1) {
-               DEBUG(3,("Unable to set %d capability (%s)\n", 
-                        capability, strerror(errno)));
-       }
-}
-
 /*
  Call to set the kernel lease signal handler
 */
@@ -127,7 +85,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);
        }