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 | {
|
---|
32 | shim = *shim_functions;
|
---|
33 | }
|
---|
34 |
|
---|
35 | void cancel_pending_lock_requests_by_fid(files_struct *fsp,
|
---|
36 | struct byte_range_lock *br_lck,
|
---|
37 | enum file_close_type close_type)
|
---|
38 | {
|
---|
39 | if (shim.cancel_pending_lock_requests_by_fid) {
|
---|
40 |
|
---|
41 | shim.cancel_pending_lock_requests_by_fid(fsp, br_lck, close_type);
|
---|
42 | }
|
---|
43 | }
|
---|
44 |
|
---|
45 | void send_stat_cache_delete_message(struct messaging_context *msg_ctx,
|
---|
46 | const char *name)
|
---|
47 | {
|
---|
48 | if (shim.send_stat_cache_delete_message) {
|
---|
49 | shim.send_stat_cache_delete_message(msg_ctx, name);
|
---|
50 | }
|
---|
51 | }
|
---|
52 |
|
---|
53 | bool change_to_root_user(void)
|
---|
54 | {
|
---|
55 | if (shim.change_to_root_user) {
|
---|
56 | return shim.change_to_root_user();
|
---|
57 | }
|
---|
58 | return false;
|
---|
59 | }
|
---|
60 |
|
---|
61 | bool become_authenticated_pipe_user(struct auth_session_info *session_info)
|
---|
62 | {
|
---|
63 | if (shim.become_authenticated_pipe_user) {
|
---|
64 | return shim.become_authenticated_pipe_user(session_info);
|
---|
65 | }
|
---|
66 |
|
---|
67 | return false;
|
---|
68 | }
|
---|
69 |
|
---|
70 | bool unbecome_authenticated_pipe_user(void)
|
---|
71 | {
|
---|
72 | if (shim.unbecome_authenticated_pipe_user) {
|
---|
73 | return shim.unbecome_authenticated_pipe_user();
|
---|
74 | }
|
---|
75 |
|
---|
76 | return false;
|
---|
77 | }
|
---|
78 |
|
---|
79 | /**
|
---|
80 | * The following two functions need to be called from inside the low-level BRL
|
---|
81 | * code for oplocks correctness in smbd. Since other utility binaries also
|
---|
82 | * link in some of the brl code directly, these dummy functions are necessary
|
---|
83 | * to avoid needing to link in the oplocks code and its dependencies to all of
|
---|
84 | * the utility binaries.
|
---|
85 | */
|
---|
86 | void contend_level2_oplocks_begin(files_struct *fsp,
|
---|
87 | enum level2_contention_type type)
|
---|
88 | {
|
---|
89 | if (shim.contend_level2_oplocks_begin) {
|
---|
90 | shim.contend_level2_oplocks_begin(fsp, type);
|
---|
91 | }
|
---|
92 | return;
|
---|
93 | }
|
---|
94 |
|
---|
95 | void contend_level2_oplocks_end(files_struct *fsp,
|
---|
96 | enum level2_contention_type type)
|
---|
97 | {
|
---|
98 | if (shim.contend_level2_oplocks_end) {
|
---|
99 | shim.contend_level2_oplocks_end(fsp, type);
|
---|
100 | }
|
---|
101 | return;
|
---|
102 | }
|
---|
103 |
|
---|
104 | void become_root(void)
|
---|
105 | {
|
---|
106 | if (shim.become_root) {
|
---|
107 | shim.become_root();
|
---|
108 | }
|
---|
109 | return;
|
---|
110 | }
|
---|
111 |
|
---|
112 | void unbecome_root(void)
|
---|
113 | {
|
---|
114 | if (shim.unbecome_root) {
|
---|
115 | shim.unbecome_root();
|
---|
116 | }
|
---|
117 | return;
|
---|
118 | }
|
---|
119 |
|
---|
120 | void exit_server(const char *reason)
|
---|
121 | {
|
---|
122 | if (shim.exit_server) {
|
---|
123 | shim.exit_server(reason);
|
---|
124 | }
|
---|
125 | exit(1);
|
---|
126 | }
|
---|
127 |
|
---|
128 | void exit_server_cleanly(const char *const reason)
|
---|
129 | {
|
---|
130 | if (shim.exit_server_cleanly) {
|
---|
131 | shim.exit_server_cleanly(reason);
|
---|
132 | }
|
---|
133 | exit(0);
|
---|
134 | }
|
---|