param.h 10.6 KB
Newer Older
1 2 3 4 5 6 7
/* 
   Unix SMB/CIFS implementation.
   Generic parameter parsing interface
   Copyright (C) Jelmer Vernooij					  2005
   
   This program is free software; you can redistribute it and/or modify
   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 10 11 12 13 14 15 16
   (at your option) any later version.
   
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   
   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
*/

Jelmer Vernooij's avatar
Jelmer Vernooij committed
20 21
#ifndef _PARAM_H /* _PARAM_H */
#define _PARAM_H 
22

23
struct loadparm_s3_helpers;
24

25
struct parmlist_entry;
26

27 28
struct param_context {
	struct param_section *sections;
29 30 31 32 33
};

struct param_section {
	const char *name;
	struct param_section *prev, *next;
34
	struct parmlist *parameters;
35 36
};

Jelmer Vernooij's avatar
Jelmer Vernooij committed
37 38 39
struct param_context;
struct smbsrv_connection;

40 41
#define Auto (2)

42
struct loadparm_context;
43
struct loadparm_service;
44
struct smbcli_options;
45
struct smbcli_session_options;
46
struct gensec_settings;
47
struct bitmap;
48
struct file_lists;
49

50
#ifdef CONFIG_H_IS_FROM_SAMBA
51
#include "lib/param/param_proto.h"
52
#include "lib/param/param_functions.h"
53 54 55 56 57
#endif

const char **lpcfg_interfaces(struct loadparm_context *);
const char *lpcfg_realm(struct loadparm_context *);
const char *lpcfg_netbios_name(struct loadparm_context *);
58
const char *lpcfg_private_dir(struct loadparm_context *);
59
const char *lpcfg_binddns_dir(struct loadparm_context *);
60
int lpcfg_server_role(struct loadparm_context *);
61
int lpcfg_allow_dns_updates(struct loadparm_context *);
62

63
void reload_charcnv(struct loadparm_context *lp_ctx);
Jelmer Vernooij's avatar
Jelmer Vernooij committed
64

65
struct loadparm_service *lpcfg_default_service(struct loadparm_context *lp_ctx);
66
bool lpcfg_autoloaded(struct loadparm_service *, struct loadparm_service *);
67 68 69 70 71 72 73

char *lpcfg_tls_keyfile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
char *lpcfg_tls_certfile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
char *lpcfg_tls_cafile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
char *lpcfg_tls_dhpfile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
char *lpcfg_tls_crlfile(TALLOC_CTX *mem_ctx, struct loadparm_context *);

74 75
const char *lpcfg_dnsdomain(struct loadparm_context *);

76 77 78 79
const char *lpcfg_servicename(const struct loadparm_service *service);


const char *lpcfg_get_parametric(struct loadparm_context *lp_ctx,
80 81 82
			      struct loadparm_service *service,
			      const char *type, const char *option);

83
const char *lpcfg_parm_string(struct loadparm_context *lp_ctx,
84 85
			   struct loadparm_service *service, const char *type,
			   const char *option);
86
const char **lpcfg_parm_string_list(TALLOC_CTX *mem_ctx,
87 88 89 90
				 struct loadparm_context *lp_ctx,
				 struct loadparm_service *service,
				 const char *type,
				 const char *option, const char *separator);
91
int lpcfg_parm_int(struct loadparm_context *lp_ctx,
92 93
		struct loadparm_service *service, const char *type,
		const char *option, int default_v);
94
int lpcfg_parm_bytes(struct loadparm_context *lp_ctx,
95 96
		  struct loadparm_service *service, const char *type,
		  const char *option, int default_v);
97
unsigned long lpcfg_parm_ulong(struct loadparm_context *lp_ctx,
98 99
			    struct loadparm_service *service, const char *type,
			    const char *option, unsigned long default_v);
100 101 102 103
unsigned long long lpcfg_parm_ulonglong(struct loadparm_context *lp_ctx,
					struct loadparm_service *service,
					const char *type, const char *option,
					unsigned long long default_v);
104 105 106
long lpcfg_parm_long(struct loadparm_context *lp_ctx,
		     struct loadparm_service *service, const char *type,
		     const char *option, long default_v);
107
double lpcfg_parm_double(struct loadparm_context *lp_ctx,
108 109
		      struct loadparm_service *service, const char *type,
		      const char *option, double default_v);
