2 Unix SMB/CIFS implementation.
3 Generic parameter parsing interface
4 Copyright (C) Jelmer Vernooij 2005
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.
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.
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/>.
20 #ifndef _PARAM_H /* _PARAM_H */
23 struct loadparm_s3_context
;
25 struct parmlist_entry
;
27 struct param_context
{
28 struct param_section
*sections
;
31 struct param_section
{
33 struct param_section
*prev
, *next
;
34 struct parmlist
*parameters
;
38 struct smbsrv_connection
;
42 typedef NTSTATUS (*init_module_fn
) (void);
44 /* this needs to be a string which is not in the C library. We
45 previously used "init_module", but that meant that modules which
46 did not define this function ended up calling the C library
47 function init_module() which makes a system call */
48 #define SAMBA_INIT_MODULE "samba_init_module"
50 #include "libds/common/roles.h"
52 struct loadparm_context
;
53 struct loadparm_service
;
54 struct smbcli_options
;
55 struct smbcli_session_options
;
56 struct gensec_settings
;
58 #ifdef CONFIG_H_IS_FROM_SAMBA
59 #include "param/param_proto.h"
62 const char **lpcfg_interfaces(struct loadparm_context
*);
63 const char *lpcfg_realm(struct loadparm_context
*);
64 const char *lpcfg_netbios_name(struct loadparm_context
*);
65 const char *lpcfg_private_dir(struct loadparm_context
*);
66 int lpcfg_server_role(struct loadparm_context
*);
68 void reload_charcnv(struct loadparm_context
*lp_ctx
);
70 struct loadparm_service
*lpcfg_default_service(struct loadparm_context
*lp_ctx
);
73 char *lpcfg_tls_keyfile(TALLOC_CTX
*mem_ctx
, struct loadparm_context
*);
74 char *lpcfg_tls_certfile(TALLOC_CTX
*mem_ctx
, struct loadparm_context
*);
75 char *lpcfg_tls_cafile(TALLOC_CTX
*mem_ctx
, struct loadparm_context
*);
76 char *lpcfg_tls_dhpfile(TALLOC_CTX
*mem_ctx
, struct loadparm_context
*);
77 char *lpcfg_tls_crlfile(TALLOC_CTX
*mem_ctx
, struct loadparm_context
*);
79 const char *lpcfg_servicename(const struct loadparm_service
*service
);
82 const char *lpcfg_get_parametric(struct loadparm_context
*lp_ctx
,
83 struct loadparm_service
*service
,
84 const char *type
, const char *option
);
86 const char *lpcfg_parm_string(struct loadparm_context
*lp_ctx
,
87 struct loadparm_service
*service
, const char *type
,
89 const char **lpcfg_parm_string_list(TALLOC_CTX
*mem_ctx
,
90 struct loadparm_context
*lp_ctx
,
91 struct loadparm_service
*service
,
93 const char *option
, const char *separator
);
94 int lpcfg_parm_int(struct loadparm_context
*lp_ctx
,
95 struct loadparm_service
*service
, const char *type
,
96 const char *option
, int default_v
);
97 int lpcfg_parm_bytes(struct loadparm_context
*lp_ctx
,
98 struct loadparm_service
*service
, const char *type
,
99 const char *option
, int default_v
);
100 unsigned long lpcfg_parm_ulong(struct loadparm_context
*lp_ctx
,
101 struct loadparm_service
*service
, const char *type
,
102 const char *option
, unsigned long default_v
);
103 double lpcfg_parm_double(struct loadparm_context
*lp_ctx
,
104 struct loadparm_service
*service
, const char *type
,
105 const char *option
, double default_v
);
106 bool lpcfg_parm_bool(struct loadparm_context
*lp_ctx
,
107 struct loadparm_service
*service
, const char *type
,
108 const char *option
, bool default_v
);
109 struct loadparm_service
*lpcfg_add_service(struct loadparm_context
*lp_ctx
,
110 const struct loadparm_service
*pservice
,
112 bool lpcfg_add_home(struct loadparm_context
*lp_ctx
,
113 const char *pszHomename
,
114 struct loadparm_service
*default_service
,
115 const char *user
, const char *pszHomedir
);
116 bool lpcfg_add_printer(struct loadparm_context
*lp_ctx
,
117 const char *pszPrintername
,
118 struct loadparm_service
*default_service
);
119 struct parm_struct
*lpcfg_parm_struct(struct loadparm_context
*lp_ctx
, const char *name
);
120 void *lpcfg_parm_ptr(struct loadparm_context
*lp_ctx
,
121 struct loadparm_service
*service
, struct parm_struct
*parm
);
122 bool lpcfg_file_list_changed(struct loadparm_context
*lp_ctx
);
124 bool lpcfg_do_global_parameter(struct loadparm_context
*lp_ctx
,
125 const char *pszParmName
, const char *pszParmValue
);
126 bool lpcfg_do_service_parameter(struct loadparm_context
*lp_ctx
,
127 struct loadparm_service
*service
,
128 const char *pszParmName
, const char *pszParmValue
);
131 * Process a parameter.
133 bool lpcfg_do_global_parameter_var(struct loadparm_context
*lp_ctx
,
134 const char *pszParmName
, const char *fmt
, ...);
135 bool lpcfg_set_cmdline(struct loadparm_context
*lp_ctx
, const char *pszParmName
,
136 const char *pszParmValue
);
137 bool lpcfg_set_option(struct loadparm_context
*lp_ctx
, const char *option
);
140 * Display the contents of a single services record.
142 bool lpcfg_dump_a_parameter(struct loadparm_context
*lp_ctx
,
143 struct loadparm_service
*service
,
144 const char *parm_name
, FILE * f
);
147 * Return info about the next service in a service. snum==-1 gives the globals.
148 * Return NULL when out of parameters.
150 struct parm_struct
*lpcfg_next_parameter(struct loadparm_context
*lp_ctx
, int snum
, int *i
,
154 * Unload unused services.
156 void lpcfg_killunused(struct loadparm_context
*lp_ctx
,
157 struct smbsrv_connection
*smb
,
158 bool (*snumused
) (struct smbsrv_connection
*, int));
161 * Initialise the global parameter structure.
163 struct loadparm_context
*loadparm_init(TALLOC_CTX
*mem_ctx
);
164 struct loadparm_context
*loadparm_init_global(bool load_default
);
165 const char *lpcfg_configfile(struct loadparm_context
*lp_ctx
);
166 bool lpcfg_load_default(struct loadparm_context
*lp_ctx
);
167 const char *lp_default_path(void);
170 * Load the services array from the services file.
172 * Return True on success, False on failure.
174 bool lpcfg_load(struct loadparm_context
*lp_ctx
, const char *filename
);
177 * Return the max number of services.
179 int lpcfg_numservices(struct loadparm_context
*lp_ctx
);
182 * Display the contents of the services array in human-readable form.
184 void lpcfg_dump(struct loadparm_context
*lp_ctx
, FILE *f
, bool show_defaults
,
188 * Display the contents of one service in human-readable form.
190 void lpcfg_dump_one(FILE *f
, bool show_defaults
, struct loadparm_service
*service
, struct loadparm_service
*sDefault
);
191 struct loadparm_service
*lpcfg_servicebynum(struct loadparm_context
*lp_ctx
,
193 struct loadparm_service
*lpcfg_service(struct loadparm_context
*lp_ctx
,
194 const char *service_name
);
197 * A useful volume label function.
199 const char *lp_cfg_volume_label(struct loadparm_service
*service
, struct loadparm_service
*sDefault
);
202 * If we are PDC then prefer us as DMB
204 const char *lpcfg_printername(struct loadparm_service
*service
, struct loadparm_service
*sDefault
);
207 * Return the max print jobs per queue.
209 int lpcfg_maxprintjobs(struct loadparm_service
*service
, struct loadparm_service
*sDefault
);
210 struct smb_iconv_handle
*lpcfg_iconv_handle(struct loadparm_context
*lp_ctx
);
211 void lpcfg_smbcli_options(struct loadparm_context
*lp_ctx
,
212 struct smbcli_options
*options
);
213 void lpcfg_smbcli_session_options(struct loadparm_context
*lp_ctx
,
214 struct smbcli_session_options
*options
);
215 struct dcerpc_server_info
*lpcfg_dcerpc_server_info(TALLOC_CTX
*mem_ctx
, struct loadparm_context
*lp_ctx
);
216 struct gensec_settings
*lpcfg_gensec_settings(TALLOC_CTX
*, struct loadparm_context
*);
219 /* The following definitions come from param/generic.c */
221 struct param_section
*param_get_section(struct param_context
*ctx
, const char *name
);
222 struct parmlist_entry
*param_section_get(struct param_section
*section
,
224 struct parmlist_entry
*param_get (struct param_context
*ctx
, const char *name
, const char *section_name
);
225 struct param_section
*param_add_section(struct param_context
*ctx
, const char *section_name
);
226 struct parmlist_entry
*param_get_add(struct param_context
*ctx
, const char *name
, const char *section_name
);
227 const char *param_get_string(struct param_context
*ctx
, const char *param
, const char *section
);
228 int param_set_string(struct param_context
*ctx
, const char *param
, const char *value
, const char *section
);
229 const char **param_get_string_list(struct param_context
*ctx
, const char *param
, const char *separator
, const char *section
);
230 int param_set_string_list(struct param_context
*ctx
, const char *param
, const char **list
, const char *section
);
231 int param_get_int(struct param_context
*ctx
, const char *param
, int default_v
, const char *section
);
232 void param_set_int(struct param_context
*ctx
, const char *param
, int value
, const char *section
);
233 unsigned long param_get_ulong(struct param_context
*ctx
, const char *param
, unsigned long default_v
, const char *section
);
234 void param_set_ulong(struct param_context
*ctx
, const char *name
, unsigned long value
, const char *section
);
235 struct param_context
*param_init(TALLOC_CTX
*mem_ctx
);
236 int param_read(struct param_context
*ctx
, const char *fn
);
237 int param_use(struct loadparm_context
*lp_ctx
, struct param_context
*ctx
);
238 int param_write(struct param_context
*ctx
, const char *fn
);
240 /* The following definitions come from param/util.c */
245 * @brief Misc utility functions
247 bool lpcfg_is_mydomain(struct loadparm_context
*lp_ctx
,
250 bool lpcfg_is_my_domain_or_realm(struct loadparm_context
*lp_ctx
,
254 see if a string matches either our primary or one of our secondary
255 netbios aliases. do a case insensitive match
257 bool lpcfg_is_myname(struct loadparm_context
*lp_ctx
, const char *name
);
260 A useful function for returning a path in the Samba lock directory.
262 char *lpcfg_lock_path(TALLOC_CTX
* mem_ctx
, struct loadparm_context
*lp_ctx
,
266 * @brief Returns an absolute path to a file in the directory containing the current config file
268 * @param name File to find, relative to the config file directory.
270 * @retval Pointer to a talloc'ed string containing the full path.
272 char *lpcfg_config_path(TALLOC_CTX
* mem_ctx
, struct loadparm_context
*lp_ctx
,
276 * @brief Returns an absolute path to a file in the Samba private directory.
278 * @param name File to find, relative to PRIVATEDIR.
279 * if name is not relative, then use it as-is
281 * @retval Pointer to a talloc'ed string containing the full path.
283 char *lpcfg_private_path(TALLOC_CTX
* mem_ctx
,
284 struct loadparm_context
*lp_ctx
,
288 return a path in the smbd.tmp directory, where all temporary file
289 for smbd go. If NULL is passed for name then return the directory
292 char *smbd_tmp_path(TALLOC_CTX
*mem_ctx
,
293 struct loadparm_context
*lp_ctx
,
297 * Obtain the init function from a shared library file
299 init_module_fn
load_module(TALLOC_CTX
*mem_ctx
, const char *path
);
302 * Obtain list of init functions from the modules in the specified
305 init_module_fn
*load_modules(TALLOC_CTX
*mem_ctx
, const char *path
);
308 * Run the specified init functions.
310 * @return true if all functions ran successfully, false otherwise
312 bool run_init_functions(init_module_fn
*fns
);
315 * Load the initialization functions from DSO files for a specific subsystem.
317 * Will return an array of function pointers to initialization functions
319 init_module_fn
*load_samba_modules(TALLOC_CTX
*mem_ctx
, const char *subsystem
);
320 const char *lpcfg_imessaging_path(TALLOC_CTX
*mem_ctx
,
321 struct loadparm_context
*lp_ctx
);
322 struct smb_iconv_handle
*smb_iconv_handle_reinit_lp(TALLOC_CTX
*mem_ctx
,
323 struct loadparm_context
*lp_ctx
,
324 struct smb_iconv_handle
*old_ic
);
326 const char *lpcfg_sam_name(struct loadparm_context
*lp_ctx
);
328 /* The following definitions come from lib/version.c */
330 const char *samba_version_string(void);
333 #endif /* _PARAM_H */