ctdb-server: Clean up connection tracking functions
[samba4-gss.git] / source3 / lib / smbd_shim.c
blobc7c64f76cd0eeae67460259a2311d88ccb2274d4
1 /*
2 Unix SMB/CIFS implementation.
3 Runtime plugin adapter for various "smbd"-functions.
5 Copyright (C) Gerald (Jerry) Carter 2004.
6 Copyright (C) Andrew Bartlett 2011.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 /* Shim functions required due to the horrible dependency mess
23 in Samba. */
25 #include "includes.h"
26 #include "smbd_shim.h"
28 static struct smbd_shim shim;
30 void set_smbd_shim(const struct smbd_shim *shim_functions)
32 shim = *shim_functions;
35 bool change_to_root_user(void)
37 if (shim.change_to_root_user) {
38 return shim.change_to_root_user();
40 return false;
43 bool become_authenticated_pipe_user(struct auth_session_info *session_info)
45 if (shim.become_authenticated_pipe_user) {
46 return shim.become_authenticated_pipe_user(session_info);
49 return false;
52 bool unbecome_authenticated_pipe_user(void)
54 if (shim.unbecome_authenticated_pipe_user) {
55 return shim.unbecome_authenticated_pipe_user();
58 return false;
61 /**
62 * The following two functions need to be called from inside the low-level BRL
63 * code for oplocks correctness in smbd. Since other utility binaries also
64 * link in some of the brl code directly, these dummy functions are necessary
65 * to avoid needing to link in the oplocks code and its dependencies to all of
66 * the utility binaries.
68 void contend_level2_oplocks_begin(files_struct *fsp,
69 enum level2_contention_type type)
71 if (shim.contend_level2_oplocks_begin) {
72 shim.contend_level2_oplocks_begin(fsp, type);
74 return;
77 void contend_level2_oplocks_end(files_struct *fsp,
78 enum level2_contention_type type)
80 if (shim.contend_level2_oplocks_end) {
81 shim.contend_level2_oplocks_end(fsp, type);
83 return;
86 void become_root(void)
88 if (shim.become_root) {
89 shim.become_root();
91 return;
94 void unbecome_root(void)
96 if (shim.unbecome_root) {
97 shim.unbecome_root();
99 return;
102 void exit_server(const char *reason)
104 if (shim.exit_server) {
105 shim.exit_server(reason);
107 exit(1);
110 void exit_server_cleanly(const char *const reason)
112 if (shim.exit_server_cleanly) {
113 shim.exit_server_cleanly(reason);
115 exit(0);