1 | /*
|
---|
2 | Unix SMB/CIFS implementation.
|
---|
3 | Generic parameter parsing interface
|
---|
4 | Copyright (C) Jelmer Vernooij 2005
|
---|
5 |
|
---|
6 | This program is free software; you can redistribute it and/or modify
|
---|
7 | it under the terms of the GNU General Public License as published by
|
---|
8 | the Free Software Foundation; either version 3 of the License, or
|
---|
9 | (at your option) any later version.
|
---|
10 |
|
---|
11 | This program is distributed in the hope that it will be useful,
|
---|
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
14 | GNU General Public License for more details.
|
---|
15 |
|
---|
16 | You should have received a copy of the GNU General Public License
|
---|
17 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
18 | */
|
---|
19 |
|
---|
20 | #ifndef _PARAM_H /* _PARAM_H */
|
---|
21 | #define _PARAM_H
|
---|
22 |
|
---|
23 | struct parmlist_entry;
|
---|
24 |
|
---|
25 | struct param_context {
|
---|
26 | struct param_section *sections;
|
---|
27 | };
|
---|
28 |
|
---|
29 | struct param_section {
|
---|
30 | const char *name;
|
---|
31 | struct param_section *prev, *next;
|
---|
32 | struct parmlist *parameters;
|
---|
33 | };
|
---|
34 |
|
---|
35 | struct param_context;
|
---|
36 | struct smbsrv_connection;
|
---|
37 |
|
---|
38 | #define Auto (2)
|
---|
39 |
|
---|
40 | typedef NTSTATUS (*init_module_fn) (void);
|
---|
41 |
|
---|
42 | /* this needs to be a string which is not in the C library. We
|
---|
43 | previously used "init_module", but that meant that modules which
|
---|
44 | did not define this function ended up calling the C library
|
---|
45 | function init_module() which makes a system call */
|
---|
46 | #define SAMBA_INIT_MODULE "samba_init_module"
|
---|
47 |
|
---|
48 | enum server_role {
|
---|
49 | ROLE_STANDALONE=0,
|
---|
50 | ROLE_DOMAIN_MEMBER=1,
|
---|
51 | ROLE_DOMAIN_CONTROLLER=2,
|
---|
52 | };
|
---|
53 |
|
---|
54 | enum sid_generator {
|
---|
55 | SID_GENERATOR_INTERNAL=0,
|
---|
56 | SID_GENERATOR_BACKEND=1,
|
---|
57 | };
|
---|
58 |
|
---|
59 | enum announce_as {/* Types of machine we can announce as. */
|
---|
60 | ANNOUNCE_AS_NT_SERVER=1,
|
---|
61 | ANNOUNCE_AS_WIN95=2,
|
---|
62 | ANNOUNCE_AS_WFW=3,
|
---|
63 | ANNOUNCE_AS_NT_WORKSTATION=4
|
---|
64 | };
|
---|
65 |
|
---|
66 | struct loadparm_context;
|
---|
67 | struct loadparm_service;
|
---|
68 | struct smbcli_options;
|
---|
69 | struct smbcli_session_options;
|
---|
70 | struct gensec_settings;
|
---|
71 |
|
---|
72 | #ifdef CONFIG_H_IS_FROM_SAMBA
|
---|
73 | #include "param/param_proto.h"
|
---|
74 | #endif
|
---|
75 |
|
---|
76 | const char **lpcfg_interfaces(struct loadparm_context *);
|
---|
77 | const char *lpcfg_realm(struct loadparm_context *);
|
---|
78 | const char *lpcfg_netbios_name(struct loadparm_context *);
|
---|
79 | const char *lpcfg_private_dir(struct loadparm_context *);
|
---|
80 | int lpcfg_server_role(struct loadparm_context *);
|
---|
81 |
|
---|
82 | void reload_charcnv(struct loadparm_context *lp_ctx);
|
---|
83 |
|
---|
84 | struct loadparm_service *lpcfg_default_service(struct loadparm_context *lp_ctx);
|
---|
85 | struct parm_struct *lpcfg_parm_table(void);
|
---|
86 |
|
---|
87 |
|
---|
88 | char *lpcfg_tls_keyfile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
|
---|
89 | char *lpcfg_tls_certfile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
|
---|
90 | char *lpcfg_tls_cafile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
|
---|
91 | char *lpcfg_tls_dhpfile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
|
---|
92 | char *lpcfg_tls_crlfile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
|
---|
93 |
|
---|
94 | const char *lpcfg_servicename(const struct loadparm_service *service);
|
---|
95 |
|
---|
96 |
|
---|
97 | const char *lpcfg_get_parametric(struct loadparm_context *lp_ctx,
|
---|
98 | struct loadparm_service *service,
|
---|
99 | const char *type, const char *option);
|
---|
100 |
|
---|
101 | const char *lpcfg_parm_string(struct loadparm_context *lp_ctx,
|
---|
102 | struct loadparm_service *service, const char *type,
|
---|
103 | const char *option);
|
---|
104 | const char **lpcfg_parm_string_list(TALLOC_CTX *mem_ctx,
|
---|
105 | struct loadparm_context *lp_ctx,
|
---|
106 | struct loadparm_service *service,
|
---|
107 | const char *type,
|
---|
108 | const char *option, const char *separator);
|
---|
109 | int lpcfg_parm_int(struct loadparm_context *lp_ctx,
|
---|
110 | struct loadparm_service *service, const char *type,
|
---|
111 | const char *option, int default_v);
|
---|
112 | int lpcfg_parm_bytes(struct loadparm_context *lp_ctx,
|
---|
113 | struct loadparm_service *service, const char *type,
|
---|
114 | const char *option, int default_v);
|
---|
115 | unsigned long lpcfg_parm_ulong(struct loadparm_context *lp_ctx,
|
---|
116 | struct loadparm_service *service, const char *type,
|
---|
117 | const char *option, unsigned long default_v);
|
---|
118 | double lpcfg_parm_double(struct loadparm_context *lp_ctx,
|
---|
119 | struct loadparm_service *service, const char *type,
|
---|
120 | const char *option, double default_v);
|
---|
121 | bool lpcfg_parm_bool(struct loadparm_context *lp_ctx,
|
---|
122 | struct loadparm_service *service, const char *type,
|
---|
123 | const char *option, bool default_v);
|
---|
124 | struct loadparm_service *lpcfg_add_service(struct loadparm_context *lp_ctx,
|
---|
125 | const struct loadparm_service *pservice,
|
---|
126 | const char *name);
|
---|
127 | bool lpcfg_add_home(struct loadparm_context *lp_ctx,
|
---|
128 | const char *pszHomename,
|
---|
129 | struct loadparm_service *default_service,
|
---|
130 | const char *user, const char *pszHomedir);
|
---|
131 | bool lpcfg_add_printer(struct loadparm_context *lp_ctx,
|
---|
132 | const char *pszPrintername,
|
---|
133 | struct loadparm_service *default_service);
|
---|
134 | struct parm_struct *lpcfg_parm_struct(const char *name);
|
---|
135 | void *lpcfg_parm_ptr(struct loadparm_context *lp_ctx,
|
---|
136 | struct loadparm_service *service, struct parm_struct *parm);
|
---|
137 | bool lpcfg_file_list_changed(struct loadparm_context *lp_ctx);
|
---|
138 |
|
---|
139 | bool lpcfg_do_global_parameter(struct loadparm_context *lp_ctx,
|
---|
140 | const char *pszParmName, const char *pszParmValue);
|
---|
141 | bool lpcfg_do_service_parameter(struct loadparm_context *lp_ctx,
|
---|
142 | struct loadparm_service *service,
|
---|
143 | const char *pszParmName, const char *pszParmValue);
|
---|
144 |
|
---|
145 | /**
|
---|
146 | * Process a parameter.
|
---|
147 | */
|
---|
148 | bool lpcfg_do_global_parameter_var(struct loadparm_context *lp_ctx,
|
---|
149 | const char *pszParmName, const char *fmt, ...);
|
---|
150 | bool lpcfg_set_cmdline(struct loadparm_context *lp_ctx, const char *pszParmName,
|
---|
151 | const char *pszParmValue);
|
---|
152 | bool lpcfg_set_option(struct loadparm_context *lp_ctx, const char *option);
|
---|
153 |
|
---|
154 | /**
|
---|
155 | * Display the contents of a single services record.
|
---|
156 | */
|
---|
157 | bool lpcfg_dump_a_parameter(struct loadparm_context *lp_ctx,
|
---|
158 | struct loadparm_service *service,
|
---|
159 | const char *parm_name, FILE * f);
|
---|
160 |
|
---|
161 | /**
|
---|
162 | * Return info about the next service in a service. snum==-1 gives the globals.
|
---|
163 | * Return NULL when out of parameters.
|
---|
164 | */
|
---|
165 | struct parm_struct *lpcfg_next_parameter(struct loadparm_context *lp_ctx, int snum, int *i,
|
---|
166 | int allparameters);
|
---|
167 |
|
---|
168 | /**
|
---|
169 | * Unload unused services.
|
---|
170 | */
|
---|
171 | void lpcfg_killunused(struct loadparm_context *lp_ctx,
|
---|
172 | struct smbsrv_connection *smb,
|
---|
173 | bool (*snumused) (struct smbsrv_connection *, int));
|
---|
174 |
|
---|
175 | /**
|
---|
176 | * Initialise the global parameter structure.
|
---|
177 | */
|
---|
178 | struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx);
|
---|
179 | struct loadparm_context *loadparm_init_global(bool load_default);
|
---|
180 | const char *lpcfg_configfile(struct loadparm_context *lp_ctx);
|
---|
181 | bool lpcfg_load_default(struct loadparm_context *lp_ctx);
|
---|
182 | const char *lp_default_path(void);
|
---|
183 |
|
---|
184 | /**
|
---|
185 | * Load the services array from the services file.
|
---|
186 | *
|
---|
187 | * Return True on success, False on failure.
|
---|
188 | */
|
---|
189 | bool lpcfg_load(struct loadparm_context *lp_ctx, const char *filename);
|
---|
190 |
|
---|
191 | /**
|
---|
192 | * Return the max number of services.
|
---|
193 | */
|
---|
194 | int lpcfg_numservices(struct loadparm_context *lp_ctx);
|
---|
195 |
|
---|
196 | /**
|
---|
197 | * Display the contents of the services array in human-readable form.
|
---|
198 | */
|
---|
199 | void lpcfg_dump(struct loadparm_context *lp_ctx, FILE *f, bool show_defaults,
|
---|
200 | int maxtoprint);
|
---|
201 |
|
---|
202 | /**
|
---|
203 | * Display the contents of one service in human-readable form.
|
---|
204 | */
|
---|
205 | void lpcfg_dump_one(FILE *f, bool show_defaults, struct loadparm_service *service, struct loadparm_service *sDefault);
|
---|
206 | struct loadparm_service *lpcfg_servicebynum(struct loadparm_context *lp_ctx,
|
---|
207 | int snum);
|
---|
208 | struct loadparm_service *lpcfg_service(struct loadparm_context *lp_ctx,
|
---|
209 | const char *service_name);
|
---|
210 |
|
---|
211 | /**
|
---|
212 | * A useful volume label function.
|
---|
213 | */
|
---|
214 | const char *volume_label(struct loadparm_service *service, struct loadparm_service *sDefault);
|
---|
215 |
|
---|
216 | /**
|
---|
217 | * If we are PDC then prefer us as DMB
|
---|
218 | */
|
---|
219 | const char *lpcfg_printername(struct loadparm_service *service, struct loadparm_service *sDefault);
|
---|
220 |
|
---|
221 | /**
|
---|
222 | * Return the max print jobs per queue.
|
---|
223 | */
|
---|
224 | int lpcfg_maxprintjobs(struct loadparm_service *service, struct loadparm_service *sDefault);
|
---|
225 | struct smb_iconv_convenience *lpcfg_iconv_convenience(struct loadparm_context *lp_ctx);
|
---|
226 | void lpcfg_smbcli_options(struct loadparm_context *lp_ctx,
|
---|
227 | struct smbcli_options *options);
|
---|
228 | void lpcfg_smbcli_session_options(struct loadparm_context *lp_ctx,
|
---|
229 | struct smbcli_session_options *options);
|
---|
230 | struct dcerpc_server_info *lpcfg_dcerpc_server_info(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx);
|
---|
231 | struct gensec_settings *lpcfg_gensec_settings(TALLOC_CTX *, struct loadparm_context *);
|
---|
232 |
|
---|
233 |
|
---|
234 | /* The following definitions come from param/generic.c */
|
---|
235 |
|
---|
236 | struct param_section *param_get_section(struct param_context *ctx, const char *name);
|
---|
237 | struct parmlist_entry *param_section_get(struct param_section *section,
|
---|
238 | const char *name);
|
---|
239 | struct parmlist_entry *param_get (struct param_context *ctx, const char *name, const char *section_name);
|
---|
240 | struct param_section *param_add_section(struct param_context *ctx, const char *section_name);
|
---|
241 | struct parmlist_entry *param_get_add(struct param_context *ctx, const char *name, const char *section_name);
|
---|
242 | const char *param_get_string(struct param_context *ctx, const char *param, const char *section);
|
---|
243 | int param_set_string(struct param_context *ctx, const char *param, const char *value, const char *section);
|
---|
244 | const char **param_get_string_list(struct param_context *ctx, const char *param, const char *separator, const char *section);
|
---|
245 | int param_set_string_list(struct param_context *ctx, const char *param, const char **list, const char *section);
|
---|
246 | int param_get_int(struct param_context *ctx, const char *param, int default_v, const char *section);
|
---|
247 | void param_set_int(struct param_context *ctx, const char *param, int value, const char *section);
|
---|
248 | unsigned long param_get_ulong(struct param_context *ctx, const char *param, unsigned long default_v, const char *section);
|
---|
249 | void param_set_ulong(struct param_context *ctx, const char *name, unsigned long value, const char *section);
|
---|
250 | struct param_context *param_init(TALLOC_CTX *mem_ctx);
|
---|
251 | int param_read(struct param_context *ctx, const char *fn);
|
---|
252 | int param_use(struct loadparm_context *lp_ctx, struct param_context *ctx);
|
---|
253 | int param_write(struct param_context *ctx, const char *fn);
|
---|
254 |
|
---|
255 | /* The following definitions come from param/util.c */
|
---|
256 |
|
---|
257 |
|
---|
258 | /**
|
---|
259 | * @file
|
---|
260 | * @brief Misc utility functions
|
---|
261 | */
|
---|
262 | bool lpcfg_is_mydomain(struct loadparm_context *lp_ctx,
|
---|
263 | const char *domain);
|
---|
264 |
|
---|
265 | bool lpcfg_is_my_domain_or_realm(struct loadparm_context *lp_ctx,
|
---|
266 | const char *domain);
|
---|
267 |
|
---|
268 | /**
|
---|
269 | see if a string matches either our primary or one of our secondary
|
---|
270 | netbios aliases. do a case insensitive match
|
---|
271 | */
|
---|
272 | bool lpcfg_is_myname(struct loadparm_context *lp_ctx, const char *name);
|
---|
273 |
|
---|
274 | /**
|
---|
275 | A useful function for returning a path in the Samba lock directory.
|
---|
276 | **/
|
---|
277 | char *lock_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx,
|
---|
278 | const char *name);
|
---|
279 |
|
---|
280 | /**
|
---|
281 | * @brief Returns an absolute path to a file in the directory containing the current config file
|
---|
282 | *
|
---|
283 | * @param name File to find, relative to the config file directory.
|
---|
284 | *
|
---|
285 | * @retval Pointer to a talloc'ed string containing the full path.
|
---|
286 | **/
|
---|
287 | char *config_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx,
|
---|
288 | const char *name);
|
---|
289 |
|
---|
290 | /**
|
---|
291 | * @brief Returns an absolute path to a file in the Samba private directory.
|
---|
292 | *
|
---|
293 | * @param name File to find, relative to PRIVATEDIR.
|
---|
294 | * if name is not relative, then use it as-is
|
---|
295 | *
|
---|
296 | * @retval Pointer to a talloc'ed string containing the full path.
|
---|
297 | **/
|
---|
298 | char *private_path(TALLOC_CTX* mem_ctx,
|
---|
299 | struct loadparm_context *lp_ctx,
|
---|
300 | const char *name);
|
---|
301 |
|
---|
302 | /**
|
---|
303 | return a path in the smbd.tmp directory, where all temporary file
|
---|
304 | for smbd go. If NULL is passed for name then return the directory
|
---|
305 | path itself
|
---|
306 | */
|
---|
307 | char *smbd_tmp_path(TALLOC_CTX *mem_ctx,
|
---|
308 | struct loadparm_context *lp_ctx,
|
---|
309 | const char *name);
|
---|
310 |
|
---|
311 | /**
|
---|
312 | * Obtain the init function from a shared library file
|
---|
313 | */
|
---|
314 | init_module_fn load_module(TALLOC_CTX *mem_ctx, const char *path);
|
---|
315 |
|
---|
316 | /**
|
---|
317 | * Obtain list of init functions from the modules in the specified
|
---|
318 | * directory
|
---|
319 | */
|
---|
320 | init_module_fn *load_modules(TALLOC_CTX *mem_ctx, const char *path);
|
---|
321 |
|
---|
322 | /**
|
---|
323 | * Run the specified init functions.
|
---|
324 | *
|
---|
325 | * @return true if all functions ran successfully, false otherwise
|
---|
326 | */
|
---|
327 | bool run_init_functions(init_module_fn *fns);
|
---|
328 |
|
---|
329 | /**
|
---|
330 | * Load the initialization functions from DSO files for a specific subsystem.
|
---|
331 | *
|
---|
332 | * Will return an array of function pointers to initialization functions
|
---|
333 | */
|
---|
334 | init_module_fn *load_samba_modules(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, const char *subsystem);
|
---|
335 | const char *lpcfg_messaging_path(TALLOC_CTX *mem_ctx,
|
---|
336 | struct loadparm_context *lp_ctx);
|
---|
337 | struct smb_iconv_convenience *smb_iconv_convenience_reinit_lp(TALLOC_CTX *mem_ctx,
|
---|
338 | struct loadparm_context *lp_ctx,
|
---|
339 | struct smb_iconv_convenience *old_ic);
|
---|
340 |
|
---|
341 | const char *lpcfg_sam_name(struct loadparm_context *lp_ctx);
|
---|
342 |
|
---|
343 | /* The following definitions come from lib/version.c */
|
---|
344 |
|
---|
345 | const char *samba_version_string(void);
|
---|
346 |
|
---|
347 |
|
---|
348 | #endif /* _PARAM_H */
|
---|