2 Unix SMB/CIFS implementation.
3 Parameter loading functions
4 Copyright (C) Karl Auer 1993-1998
6 Largely re-written by Andrew Tridgell, September 1994
8 Copyright (C) Simo Sorce 2001
9 Copyright (C) Alexander Bokovoy 2002
10 Copyright (C) Stefan (metze) Metzmacher 2002
11 Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2003.
12 Copyright (C) James Myers 2003 <myersjj@samba.org>
13 Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
14 Copyright (C) Andrew Bartlett 2011-2012
16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 3 of the License, or
19 (at your option) any later version.
21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 GNU General Public License for more details.
26 You should have received a copy of the GNU General Public License
27 along with this program. If not, see <http://www.gnu.org/licenses/>.
33 * This module provides suitable callback functions for the params
34 * module. It builds the internal table of service details which is
35 * then used by the rest of the server.
39 * 1) add it to the global or service structure definition
40 * 2) add it to the parm_table
41 * 3) add it to the list of available functions (eg: using FN_GLOBAL_STRING())
42 * 4) If it's a global then initialise it in init_globals. If a local
43 * (ie. service) parameter then initialise it in the sDefault structure
47 * The configuration file is processed sequentially for speed. It is NOT
48 * accessed randomly as happens in 'real' Windows. For this reason, there
49 * is a fair bit of sequence-dependent code here - ie., code which assumes
50 * that certain things happen before others. In particular, the code which
51 * happens at the boundary between sections is delicately poised, so be
58 #include "dynconfig/dynconfig.h"
59 #include "system/time.h"
60 #include "system/locale.h"
61 #include "system/network.h" /* needed for TCP_NODELAY */
62 #include "../lib/util/dlinklist.h"
63 #include "lib/param/param.h"
64 #define LOADPARM_SUBSTITUTION_INTERNALS 1
65 #include "lib/param/loadparm.h"
66 #include "auth/gensec/gensec.h"
67 #include "lib/param/s3_param.h"
68 #include "lib/util/bitmap.h"
69 #include "libcli/smb/smb_constants.h"
71 #include "librpc/gen_ndr/nbt.h"
72 #include "librpc/gen_ndr/dns.h"
73 #include "librpc/gen_ndr/security.h"
74 #include "libds/common/roles.h"
75 #include "lib/util/samba_util.h"
76 #include "libcli/auth/ntlm_check.h"
77 #include "lib/crypto/gnutls_helpers.h"
78 #include "lib/util/smb_strtox.h"
79 #include "auth/credentials/credentials.h"
81 #ifdef HAVE_HTTPCONNECTENCRYPT
82 #include <cups/http.h>
85 #define standard_sub_basic talloc_strdup
87 #include "lib/param/param_global.h"
89 struct loadparm_service
*lpcfg_default_service(struct loadparm_context
*lp_ctx
)
91 return lp_ctx
->sDefault
;
94 int lpcfg_rpc_low_port(struct loadparm_context
*lp_ctx
)
96 return lp_ctx
->globals
->rpc_low_port
;
99 int lpcfg_rpc_high_port(struct loadparm_context
*lp_ctx
)
101 return lp_ctx
->globals
->rpc_high_port
;
104 enum samba_weak_crypto
lpcfg_weak_crypto(struct loadparm_context
*lp_ctx
)
106 if (lp_ctx
->globals
->weak_crypto
== SAMBA_WEAK_CRYPTO_UNKNOWN
) {
107 lp_ctx
->globals
->weak_crypto
= SAMBA_WEAK_CRYPTO_DISALLOWED
;
109 if (samba_gnutls_weak_crypto_allowed()) {
110 lp_ctx
->globals
->weak_crypto
= SAMBA_WEAK_CRYPTO_ALLOWED
;
114 return lp_ctx
->globals
->weak_crypto
;
118 * Convenience routine to grab string parameters into temporary memory
119 * and run standard_sub_basic on them.
121 * The buffers can be written to by
122 * callers without affecting the source string.
125 static const char *lpcfg_string(const char *s
)
127 #if 0 /* until REWRITE done to make thread-safe */
128 size_t len
= s
? strlen(s
) : 0;
132 /* The follow debug is useful for tracking down memory problems
133 especially if you have an inner loop that is calling a lp_*()
134 function that returns a string. Perhaps this debug should be
135 present all the time? */
138 DEBUG(10, ("lpcfg_string(%s)\n", s
));
141 #if 0 /* until REWRITE done to make thread-safe */
143 lp_talloc
= talloc_init("lp_talloc");
145 ret
= talloc_array(lp_talloc
, char, len
+ 100); /* leave room for substitution */
153 strlcpy(ret
, s
, len
);
155 if (trim_string(ret
, "\"", "\"")) {
156 if (strchr(ret
,'"') != NULL
)
157 strlcpy(ret
, s
, len
);
160 standard_sub_basic(ret
,len
+100);
167 In this section all the functions that are used to access the
168 parameters from the rest of the program are defined
172 * the creation of separate lpcfg_*() and lp_*() functions is to allow
173 * for code compatibility between existing Samba4 and Samba3 code.
176 /* this global context supports the lp_*() function variants */
177 static struct loadparm_context
*global_loadparm_context
;
179 #define FN_GLOBAL_SUBSTITUTED_STRING(fn_name,var_name) \
180 _PUBLIC_ char *lpcfg_ ## fn_name(struct loadparm_context *lp_ctx, \
181 const struct loadparm_substitution *lp_sub, TALLOC_CTX *mem_ctx) \
183 if (lp_ctx == NULL) return NULL; \
184 return lpcfg_substituted_string(mem_ctx, lp_sub, \
185 lp_ctx->globals->var_name ? lp_ctx->globals->var_name : ""); \
188 #define FN_GLOBAL_CONST_STRING(fn_name,var_name) \
189 _PUBLIC_ const char *lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) { \
190 if (lp_ctx == NULL) return NULL; \
191 return lp_ctx->globals->var_name ? lpcfg_string(lp_ctx->globals->var_name) : ""; \
194 #define FN_GLOBAL_LIST(fn_name,var_name) \
195 _PUBLIC_ const char **lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) { \
196 if (lp_ctx == NULL) return NULL; \
197 return lp_ctx->globals->var_name; \
200 #define FN_GLOBAL_BOOL(fn_name,var_name) \
201 _PUBLIC_ bool lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) {\
202 if (lp_ctx == NULL) return false; \
203 return lp_ctx->globals->var_name; \
206 #define FN_GLOBAL_INTEGER(fn_name,var_name) \
207 _PUBLIC_ int lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) { \
208 return lp_ctx->globals->var_name; \
211 /* Local parameters don't need the ->s3_fns because the struct
212 * loadparm_service is shared and lpcfg_service() checks the ->s3_fns
214 #define FN_LOCAL_SUBSTITUTED_STRING(fn_name,val) \
215 _PUBLIC_ char *lpcfg_ ## fn_name(struct loadparm_service *service, \
216 struct loadparm_service *sDefault, TALLOC_CTX *ctx) { \
217 return(talloc_strdup(ctx, lpcfg_string((const char *)((service != NULL && service->val != NULL) ? service->val : sDefault->val)))); \
220 #define FN_LOCAL_CONST_STRING(fn_name,val) \
221 _PUBLIC_ const char *lpcfg_ ## fn_name(struct loadparm_service *service, \
222 struct loadparm_service *sDefault) { \
223 return((const char *)((service != NULL && service->val != NULL) ? service->val : sDefault->val)); \
226 #define FN_LOCAL_LIST(fn_name,val) \
227 _PUBLIC_ const char **lpcfg_ ## fn_name(struct loadparm_service *service, \
228 struct loadparm_service *sDefault) {\
229 return(const char **)(service != NULL && service->val != NULL? service->val : sDefault->val); \
232 #define FN_LOCAL_PARM_BOOL(fn_name, val) FN_LOCAL_BOOL(fn_name, val)
234 #define FN_LOCAL_BOOL(fn_name,val) \
235 _PUBLIC_ bool lpcfg_ ## fn_name(struct loadparm_service *service, \
236 struct loadparm_service *sDefault) { \
237 return((service != NULL)? service->val : sDefault->val); \
240 #define FN_LOCAL_INTEGER(fn_name,val) \
241 _PUBLIC_ int lpcfg_ ## fn_name(struct loadparm_service *service, \
242 struct loadparm_service *sDefault) { \
243 return((service != NULL)? service->val : sDefault->val); \
246 #define FN_LOCAL_PARM_INTEGER(fn_name, val) FN_LOCAL_INTEGER(fn_name, val)
248 #define FN_LOCAL_CHAR(fn_name,val) \
249 _PUBLIC_ char lpcfg_ ## fn_name(struct loadparm_service *service, \
250 struct loadparm_service *sDefault) { \
251 return((service != NULL)? service->val : sDefault->val); \
254 #define FN_LOCAL_PARM_CHAR(fn_name,val) FN_LOCAL_CHAR(fn_name, val)
256 #include "lib/param/param_functions.c"
258 /* These functions cannot be auto-generated */
259 FN_LOCAL_BOOL(autoloaded
, autoloaded
)
260 FN_GLOBAL_CONST_STRING(dnsdomain
, dnsdomain
)
262 /* local prototypes */
263 static struct loadparm_service
*lpcfg_getservicebyname(struct loadparm_context
*lp_ctx
,
264 const char *pszServiceName
);
265 static bool do_section(const char *pszSectionName
, void *);
266 static bool set_variable_helper(TALLOC_CTX
*mem_ctx
, int parmnum
, void *parm_ptr
,
267 const char *pszParmName
, const char *pszParmValue
);
268 static bool lp_do_parameter_parametric(struct loadparm_context
*lp_ctx
,
269 struct loadparm_service
*service
,
270 const char *pszParmName
,
271 const char *pszParmValue
, int flags
);
273 /* The following are helper functions for parametrical options support. */
274 /* It returns a pointer to parametrical option value if it exists or NULL otherwise */
275 /* Actual parametrical functions are quite simple */
276 struct parmlist_entry
*get_parametric_helper(struct loadparm_service
*service
,
277 const char *type
, const char *option
,
278 struct parmlist_entry
*global_opts
)
280 size_t type_len
= strlen(type
);
281 size_t option_len
= strlen(option
);
282 char param_key
[type_len
+ option_len
+ 2];
283 struct parmlist_entry
*data
= NULL
;
285 snprintf(param_key
, sizeof(param_key
), "%s:%s", type
, option
);
288 * Try to fetch the option from the data.
290 if (service
!= NULL
) {
291 data
= service
->param_opt
;
292 while (data
!= NULL
) {
293 if (strwicmp(data
->key
, param_key
) == 0) {
301 * Fall back to fetching from the globals.
304 while (data
!= NULL
) {
305 if (strwicmp(data
->key
, param_key
) == 0) {
314 const char *lpcfg_get_parametric(struct loadparm_context
*lp_ctx
,
315 struct loadparm_service
*service
,
316 const char *type
, const char *option
)
318 struct parmlist_entry
*data
;
323 data
= get_parametric_helper(service
,
324 type
, option
, lp_ctx
->globals
->param_opt
);
335 * convenience routine to return int parameters.
337 int lp_int(const char *s
)
341 DEBUG(0,("lp_int(%s): is called with NULL!\n",s
));
345 return strtol(s
, NULL
, 0);
349 * convenience routine to return unsigned long parameters.
351 unsigned long lp_ulong(const char *s
)
354 unsigned long int ret
;
357 DBG_DEBUG("lp_ulong(%s): is called with NULL!\n",s
);
361 ret
= smb_strtoul(s
, NULL
, 0, &error
, SMB_STR_STANDARD
);
363 DBG_DEBUG("lp_ulong(%s): conversion failed\n",s
);
371 * convenience routine to return unsigned long long parameters.
373 unsigned long long lp_ulonglong(const char *s
)
376 unsigned long long int ret
;
379 DBG_DEBUG("lp_ulonglong(%s): is called with NULL!\n", s
);
383 ret
= smb_strtoull(s
, NULL
, 0, &error
, SMB_STR_STANDARD
);
385 DBG_DEBUG("lp_ulonglong(%s): conversion failed\n",s
);
393 * convenience routine to return unsigned long parameters.
395 static long lp_long(const char *s
)
399 DEBUG(0,("lp_long(%s): is called with NULL!\n",s
));
403 return strtol(s
, NULL
, 0);
407 * convenience routine to return unsigned long parameters.
409 static double lp_double(const char *s
)
413 DEBUG(0,("lp_double(%s): is called with NULL!\n",s
));
417 return strtod(s
, NULL
);
421 * convenience routine to return boolean parameters.
423 bool lp_bool(const char *s
)
428 DEBUG(0,("lp_bool(%s): is called with NULL!\n",s
));
432 if (!set_boolean(s
, &ret
)) {
433 DEBUG(0,("lp_bool(%s): value is not boolean!\n",s
));
441 * Return parametric option from a given service. Type is a part of option before ':'
442 * Parametric option has following syntax: 'Type: option = value'
443 * Returned value is allocated in 'lp_talloc' context
446 const char *lpcfg_parm_string(struct loadparm_context
*lp_ctx
,
447 struct loadparm_service
*service
, const char *type
,
450 const char *value
= lpcfg_get_parametric(lp_ctx
, service
, type
, option
);
453 return lpcfg_string(value
);
459 * Return parametric option from a given service. Type is a part of option before ':'
460 * Parametric option has following syntax: 'Type: option = value'
461 * Returned value is allocated in 'lp_talloc' context
464 const char **lpcfg_parm_string_list(TALLOC_CTX
*mem_ctx
,
465 struct loadparm_context
*lp_ctx
,
466 struct loadparm_service
*service
,
468 const char *option
, const char *separator
)
470 const char *value
= lpcfg_get_parametric(lp_ctx
, service
, type
, option
);
473 char **l
= str_list_make(mem_ctx
, value
, separator
);
474 return discard_const_p(const char *, l
);
481 * Return parametric option from a given service. Type is a part of option before ':'
482 * Parametric option has following syntax: 'Type: option = value'
485 int lpcfg_parm_int(struct loadparm_context
*lp_ctx
,
486 struct loadparm_service
*service
, const char *type
,
487 const char *option
, int default_v
)
489 const char *value
= lpcfg_get_parametric(lp_ctx
, service
, type
, option
);
492 return lp_int(value
);
498 * Return parametric option from a given service. Type is a part of
500 * Parametric option has following syntax: 'Type: option = value'.
503 int lpcfg_parm_bytes(struct loadparm_context
*lp_ctx
,
504 struct loadparm_service
*service
, const char *type
,
505 const char *option
, int default_v
)
509 const char *value
= lpcfg_get_parametric(lp_ctx
, service
, type
, option
);
511 if (value
&& conv_str_size_error(value
, &bval
)) {
512 if (bval
<= INT_MAX
) {
521 * Return parametric option from a given service.
522 * Type is a part of option before ':'
523 * Parametric option has following syntax: 'Type: option = value'
525 unsigned long lpcfg_parm_ulong(struct loadparm_context
*lp_ctx
,
526 struct loadparm_service
*service
, const char *type
,
527 const char *option
, unsigned long default_v
)
529 const char *value
= lpcfg_get_parametric(lp_ctx
, service
, type
, option
);
532 return lp_ulong(value
);
538 * Return parametric option from a given service.
539 * Type is a part of option before ':'
540 * Parametric option has following syntax: 'Type: option = value'
542 unsigned long long lpcfg_parm_ulonglong(struct loadparm_context
*lp_ctx
,
543 struct loadparm_service
*service
,
544 const char *type
, const char *option
,
545 unsigned long long default_v
)
547 const char *value
= lpcfg_get_parametric(lp_ctx
, service
, type
, option
);
550 return lp_ulonglong(value
);
556 long lpcfg_parm_long(struct loadparm_context
*lp_ctx
,
557 struct loadparm_service
*service
, const char *type
,
558 const char *option
, long default_v
)
560 const char *value
= lpcfg_get_parametric(lp_ctx
, service
, type
, option
);
563 return lp_long(value
);
568 double lpcfg_parm_double(struct loadparm_context
*lp_ctx
,
569 struct loadparm_service
*service
, const char *type
,
570 const char *option
, double default_v
)
572 const char *value
= lpcfg_get_parametric(lp_ctx
, service
, type
, option
);
575 return lp_double(value
);
581 * Return parametric option from a given service. Type is a part of option before ':'
582 * Parametric option has following syntax: 'Type: option = value'
585 bool lpcfg_parm_bool(struct loadparm_context
*lp_ctx
,
586 struct loadparm_service
*service
, const char *type
,
587 const char *option
, bool default_v
)
589 const char *value
= lpcfg_get_parametric(lp_ctx
, service
, type
, option
);
592 return lp_bool(value
);
598 /* this is used to prevent lots of mallocs of size 1 */
599 static const char lpcfg_string_empty
[] = "";
604 void lpcfg_string_free(char **s
)
609 if (*s
== lpcfg_string_empty
) {
617 * Set a string value, deallocating any existing space, and allocing the space
620 bool lpcfg_string_set(TALLOC_CTX
*mem_ctx
, char **dest
, const char *src
)
622 lpcfg_string_free(dest
);
624 if ((src
== NULL
) || (*src
== '\0')) {
625 *dest
= discard_const_p(char, lpcfg_string_empty
);
629 *dest
= talloc_strdup(mem_ctx
, src
);
630 if ((*dest
) == NULL
) {
631 DEBUG(0,("Out of memory in string_set\n"));
639 * Set a string value, deallocating any existing space, and allocing the space
642 bool lpcfg_string_set_upper(TALLOC_CTX
*mem_ctx
, char **dest
, const char *src
)
644 lpcfg_string_free(dest
);
646 if ((src
== NULL
) || (*src
== '\0')) {
647 *dest
= discard_const_p(char, lpcfg_string_empty
);
651 *dest
= strupper_talloc(mem_ctx
, src
);
652 if ((*dest
) == NULL
) {
653 DEBUG(0,("Out of memory in string_set_upper\n"));
663 * Add a new service to the services array initialising it with the given
667 struct loadparm_service
*lpcfg_add_service(struct loadparm_context
*lp_ctx
,
668 const struct loadparm_service
*pservice
,
672 int num_to_alloc
= lp_ctx
->iNumServices
+ 1;
673 struct parmlist_entry
*data
, *pdata
;
675 if (lp_ctx
->s3_fns
!= NULL
) {
676 smb_panic("Add a service should not be called on an s3 loadparm ctx");
679 if (pservice
== NULL
) {
680 pservice
= lp_ctx
->sDefault
;
683 /* it might already exist */
685 struct loadparm_service
*service
= lpcfg_getservicebyname(lp_ctx
,
687 if (service
!= NULL
) {
688 /* Clean all parametric options for service */
689 /* They will be added during parsing again */
690 data
= service
->param_opt
;
696 service
->param_opt
= NULL
;
701 /* find an invalid one */
702 for (i
= 0; i
< lp_ctx
->iNumServices
; i
++)
703 if (lp_ctx
->services
[i
] == NULL
)
706 /* if not, then create one */
707 if (i
== lp_ctx
->iNumServices
) {
708 struct loadparm_service
**tsp
;
710 tsp
= talloc_realloc(lp_ctx
, lp_ctx
->services
, struct loadparm_service
*, num_to_alloc
);
713 DEBUG(0,("lpcfg_add_service: failed to enlarge services!\n"));
716 lp_ctx
->services
= tsp
;
717 lp_ctx
->services
[lp_ctx
->iNumServices
] = NULL
;
720 lp_ctx
->iNumServices
++;
723 lp_ctx
->services
[i
] = talloc_zero(lp_ctx
->services
, struct loadparm_service
);
724 if (lp_ctx
->services
[i
] == NULL
) {
725 DEBUG(0,("lpcfg_add_service: out of memory!\n"));
728 copy_service(lp_ctx
->services
[i
], pservice
, NULL
);
730 lpcfg_string_set(lp_ctx
->services
[i
], &lp_ctx
->services
[i
]->szService
, name
);
731 return lp_ctx
->services
[i
];
735 * Map a parameter's string representation to something we can use.
736 * Returns False if the parameter string is not recognised, else TRUE.
739 int lpcfg_map_parameter(const char *pszParmName
)
743 for (iIndex
= 0; parm_table
[iIndex
].label
; iIndex
++)
744 if (strwicmp(parm_table
[iIndex
].label
, pszParmName
) == 0)
747 /* Warn only if it isn't parametric option */
748 if (strchr(pszParmName
, ':') == NULL
)
749 DEBUG(0, ("Unknown parameter encountered: \"%s\"\n", pszParmName
));
750 /* We do return 'fail' for parametric options as well because they are
751 stored in different storage
758 return the parameter structure for a parameter
760 struct parm_struct
*lpcfg_parm_struct(struct loadparm_context
*lp_ctx
, const char *name
)
762 int num
= lpcfg_map_parameter(name
);
768 return &parm_table
[num
];
772 return the parameter pointer for a parameter
774 void *lpcfg_parm_ptr(struct loadparm_context
*lp_ctx
,
775 struct loadparm_service
*service
, struct parm_struct
*parm
)
777 if (lp_ctx
->s3_fns
) {
778 return lp_ctx
->s3_fns
->get_parm_ptr(service
, parm
);
781 if (service
== NULL
) {
782 if (parm
->p_class
== P_LOCAL
)
783 return ((char *)lp_ctx
->sDefault
)+parm
->offset
;
784 else if (parm
->p_class
== P_GLOBAL
)
785 return ((char *)lp_ctx
->globals
)+parm
->offset
;
788 return ((char *)service
) + parm
->offset
;
793 return the parameter pointer for a parameter
795 bool lpcfg_parm_is_cmdline(struct loadparm_context
*lp_ctx
, const char *name
)
799 parmnum
= lpcfg_map_parameter(name
);
800 if (parmnum
== -1) return false;
802 return lp_ctx
->flags
[parmnum
] & FLAG_CMDLINE
;
805 bool lpcfg_parm_is_unspecified(struct loadparm_context
*lp_ctx
, const char *name
)
809 parmnum
= lpcfg_map_parameter(name
);
810 if (parmnum
== -1) return false;
812 return lp_ctx
->flags
[parmnum
] & FLAG_DEFAULT
;
816 * Find a service by name. Otherwise works like get_service.
819 static struct loadparm_service
*lpcfg_getservicebyname(struct loadparm_context
*lp_ctx
,
820 const char *pszServiceName
)
824 if (lp_ctx
->s3_fns
) {
825 return lp_ctx
->s3_fns
->get_service(pszServiceName
);
828 for (iService
= lp_ctx
->iNumServices
- 1; iService
>= 0; iService
--)
829 if (lp_ctx
->services
[iService
] != NULL
&&
830 strwicmp(lp_ctx
->services
[iService
]->szService
, pszServiceName
) == 0) {
831 return lp_ctx
->services
[iService
];
838 * Add a parametric option to a parmlist_entry,
839 * replacing old value, if already present.
841 void set_param_opt(TALLOC_CTX
*mem_ctx
,
842 struct parmlist_entry
**opt_list
,
843 const char *opt_name
,
844 const char *opt_value
,
847 struct parmlist_entry
*new_opt
, *opt
;
851 /* Traverse destination */
853 /* If we already have same option, override it */
854 if (strwicmp(opt
->key
, opt_name
) == 0) {
855 if ((opt
->priority
& FLAG_CMDLINE
) &&
856 !(priority
& FLAG_CMDLINE
)) {
857 /* it's been marked as not to be
861 TALLOC_FREE(opt
->list
);
862 lpcfg_string_set(opt
, &opt
->value
, opt_value
);
863 opt
->priority
= priority
;
869 new_opt
= talloc_pooled_object(
870 mem_ctx
, struct parmlist_entry
,
871 2, strlen(opt_name
) + 1 + strlen(opt_value
) + 1);
872 if (new_opt
== NULL
) {
876 lpcfg_string_set(new_opt
, &new_opt
->key
, opt_name
);
877 new_opt
->value
= NULL
;
878 lpcfg_string_set(new_opt
, &new_opt
->value
, opt_value
);
880 new_opt
->list
= NULL
;
881 new_opt
->priority
= priority
;
882 DLIST_ADD(*opt_list
, new_opt
);
886 * Copy a service structure to another.
887 * If pcopymapDest is NULL then copy all fields
890 void copy_service(struct loadparm_service
*pserviceDest
,
891 const struct loadparm_service
*pserviceSource
,
892 struct bitmap
*pcopymapDest
)
895 bool bcopyall
= (pcopymapDest
== NULL
);
896 struct parmlist_entry
*data
;
898 for (i
= 0; parm_table
[i
].label
; i
++)
899 if (parm_table
[i
].p_class
== P_LOCAL
&&
900 (bcopyall
|| bitmap_query(pcopymapDest
, i
))) {
901 const void *src_ptr
=
902 ((const char *)pserviceSource
) + parm_table
[i
].offset
;
904 ((char *)pserviceDest
) + parm_table
[i
].offset
;
906 switch (parm_table
[i
].type
) {
909 *(bool *)dest_ptr
= *(const bool *)src_ptr
;
916 *(int *)dest_ptr
= *(const int *)src_ptr
;
920 *(char *)dest_ptr
= *(const char *)src_ptr
;
924 lpcfg_string_set(pserviceDest
,
926 *(const char * const *)src_ptr
);
930 lpcfg_string_set_upper(pserviceDest
,
932 *(const char * const *)src_ptr
);
936 TALLOC_FREE(*((char ***)dest_ptr
));
937 *(char ***)dest_ptr
= str_list_copy(pserviceDest
,
938 *discard_const_p(const char **, src_ptr
));
946 init_copymap(pserviceDest
);
947 if (pserviceSource
->copymap
)
948 bitmap_copy(pserviceDest
->copymap
,
949 pserviceSource
->copymap
);
952 for (data
= pserviceSource
->param_opt
; data
!= NULL
; data
= data
->next
) {
953 set_param_opt(pserviceDest
, &pserviceDest
->param_opt
,
954 data
->key
, data
->value
, data
->priority
);
959 * Check a service for consistency. Return False if the service is in any way
960 * incomplete or faulty, else True.
962 bool lpcfg_service_ok(struct loadparm_service
*service
)
967 if (service
->szService
[0] == '\0') {
968 DEBUG(0, ("The following message indicates an internal error:\n"));
969 DEBUG(0, ("No service name in service entry.\n"));
973 /* The [printers] entry MUST be printable. I'm all for flexibility, but */
974 /* I can't see why you'd want a non-printable printer service... */
975 if (strwicmp(service
->szService
, PRINTERS_NAME
) == 0) {
976 if (!service
->printable
) {
977 DEBUG(0, ("WARNING: [%s] service MUST be printable!\n",
978 service
->szService
));
979 service
->printable
= true;
981 /* [printers] service must also be non-browsable. */
982 if (service
->browseable
)
983 service
->browseable
= false;
986 if (service
->path
[0] == '\0' &&
987 strwicmp(service
->szService
, HOMES_NAME
) != 0 &&
988 service
->msdfs_proxy
[0] == '\0')
990 DEBUG(0, ("WARNING: No path in service %s - making it unavailable!\n",
991 service
->szService
));
992 service
->available
= false;
995 if (!service
->available
)
996 DEBUG(1, ("NOTE: Service %s is flagged unavailable.\n",
997 service
->szService
));
1003 /*******************************************************************
1004 Keep a linked list of all config files so we know when one has changed
1005 it's date and needs to be reloaded.
1006 ********************************************************************/
1008 void add_to_file_list(TALLOC_CTX
*mem_ctx
, struct file_lists
**list
,
1009 const char *fname
, const char *subfname
)
1011 struct file_lists
*f
= *list
;
1014 if (f
->name
&& !strcmp(f
->name
, fname
))
1020 f
= talloc_zero(mem_ctx
, struct file_lists
);
1024 f
->name
= talloc_strdup(f
, fname
);
1029 f
->subfname
= talloc_strdup(f
, subfname
);
1037 /* If file_modtime() fails it leaves f->modtime as zero. */
1038 (void)file_modtime(subfname
, &f
->modtime
);
1042 DEBUG(0, ("Unable to add file to file list: %s\n", fname
));
1047 * set the value for a P_ENUM
1049 bool lp_set_enum_parm( struct parm_struct
*parm
, const char *pszParmValue
,
1054 for (i
= 0; parm
->enum_list
[i
].name
; i
++) {
1055 if (strwicmp(pszParmValue
, parm
->enum_list
[i
].name
) == 0) {
1056 *ptr
= parm
->enum_list
[i
].value
;
1060 DEBUG(0, ("WARNING: Ignoring invalid value '%s' for parameter '%s'\n",
1061 pszParmValue
, parm
->label
));
1066 /***************************************************************************
1067 Handle the "realm" parameter
1068 ***************************************************************************/
1070 bool handle_realm(struct loadparm_context
*lp_ctx
, struct loadparm_service
*service
,
1071 const char *pszParmValue
, char **ptr
)
1076 upper
= strupper_talloc(lp_ctx
, pszParmValue
);
1077 if (upper
== NULL
) {
1081 lower
= strlower_talloc(lp_ctx
, pszParmValue
);
1082 if (lower
== NULL
) {
1087 lpcfg_string_set(lp_ctx
->globals
->ctx
, &lp_ctx
->globals
->realm
, upper
);
1088 lpcfg_string_set(lp_ctx
->globals
->ctx
, &lp_ctx
->globals
->dnsdomain
, lower
);
1093 /***************************************************************************
1094 Handle the include operation.
1095 ***************************************************************************/
1097 bool handle_include(struct loadparm_context
*lp_ctx
, struct loadparm_service
*service
,
1098 const char *pszParmValue
, char **ptr
)
1101 const char *substitution_variable_substring
;
1104 if (lp_ctx
->s3_fns
) {
1105 return lp_ctx
->s3_fns
->lp_include(lp_ctx
, service
, pszParmValue
, ptr
);
1108 fname
= standard_sub_basic(lp_ctx
, pszParmValue
);
1110 add_to_file_list(lp_ctx
, &lp_ctx
->file_lists
, pszParmValue
, fname
);
1112 lpcfg_string_set(lp_ctx
, ptr
, fname
);
1114 if (file_exist(fname
))
1115 return pm_process(fname
, do_section
, lpcfg_do_parameter
, lp_ctx
);
1118 * If the file doesn't exist, we check that it isn't due to variable
1121 substitution_variable_substring
= strchr(fname
, '%');
1123 if (substitution_variable_substring
!= NULL
) {
1124 next_char
= substitution_variable_substring
[1];
1125 if ((next_char
>= 'a' && next_char
<= 'z')
1126 || (next_char
>= 'A' && next_char
<= 'Z')) {
1127 DEBUG(2, ("Tried to load %s but variable substitution in "
1128 "filename, ignoring file.\n", fname
));
1133 DEBUG(2, ("Can't find include file %s\n", fname
));
1138 /***************************************************************************
1139 Handle the interpretation of the copy parameter.
1140 ***************************************************************************/
1142 bool handle_copy(struct loadparm_context
*lp_ctx
, struct loadparm_service
*service
,
1143 const char *pszParmValue
, char **ptr
)
1146 struct loadparm_service
*serviceTemp
= NULL
;
1150 DEBUG(3, ("Copying service from service %s\n", pszParmValue
));
1152 serviceTemp
= lpcfg_getservicebyname(lp_ctx
, pszParmValue
);
1154 if (service
== NULL
) {
1155 DEBUG(0, ("Unable to copy service - invalid service destination.\n"));
1159 if (serviceTemp
!= NULL
) {
1160 if (serviceTemp
== service
) {
1161 DEBUG(0, ("Can't copy service %s - unable to copy self!\n", pszParmValue
));
1163 copy_service(service
,
1166 lpcfg_string_set(service
, ptr
, pszParmValue
);
1171 DEBUG(0, ("Unable to copy service - source not found: %s\n",
1179 bool handle_debug_list(struct loadparm_context
*lp_ctx
, struct loadparm_service
*service
,
1180 const char *pszParmValue
, char **ptr
)
1182 lpcfg_string_set(lp_ctx
->globals
->ctx
, ptr
, pszParmValue
);
1184 return debug_parse_levels(pszParmValue
);
1187 bool handle_logfile(struct loadparm_context
*lp_ctx
, struct loadparm_service
*service
,
1188 const char *pszParmValue
, char **ptr
)
1190 if (lp_ctx
->s3_fns
== NULL
) {
1191 debug_set_logfile(pszParmValue
);
1194 lpcfg_string_set(lp_ctx
->globals
->ctx
, ptr
, pszParmValue
);
1200 * These special charset handling methods only run in the source3 code.
1203 bool handle_charset(struct loadparm_context
*lp_ctx
, struct loadparm_service
*service
,
1204 const char *pszParmValue
, char **ptr
)
1206 if (lp_ctx
->s3_fns
) {
1207 if (*ptr
== NULL
|| strcmp(*ptr
, pszParmValue
) != 0) {
1208 struct smb_iconv_handle
*ret
= NULL
;
1210 ret
= reinit_iconv_handle(NULL
,
1211 lpcfg_dos_charset(lp_ctx
),
1212 lpcfg_unix_charset(lp_ctx
));
1214 smb_panic("reinit_iconv_handle failed");
1219 return lpcfg_string_set(lp_ctx
->globals
->ctx
, ptr
, pszParmValue
);
1223 bool handle_dos_charset(struct loadparm_context
*lp_ctx
, struct loadparm_service
*service
,
1224 const char *pszParmValue
, char **ptr
)
1226 bool is_utf8
= false;
1227 size_t len
= strlen(pszParmValue
);
1229 if (lp_ctx
->s3_fns
) {
1230 if (len
== 4 || len
== 5) {
1231 /* Don't use StrCaseCmp here as we don't want to
1232 initialize iconv. */
1233 if ((toupper_m(pszParmValue
[0]) == 'U') &&
1234 (toupper_m(pszParmValue
[1]) == 'T') &&
1235 (toupper_m(pszParmValue
[2]) == 'F')) {
1237 if (pszParmValue
[3] == '8') {
1241 if (pszParmValue
[3] == '-' &&
1242 pszParmValue
[4] == '8') {
1249 if (*ptr
== NULL
|| strcmp(*ptr
, pszParmValue
) != 0) {
1250 struct smb_iconv_handle
*ret
= NULL
;
1252 DEBUG(0,("ERROR: invalid DOS charset: 'dos charset' must not "
1253 "be UTF8, using (default value) %s instead.\n",
1254 DEFAULT_DOS_CHARSET
));
1255 pszParmValue
= DEFAULT_DOS_CHARSET
;
1257 ret
= reinit_iconv_handle(NULL
,
1258 lpcfg_dos_charset(lp_ctx
),
1259 lpcfg_unix_charset(lp_ctx
));
1261 smb_panic("reinit_iconv_handle failed");
1266 return lpcfg_string_set(lp_ctx
->globals
->ctx
, ptr
, pszParmValue
);
1269 bool handle_printing(struct loadparm_context
*lp_ctx
, struct loadparm_service
*service
,
1270 const char *pszParmValue
, char **ptr
)
1272 static int parm_num
= -1;
1274 if (parm_num
== -1) {
1275 parm_num
= lpcfg_map_parameter("printing");
1276 if (parm_num
== -1) {
1281 if (!lp_set_enum_parm(&parm_table
[parm_num
], pszParmValue
, (int*)ptr
)) {
1285 if (lp_ctx
->s3_fns
) {
1286 if (service
== NULL
) {
1287 init_printer_values(lp_ctx
, lp_ctx
->globals
->ctx
, lp_ctx
->sDefault
);
1289 init_printer_values(lp_ctx
, service
, service
);
1296 bool handle_ldap_debug_level(struct loadparm_context
*lp_ctx
, struct loadparm_service
*service
,
1297 const char *pszParmValue
, char **ptr
)
1299 lp_ctx
->globals
->ldap_debug_level
= lp_int(pszParmValue
);
1301 if (lp_ctx
->s3_fns
) {
1302 lp_ctx
->s3_fns
->init_ldap_debugging();
1308 * idmap related parameters
1311 bool handle_idmap_backend(struct loadparm_context
*lp_ctx
, struct loadparm_service
*service
,
1312 const char *pszParmValue
, char **ptr
)
1314 if (lp_ctx
->s3_fns
) {
1315 lp_do_parameter_parametric(lp_ctx
, service
, "idmap config * : backend",
1319 return lpcfg_string_set(lp_ctx
->globals
->ctx
, ptr
, pszParmValue
);
1322 bool handle_idmap_uid(struct loadparm_context
*lp_ctx
, struct loadparm_service
*service
,
1323 const char *pszParmValue
, char **ptr
)
1325 if (lp_ctx
->s3_fns
) {
1326 lp_do_parameter_parametric(lp_ctx
, service
, "idmap config * : range",
1330 return lpcfg_string_set(lp_ctx
->globals
->ctx
, ptr
, pszParmValue
);
1333 bool handle_idmap_gid(struct loadparm_context
*lp_ctx
, struct loadparm_service
*service
,
1334 const char *pszParmValue
, char **ptr
)
1336 if (lp_ctx
->s3_fns
) {
1337 lp_do_parameter_parametric(lp_ctx
, service
, "idmap config * : range",
1341 return lpcfg_string_set(lp_ctx
->globals
->ctx
, ptr
, pszParmValue
);
1344 bool handle_smb_ports(struct loadparm_context
*lp_ctx
, struct loadparm_service
*service
,
1345 const char *pszParmValue
, char **ptr
)
1347 static int parm_num
= -1;
1351 if (!pszParmValue
|| !*pszParmValue
) {
1355 if (parm_num
== -1) {
1356 parm_num
= lpcfg_map_parameter("smb ports");
1357 if (parm_num
== -1) {
1362 if (!set_variable_helper(lp_ctx
->globals
->ctx
, parm_num
, ptr
, "smb ports",
1367 list
= lp_ctx
->globals
->smb_ports
;
1372 /* Check that each port is a valid integer and within range */
1373 for (i
= 0; list
[i
] != NULL
; i
++) {
1376 port
= strtol(list
[i
], &end
, 10);
1377 if (*end
!= '\0' || port
<= 0 || port
> 65535) {
1386 bool handle_rpc_server_dynamic_port_range(struct loadparm_context
*lp_ctx
,
1387 struct loadparm_service
*service
,
1388 const char *pszParmValue
,
1391 static int parm_num
= -1;
1392 int low_port
= -1, high_port
= -1;
1395 if (parm_num
== -1) {
1396 parm_num
= lpcfg_map_parameter("rpc server dynamic port range");
1397 if (parm_num
== -1) {
1402 if (pszParmValue
== NULL
|| pszParmValue
[0] == '\0') {
1406 rc
= sscanf(pszParmValue
, "%d - %d", &low_port
, &high_port
);
1411 if (low_port
> high_port
) {
1415 if (low_port
< SERVER_TCP_PORT_MIN
|| high_port
> SERVER_TCP_PORT_MAX
) {
1419 if (!set_variable_helper(lp_ctx
->globals
->ctx
, parm_num
, ptr
,
1420 "rpc server dynamic port range",
1425 lp_ctx
->globals
->rpc_low_port
= low_port
;
1426 lp_ctx
->globals
->rpc_high_port
= high_port
;
1431 bool handle_smb2_max_credits(struct loadparm_context
*lp_ctx
,
1432 struct loadparm_service
*service
,
1433 const char *pszParmValue
, char **ptr
)
1435 int value
= lp_int(pszParmValue
);
1438 value
= DEFAULT_SMB2_MAX_CREDITS
;
1441 *(int *)ptr
= value
;
1446 bool handle_cups_encrypt(struct loadparm_context
*lp_ctx
,
1447 struct loadparm_service
*service
,
1448 const char *pszParmValue
, char **ptr
)
1451 #ifdef HAVE_HTTPCONNECTENCRYPT
1452 int value
= lp_int(pszParmValue
);
1456 result
= HTTP_ENCRYPT_REQUIRED
;
1459 result
= HTTP_ENCRYPT_ALWAYS
;
1462 result
= HTTP_ENCRYPT_NEVER
;
1469 *(int *)ptr
= result
;
1474 /***************************************************************************
1475 Initialise a copymap.
1476 ***************************************************************************/
1479 * Initializes service copymap
1480 * Note: pservice *must* be valid TALLOC_CTX
1482 void init_copymap(struct loadparm_service
*pservice
)
1486 TALLOC_FREE(pservice
->copymap
);
1488 pservice
->copymap
= bitmap_talloc(pservice
, num_parameters());
1489 if (!pservice
->copymap
) {
1491 ("Couldn't allocate copymap!! (size %d)\n",
1492 (int)num_parameters()));
1494 for (i
= 0; i
< num_parameters(); i
++) {
1495 bitmap_set(pservice
->copymap
, i
);
1501 * Process a parametric option
1503 static bool lp_do_parameter_parametric(struct loadparm_context
*lp_ctx
,
1504 struct loadparm_service
*service
,
1505 const char *pszParmName
,
1506 const char *pszParmValue
, int flags
)
1508 struct parmlist_entry
**data
;
1510 TALLOC_CTX
*mem_ctx
;
1512 while (isspace((unsigned char)*pszParmName
)) {
1516 name
= strlower_talloc(lp_ctx
, pszParmName
);
1517 if (!name
) return false;
1519 if (service
== NULL
) {
1520 data
= &lp_ctx
->globals
->param_opt
;
1522 * s3 code cannot deal with parametric options stored on the globals ctx.
1524 if (lp_ctx
->s3_fns
!= NULL
) {
1527 mem_ctx
= lp_ctx
->globals
->ctx
;
1530 data
= &service
->param_opt
;
1534 set_param_opt(mem_ctx
, data
, name
, pszParmValue
, flags
);
1541 static bool set_variable_helper(TALLOC_CTX
*mem_ctx
, int parmnum
, void *parm_ptr
,
1542 const char *pszParmName
, const char *pszParmValue
)
1546 /* switch on the type of variable it is */
1547 switch (parm_table
[parmnum
].type
)
1551 if (!set_boolean(pszParmValue
, &b
)) {
1552 DEBUG(0, ("set_variable_helper(%s): value is not "
1553 "boolean!\n", pszParmValue
));
1556 *(bool *)parm_ptr
= b
;
1562 if (!set_boolean(pszParmValue
, &b
)) {
1563 DEBUG(0, ("set_variable_helper(%s): value is not "
1564 "boolean!\n", pszParmValue
));
1567 *(bool *)parm_ptr
= !b
;
1572 *(int *)parm_ptr
= lp_int(pszParmValue
);
1576 *(char *)parm_ptr
= *pszParmValue
;
1580 i
= sscanf(pszParmValue
, "%o", (int *)parm_ptr
);
1582 DEBUG ( 0, ("Invalid octal number %s\n", pszParmName
));
1590 if (conv_str_size_error(pszParmValue
, &val
)) {
1591 if (val
<= INT_MAX
) {
1592 *(int *)parm_ptr
= (int)val
;
1597 DEBUG(0, ("set_variable_helper(%s): value is not "
1598 "a valid size specifier!\n", pszParmValue
));
1603 TALLOC_FREE(*(char ***)parm_ptr
);
1604 *(char ***)parm_ptr
= str_list_make_v3(mem_ctx
,
1605 pszParmValue
, NULL
);
1610 char **new_list
= str_list_make_v3(mem_ctx
,
1611 pszParmValue
, NULL
);
1612 if (new_list
== NULL
) {
1616 for (i
=0; new_list
[i
]; i
++) {
1617 if (*(const char ***)parm_ptr
!= NULL
&&
1618 new_list
[i
][0] == '+' &&
1621 if (!str_list_check(*(const char ***)parm_ptr
,
1623 *(const char ***)parm_ptr
= str_list_add(*(const char ***)parm_ptr
,
1626 } else if (*(const char ***)parm_ptr
!= NULL
&&
1627 new_list
[i
][0] == '-' &&
1630 str_list_remove(*(const char ***)parm_ptr
,
1634 DEBUG(0, ("Unsupported list syntax for: %s = %s\n",
1635 pszParmName
, pszParmValue
));
1638 *(char ***)parm_ptr
= new_list
;
1646 lpcfg_string_set(mem_ctx
, (char **)parm_ptr
, pszParmValue
);
1650 lpcfg_string_set_upper(mem_ctx
, (char **)parm_ptr
, pszParmValue
);
1654 if (!lp_set_enum_parm(&parm_table
[parmnum
], pszParmValue
, (int*)parm_ptr
)) {
1665 bool handle_name_resolve_order(struct loadparm_context
*lp_ctx
,
1666 struct loadparm_service
*service
,
1667 const char *pszParmValue
, char **ptr
)
1669 const char **valid_values
= NULL
;
1670 const char **values_to_set
= NULL
;
1672 bool value_is_valid
= false;
1673 valid_values
= str_list_make_v3_const(NULL
,
1674 DEFAULT_NAME_RESOLVE_ORDER
,
1676 if (valid_values
== NULL
) {
1677 DBG_ERR("OOM: failed to make string list from %s\n",
1678 DEFAULT_NAME_RESOLVE_ORDER
);
1681 values_to_set
= str_list_make_v3_const(lp_ctx
->globals
->ctx
,
1684 if (values_to_set
== NULL
) {
1685 DBG_ERR("OOM: failed to make string list from %s\n",
1689 TALLOC_FREE(lp_ctx
->globals
->name_resolve_order
);
1690 for (i
= 0; values_to_set
[i
] != NULL
; i
++) {
1691 value_is_valid
= str_list_check(valid_values
, values_to_set
[i
]);
1692 if (!value_is_valid
) {
1693 DBG_ERR("WARNING: Ignoring invalid list value '%s' "
1694 "for parameter 'name resolve order'\n",
1700 if (value_is_valid
) {
1701 lp_ctx
->globals
->name_resolve_order
= values_to_set
;
1703 TALLOC_FREE(values_to_set
);
1705 TALLOC_FREE(valid_values
);
1706 return value_is_valid
;
1709 bool handle_kdc_default_domain_supported_enctypes(struct loadparm_context
*lp_ctx
,
1710 struct loadparm_service
*service
,
1711 const char *pszParmValue
, char **ptr
)
1713 char **enctype_list
= NULL
;
1714 char **enctype
= NULL
;
1715 uint32_t result
= 0;
1718 enctype_list
= str_list_make(NULL
, pszParmValue
, NULL
);
1719 if (enctype_list
== NULL
) {
1720 DBG_ERR("OOM: failed to make string list from %s\n",
1726 for (enctype
= enctype_list
; *enctype
!= NULL
; ++enctype
) {
1727 if (strwicmp(*enctype
, "arcfour-hmac-md5") == 0 ||
1728 strwicmp(*enctype
, "rc4-hmac") == 0)
1730 result
|= KERB_ENCTYPE_RC4_HMAC_MD5
;
1732 else if (strwicmp(*enctype
, "aes128-cts-hmac-sha1-96") == 0 ||
1733 strwicmp(*enctype
, "aes128-cts") == 0)
1735 result
|= KERB_ENCTYPE_AES128_CTS_HMAC_SHA1_96
;
1737 else if (strwicmp(*enctype
, "aes256-cts-hmac-sha1-96") == 0 ||
1738 strwicmp(*enctype
, "aes256-cts") == 0)
1740 result
|= KERB_ENCTYPE_AES256_CTS_HMAC_SHA1_96
;
1742 else if (strwicmp(*enctype
, "aes256-cts-hmac-sha1-96-sk") == 0 ||
1743 strwicmp(*enctype
, "aes256-cts-sk") == 0)
1745 result
|= KERB_ENCTYPE_AES256_CTS_HMAC_SHA1_96_SK
;
1748 const char *bitstr
= *enctype
;
1753 /* See if the bit's specified in hexadecimal. */
1754 if (bitstr
[0] == '0' &&
1755 (bitstr
[1] == 'x' || bitstr
[2] == 'X'))
1764 bit
= smb_strtoul(bitstr
, NULL
, base
, &error
, SMB_STR_FULL_STR_CONV
);
1766 DBG_ERR("WARNING: Ignoring invalid value '%s' "
1767 "for parameter 'kdc default domain supported enctypes'\n",
1776 *(int *)ptr
= result
;
1778 TALLOC_FREE(enctype_list
);
1783 bool handle_kdc_supported_enctypes(struct loadparm_context
*lp_ctx
,
1784 struct loadparm_service
*service
,
1785 const char *pszParmValue
, char **ptr
)
1787 char **enctype_list
= NULL
;
1788 char **enctype
= NULL
;
1789 uint32_t result
= 0;
1792 enctype_list
= str_list_make(NULL
, pszParmValue
, NULL
);
1793 if (enctype_list
== NULL
) {
1794 DBG_ERR("OOM: failed to make string list from %s\n",
1800 for (enctype
= enctype_list
; *enctype
!= NULL
; ++enctype
) {
1801 if (strwicmp(*enctype
, "arcfour-hmac-md5") == 0 ||
1802 strwicmp(*enctype
, "rc4-hmac") == 0)
1804 result
|= KERB_ENCTYPE_RC4_HMAC_MD5
;
1806 else if (strwicmp(*enctype
, "aes128-cts-hmac-sha1-96") == 0 ||
1807 strwicmp(*enctype
, "aes128-cts") == 0)
1809 result
|= KERB_ENCTYPE_AES128_CTS_HMAC_SHA1_96
;
1811 else if (strwicmp(*enctype
, "aes256-cts-hmac-sha1-96") == 0 ||
1812 strwicmp(*enctype
, "aes256-cts") == 0)
1814 result
|= KERB_ENCTYPE_AES256_CTS_HMAC_SHA1_96
;
1817 const char *bitstr
= *enctype
;
1822 /* See if the bit's specified in hexadecimal. */
1823 if (bitstr
[0] == '0' &&
1824 (bitstr
[1] == 'x' || bitstr
[2] == 'X'))
1833 bit
= smb_strtoul(bitstr
, NULL
, base
, &error
, SMB_STR_FULL_STR_CONV
);
1835 DBG_ERR("WARNING: Ignoring invalid value '%s' "
1836 "for parameter 'kdc default domain supported enctypes'\n",
1845 *(int *)ptr
= result
;
1847 TALLOC_FREE(enctype_list
);
1852 static bool set_variable(TALLOC_CTX
*mem_ctx
, struct loadparm_service
*service
,
1853 int parmnum
, void *parm_ptr
,
1854 const char *pszParmName
, const char *pszParmValue
,
1855 struct loadparm_context
*lp_ctx
, bool on_globals
)
1860 /* if it is a special case then go ahead */
1861 if (parm_table
[parmnum
].special
) {
1862 ok
= parm_table
[parmnum
].special(lp_ctx
, service
, pszParmValue
,
1865 ok
= set_variable_helper(mem_ctx
, parmnum
, parm_ptr
,
1866 pszParmName
, pszParmValue
);
1873 if (on_globals
&& (lp_ctx
->flags
[parmnum
] & FLAG_DEFAULT
)) {
1874 lp_ctx
->flags
[parmnum
] &= ~FLAG_DEFAULT
;
1875 /* we have to also unset FLAG_DEFAULT on aliases */
1876 for (i
=parmnum
-1;i
>=0 && parm_table
[i
].offset
== parm_table
[parmnum
].offset
;i
--) {
1877 lp_ctx
->flags
[i
] &= ~FLAG_DEFAULT
;
1879 for (i
=parmnum
+1;i
<num_parameters() && parm_table
[i
].offset
== parm_table
[parmnum
].offset
;i
++) {
1880 lp_ctx
->flags
[i
] &= ~FLAG_DEFAULT
;
1887 bool lpcfg_do_global_parameter(struct loadparm_context
*lp_ctx
,
1888 const char *pszParmName
, const char *pszParmValue
)
1890 int parmnum
= lpcfg_map_parameter(pszParmName
);
1894 if (strchr(pszParmName
, ':')) {
1895 return lp_do_parameter_parametric(lp_ctx
, NULL
, pszParmName
, pszParmValue
, 0);
1897 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName
));
1901 /* if the flag has been set on the command line, then don't allow override,
1902 but don't report an error */
1903 if (lp_ctx
->flags
[parmnum
] & FLAG_CMDLINE
) {
1907 if (parm_table
[parmnum
].flags
& FLAG_DEPRECATED
) {
1908 char *suppress_env
= getenv("SAMBA_DEPRECATED_SUPPRESS");
1909 bool print_warning
= (suppress_env
== NULL
1910 || suppress_env
[0] == '\0');
1911 if (print_warning
) {
1912 DBG_WARNING("WARNING: The \"%s\" option "
1919 parm_ptr
= lpcfg_parm_ptr(lp_ctx
, NULL
, &parm_table
[parmnum
]);
1921 return set_variable(lp_ctx
->globals
->ctx
, NULL
, parmnum
, parm_ptr
,
1922 pszParmName
, pszParmValue
, lp_ctx
, true);
1925 bool lpcfg_do_service_parameter(struct loadparm_context
*lp_ctx
,
1926 struct loadparm_service
*service
,
1927 const char *pszParmName
, const char *pszParmValue
)
1931 int parmnum
= lpcfg_map_parameter(pszParmName
);
1934 if (strchr(pszParmName
, ':')) {
1935 return lp_do_parameter_parametric(lp_ctx
, service
, pszParmName
, pszParmValue
, 0);
1937 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName
));
1941 /* if the flag has been set on the command line, then don't allow override,
1942 but don't report an error */
1943 if (lp_ctx
->flags
[parmnum
] & FLAG_CMDLINE
) {
1947 if (parm_table
[parmnum
].flags
& FLAG_DEPRECATED
) {
1948 char *suppress_env
= getenv("SAMBA_DEPRECATED_SUPPRESS");
1949 bool print_warning
= (suppress_env
== NULL
1950 || suppress_env
[0] == '\0');
1951 if (print_warning
) {
1952 DBG_WARNING("WARNING: The \"%s\" option "
1959 if (parm_table
[parmnum
].p_class
== P_GLOBAL
) {
1961 ("Global parameter %s found in service section!\n",
1965 parm_ptr
= ((char *)service
) + parm_table
[parmnum
].offset
;
1967 if (!service
->copymap
)
1968 init_copymap(service
);
1970 /* this handles the aliases - set the copymap for other
1971 * entries with the same data pointer */
1972 for (i
= 0; parm_table
[i
].label
; i
++)
1973 if (parm_table
[i
].offset
== parm_table
[parmnum
].offset
&&
1974 parm_table
[i
].p_class
== parm_table
[parmnum
].p_class
)
1975 bitmap_clear(service
->copymap
, i
);
1977 return set_variable(service
, service
, parmnum
, parm_ptr
, pszParmName
,
1978 pszParmValue
, lp_ctx
, false);
1982 * Process a parameter.
1985 bool lpcfg_do_parameter(const char *pszParmName
, const char *pszParmValue
,
1988 struct loadparm_context
*lp_ctx
= (struct loadparm_context
*)userdata
;
1990 if (lp_ctx
->bInGlobalSection
)
1991 return lpcfg_do_global_parameter(lp_ctx
, pszParmName
,
1994 return lpcfg_do_service_parameter(lp_ctx
, lp_ctx
->currentService
,
1995 pszParmName
, pszParmValue
);
1999 variable argument do parameter
2001 bool lpcfg_do_global_parameter_var(struct loadparm_context
*lp_ctx
, const char *pszParmName
, const char *fmt
, ...) PRINTF_ATTRIBUTE(3, 4);
2002 bool lpcfg_do_global_parameter_var(struct loadparm_context
*lp_ctx
,
2003 const char *pszParmName
, const char *fmt
, ...)
2010 s
= talloc_vasprintf(NULL
, fmt
, ap
);
2012 ret
= lpcfg_do_global_parameter(lp_ctx
, pszParmName
, s
);
2019 set a parameter from the commandline - this is called from command line parameter
2020 parsing code. It sets the parameter then marks the parameter as unable to be modified
2021 by smb.conf processing
2023 bool lpcfg_set_cmdline(struct loadparm_context
*lp_ctx
, const char *pszParmName
,
2024 const char *pszParmValue
)
2029 while (isspace((unsigned char)*pszParmValue
)) pszParmValue
++;
2031 parmnum
= lpcfg_map_parameter(pszParmName
);
2033 if (parmnum
< 0 && strchr(pszParmName
, ':')) {
2034 /* set a parametric option */
2036 ok
= lp_do_parameter_parametric(lp_ctx
, NULL
, pszParmName
,
2037 pszParmValue
, FLAG_CMDLINE
);
2038 if (lp_ctx
->s3_fns
!= NULL
) {
2040 lp_ctx
->s3_fns
->store_cmdline(pszParmName
, pszParmValue
);
2047 DEBUG(0,("Unknown option '%s'\n", pszParmName
));
2051 /* reset the CMDLINE flag in case this has been called before */
2052 lp_ctx
->flags
[parmnum
] &= ~FLAG_CMDLINE
;
2054 if (!lpcfg_do_global_parameter(lp_ctx
, pszParmName
, pszParmValue
)) {
2058 lp_ctx
->flags
[parmnum
] |= FLAG_CMDLINE
;
2060 /* we have to also set FLAG_CMDLINE on aliases */
2062 i
>=0 && parm_table
[i
].p_class
== parm_table
[parmnum
].p_class
&&
2063 parm_table
[i
].offset
== parm_table
[parmnum
].offset
;
2065 lp_ctx
->flags
[i
] |= FLAG_CMDLINE
;
2068 i
<num_parameters() &&
2069 parm_table
[i
].p_class
== parm_table
[parmnum
].p_class
&&
2070 parm_table
[i
].offset
== parm_table
[parmnum
].offset
;
2072 lp_ctx
->flags
[i
] |= FLAG_CMDLINE
;
2075 if (lp_ctx
->s3_fns
!= NULL
) {
2076 lp_ctx
->s3_fns
->store_cmdline(pszParmName
, pszParmValue
);
2083 set a option from the commandline in 'a=b' format. Use to support --option
2085 bool lpcfg_set_option(struct loadparm_context
*lp_ctx
, const char *option
)
2090 s
= talloc_strdup(NULL
, option
);
2103 ret
= lpcfg_set_cmdline(lp_ctx
, s
, p
+1);
2109 #define BOOLSTR(b) ((b) ? "Yes" : "No")
2112 * Print a parameter of the specified type.
2115 void lpcfg_print_parameter(struct parm_struct
*p
, void *ptr
, FILE * f
)
2117 /* For the separation of lists values that we print below */
2118 const char *list_sep
= ", ";
2123 for (i
= 0; p
->enum_list
[i
].name
; i
++) {
2124 if (*(int *)ptr
== p
->enum_list
[i
].value
) {
2126 p
->enum_list
[i
].name
);
2133 fprintf(f
, "%s", BOOLSTR(*(bool *)ptr
));
2137 fprintf(f
, "%s", BOOLSTR(!*(bool *)ptr
));
2142 fprintf(f
, "%d", *(int *)ptr
);
2146 fprintf(f
, "%c", *(char *)ptr
);
2150 int val
= *(int *)ptr
;
2154 fprintf(f
, "0%03o", val
);
2164 if ((char ***)ptr
&& *(char ***)ptr
) {
2165 char **list
= *(char ***)ptr
;
2166 for (; *list
; list
++) {
2167 /* surround strings with whitespace in double quotes */
2168 if (*(list
+1) == NULL
) {
2169 /* last item, no extra separator */
2172 if ( strchr_m( *list
, ' ' ) ) {
2173 fprintf(f
, "\"%s\"%s", *list
, list_sep
);
2175 fprintf(f
, "%s%s", *list
, list_sep
);
2183 if (*(char **)ptr
) {
2184 fprintf(f
, "%s", *(char **)ptr
);
2191 * Check if two parameters are equal.
2194 static bool lpcfg_equal_parameter(parm_type type
, void *ptr1
, void *ptr2
)
2199 return (*((bool *)ptr1
) == *((bool *)ptr2
));
2205 return (*((int *)ptr1
) == *((int *)ptr2
));
2208 return (*((char *)ptr1
) == *((char *)ptr2
));
2212 return str_list_equal(*(const char ***)ptr1
, *(const char ***)ptr2
);
2217 char *p1
= *(char **)ptr1
, *p2
= *(char **)ptr2
;
2222 return (p1
== p2
|| strequal(p1
, p2
));
2229 * Process a new section (service).
2231 * At this stage all sections are services.
2232 * Later we'll have special sections that permit server parameters to be set.
2233 * Returns True on success, False on failure.
2236 static bool do_section(const char *pszSectionName
, void *userdata
)
2238 struct loadparm_context
*lp_ctx
= (struct loadparm_context
*)userdata
;
2242 if (lp_ctx
->s3_fns
!= NULL
) {
2243 return lp_ctx
->s3_fns
->do_section(pszSectionName
, lp_ctx
);
2246 isglobal
= ((strwicmp(pszSectionName
, GLOBAL_NAME
) == 0) ||
2247 (strwicmp(pszSectionName
, GLOBAL_NAME2
) == 0));
2249 /* if we've just struck a global section, note the fact. */
2250 lp_ctx
->bInGlobalSection
= isglobal
;
2252 /* check for multiple global sections */
2253 if (lp_ctx
->bInGlobalSection
) {
2254 DEBUG(4, ("Processing section \"[%s]\"\n", pszSectionName
));
2259 /* if we have a current service, tidy it up before moving on */
2262 if (lp_ctx
->currentService
!= NULL
)
2263 bRetval
= lpcfg_service_ok(lp_ctx
->currentService
);
2265 /* if all is still well, move to the next record in the services array */
2267 /* We put this here to avoid an odd message order if messages are */
2268 /* issued by the post-processing of a previous section. */
2269 DEBUG(4, ("Processing section \"[%s]\"\n", pszSectionName
));
2271 if ((lp_ctx
->currentService
= lpcfg_add_service(lp_ctx
, lp_ctx
->sDefault
,
2274 DEBUG(0, ("Failed to add a new service\n"));
2285 * Determine if a particular base parameter is currently set to the default value.
2288 static bool is_default(void *base_structure
, int i
)
2290 void *def_ptr
= ((char *)base_structure
) + parm_table
[i
].offset
;
2291 switch (parm_table
[i
].type
) {
2294 return str_list_equal((const char * const *)parm_table
[i
].def
.lvalue
,
2295 *(const char * const **)def_ptr
);
2298 return strequal(parm_table
[i
].def
.svalue
,
2302 return parm_table
[i
].def
.bvalue
==
2309 return parm_table
[i
].def
.ivalue
==
2316 *Display the contents of the global structure.
2319 void lpcfg_dump_globals(struct loadparm_context
*lp_ctx
, FILE *f
,
2323 struct parmlist_entry
*data
;
2325 fprintf(f
, "# Global parameters\n[global]\n");
2327 for (i
= 0; parm_table
[i
].label
; i
++) {
2328 if (parm_table
[i
].p_class
!= P_GLOBAL
) {
2332 if (parm_table
[i
].flags
& FLAG_SYNONYM
) {
2336 if (!show_defaults
) {
2337 if (lp_ctx
->flags
&& (lp_ctx
->flags
[i
] & FLAG_DEFAULT
)) {
2341 if (is_default(lp_ctx
->globals
, i
)) {
2346 fprintf(f
, "\t%s = ", parm_table
[i
].label
);
2347 lpcfg_print_parameter(&parm_table
[i
], lpcfg_parm_ptr(lp_ctx
, NULL
, &parm_table
[i
]), f
);
2350 if (lp_ctx
->globals
->param_opt
!= NULL
) {
2351 for (data
= lp_ctx
->globals
->param_opt
; data
;
2352 data
= data
->next
) {
2353 if (!show_defaults
&& (data
->priority
& FLAG_DEFAULT
)) {
2356 fprintf(f
, "\t%s = %s\n", data
->key
, data
->value
);
2363 * Display the contents of a single services record.
2366 void lpcfg_dump_a_service(struct loadparm_service
* pService
, struct loadparm_service
*sDefault
, FILE * f
,
2367 unsigned int *flags
, bool show_defaults
)
2370 struct parmlist_entry
*data
;
2372 if (pService
!= sDefault
)
2373 fprintf(f
, "\n[%s]\n", pService
->szService
);
2375 for (i
= 0; parm_table
[i
].label
; i
++) {
2376 if (parm_table
[i
].p_class
!= P_LOCAL
) {
2380 if (parm_table
[i
].flags
& FLAG_SYNONYM
) {
2384 if (*parm_table
[i
].label
== '-') {
2388 if (pService
== sDefault
) {
2389 if (!show_defaults
) {
2390 if (flags
&& (flags
[i
] & FLAG_DEFAULT
)) {
2394 if (is_default(sDefault
, i
)) {
2401 equal
= lpcfg_equal_parameter(parm_table
[i
].type
,
2402 ((char *)pService
) +
2403 parm_table
[i
].offset
,
2404 ((char *)sDefault
) +
2405 parm_table
[i
].offset
);
2411 fprintf(f
, "\t%s = ", parm_table
[i
].label
);
2412 lpcfg_print_parameter(&parm_table
[i
],
2413 ((char *)pService
) + parm_table
[i
].offset
, f
);
2416 if (pService
->param_opt
!= NULL
) {
2417 for (data
= pService
->param_opt
; data
; data
= data
->next
) {
2418 if (!show_defaults
&& (data
->priority
& FLAG_DEFAULT
)) {
2421 fprintf(f
, "\t%s = %s\n", data
->key
, data
->value
);
2426 bool lpcfg_dump_a_parameter(struct loadparm_context
*lp_ctx
,
2427 struct loadparm_service
*service
,
2428 const char *parm_name
, FILE * f
)
2430 struct parm_struct
*parm
;
2432 char *local_parm_name
;
2434 const char *parm_opt_value
;
2436 /* check for parametrical option */
2437 local_parm_name
= talloc_strdup(lp_ctx
, parm_name
);
2438 if (local_parm_name
== NULL
) {
2442 parm_opt
= strchr( local_parm_name
, ':');
2447 if (strlen(parm_opt
)) {
2448 parm_opt_value
= lpcfg_parm_string(lp_ctx
, service
,
2449 local_parm_name
, parm_opt
);
2450 if (parm_opt_value
) {
2451 fprintf(f
, "%s\n", parm_opt_value
);
2452 TALLOC_FREE(local_parm_name
);
2456 TALLOC_FREE(local_parm_name
);
2459 TALLOC_FREE(local_parm_name
);
2461 /* parameter is not parametric, search the table */
2462 parm
= lpcfg_parm_struct(lp_ctx
, parm_name
);
2467 if (service
!= NULL
&& parm
->p_class
== P_GLOBAL
) {
2471 ptr
= lpcfg_parm_ptr(lp_ctx
, service
,parm
);
2473 lpcfg_print_parameter(parm
, ptr
, f
);
2479 * Auto-load some home services.
2481 static void lpcfg_add_auto_services(struct loadparm_context
*lp_ctx
,
2487 /***************************************************************************
2488 Initialise the sDefault parameter structure for the printer values.
2489 ***************************************************************************/
2491 void init_printer_values(struct loadparm_context
*lp_ctx
, TALLOC_CTX
*ctx
,
2492 struct loadparm_service
*pService
)
2494 /* choose defaults depending on the type of printing */
2495 switch (pService
->printing
) {
2500 lpcfg_string_set(ctx
, &pService
->lpq_command
, "lpq -P'%p'");
2501 lpcfg_string_set(ctx
, &pService
->lprm_command
, "lprm -P'%p' %j");
2502 lpcfg_string_set(ctx
, &pService
->print_command
, "lpr -r -P'%p' %s");
2507 lpcfg_string_set(ctx
, &pService
->lpq_command
, "lpq -P'%p'");
2508 lpcfg_string_set(ctx
, &pService
->lprm_command
, "lprm -P'%p' %j");
2509 lpcfg_string_set(ctx
, &pService
->print_command
, "lpr -r -P'%p' %s");
2510 lpcfg_string_set(ctx
, &pService
->queuepause_command
, "lpc stop '%p'");
2511 lpcfg_string_set(ctx
, &pService
->queueresume_command
, "lpc start '%p'");
2512 lpcfg_string_set(ctx
, &pService
->lppause_command
, "lpc hold '%p' %j");
2513 lpcfg_string_set(ctx
, &pService
->lpresume_command
, "lpc release '%p' %j");
2518 /* set the lpq command to contain the destination printer
2519 name only. This is used by cups_queue_get() */
2520 lpcfg_string_set(ctx
, &pService
->lpq_command
, "%p");
2521 lpcfg_string_set(ctx
, &pService
->lprm_command
, "");
2522 lpcfg_string_set(ctx
, &pService
->print_command
, "");
2523 lpcfg_string_set(ctx
, &pService
->lppause_command
, "");
2524 lpcfg_string_set(ctx
, &pService
->lpresume_command
, "");
2525 lpcfg_string_set(ctx
, &pService
->queuepause_command
, "");
2526 lpcfg_string_set(ctx
, &pService
->queueresume_command
, "");
2531 lpcfg_string_set(ctx
, &pService
->lpq_command
, "lpstat -o%p");
2532 lpcfg_string_set(ctx
, &pService
->lprm_command
, "cancel %p-%j");
2533 lpcfg_string_set(ctx
, &pService
->print_command
, "lp -c -d%p %s; rm %s");
2534 lpcfg_string_set(ctx
, &pService
->queuepause_command
, "disable %p");
2535 lpcfg_string_set(ctx
, &pService
->queueresume_command
, "enable %p");
2537 lpcfg_string_set(ctx
, &pService
->lppause_command
, "lp -i %p-%j -H hold");
2538 lpcfg_string_set(ctx
, &pService
->lpresume_command
, "lp -i %p-%j -H resume");
2543 lpcfg_string_set(ctx
, &pService
->lpq_command
, "lpq -P%p");
2544 lpcfg_string_set(ctx
, &pService
->lprm_command
, "lprm -P%p %j");
2545 lpcfg_string_set(ctx
, &pService
->print_command
, "lp -r -P%p %s");
2548 #if defined(DEVELOPER) || defined(ENABLE_SELFTEST)
2552 const char *tdbfile
;
2553 TALLOC_CTX
*tmp_ctx
= talloc_new(ctx
);
2556 tmp
= lpcfg_parm_string(lp_ctx
, NULL
, "vlp", "tdbfile");
2558 tmp
= "/tmp/vlp.tdb";
2561 tdbfile
= talloc_asprintf(tmp_ctx
, "tdbfile=%s", tmp
);
2562 if (tdbfile
== NULL
) {
2563 tdbfile
="tdbfile=/tmp/vlp.tdb";
2566 tmp
= talloc_asprintf(tmp_ctx
, "vlp %s print %%p %%s",
2568 lpcfg_string_set(ctx
, &pService
->print_command
,
2569 tmp
? tmp
: "vlp print %p %s");
2571 tmp
= talloc_asprintf(tmp_ctx
, "vlp %s lpq %%p",
2573 lpcfg_string_set(ctx
, &pService
->lpq_command
,
2574 tmp
? tmp
: "vlp lpq %p");
2576 tmp
= talloc_asprintf(tmp_ctx
, "vlp %s lprm %%p %%j",
2578 lpcfg_string_set(ctx
, &pService
->lprm_command
,
2579 tmp
? tmp
: "vlp lprm %p %j");
2581 tmp
= talloc_asprintf(tmp_ctx
, "vlp %s lppause %%p %%j",
2583 lpcfg_string_set(ctx
, &pService
->lppause_command
,
2584 tmp
? tmp
: "vlp lppause %p %j");
2586 tmp
= talloc_asprintf(tmp_ctx
, "vlp %s lpresume %%p %%j",
2588 lpcfg_string_set(ctx
, &pService
->lpresume_command
,
2589 tmp
? tmp
: "vlp lpresume %p %j");
2591 tmp
= talloc_asprintf(tmp_ctx
, "vlp %s queuepause %%p",
2593 lpcfg_string_set(ctx
, &pService
->queuepause_command
,
2594 tmp
? tmp
: "vlp queuepause %p");
2596 tmp
= talloc_asprintf(tmp_ctx
, "vlp %s queueresume %%p",
2598 lpcfg_string_set(ctx
, &pService
->queueresume_command
,
2599 tmp
? tmp
: "vlp queueresume %p");
2600 TALLOC_FREE(tmp_ctx
);
2604 #endif /* DEVELOPER */
2610 static int lpcfg_destructor(struct loadparm_context
*lp_ctx
)
2612 struct parmlist_entry
*data
;
2614 if (lp_ctx
->refuse_free
) {
2615 /* someone is trying to free the
2616 global_loadparm_context.
2617 We can't allow that. */
2621 if (lp_ctx
->globals
->param_opt
!= NULL
) {
2622 struct parmlist_entry
*next
;
2623 for (data
= lp_ctx
->globals
->param_opt
; data
; data
=next
) {
2625 if (data
->priority
& FLAG_CMDLINE
) continue;
2626 DLIST_REMOVE(lp_ctx
->globals
->param_opt
, data
);
2635 * Initialise the global parameter structure.
2637 * Note that most callers should use loadparm_init_global() instead
2639 struct loadparm_context
*loadparm_init(TALLOC_CTX
*mem_ctx
)
2643 struct loadparm_context
*lp_ctx
;
2644 struct parmlist_entry
*parm
;
2647 lp_ctx
= talloc_zero(mem_ctx
, struct loadparm_context
);
2651 talloc_set_destructor(lp_ctx
, lpcfg_destructor
);
2652 lp_ctx
->bInGlobalSection
= true;
2653 lp_ctx
->globals
= talloc_zero(lp_ctx
, struct loadparm_global
);
2654 /* This appears odd, but globals in s3 isn't a pointer */
2655 lp_ctx
->globals
->ctx
= lp_ctx
->globals
;
2656 lp_ctx
->globals
->rpc_low_port
= SERVER_TCP_LOW_PORT
;
2657 lp_ctx
->globals
->rpc_high_port
= SERVER_TCP_HIGH_PORT
;
2658 lp_ctx
->globals
->weak_crypto
= SAMBA_WEAK_CRYPTO_UNKNOWN
;
2659 lp_ctx
->sDefault
= talloc_zero(lp_ctx
, struct loadparm_service
);
2660 lp_ctx
->flags
= talloc_zero_array(lp_ctx
, unsigned int, num_parameters());
2662 lp_ctx
->sDefault
->max_print_jobs
= 1000;
2663 lp_ctx
->sDefault
->available
= true;
2664 lp_ctx
->sDefault
->browseable
= true;
2665 lp_ctx
->sDefault
->read_only
= true;
2666 lp_ctx
->sDefault
->map_archive
= true;
2667 lp_ctx
->sDefault
->strict_locking
= true;
2668 lp_ctx
->sDefault
->oplocks
= true;
2669 lp_ctx
->sDefault
->create_mask
= 0744;
2670 lp_ctx
->sDefault
->force_create_mode
= 0000;
2671 lp_ctx
->sDefault
->directory_mask
= 0755;
2672 lp_ctx
->sDefault
->force_directory_mode
= 0000;
2673 lp_ctx
->sDefault
->aio_read_size
= 1;
2674 lp_ctx
->sDefault
->aio_write_size
= 1;
2675 lp_ctx
->sDefault
->smbd_search_ask_sharemode
= true;
2676 lp_ctx
->sDefault
->smbd_getinfo_ask_sharemode
= true;
2677 lp_ctx
->sDefault
->volume_serial_number
= -1;
2679 DEBUG(3, ("Initialising global parameters\n"));
2681 for (i
= 0; parm_table
[i
].label
; i
++) {
2682 if ((parm_table
[i
].type
== P_STRING
||
2683 parm_table
[i
].type
== P_USTRING
) &&
2684 !(lp_ctx
->flags
[i
] & FLAG_CMDLINE
)) {
2685 TALLOC_CTX
*parent_mem
;
2687 if (parm_table
[i
].p_class
== P_LOCAL
) {
2688 parent_mem
= lp_ctx
->sDefault
;
2689 r
= (char **)(((char *)lp_ctx
->sDefault
) + parm_table
[i
].offset
);
2691 parent_mem
= lp_ctx
->globals
;
2692 r
= (char **)(((char *)lp_ctx
->globals
) + parm_table
[i
].offset
);
2694 lpcfg_string_set(parent_mem
, r
, "");
2698 logfile
= talloc_asprintf(lp_ctx
, "%s/log.samba", dyn_LOGFILEBASE
);
2699 lpcfg_do_global_parameter(lp_ctx
, "log file", logfile
);
2700 talloc_free(logfile
);
2702 lpcfg_do_global_parameter(lp_ctx
, "log level", "0");
2704 lpcfg_do_global_parameter(lp_ctx
, "syslog", "1");
2705 lpcfg_do_global_parameter(lp_ctx
, "syslog only", "No");
2706 lpcfg_do_global_parameter(lp_ctx
, "debug timestamp", "Yes");
2707 lpcfg_do_global_parameter(lp_ctx
, "debug prefix timestamp", "No");
2708 lpcfg_do_global_parameter(lp_ctx
, "debug hires timestamp", "Yes");
2709 lpcfg_do_global_parameter(lp_ctx
, "debug syslog format", "No");
2710 lpcfg_do_global_parameter(lp_ctx
, "debug pid", "No");
2711 lpcfg_do_global_parameter(lp_ctx
, "debug uid", "No");
2712 lpcfg_do_global_parameter(lp_ctx
, "debug class", "No");
2713 lpcfg_do_global_parameter(lp_ctx
, "winbind debug traceid", "Yes");
2715 lpcfg_do_global_parameter(lp_ctx
, "server role", "auto");
2716 lpcfg_do_global_parameter(lp_ctx
, "domain logons", "No");
2717 lpcfg_do_global_parameter(lp_ctx
, "domain master", "Auto");
2719 /* options that can be set on the command line must be initialised via
2720 the slower lpcfg_do_global_parameter() to ensure that FLAG_CMDLINE is obeyed */
2722 lpcfg_do_global_parameter(lp_ctx
, "socket options", "TCP_NODELAY");
2724 lpcfg_do_global_parameter(lp_ctx
, "workgroup", DEFAULT_WORKGROUP
);
2725 myname
= get_myname(lp_ctx
);
2726 lpcfg_do_global_parameter(lp_ctx
, "netbios name", myname
);
2727 talloc_free(myname
);
2728 lpcfg_do_global_parameter(lp_ctx
,
2729 "name resolve order",
2730 DEFAULT_NAME_RESOLVE_ORDER
);
2732 lpcfg_do_global_parameter(lp_ctx
, "fstype", "NTFS");
2734 lpcfg_do_global_parameter(lp_ctx
, "ntvfs handler", "unixuid default");
2735 lpcfg_do_global_parameter(lp_ctx
, "max connections", "0");
2737 lpcfg_do_global_parameter(lp_ctx
, "dcerpc endpoint servers", "epmapper wkssvc samr netlogon lsarpc drsuapi dssetup unixinfo browser eventlog6 backupkey dnsserver");
2738 lpcfg_do_global_parameter(lp_ctx
, "server services", "s3fs rpc nbt wrepl ldap cldap kdc drepl winbindd ntp_signd kcc dnsupdate dns");
2739 lpcfg_do_global_parameter(lp_ctx
, "kccsrv:samba_kcc", "true");
2740 /* the winbind method for domain controllers is for both RODC
2741 auth forwarding and for trusted domains */
2742 lpcfg_do_global_parameter(lp_ctx
, "private dir", dyn_PRIVATE_DIR
);
2743 lpcfg_do_global_parameter(lp_ctx
, "binddns dir", dyn_BINDDNS_DIR
);
2744 lpcfg_do_global_parameter(lp_ctx
, "registry:HKEY_LOCAL_MACHINE", "hklm.ldb");
2746 /* This hive should be dynamically generated by Samba using
2747 data from the sam, but for the moment leave it in a tdb to
2748 keep regedt32 from popping up an annoying dialog. */
2749 lpcfg_do_global_parameter(lp_ctx
, "registry:HKEY_USERS", "hku.ldb");
2751 /* using UTF8 by default allows us to support all chars */
2752 lpcfg_do_global_parameter(lp_ctx
, "unix charset", "UTF-8");
2754 /* Use codepage 850 as a default for the dos character set */
2755 lpcfg_do_global_parameter(lp_ctx
, "dos charset", "CP850");
2758 * Allow the default PASSWD_CHAT to be overridden in local.h.
2760 lpcfg_do_global_parameter(lp_ctx
, "passwd chat", DEFAULT_PASSWD_CHAT
);
2762 lpcfg_do_global_parameter(lp_ctx
, "pid directory", dyn_PIDDIR
);
2763 lpcfg_do_global_parameter(lp_ctx
, "lock dir", dyn_LOCKDIR
);
2764 lpcfg_do_global_parameter(lp_ctx
, "state directory", dyn_STATEDIR
);
2765 lpcfg_do_global_parameter(lp_ctx
, "cache directory", dyn_CACHEDIR
);
2766 lpcfg_do_global_parameter(lp_ctx
, "ncalrpc dir", dyn_NCALRPCDIR
);
2768 lpcfg_do_global_parameter(lp_ctx
, "nbt client socket address", "0.0.0.0");
2769 lpcfg_do_global_parameter_var(lp_ctx
, "server string",
2770 "Samba %s", SAMBA_VERSION_STRING
);
2772 lpcfg_do_global_parameter(lp_ctx
, "password server", "*");
2774 lpcfg_do_global_parameter(lp_ctx
, "max mux", "50");
2775 lpcfg_do_global_parameter(lp_ctx
, "max xmit", "16644");
2776 lpcfg_do_global_parameter(lp_ctx
, "host msdfs", "true");
2778 lpcfg_do_global_parameter(lp_ctx
, "LargeReadwrite", "True");
2779 lpcfg_do_global_parameter(lp_ctx
, "server min protocol", "SMB2_02");
2780 lpcfg_do_global_parameter(lp_ctx
, "server max protocol", "SMB3");
2781 lpcfg_do_global_parameter(lp_ctx
, "client min protocol", "SMB2_02");
2782 lpcfg_do_global_parameter(lp_ctx
, "client max protocol", "default");
2783 lpcfg_do_global_parameter(lp_ctx
, "client ipc min protocol", "default");
2784 lpcfg_do_global_parameter(lp_ctx
, "client ipc max protocol", "default");
2785 lpcfg_do_global_parameter(lp_ctx
, "security", "AUTO");
2786 lpcfg_do_global_parameter(lp_ctx
, "EncryptPasswords", "True");
2787 lpcfg_do_global_parameter(lp_ctx
, "ReadRaw", "True");
2788 lpcfg_do_global_parameter(lp_ctx
, "WriteRaw", "True");
2789 lpcfg_do_global_parameter(lp_ctx
, "NullPasswords", "False");
2790 lpcfg_do_global_parameter(lp_ctx
, "old password allowed period", "60");
2791 lpcfg_do_global_parameter(lp_ctx
, "ObeyPamRestrictions", "False");
2793 lpcfg_do_global_parameter(lp_ctx
, "TimeServer", "False");
2794 lpcfg_do_global_parameter(lp_ctx
, "BindInterfacesOnly", "False");
2795 lpcfg_do_global_parameter(lp_ctx
, "Unicode", "True");
2796 lpcfg_do_global_parameter(lp_ctx
, "ClientLanManAuth", "False");
2797 lpcfg_do_global_parameter(lp_ctx
, "ClientNTLMv2Auth", "True");
2798 lpcfg_do_global_parameter(lp_ctx
, "LanmanAuth", "False");
2799 lpcfg_do_global_parameter(lp_ctx
, "NTLMAuth", "ntlmv2-only");
2800 lpcfg_do_global_parameter(lp_ctx
, "NT hash store", "always");
2801 lpcfg_do_global_parameter(lp_ctx
, "RawNTLMv2Auth", "False");
2803 lpcfg_do_global_parameter(lp_ctx
, "allow dcerpc auth level connect", "False");
2805 lpcfg_do_global_parameter(lp_ctx
, "UnixExtensions", "True");
2807 lpcfg_do_global_parameter(lp_ctx
, "PreferredMaster", "Auto");
2808 lpcfg_do_global_parameter(lp_ctx
, "LocalMaster", "True");
2810 lpcfg_do_global_parameter(lp_ctx
, "wins support", "False");
2811 lpcfg_do_global_parameter(lp_ctx
, "dns proxy", "True");
2813 lpcfg_do_global_parameter(lp_ctx
, "winbind separator", "\\");
2814 lpcfg_do_global_parameter(lp_ctx
, "winbind sealed pipes", "True");
2815 lpcfg_do_global_parameter(lp_ctx
, "winbind scan trusted domains", "False");
2816 lpcfg_do_global_parameter(lp_ctx
, "require strong key", "True");
2817 lpcfg_do_global_parameter(lp_ctx
, "reject md5 servers", "True");
2818 lpcfg_do_global_parameter(lp_ctx
, "winbindd socket directory", dyn_WINBINDD_SOCKET_DIR
);
2819 lpcfg_do_global_parameter(lp_ctx
, "ntp signd socket directory", dyn_NTP_SIGND_SOCKET_DIR
);
2820 lpcfg_do_global_parameter_var(lp_ctx
, "gpo update command", "%s/samba-gpupdate", dyn_SCRIPTSBINDIR
);
2821 lpcfg_do_global_parameter_var(lp_ctx
, "apply group policies", "False");
2822 lpcfg_do_global_parameter_var(lp_ctx
, "dns update command", "%s/samba_dnsupdate", dyn_SCRIPTSBINDIR
);
2823 lpcfg_do_global_parameter_var(lp_ctx
, "spn update command", "%s/samba_spnupdate", dyn_SCRIPTSBINDIR
);
2824 lpcfg_do_global_parameter_var(lp_ctx
, "samba kcc command",
2825 "%s/samba_kcc", dyn_SCRIPTSBINDIR
);
2827 lpcfg_do_global_parameter_var(lp_ctx
,
2831 lpcfg_do_global_parameter(lp_ctx
, "template shell", "/bin/false");
2832 lpcfg_do_global_parameter(lp_ctx
, "template homedir", "/home/%D/%U");
2834 lpcfg_do_global_parameter(lp_ctx
, "client signing", "default");
2835 lpcfg_do_global_parameter(lp_ctx
, "client ipc signing", "default");
2836 lpcfg_do_global_parameter(lp_ctx
, "server signing", "default");
2838 lpcfg_do_global_parameter(lp_ctx
, "use mmap", "True");
2840 lpcfg_do_global_parameter(lp_ctx
, "smb ports", "445 139");
2841 lpcfg_do_global_parameter_var(lp_ctx
, "nbt port", "%d", NBT_NAME_SERVICE_PORT
);
2842 lpcfg_do_global_parameter_var(lp_ctx
, "dgram port", "%d", NBT_DGRAM_SERVICE_PORT
);
2843 lpcfg_do_global_parameter(lp_ctx
, "cldap port", "389");
2844 lpcfg_do_global_parameter(lp_ctx
, "krb5 port", "88");
2845 lpcfg_do_global_parameter(lp_ctx
, "kpasswd port", "464");
2846 lpcfg_do_global_parameter_var(lp_ctx
, "dns port", "%d", DNS_SERVICE_PORT
);
2848 lpcfg_do_global_parameter(lp_ctx
, "kdc enable fast", "True");
2850 lpcfg_do_global_parameter(lp_ctx
, "nt status support", "True");
2852 lpcfg_do_global_parameter(lp_ctx
, "max wins ttl", "518400"); /* 6 days */
2853 lpcfg_do_global_parameter(lp_ctx
, "min wins ttl", "21600");
2855 lpcfg_do_global_parameter(lp_ctx
, "tls enabled", "True");
2856 lpcfg_do_global_parameter(lp_ctx
, "tls verify peer", "as_strict_as_possible");
2857 lpcfg_do_global_parameter(lp_ctx
, "tls keyfile", "tls/key.pem");
2858 lpcfg_do_global_parameter(lp_ctx
, "tls certfile", "tls/cert.pem");
2859 lpcfg_do_global_parameter(lp_ctx
, "tls cafile", "tls/ca.pem");
2860 lpcfg_do_global_parameter(lp_ctx
,
2862 "NORMAL:-VERS-SSL3.0");
2864 lpcfg_do_global_parameter(lp_ctx
, "nsupdate command", "/usr/bin/nsupdate -g");
2866 lpcfg_do_global_parameter(lp_ctx
, "allow dns updates", "secure only");
2867 lpcfg_do_global_parameter(lp_ctx
, "dns zone scavenging", "False");
2868 lpcfg_do_global_parameter(lp_ctx
, "dns forwarder", "");
2870 lpcfg_do_global_parameter(lp_ctx
, "algorithmic rid base", "1000");
2872 lpcfg_do_global_parameter(lp_ctx
, "enhanced browsing", "True");
2874 lpcfg_do_global_parameter(lp_ctx
, "winbind nss info", "template");
2876 lpcfg_do_global_parameter(lp_ctx
, "server schannel", "True");
2877 lpcfg_do_global_parameter(lp_ctx
, "server schannel require seal", "True");
2878 lpcfg_do_global_parameter(lp_ctx
, "reject md5 clients", "True");
2880 lpcfg_do_global_parameter(lp_ctx
, "short preserve case", "True");
2882 lpcfg_do_global_parameter(lp_ctx
, "max open files", "16384");
2884 lpcfg_do_global_parameter(lp_ctx
, "cups connection timeout", "30");
2886 lpcfg_do_global_parameter(lp_ctx
, "locking", "True");
2888 lpcfg_do_global_parameter(lp_ctx
, "block size", "1024");
2890 lpcfg_do_global_parameter(lp_ctx
, "client use spnego", "True");
2892 lpcfg_do_global_parameter(lp_ctx
, "change notify", "True");
2894 lpcfg_do_global_parameter(lp_ctx
, "name cache timeout", "660");
2896 lpcfg_do_global_parameter(lp_ctx
, "defer sharing violations", "True");
2898 lpcfg_do_global_parameter(lp_ctx
, "ldap replication sleep", "1000");
2900 lpcfg_do_global_parameter(lp_ctx
, "idmap backend", "tdb");
2902 lpcfg_do_global_parameter(lp_ctx
, "enable privileges", "True");
2904 lpcfg_do_global_parameter_var(lp_ctx
, "smb2 max write", "%u", DEFAULT_SMB2_MAX_WRITE
);
2906 lpcfg_do_global_parameter(lp_ctx
, "passdb backend", "tdbsam");
2908 lpcfg_do_global_parameter(lp_ctx
, "deadtime", "10080");
2910 lpcfg_do_global_parameter(lp_ctx
, "getwd cache", "True");
2912 lpcfg_do_global_parameter(lp_ctx
, "winbind nested groups", "True");
2914 lpcfg_do_global_parameter(lp_ctx
, "mangled names", "illegal");
2916 lpcfg_do_global_parameter_var(lp_ctx
, "smb2 max credits", "%u", DEFAULT_SMB2_MAX_CREDITS
);
2918 lpcfg_do_global_parameter(lp_ctx
, "ldap ssl", "start tls");
2920 lpcfg_do_global_parameter(lp_ctx
, "ldap deref", "auto");
2922 lpcfg_do_global_parameter(lp_ctx
, "lm interval", "60");
2924 lpcfg_do_global_parameter(lp_ctx
, "mangling method", "hash2");
2926 lpcfg_do_global_parameter(lp_ctx
, "hide dot files", "True");
2928 lpcfg_do_global_parameter(lp_ctx
, "browse list", "True");
2930 lpcfg_do_global_parameter(lp_ctx
, "passwd chat timeout", "2");
2932 lpcfg_do_global_parameter(lp_ctx
, "guest account", GUEST_ACCOUNT
);
2934 lpcfg_do_global_parameter(lp_ctx
, "client schannel", "True");
2936 lpcfg_do_global_parameter(lp_ctx
, "smb encrypt", "default");
2938 lpcfg_do_global_parameter(lp_ctx
, "max log size", "5000");
2940 lpcfg_do_global_parameter(lp_ctx
, "idmap negative cache time", "120");
2942 lpcfg_do_global_parameter(lp_ctx
, "ldap follow referral", "auto");
2944 lpcfg_do_global_parameter(lp_ctx
, "multicast dns register", "yes");
2946 lpcfg_do_global_parameter(lp_ctx
, "winbind reconnect delay", "30");
2948 lpcfg_do_global_parameter(lp_ctx
, "winbind request timeout", "60");
2950 lpcfg_do_global_parameter(lp_ctx
, "nt acl support", "yes");
2952 lpcfg_do_global_parameter(lp_ctx
, "acl check permissions", "yes");
2954 lpcfg_do_global_parameter(lp_ctx
, "keepalive", "300");
2956 lpcfg_do_global_parameter(lp_ctx
, "smbd profiling level", "off");
2958 lpcfg_do_global_parameter(lp_ctx
, "winbind cache time", "300");
2960 lpcfg_do_global_parameter(lp_ctx
, "level2 oplocks", "yes");
2962 lpcfg_do_global_parameter(lp_ctx
, "show add printer wizard", "yes");
2964 lpcfg_do_global_parameter(lp_ctx
, "ldap page size", "1000");
2966 lpcfg_do_global_parameter(lp_ctx
, "kernel share modes", "no");
2968 lpcfg_do_global_parameter(lp_ctx
, "strict locking", "Auto");
2970 lpcfg_do_global_parameter(lp_ctx
, "strict sync", "yes");
2972 lpcfg_do_global_parameter(lp_ctx
, "map readonly", "no");
2974 lpcfg_do_global_parameter(lp_ctx
, "allow trusted domains", "yes");
2976 lpcfg_do_global_parameter(lp_ctx
, "default devmode", "yes");
2978 lpcfg_do_global_parameter(lp_ctx
, "os level", "20");
2980 lpcfg_do_global_parameter(lp_ctx
, "dos filetimes", "yes");
2982 lpcfg_do_global_parameter(lp_ctx
, "mangling char", "~");
2984 lpcfg_do_global_parameter(lp_ctx
, "printcap cache time", "750");
2986 lpcfg_do_global_parameter(lp_ctx
, "create krb5 conf", "yes");
2988 lpcfg_do_global_parameter(lp_ctx
, "winbind max clients", "200");
2990 lpcfg_do_global_parameter(lp_ctx
, "acl map full control", "yes");
2992 lpcfg_do_global_parameter(lp_ctx
, "nt pipe support", "yes");
2994 lpcfg_do_global_parameter(lp_ctx
, "ldap debug threshold", "10");
2996 lpcfg_do_global_parameter(lp_ctx
, "client ldap sasl wrapping", "seal");
2998 lpcfg_do_global_parameter(lp_ctx
, "mdns name", "netbios");
3000 lpcfg_do_global_parameter(lp_ctx
, "ldap server require strong auth", "yes");
3002 lpcfg_do_global_parameter(lp_ctx
, "follow symlinks", "yes");
3004 lpcfg_do_global_parameter(lp_ctx
, "machine password timeout", "604800");
3006 lpcfg_do_global_parameter(lp_ctx
, "ldap connection timeout", "2");
3008 lpcfg_do_global_parameter(lp_ctx
, "winbind expand groups", "0");
3010 lpcfg_do_global_parameter(lp_ctx
, "stat cache", "yes");
3012 lpcfg_do_global_parameter(lp_ctx
, "lpq cache time", "30");
3014 lpcfg_do_global_parameter_var(lp_ctx
, "smb2 max trans", "%u", DEFAULT_SMB2_MAX_TRANSACT
);
3016 lpcfg_do_global_parameter_var(lp_ctx
, "smb2 max read", "%u", DEFAULT_SMB2_MAX_READ
);
3018 lpcfg_do_global_parameter(lp_ctx
, "durable handles", "yes");
3020 lpcfg_do_global_parameter(lp_ctx
, "max stat cache size", "512");
3022 lpcfg_do_global_parameter(lp_ctx
, "ldap passwd sync", "no");
3024 lpcfg_do_global_parameter(lp_ctx
, "kernel change notify", "yes");
3026 lpcfg_do_global_parameter(lp_ctx
, "max ttl", "259200");
3028 lpcfg_do_global_parameter(lp_ctx
, "blocking locks", "yes");
3030 lpcfg_do_global_parameter(lp_ctx
, "load printers", "yes");
3032 lpcfg_do_global_parameter(lp_ctx
, "idmap cache time", "604800");
3034 lpcfg_do_global_parameter(lp_ctx
, "preserve case", "yes");
3036 lpcfg_do_global_parameter(lp_ctx
, "lm announce", "auto");
3038 lpcfg_do_global_parameter(lp_ctx
, "afs token lifetime", "604800");
3040 lpcfg_do_global_parameter(lp_ctx
, "enable core files", "yes");
3042 lpcfg_do_global_parameter(lp_ctx
, "winbind max domain connections", "1");
3044 lpcfg_do_global_parameter(lp_ctx
, "case sensitive", "auto");
3046 lpcfg_do_global_parameter(lp_ctx
, "ldap timeout", "15");
3048 lpcfg_do_global_parameter(lp_ctx
, "mangle prefix", "1");
3050 lpcfg_do_global_parameter(lp_ctx
, "posix locking", "yes");
3052 lpcfg_do_global_parameter(lp_ctx
, "lock spin time", "200");
3054 lpcfg_do_global_parameter(lp_ctx
, "nmbd bind explicit broadcast", "yes");
3056 lpcfg_do_global_parameter(lp_ctx
, "init logon delay", "100");
3058 lpcfg_do_global_parameter(lp_ctx
, "usershare owner only", "yes");
3060 lpcfg_do_global_parameter(lp_ctx
, "-valid", "yes");
3062 lpcfg_do_global_parameter_var(lp_ctx
, "usershare path", "%s/usershares", get_dyn_STATEDIR());
3065 lpcfg_do_global_parameter_var(lp_ctx
, "panic action", "/bin/sleep 999999999");
3068 lpcfg_do_global_parameter(lp_ctx
, "smb passwd file", get_dyn_SMB_PASSWD_FILE());
3070 lpcfg_do_global_parameter(lp_ctx
, "logon home", "\\\\%N\\%U");
3072 lpcfg_do_global_parameter(lp_ctx
, "logon path", "\\\\%N\\%U\\profile");
3074 lpcfg_do_global_parameter(lp_ctx
, "printjob username", "%U");
3076 lpcfg_do_global_parameter(lp_ctx
, "aio max threads", "100");
3078 lpcfg_do_global_parameter(lp_ctx
, "smb2 leases", "yes");
3080 lpcfg_do_global_parameter(lp_ctx
, "server multi channel support", "yes");
3082 lpcfg_do_global_parameter(lp_ctx
, "kerberos encryption types", "all");
3084 lpcfg_do_global_parameter(lp_ctx
,
3085 "rpc server dynamic port range",
3088 lpcfg_do_global_parameter(lp_ctx
, "prefork children", "4");
3089 lpcfg_do_global_parameter(lp_ctx
, "prefork backoff increment", "10");
3090 lpcfg_do_global_parameter(lp_ctx
, "prefork maximum backoff", "120");
3092 lpcfg_do_global_parameter(lp_ctx
, "check parent directory delete on close", "no");
3094 lpcfg_do_global_parameter(lp_ctx
, "ea support", "yes");
3096 lpcfg_do_global_parameter(lp_ctx
, "store dos attributes", "yes");
3098 lpcfg_do_global_parameter(lp_ctx
, "debug encryption", "no");
3100 lpcfg_do_global_parameter(lp_ctx
, "spotlight backend", "noindex");
3102 lpcfg_do_global_parameter(
3103 lp_ctx
, "ldap max anonymous request size", "256000");
3104 lpcfg_do_global_parameter(
3105 lp_ctx
, "ldap max authenticated request size", "16777216");
3106 lpcfg_do_global_parameter(
3107 lp_ctx
, "ldap max search request size", "256000");
3109 /* Async DNS query timeout in seconds. */
3110 lpcfg_do_global_parameter(lp_ctx
, "async dns timeout", "10");
3112 lpcfg_do_global_parameter(lp_ctx
,
3113 "client smb encrypt",
3116 lpcfg_do_global_parameter(lp_ctx
,
3117 "client use kerberos",
3120 lpcfg_do_global_parameter(lp_ctx
,
3121 "client protection",
3124 lpcfg_do_global_parameter(lp_ctx
,
3125 "smbd max xattr size",
3128 lpcfg_do_global_parameter(lp_ctx
,
3129 "acl flag inherited canonicalization",
3132 lpcfg_do_global_parameter(lp_ctx
,
3133 "winbind use krb5 enterprise principals",
3136 lpcfg_do_global_parameter(lp_ctx
,
3137 "client smb3 signing algorithms",
3138 DEFAULT_SMB3_SIGNING_ALGORITHMS
);
3139 lpcfg_do_global_parameter(lp_ctx
,
3140 "server smb3 signing algorithms",
3141 DEFAULT_SMB3_SIGNING_ALGORITHMS
);
3143 lpcfg_do_global_parameter(lp_ctx
,
3144 "client smb3 encryption algorithms",
3145 DEFAULT_SMB3_ENCRYPTION_ALGORITHMS
);
3146 lpcfg_do_global_parameter(lp_ctx
,
3147 "server smb3 encryption algorithms",
3148 DEFAULT_SMB3_ENCRYPTION_ALGORITHMS
);
3150 lpcfg_do_global_parameter(lp_ctx
,
3154 lpcfg_do_global_parameter(lp_ctx
,
3155 "rpc start on demand helpers",
3158 lpcfg_do_global_parameter(lp_ctx
,
3159 "ad dc functional level",
3162 lpcfg_do_global_parameter(lp_ctx
,
3163 "acl claims evaluation",
3166 for (i
= 0; parm_table
[i
].label
; i
++) {
3167 if (!(lp_ctx
->flags
[i
] & FLAG_CMDLINE
)) {
3168 lp_ctx
->flags
[i
] |= FLAG_DEFAULT
;
3172 for (parm
=lp_ctx
->globals
->param_opt
; parm
; parm
=parm
->next
) {
3173 if (!(parm
->priority
& FLAG_CMDLINE
)) {
3174 parm
->priority
|= FLAG_DEFAULT
;
3178 for (parm
=lp_ctx
->sDefault
->param_opt
; parm
; parm
=parm
->next
) {
3179 if (!(parm
->priority
& FLAG_CMDLINE
)) {
3180 parm
->priority
|= FLAG_DEFAULT
;
3188 * Initialise the global parameter structure.
3190 struct loadparm_context
*loadparm_init_global(bool load_default
)
3192 if (global_loadparm_context
== NULL
) {
3193 global_loadparm_context
= loadparm_init(NULL
);
3195 if (global_loadparm_context
== NULL
) {
3198 global_loadparm_context
->global
= true;
3199 if (load_default
&& !global_loadparm_context
->loaded
) {
3200 lpcfg_load_default(global_loadparm_context
);
3202 global_loadparm_context
->refuse_free
= true;
3203 return global_loadparm_context
;
3207 * @brief Initialise the global parameter structure.
3209 * This function initialized the globals if needed. Make sure that
3210 * gfree_loadparm() is called before the application exits.
3212 * @param mem_ctx The talloc memory context to allocate lp_ctx on.
3214 * @param s3_fns The loadparm helper functions to use
3216 * @return An initialized lp_ctx pointer or NULL on error.
3218 struct loadparm_context
*loadparm_init_s3(TALLOC_CTX
*mem_ctx
,
3219 const struct loadparm_s3_helpers
*s3_fns
)
3221 struct loadparm_context
*loadparm_context
= talloc_zero(mem_ctx
, struct loadparm_context
);
3222 if (!loadparm_context
) {
3225 loadparm_context
->s3_fns
= s3_fns
;
3226 loadparm_context
->globals
= s3_fns
->globals
;
3227 loadparm_context
->flags
= s3_fns
->flags
;
3229 /* Make sure globals are correctly initialized */
3230 loadparm_context
->s3_fns
->init_globals(loadparm_context
, false);
3232 return loadparm_context
;
3235 const char *lpcfg_configfile(struct loadparm_context
*lp_ctx
)
3237 return lp_ctx
->szConfigFile
;
3240 const char *lp_default_path(void)
3242 if (getenv("SMB_CONF_PATH"))
3243 return getenv("SMB_CONF_PATH");
3245 return dyn_CONFIGFILE
;
3249 * Update the internal state of a loadparm context after settings
3252 static bool lpcfg_update(struct loadparm_context
*lp_ctx
)
3254 struct debug_settings settings
;
3255 int max_protocol
, min_protocol
;
3256 TALLOC_CTX
*tmp_ctx
;
3257 const struct loadparm_substitution
*lp_sub
=
3258 lpcfg_noop_substitution();
3260 tmp_ctx
= talloc_new(lp_ctx
);
3261 if (tmp_ctx
== NULL
) {
3265 lpcfg_add_auto_services(lp_ctx
, lpcfg_auto_services(lp_ctx
, lp_sub
, tmp_ctx
));
3267 if (!lp_ctx
->globals
->wins_server_list
&& lp_ctx
->globals
->we_are_a_wins_server
) {
3268 lpcfg_do_global_parameter(lp_ctx
, "wins server", "127.0.0.1");
3271 if (!lp_ctx
->global
) {
3272 TALLOC_FREE(tmp_ctx
);
3276 panic_action
= lp_ctx
->globals
->panic_action
;
3278 reload_charcnv(lp_ctx
);
3280 ZERO_STRUCT(settings
);
3281 /* Add any more debug-related smb.conf parameters created in
3283 settings
.timestamp_logs
= lp_ctx
->globals
->timestamp_logs
;
3284 settings
.debug_prefix_timestamp
= lp_ctx
->globals
->debug_prefix_timestamp
;
3285 settings
.debug_hires_timestamp
= lp_ctx
->globals
->debug_hires_timestamp
;
3286 settings
.debug_syslog_format
= lp_ctx
->globals
->debug_syslog_format
;
3287 settings
.debug_pid
= lp_ctx
->globals
->debug_pid
;
3288 settings
.debug_uid
= lp_ctx
->globals
->debug_uid
;
3289 settings
.debug_class
= lp_ctx
->globals
->debug_class
;
3290 settings
.max_log_size
= lp_ctx
->globals
->max_log_size
;
3291 debug_set_settings(&settings
, lp_ctx
->globals
->logging
,
3292 lp_ctx
->globals
->syslog
,
3293 lp_ctx
->globals
->syslog_only
);
3295 /* FIXME: This is a bit of a hack, but we can't use a global, since
3296 * not everything that uses lp also uses the socket library */
3297 if (lpcfg_parm_bool(lp_ctx
, NULL
, "socket", "testnonblock", false)) {
3298 setenv("SOCKET_TESTNONBLOCK", "1", 1);
3300 unsetenv("SOCKET_TESTNONBLOCK");
3303 /* Check if command line max protocol < min protocol, if so
3304 * report a warning to the user.
3306 max_protocol
= lpcfg_client_max_protocol(lp_ctx
);
3307 min_protocol
= lpcfg_client_min_protocol(lp_ctx
);
3308 if (lpcfg_client_max_protocol(lp_ctx
) < lpcfg_client_min_protocol(lp_ctx
)) {
3309 const char *max_protocolp
, *min_protocolp
;
3310 max_protocolp
= lpcfg_get_smb_protocol(max_protocol
);
3311 min_protocolp
= lpcfg_get_smb_protocol(min_protocol
);
3312 DBG_ERR("Max protocol %s is less than min protocol %s.\n",
3313 max_protocolp
, min_protocolp
);
3316 TALLOC_FREE(tmp_ctx
);
3320 bool lpcfg_load_default(struct loadparm_context
*lp_ctx
)
3324 path
= lp_default_path();
3326 if (!file_exist(path
)) {
3327 /* We allow the default smb.conf file to not exist,
3328 * basically the equivalent of an empty file. */
3329 return lpcfg_update(lp_ctx
);
3332 return lpcfg_load(lp_ctx
, path
);
3336 * Load the services array from the services file.
3338 * Return True on success, False on failure.
3340 static bool lpcfg_load_internal(struct loadparm_context
*lp_ctx
,
3341 const char *filename
, bool set_global
)
3346 if (lp_ctx
->szConfigFile
!= NULL
) {
3347 talloc_free(discard_const_p(char, lp_ctx
->szConfigFile
));
3348 lp_ctx
->szConfigFile
= NULL
;
3351 lp_ctx
->szConfigFile
= talloc_strdup(lp_ctx
, filename
);
3353 if (lp_ctx
->s3_fns
) {
3354 return lp_ctx
->s3_fns
->load(filename
);
3357 lp_ctx
->bInGlobalSection
= true;
3358 n2
= standard_sub_basic(lp_ctx
, lp_ctx
->szConfigFile
);
3359 DEBUG(2, ("lpcfg_load: refreshing parameters from %s\n", n2
));
3361 add_to_file_list(lp_ctx
, &lp_ctx
->file_lists
, lp_ctx
->szConfigFile
, n2
);
3363 /* We get sections first, so have to start 'behind' to make up */
3364 lp_ctx
->currentService
= NULL
;
3365 bRetval
= pm_process(n2
, do_section
, lpcfg_do_parameter
, lp_ctx
);
3367 /* finish up the last section */
3368 DEBUG(4, ("pm_process() returned %s\n", BOOLSTR(bRetval
)));
3370 if (lp_ctx
->currentService
!= NULL
)
3371 bRetval
= lpcfg_service_ok(lp_ctx
->currentService
);
3373 bRetval
= bRetval
&& lpcfg_update(lp_ctx
);
3375 /* we do this unconditionally, so that it happens even
3376 for a missing smb.conf */
3377 reload_charcnv(lp_ctx
);
3379 if (bRetval
== true && set_global
) {
3380 /* set this up so that any child python tasks will
3381 find the right smb.conf */
3382 setenv("SMB_CONF_PATH", filename
, 1);
3384 /* set the context used by the lp_*() function
3386 global_loadparm_context
= lp_ctx
;
3387 lp_ctx
->loaded
= true;
3393 bool lpcfg_load_no_global(struct loadparm_context
*lp_ctx
, const char *filename
)
3395 return lpcfg_load_internal(lp_ctx
, filename
, false);
3398 bool lpcfg_load(struct loadparm_context
*lp_ctx
, const char *filename
)
3400 return lpcfg_load_internal(lp_ctx
, filename
, true);
3404 * Return the max number of services.
3407 int lpcfg_numservices(struct loadparm_context
*lp_ctx
)
3409 if (lp_ctx
->s3_fns
) {
3410 return lp_ctx
->s3_fns
->get_numservices();
3413 return lp_ctx
->iNumServices
;
3417 * Display the contents of the services array in human-readable form.
3420 void lpcfg_dump(struct loadparm_context
*lp_ctx
, FILE *f
, bool show_defaults
,
3425 if (lp_ctx
->s3_fns
) {
3426 lp_ctx
->s3_fns
->dump(f
, show_defaults
, maxtoprint
);
3430 lpcfg_dump_globals(lp_ctx
, f
, show_defaults
);
3432 lpcfg_dump_a_service(lp_ctx
->sDefault
, lp_ctx
->sDefault
, f
, lp_ctx
->flags
, show_defaults
);
3434 for (iService
= 0; iService
< maxtoprint
; iService
++)
3435 lpcfg_dump_one(f
, show_defaults
, lp_ctx
->services
[iService
], lp_ctx
->sDefault
);
3439 * Display the contents of one service in human-readable form.
3441 void lpcfg_dump_one(FILE *f
, bool show_defaults
, struct loadparm_service
*service
, struct loadparm_service
*sDefault
)
3443 if (service
!= NULL
) {
3444 if (service
->szService
[0] == '\0')
3446 lpcfg_dump_a_service(service
, sDefault
, f
, NULL
, show_defaults
);
3450 struct loadparm_service
*lpcfg_servicebynum(struct loadparm_context
*lp_ctx
,
3453 if (lp_ctx
->s3_fns
) {
3454 return lp_ctx
->s3_fns
->get_servicebynum(snum
);
3457 return lp_ctx
->services
[snum
];
3460 struct loadparm_service
*lpcfg_service(struct loadparm_context
*lp_ctx
,
3461 const char *service_name
)
3466 if (lp_ctx
->s3_fns
) {
3467 return lp_ctx
->s3_fns
->get_service(service_name
);
3470 for (iService
= lp_ctx
->iNumServices
- 1; iService
>= 0; iService
--) {
3471 if (lp_ctx
->services
[iService
] &&
3472 lp_ctx
->services
[iService
]->szService
) {
3474 * The substitution here is used to support %U is
3477 serviceName
= standard_sub_basic(
3478 lp_ctx
->services
[iService
],
3479 lp_ctx
->services
[iService
]->szService
);
3480 if (strequal(serviceName
, service_name
)) {
3481 talloc_free(serviceName
);
3482 return lp_ctx
->services
[iService
];
3484 talloc_free(serviceName
);
3488 DEBUG(7,("lpcfg_servicenumber: couldn't find %s\n", service_name
));
3492 const char *lpcfg_servicename(const struct loadparm_service
*service
)
3494 return service
? lpcfg_string((const char *)service
->szService
) : NULL
;
3497 struct smb_iconv_handle
*lpcfg_iconv_handle(struct loadparm_context
*lp_ctx
)
3499 if (lp_ctx
== NULL
) {
3500 return get_iconv_handle();
3502 return lp_ctx
->iconv_handle
;
3505 _PUBLIC_
void reload_charcnv(struct loadparm_context
*lp_ctx
)
3507 if (!lp_ctx
->global
) {
3511 lp_ctx
->iconv_handle
=
3512 reinit_iconv_handle(lp_ctx
,
3513 lpcfg_dos_charset(lp_ctx
),
3514 lpcfg_unix_charset(lp_ctx
));
3515 if (lp_ctx
->iconv_handle
== NULL
) {
3516 smb_panic("reinit_iconv_handle failed");
3520 _PUBLIC_
char *lpcfg_tls_keyfile(TALLOC_CTX
*mem_ctx
, struct loadparm_context
*lp_ctx
)
3522 return lpcfg_private_path(mem_ctx
, lp_ctx
, lpcfg__tls_keyfile(lp_ctx
));
3525 _PUBLIC_
char *lpcfg_tls_certfile(TALLOC_CTX
*mem_ctx
, struct loadparm_context
*lp_ctx
)
3527 return lpcfg_private_path(mem_ctx
, lp_ctx
, lpcfg__tls_certfile(lp_ctx
));
3530 _PUBLIC_
char *lpcfg_tls_cafile(TALLOC_CTX
*mem_ctx
, struct loadparm_context
*lp_ctx
)
3532 return lpcfg_private_path(mem_ctx
, lp_ctx
, lpcfg__tls_cafile(lp_ctx
));
3535 _PUBLIC_
char *lpcfg_tls_crlfile(TALLOC_CTX
*mem_ctx
, struct loadparm_context
*lp_ctx
)
3537 return lpcfg_private_path(mem_ctx
, lp_ctx
, lpcfg__tls_crlfile(lp_ctx
));
3540 _PUBLIC_
char *lpcfg_tls_dhpfile(TALLOC_CTX
*mem_ctx
, struct loadparm_context
*lp_ctx
)
3542 return lpcfg_private_path(mem_ctx
, lp_ctx
, lpcfg__tls_dhpfile(lp_ctx
));
3545 struct gensec_settings
*lpcfg_gensec_settings(TALLOC_CTX
*mem_ctx
, struct loadparm_context
*lp_ctx
)
3547 struct gensec_settings
*settings
= talloc_zero(mem_ctx
, struct gensec_settings
);
3548 if (settings
== NULL
)
3550 SMB_ASSERT(lp_ctx
!= NULL
);
3551 settings
->lp_ctx
= talloc_reference(settings
, lp_ctx
);
3552 settings
->target_hostname
= lpcfg_parm_string(lp_ctx
, NULL
, "gensec", "target_hostname");
3556 int lpcfg_server_role(struct loadparm_context
*lp_ctx
)
3558 int domain_master
= lpcfg__domain_master(lp_ctx
);
3560 return lp_find_server_role(lpcfg__server_role(lp_ctx
),
3561 lpcfg__security(lp_ctx
),
3562 lpcfg__domain_logons(lp_ctx
),
3563 (domain_master
== true) ||
3564 (domain_master
== Auto
));
3567 int lpcfg_security(struct loadparm_context
*lp_ctx
)
3569 return lp_find_security(lpcfg__server_role(lp_ctx
),
3570 lpcfg__security(lp_ctx
));
3573 int lpcfg_client_max_protocol(struct loadparm_context
*lp_ctx
)
3575 int client_max_protocol
= lpcfg__client_max_protocol(lp_ctx
);
3576 if (client_max_protocol
== PROTOCOL_DEFAULT
) {
3577 return PROTOCOL_LATEST
;
3579 return client_max_protocol
;
3582 int lpcfg_client_ipc_min_protocol(struct loadparm_context
*lp_ctx
)
3584 int client_ipc_min_protocol
= lpcfg__client_ipc_min_protocol(lp_ctx
);
3585 if (client_ipc_min_protocol
== PROTOCOL_DEFAULT
) {
3586 client_ipc_min_protocol
= lpcfg_client_min_protocol(lp_ctx
);
3588 if (client_ipc_min_protocol
< PROTOCOL_NT1
) {
3589 return PROTOCOL_NT1
;
3591 return client_ipc_min_protocol
;
3594 int lpcfg_client_ipc_max_protocol(struct loadparm_context
*lp_ctx
)
3596 int client_ipc_max_protocol
= lpcfg__client_ipc_max_protocol(lp_ctx
);
3597 if (client_ipc_max_protocol
== PROTOCOL_DEFAULT
) {
3598 return PROTOCOL_LATEST
;
3600 if (client_ipc_max_protocol
< PROTOCOL_NT1
) {
3601 return PROTOCOL_NT1
;
3603 return client_ipc_max_protocol
;
3606 int lpcfg_client_ipc_signing(struct loadparm_context
*lp_ctx
)
3608 int client_ipc_signing
= lpcfg__client_ipc_signing(lp_ctx
);
3609 if (client_ipc_signing
== SMB_SIGNING_DEFAULT
) {
3610 return SMB_SIGNING_REQUIRED
;
3612 return client_ipc_signing
;
3615 enum credentials_use_kerberos
lpcfg_client_use_kerberos(struct loadparm_context
*lp_ctx
)
3617 if (lpcfg_weak_crypto(lp_ctx
) == SAMBA_WEAK_CRYPTO_DISALLOWED
) {
3618 return CRED_USE_KERBEROS_REQUIRED
;
3621 return lpcfg__client_use_kerberos(lp_ctx
);
3624 bool lpcfg_server_signing_allowed(struct loadparm_context
*lp_ctx
, bool *mandatory
)
3626 bool allowed
= true;
3627 enum smb_signing_setting signing_setting
= lpcfg_server_signing(lp_ctx
);
3631 if (signing_setting
== SMB_SIGNING_DEFAULT
) {
3633 * If we are a domain controller, SMB signing is
3634 * really important, as it can prevent a number of
3635 * attacks on communications between us and the
3638 * However, it really sucks (no sendfile, CPU
3639 * overhead) performance-wise when used on a
3640 * file server, so disable it by default
3644 if (lpcfg_server_role(lp_ctx
) >= ROLE_ACTIVE_DIRECTORY_DC
) {
3645 signing_setting
= SMB_SIGNING_REQUIRED
;
3647 signing_setting
= SMB_SIGNING_OFF
;
3651 switch (signing_setting
) {
3652 case SMB_SIGNING_REQUIRED
:
3655 case SMB_SIGNING_DESIRED
:
3656 case SMB_SIGNING_IF_REQUIRED
:
3658 case SMB_SIGNING_OFF
:
3661 case SMB_SIGNING_DEFAULT
:
3662 case SMB_SIGNING_IPC_DEFAULT
:
3663 smb_panic(__location__
);
3670 int lpcfg_tdb_hash_size(struct loadparm_context
*lp_ctx
, const char *name
)
3678 base
= strrchr_m(name
, '/');
3684 return lpcfg_parm_int(lp_ctx
, NULL
, "tdb_hashsize", base
, 0);
3688 int lpcfg_tdb_flags(struct loadparm_context
*lp_ctx
, int tdb_flags
)
3690 if (!lpcfg_use_mmap(lp_ctx
)) {
3691 tdb_flags
|= TDB_NOMMAP
;
3697 * Do not allow LanMan auth if unless NTLMv1 is also allowed
3699 * This also ensures it is disabled if NTLM is totally disabled
3701 bool lpcfg_lanman_auth(struct loadparm_context
*lp_ctx
)
3703 enum ntlm_auth_level ntlm_auth_level
= lpcfg_ntlm_auth(lp_ctx
);
3705 if (ntlm_auth_level
== NTLM_AUTH_ON
) {
3706 return lpcfg__lanman_auth(lp_ctx
);
3712 static char *lpcfg_noop_substitution_fn(
3713 TALLOC_CTX
*mem_ctx
,
3714 const struct loadparm_substitution
*lp_sub
,
3715 const char *raw_value
,
3718 return talloc_strdup(mem_ctx
, raw_value
);
3721 static const struct loadparm_substitution global_noop_substitution
= {
3722 .substituted_string_fn
= lpcfg_noop_substitution_fn
,
3725 const struct loadparm_substitution
*lpcfg_noop_substitution(void)
3727 return &global_noop_substitution
;
3730 char *lpcfg_substituted_string(TALLOC_CTX
*mem_ctx
,
3731 const struct loadparm_substitution
*lp_sub
,
3732 const char *raw_value
)
3734 return lp_sub
->substituted_string_fn(mem_ctx
,
3737 lp_sub
->private_data
);
3741 * @brief Parse a string value of a given parameter to its integer enum value.
3743 * @param[in] param_name The parameter name (e.g. 'client smb encrypt')
3745 * @param[in] param_value The parameter value (e.g. 'required').
3747 * @return The integer value of the enum the param_value matches or INT32_MIN
3750 int32_t lpcfg_parse_enum_vals(const char *param_name
,
3751 const char *param_value
)
3753 struct parm_struct
*parm
= NULL
;
3754 int32_t ret
= INT32_MIN
;
3757 parm
= lpcfg_parm_struct(NULL
, param_name
);
3762 ok
= lp_set_enum_parm(parm
, param_value
, &ret
);
3770 const char *lpcfg_dns_hostname(struct loadparm_context
*lp_ctx
)
3772 const char *dns_hostname
= lpcfg__dns_hostname(lp_ctx
);
3773 const char *dns_domain
= lpcfg_dnsdomain(lp_ctx
);
3774 char *netbios_name
= NULL
;
3775 char *hostname
= NULL
;
3777 if (dns_hostname
!= NULL
&& dns_hostname
[0] != '\0') {
3778 return dns_hostname
;
3781 netbios_name
= strlower_talloc(lp_ctx
, lpcfg_netbios_name(lp_ctx
));
3782 if (netbios_name
== NULL
) {
3786 /* If it isn't set, try to initialize with [netbios name].[realm] */
3787 if (dns_domain
!= NULL
&& dns_domain
[0] != '\0') {
3788 hostname
= talloc_asprintf(lp_ctx
,
3793 hostname
= talloc_strdup(lp_ctx
, netbios_name
);
3795 TALLOC_FREE(netbios_name
);
3796 if (hostname
== NULL
) {
3800 lpcfg_string_set(lp_ctx
->globals
->ctx
,
3801 &lp_ctx
->globals
->_dns_hostname
,