/* [<][>][^][v][top][bottom][index][help] */
DEFINITIONS
This source file includes following definitions.
- set_process_capability
- set_inherited_process_capability
1 /*
2 Unix SMB/CIFS implementation.
3
4 Copyright (C) Andrew Tridgell 1992-1998
5 Copyright (C) Jeremy Allison 1998-2002
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 /**
22 * @file
23 * @brief Capabilities functions
24 **/
25
26 /*
27 capabilities fns - will be needed when we enable kernel oplocks
28 */
29
30 #include "includes.h"
31 #include "system/network.h"
32 #include "system/wait.h"
33 #include "system/filesys.h"
34
35
36 #if defined(HAVE_IRIX_SPECIFIC_CAPABILITIES)
37 /**************************************************************************
38 Try and abstract process capabilities (for systems that have them).
39 ****************************************************************************/
40 static bool set_process_capability( uint32_t cap_flag, bool enable )
/* [<][>][^][v][top][bottom][index][help] */
41 {
42 if(cap_flag == KERNEL_OPLOCK_CAPABILITY) {
43 cap_t cap = cap_get_proc();
44
45 if (cap == NULL) {
46 DEBUG(0,("set_process_capability: cap_get_proc failed. Error was %s\n",
47 strerror(errno)));
48 return false;
49 }
50
51 if(enable)
52 cap->cap_effective |= CAP_NETWORK_MGT;
53 else
54 cap->cap_effective &= ~CAP_NETWORK_MGT;
55
56 if (cap_set_proc(cap) == -1) {
57 DEBUG(0,("set_process_capability: cap_set_proc failed. Error was %s\n",
58 strerror(errno)));
59 cap_free(cap);
60 return false;
61 }
62
63 cap_free(cap);
64
65 DEBUG(10,("set_process_capability: Set KERNEL_OPLOCK_CAPABILITY.\n"));
66 }
67 return true;
68 }
69
70 /**************************************************************************
71 Try and abstract inherited process capabilities (for systems that have them).
72 ****************************************************************************/
73
74 static bool set_inherited_process_capability( uint32_t cap_flag, bool enable )
/* [<][>][^][v][top][bottom][index][help] */
75 {
76 if(cap_flag == KERNEL_OPLOCK_CAPABILITY) {
77 cap_t cap = cap_get_proc();
78
79 if (cap == NULL) {
80 DEBUG(0,("set_inherited_process_capability: cap_get_proc failed. Error was %s\n",
81 strerror(errno)));
82 return false;
83 }
84
85 if(enable)
86 cap->cap_inheritable |= CAP_NETWORK_MGT;
87 else
88 cap->cap_inheritable &= ~CAP_NETWORK_MGT;
89
90 if (cap_set_proc(cap) == -1) {
91 DEBUG(0,("set_inherited_process_capability: cap_set_proc failed. Error was %s\n",
92 strerror(errno)));
93 cap_free(cap);
94 return false;
95 }
96
97 cap_free(cap);
98
99 DEBUG(10,("set_inherited_process_capability: Set KERNEL_OPLOCK_CAPABILITY.\n"));
100 }
101 return true;
102 }
103 #endif