/src/samba/source3/lib/smbd_shim.c
Line | Count | Source |
1 | | /* |
2 | | Unix SMB/CIFS implementation. |
3 | | Runtime plugin adapter for various "smbd"-functions. |
4 | | |
5 | | Copyright (C) Gerald (Jerry) Carter 2004. |
6 | | Copyright (C) Andrew Bartlett 2011. |
7 | | |
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. |
12 | | |
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. |
17 | | |
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/>. |
20 | | */ |
21 | | |
22 | | /* Shim functions required due to the horrible dependency mess |
23 | | in Samba. */ |
24 | | |
25 | | #include "includes.h" |
26 | | #include "smbd_shim.h" |
27 | | |
28 | | static struct smbd_shim shim; |
29 | | |
30 | | void set_smbd_shim(const struct smbd_shim *shim_functions) |
31 | 0 | { |
32 | 0 | shim = *shim_functions; |
33 | 0 | } |
34 | | |
35 | | bool change_to_root_user(void) |
36 | 0 | { |
37 | 0 | if (shim.change_to_root_user) { |
38 | 0 | return shim.change_to_root_user(); |
39 | 0 | } |
40 | 0 | return false; |
41 | 0 | } |
42 | | |
43 | | bool become_authenticated_pipe_user(struct auth_session_info *session_info) |
44 | 0 | { |
45 | 0 | if (shim.become_authenticated_pipe_user) { |
46 | 0 | return shim.become_authenticated_pipe_user(session_info); |
47 | 0 | } |
48 | | |
49 | 0 | return false; |
50 | 0 | } |
51 | | |
52 | | bool unbecome_authenticated_pipe_user(void) |
53 | 0 | { |
54 | 0 | if (shim.unbecome_authenticated_pipe_user) { |
55 | 0 | return shim.unbecome_authenticated_pipe_user(); |
56 | 0 | } |
57 | | |
58 | 0 | return false; |
59 | 0 | } |
60 | | |
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. |
67 | | */ |
68 | | void contend_level2_oplocks_begin(files_struct *fsp, |
69 | | enum level2_contention_type type) |
70 | 0 | { |
71 | 0 | if (shim.contend_level2_oplocks_begin) { |
72 | 0 | shim.contend_level2_oplocks_begin(fsp, type); |
73 | 0 | } |
74 | 0 | return; |
75 | 0 | } |
76 | | |
77 | | void contend_level2_oplocks_end(files_struct *fsp, |
78 | | enum level2_contention_type type) |
79 | 0 | { |
80 | 0 | if (shim.contend_level2_oplocks_end) { |
81 | 0 | shim.contend_level2_oplocks_end(fsp, type); |
82 | 0 | } |
83 | 0 | return; |
84 | 0 | } |
85 | | |
86 | | void become_root(void) |
87 | 0 | { |
88 | 0 | if (shim.become_root) { |
89 | 0 | shim.become_root(); |
90 | 0 | } |
91 | 0 | return; |
92 | 0 | } |
93 | | |
94 | | void unbecome_root(void) |
95 | 0 | { |
96 | 0 | if (shim.unbecome_root) { |
97 | 0 | shim.unbecome_root(); |
98 | 0 | } |
99 | 0 | return; |
100 | 0 | } |
101 | | |
102 | | void exit_server(const char *reason) |
103 | 0 | { |
104 | 0 | if (shim.exit_server) { |
105 | 0 | shim.exit_server(reason); |
106 | 0 | } |
107 | 0 | exit(1); |
108 | 0 | } |
109 | | |
110 | | void exit_server_cleanly(const char *const reason) |
111 | 0 | { |
112 | 0 | if (shim.exit_server_cleanly) { |
113 | 0 | shim.exit_server_cleanly(reason); |
114 | 0 | } |
115 | 0 | exit(0); |
116 | 0 | } |