110 111 112 113
bool lpcfg_parm_bool(struct loadparm_context *lp_ctx,
		     struct loadparm_service *service, const char *type,
		     const char *option, bool default_v);
struct loadparm_service *lpcfg_add_service(struct loadparm_context *lp_ctx,
114 115
				     const struct loadparm_service *pservice,
				     const char *name);
116
bool lpcfg_add_home(struct loadparm_context *lp_ctx,
117 118 119
		 const char *pszHomename,
		 struct loadparm_service *default_service,
		 const char *user, const char *pszHomedir);
120
bool lpcfg_add_printer(struct loadparm_context *lp_ctx,
121 122
		    const char *pszPrintername,
		    struct loadparm_service *default_service);
123
struct parm_struct *lpcfg_parm_struct(struct loadparm_context *lp_ctx, const char *name);
124
void *lpcfg_parm_ptr(struct loadparm_context *lp_ctx,
125
		  struct loadparm_service *service, struct parm_struct *parm);
126
bool lpcfg_parm_is_cmdline(struct loadparm_context *lp_ctx, const char *name);
127
bool lpcfg_file_list_changed(struct loadparm_context *lp_ctx);
128

129
bool lpcfg_do_global_parameter(struct loadparm_context *lp_ctx,
130
			    const char *pszParmName, const char *pszParmValue);
131
bool lpcfg_do_service_parameter(struct loadparm_context *lp_ctx,
132 133 134 135 136 137
			     struct loadparm_service *service,
			     const char *pszParmName, const char *pszParmValue);

/**
 * Process a parameter.
 */
138
bool lpcfg_do_global_parameter_var(struct loadparm_context *lp_ctx,
139
				const char *pszParmName, const char *fmt, ...);
140
bool lpcfg_set_cmdline(struct loadparm_context *lp_ctx, const char *pszParmName,
141
		    const char *pszParmValue);
142
bool lpcfg_set_option(struct loadparm_context *lp_ctx, const char *option);
143 144 145 146

/**
 * Display the contents of a single services record.
 */
147
bool lpcfg_dump_a_parameter(struct loadparm_context *lp_ctx,
148 149 150 151 152 153
			 struct loadparm_service *service,
			 const char *parm_name, FILE * f);

/**
 * Unload unused services.
 */
154
void lpcfg_killunused(struct loadparm_context *lp_ctx,
155 156 157 158 159 160 161
		   struct smbsrv_connection *smb,
		   bool (*snumused) (struct smbsrv_connection *, int));

/**
 * Initialise the global parameter structure.
 */
struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx);
162
struct loadparm_context *loadparm_init_global(bool load_default);
163 164
const char *lpcfg_configfile(struct loadparm_context *lp_ctx);
bool lpcfg_load_default(struct loadparm_context *lp_ctx);
165
const char *lp_default_path(void);
166 167 168 169 170 171

/**
 * Load the services array from the services file.
 *
 * Return True on success, False on failure.
 */
172
bool lpcfg_load(struct loadparm_context *lp_ctx, const char *filename);
173 174 175 176

/**
 * Return the max number of services.
 */
177
int lpcfg_numservices(struct loadparm_context *lp_ctx);
178 179 180 181

/**
 * Display the contents of the services array in human-readable form.
 */
182
void lpcfg_dump(struct loadparm_context *lp_ctx, FILE *f, bool show_defaults,
183 184 185 186 187
	     int maxtoprint);

/**
 * Display the contents of one service in human-readable form.
 */
188 189
void lpcfg_dump_one(FILE *f, bool show_defaults, struct loadparm_service *service, struct loadparm_service *sDefault);
struct loadparm_service *lpcfg_servicebynum(struct loadparm_context *lp_ctx,
190
					 int snum);
191
struct loadparm_service *lpcfg_service(struct loadparm_context *lp_ctx,
192 193 194 195 196
				    const char *service_name);

/**
 * A useful volume label function.
 */
197
const char *lp_cfg_volume_label(struct loadparm_service *service, struct loadparm_service *sDefault);
198 199 200 201

/**
 * If we are PDC then prefer us as DMB
 */
202
const char *lpcfg_printername(struct loadparm_service *service, struct loadparm_service *sDefault);
203 204 205 206

