From dfc517b05395d925a4d7b1ce9633a849f9468e70 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 23 Feb 2006 15:52:24 +0000 Subject: r13658: More moving around of files: - Collect the generic utility functions into a lib/util/ (a la GLib is for the GNOME folks) - Remove even more files from include/ (This used to be commit ba62880f5b05c2a505dc7f54676b231197a7e707) --- source4/lib/util/capability.c | 112 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 source4/lib/util/capability.c (limited to 'source4/lib/util/capability.c') diff --git a/source4/lib/util/capability.c b/source4/lib/util/capability.c new file mode 100644 index 0000000000..0cebd33303 --- /dev/null +++ b/source4/lib/util/capability.c @@ -0,0 +1,112 @@ +/* + Unix SMB/CIFS implementation. + + Copyright (C) Andrew Tridgell 1992-1998 + Copyright (C) Jeremy Allison 1998-2002 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/* + capabilities fns - will be needed when we enable kernel oplocks +*/ + +#include "includes.h" +#include "system/network.h" +#include "system/wait.h" +#include "system/filesys.h" + + +#if defined(HAVE_IRIX_SPECIFIC_CAPABILITIES) +/************************************************************************** + Try and abstract process capabilities (for systems that have them). +****************************************************************************/ +static BOOL set_process_capability( uint32_t cap_flag, BOOL enable ) +{ + if(cap_flag == KERNEL_OPLOCK_CAPABILITY) { + cap_t cap = cap_get_proc(); + + if (cap == NULL) { + DEBUG(0,("set_process_capability: cap_get_proc failed. Error was %s\n", + strerror(errno))); + return False; + } + + if(enable) + cap->cap_effective |= CAP_NETWORK_MGT; + else + cap->cap_effective &= ~CAP_NETWORK_MGT; + + if (cap_set_proc(cap) == -1) { + DEBUG(0,("set_process_capability: cap_set_proc failed. Error was %s\n", + strerror(errno))); + cap_free(cap); + return False; + } + + cap_free(cap); + + DEBUG(10,("set_process_capability: Set KERNEL_OPLOCK_CAPABILITY.\n")); + } + return True; +} + +/************************************************************************** + Try and abstract inherited process capabilities (for systems that have them). +****************************************************************************/ + +static BOOL set_inherited_process_capability( uint32_t cap_flag, BOOL enable ) +{ + if(cap_flag == KERNEL_OPLOCK_CAPABILITY) { + cap_t cap = cap_get_proc(); + + if (cap == NULL) { + DEBUG(0,("set_inherited_process_capability: cap_get_proc failed. Error was %s\n", + strerror(errno))); + return False; + } + + if(enable) + cap->cap_inheritable |= CAP_NETWORK_MGT; + else + cap->cap_inheritable &= ~CAP_NETWORK_MGT; + + if (cap_set_proc(cap) == -1) { + DEBUG(0,("set_inherited_process_capability: cap_set_proc failed. Error was %s\n", + strerror(errno))); + cap_free(cap); + return False; + } + + cap_free(cap); + + DEBUG(10,("set_inherited_process_capability: Set KERNEL_OPLOCK_CAPABILITY.\n")); + } + return True; +} +#endif + +/**************************************************************************** + Gain the oplock capability from the kernel if possible. +****************************************************************************/ + +void oplock_set_capability(BOOL this_process, BOOL inherit) +{ +#if HAVE_KERNEL_OPLOCKS_IRIX + set_process_capability(KERNEL_OPLOCK_CAPABILITY,this_process); + set_inherited_process_capability(KERNEL_OPLOCK_CAPABILITY,inherit); +#endif +} + -- cgit From aa04388943fe5d7d8c873a6ee8a4cc9af2491532 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 28 Feb 2006 13:12:39 +0000 Subject: r13752: Add doxyfile and fix formatting of comments. Current output is available at http://samba.org/~jelmer/util-api/ (This used to be commit 90812203df151a5e62394306827c72adfe13c63c) --- source4/lib/util/capability.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source4/lib/util/capability.c') diff --git a/source4/lib/util/capability.c b/source4/lib/util/capability.c index 0cebd33303..ae08fab533 100644 --- a/source4/lib/util/capability.c +++ b/source4/lib/util/capability.c @@ -19,6 +19,11 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +/** + * @file + * @brief Capabilities functions + **/ + /* capabilities fns - will be needed when we enable kernel oplocks */ -- cgit From af30a32b6924b0f2b701186e435defbca2ebd1aa Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 5 Mar 2006 17:15:19 +0000 Subject: r13840: Mark some functions as public. (This used to be commit 9a188eb1f48a50d92a67a4fc2b3899b90074059a) --- source4/lib/util/capability.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/util/capability.c') diff --git a/source4/lib/util/capability.c b/source4/lib/util/capability.c index ae08fab533..0062bb5cd6 100644 --- a/source4/lib/util/capability.c +++ b/source4/lib/util/capability.c @@ -107,7 +107,7 @@ static BOOL set_inherited_process_capability( uint32_t cap_flag, BOOL enable ) Gain the oplock capability from the kernel if possible. ****************************************************************************/ -void oplock_set_capability(BOOL this_process, BOOL inherit) +_PUBLIC_ void oplock_set_capability(BOOL this_process, BOOL inherit) { #if HAVE_KERNEL_OPLOCKS_IRIX set_process_capability(KERNEL_OPLOCK_CAPABILITY,this_process); -- cgit From c287cc247d90c996894cab18e870c992e7f84f85 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 6 Mar 2006 00:24:51 +0000 Subject: r13851: More doc improvements. (This used to be commit 936d26ae64b93ef8f8b2fbc632b1c2fd60840405) --- source4/lib/util/capability.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/util/capability.c') diff --git a/source4/lib/util/capability.c b/source4/lib/util/capability.c index 0062bb5cd6..09af293087 100644 --- a/source4/lib/util/capability.c +++ b/source4/lib/util/capability.c @@ -103,9 +103,9 @@ static BOOL set_inherited_process_capability( uint32_t cap_flag, BOOL enable ) } #endif -/**************************************************************************** +/** Gain the oplock capability from the kernel if possible. -****************************************************************************/ +**/ _PUBLIC_ void oplock_set_capability(BOOL this_process, BOOL inherit) { -- cgit From 4ab73d6045aacd354894fe5edf0c5cfc75784064 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 8 Apr 2006 16:25:53 +0000 Subject: r15000: Move some more autoconf tests out of build/m4/rewrite.m4 Guarantee availability of __FUNCTION__ in libreplace (This used to be commit 76b1576541210f2bb306ae17e0876b254e8dcead) --- source4/lib/util/capability.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/util/capability.c') diff --git a/source4/lib/util/capability.c b/source4/lib/util/capability.c index 09af293087..683bc99723 100644 --- a/source4/lib/util/capability.c +++ b/source4/lib/util/capability.c @@ -114,4 +114,3 @@ _PUBLIC_ void oplock_set_capability(BOOL this_process, BOOL inherit) set_inherited_process_capability(KERNEL_OPLOCK_CAPABILITY,inherit); #endif } - -- cgit From 53f005f6aaa2aa2eb599e6787e2c700a1d44d2a2 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 13 May 2006 18:12:53 +0000 Subject: r15572: Trim build/m4/rewrite.m4 a bit more, remove unused tests. (This used to be commit d72c5c8f755277eb22e1f6834d98202f00c09934) --- source4/lib/util/capability.c | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'source4/lib/util/capability.c') diff --git a/source4/lib/util/capability.c b/source4/lib/util/capability.c index 683bc99723..7d8222fe11 100644 --- a/source4/lib/util/capability.c +++ b/source4/lib/util/capability.c @@ -102,15 +102,3 @@ static BOOL set_inherited_process_capability( uint32_t cap_flag, BOOL enable ) return True; } #endif - -/** - Gain the oplock capability from the kernel if possible. -**/ - -_PUBLIC_ void oplock_set_capability(BOOL this_process, BOOL inherit) -{ -#if HAVE_KERNEL_OPLOCKS_IRIX - set_process_capability(KERNEL_OPLOCK_CAPABILITY,this_process); - set_inherited_process_capability(KERNEL_OPLOCK_CAPABILITY,inherit); -#endif -} -- cgit From 0479a2f1cbae51fcd8dbdc3c148c808421fb4d25 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:07:03 +0000 Subject: r23792: convert Samba4 to GPLv3 There are still a few tidyups of old FSF addresses to come (in both s3 and s4). More commits soon. (This used to be commit fcf38a38ac691abd0fa51b89dc951a08e89fdafa) --- source4/lib/util/capability.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/lib/util/capability.c') diff --git a/source4/lib/util/capability.c b/source4/lib/util/capability.c index 7d8222fe11..d42d13e008 100644 --- a/source4/lib/util/capability.c +++ b/source4/lib/util/capability.c @@ -6,7 +6,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -15,8 +15,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ /** -- cgit From 4fb038b0b8e7a4bb69ac0d9022684eeaca8a491a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 27 Aug 2007 17:21:16 +0000 Subject: r24710: Use standard boolean type for easier use by external users. (This used to be commit 99f4124137d4a61216e8189f26d4da32882c0f4a) --- source4/lib/util/capability.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'source4/lib/util/capability.c') diff --git a/source4/lib/util/capability.c b/source4/lib/util/capability.c index d42d13e008..2d13826c14 100644 --- a/source4/lib/util/capability.c +++ b/source4/lib/util/capability.c @@ -37,7 +37,7 @@ /************************************************************************** Try and abstract process capabilities (for systems that have them). ****************************************************************************/ -static BOOL set_process_capability( uint32_t cap_flag, BOOL enable ) +static bool set_process_capability( uint32_t cap_flag, bool enable ) { if(cap_flag == KERNEL_OPLOCK_CAPABILITY) { cap_t cap = cap_get_proc(); @@ -45,7 +45,7 @@ static BOOL set_process_capability( uint32_t cap_flag, BOOL enable ) if (cap == NULL) { DEBUG(0,("set_process_capability: cap_get_proc failed. Error was %s\n", strerror(errno))); - return False; + return false; } if(enable) @@ -57,21 +57,21 @@ static BOOL set_process_capability( uint32_t cap_flag, BOOL enable ) DEBUG(0,("set_process_capability: cap_set_proc failed. Error was %s\n", strerror(errno))); cap_free(cap); - return False; + return false; } cap_free(cap); DEBUG(10,("set_process_capability: Set KERNEL_OPLOCK_CAPABILITY.\n")); } - return True; + return true; } /************************************************************************** Try and abstract inherited process capabilities (for systems that have them). ****************************************************************************/ -static BOOL set_inherited_process_capability( uint32_t cap_flag, BOOL enable ) +static bool set_inherited_process_capability( uint32_t cap_flag, bool enable ) { if(cap_flag == KERNEL_OPLOCK_CAPABILITY) { cap_t cap = cap_get_proc(); @@ -79,7 +79,7 @@ static BOOL set_inherited_process_capability( uint32_t cap_flag, BOOL enable ) if (cap == NULL) { DEBUG(0,("set_inherited_process_capability: cap_get_proc failed. Error was %s\n", strerror(errno))); - return False; + return false; } if(enable) @@ -91,13 +91,13 @@ static BOOL set_inherited_process_capability( uint32_t cap_flag, BOOL enable ) DEBUG(0,("set_inherited_process_capability: cap_set_proc failed. Error was %s\n", strerror(errno))); cap_free(cap); - return False; + return false; } cap_free(cap); DEBUG(10,("set_inherited_process_capability: Set KERNEL_OPLOCK_CAPABILITY.\n")); } - return True; + return true; } #endif -- cgit