summaryrefslogtreecommitdiffstats
path: root/source/lib/system.c
diff options
context:
space:
mode:
authorJames Peach <jpeach@samba.org>2006-03-22 23:49:09 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:15:42 -0500
commit514a767c57f8194547e5b708ad2573ab9a0719c6 (patch)
tree877d0fb5844fae5bc4eaea6bf7e085daddc08891 /source/lib/system.c
parent203b4911c16bd7e10198a6f0e63960f2813025ef (diff)
downloadsamba-514a767c57f8194547e5b708ad2573ab9a0719c6.tar.gz
samba-514a767c57f8194547e5b708ad2573ab9a0719c6.tar.xz
samba-514a767c57f8194547e5b708ad2573ab9a0719c6.zip
r14668: Set the FILE_STATUS_OFFLINE bit by observing the events a DMAPI-based
HSM is interested in. Tested on both IRIX and SLES9.
Diffstat (limited to 'source/lib/system.c')
-rw-r--r--source/lib/system.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/source/lib/system.c b/source/lib/system.c
index ffb70317150..2e5f42307bd 100644
--- a/source/lib/system.c
+++ b/source/lib/system.c
@@ -22,6 +22,10 @@
#include "includes.h"
+#ifdef HAVE_SYS_PRCTL_H
+#include <sys/prctl.h>
+#endif
+
/*
The idea is that this file will eventually have wrappers around all
important system calls in samba. The aims are:
@@ -661,6 +665,19 @@ static BOOL set_process_capability(enum smbd_capability capability,
cap_t cap;
+#if defined(HAVE_PRCTL) && defined(PR_GET_KEEPCAPS) && defined(PR_SET_KEEPCAPS)
+ /* On Linux, make sure that any capabilities we grab are sticky
+ * across UID changes. We expect that this would allow us to keep both
+ * the effective and permitted capability sets, but as of circa 2.6.16,
+ * only the permitted set is kept. It is a bug (which we work around)
+ * that the effective set is lost, but we still require the effective
+ * set to be kept.
+ */
+ if (!prctl(PR_GET_KEEPCAPS)) {
+ prctl(PR_SET_KEEPCAPS, 1);
+ }
+#endif
+
cap = cap_get_proc();
if (cap == NULL) {
DEBUG(0,("set_process_capability: cap_get_proc failed: %s\n",
@@ -675,6 +692,15 @@ static BOOL set_process_capability(enum smbd_capability capability,
cap_vals[num_cap_vals++] = CAP_NETWORK_MGT;
#endif
break;
+ case DMAPI_ACCESS_CAPABILITY:
+#ifdef CAP_DEVICE_MGT
+ /* IRIX has CAP_DEVICE_MGT for DMAPI access. */
+ cap_vals[num_cap_vals++] = CAP_DEVICE_MGT;
+#elif CAP_MKNOD
+ /* Linux has CAP_MKNOD for DMAPI access. */
+ cap_vals[num_cap_vals++] = CAP_MKNOD;
+#endif
+ break;
}
SMB_ASSERT(num_cap_vals <= ARRAY_SIZE(cap_vals));
@@ -686,6 +712,10 @@ static BOOL set_process_capability(enum smbd_capability capability,
cap_set_flag(cap, CAP_EFFECTIVE, num_cap_vals, cap_vals,
enable ? CAP_SET : CAP_CLEAR);
+
+ /* We never want to pass capabilities down to our children, so make
+ * sure they are not inherited.
+ */
cap_set_flag(cap, CAP_INHERITABLE, num_cap_vals, cap_vals, CAP_CLEAR);
if (cap_set_proc(cap) == -1) {