/**
 * Return the max print jobs per queue.
 */
207
int lpcfg_maxprintjobs(struct loadparm_service *service, struct loadparm_service *sDefault);
208
struct smb_iconv_handle *lpcfg_iconv_handle(struct loadparm_context *lp_ctx);
209
void lpcfg_smbcli_options(struct loadparm_context *lp_ctx,
210
			 struct smbcli_options *options);
211
void lpcfg_smbcli_session_options(struct loadparm_context *lp_ctx,
212
				 struct smbcli_session_options *options);
213
const char **lpcfg_smb_ports(struct loadparm_context *);
214
const char *lpcfg_socket_options(struct loadparm_context *);
215 216
struct dcerpc_server_info *lpcfg_dcerpc_server_info(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx);
struct gensec_settings *lpcfg_gensec_settings(TALLOC_CTX *, struct loadparm_context *);
217

218 219 220 221 222 223 224
/* The following definitions come from param/util.c  */


/**
 * @file
 * @brief Misc utility functions
 */
225
bool lpcfg_is_mydomain(struct loadparm_context *lp_ctx,
226 227
			     const char *domain);

228
bool lpcfg_is_my_domain_or_realm(struct loadparm_context *lp_ctx,
229 230
			      const char *domain);

231 232 233 234
/**
  see if a string matches either our primary or one of our secondary 
  netbios aliases. do a case insensitive match
*/
235
bool lpcfg_is_myname(struct loadparm_context *lp_ctx, const char *name);
236 237 238 239

/**
 A useful function for returning a path in the Samba lock directory.
**/
240
char *lpcfg_lock_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx,
241 242 243 244 245 246 247 248 249
			 const char *name);

/**
 * @brief Returns an absolute path to a file in the directory containing the current config file
 *
 * @param name File to find, relative to the config file directory.
 *
 * @retval Pointer to a talloc'ed string containing the full path.
 **/
250
char *lpcfg_config_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx,
251 252 253 254 255 256 257 258 259 260
			   const char *name);

/**
 * @brief Returns an absolute path to a file in the Samba private directory.
 *
 * @param name File to find, relative to PRIVATEDIR.
 * if name is not relative, then use it as-is
 *
 * @retval Pointer to a talloc'ed string containing the full path.
 **/
261
char *lpcfg_private_path(TALLOC_CTX* mem_ctx,
262 263 264
			    struct loadparm_context *lp_ctx,
			    const char *name);

265 266 267 268
/**
 * @brief Returns an absolute path to a NTDB or TDB file in the Samba
 * private directory.
 *
269
 * @param name File to find, relative to PRIVATEDIR, without .tdb extension.
270 271 272 273 274 275 276 277
 *
 * @retval Pointer to a talloc'ed string containing the full path, for
 * use with dbwrap_local_open().
 **/
char *lpcfg_private_db_path(TALLOC_CTX *mem_ctx,
			    struct loadparm_context *lp_ctx,
			    const char *name);

278 279 280 281 282 283
/**
  return a path in the smbd.tmp directory, where all temporary file
  for smbd go. If NULL is passed for name then return the directory 
  path itself
*/
char *smbd_tmp_path(TALLOC_CTX *mem_ctx, 
284
			     struct loadparm_context *lp_ctx,
285 286
			     const char *name);

287
const char *lpcfg_imessaging_path(TALLOC_CTX *mem_ctx,
288
				       struct loadparm_context *lp_ctx);
289
const char *lpcfg_sam_name(struct loadparm_context *lp_ctx);
290
const char *lpcfg_sam_dnsname(struct loadparm_context *lp_ctx);
291

292 293 294 295 296
void lpcfg_default_kdc_policy(struct loadparm_context *lp_ctx,
				time_t *svc_tkt_lifetime,
				time_t *usr_tkt_lifetime,
				time_t *renewal_lifetime);

297 298 299
int lpcfg_rpc_port_low(struct loadparm_context *lp_ctx);
int lpcfg_rpc_port_high(struct loadparm_context *lp_ctx);

300 301 302 303 304
/* The following definitions come from lib/version.c  */

const char *samba_version_string(void);


Jelmer Vernooij's avatar
Jelmer Vernooij committed
305
#endif /* _PARAM_H */