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 #include "lib/param/loadparm.h"
65 #include "auth/gensec/gensec.h"
66 #include "lib/param/s3_param.h"
67 #include "lib/util/bitmap.h"
68 #include "libcli/smb/smb_constants.h"
70 #include "librpc/gen_ndr/nbt.h"
72 #ifdef HAVE_HTTPCONNECTENCRYPT
73 #include <cups/http.h>
76 #define standard_sub_basic talloc_strdup
78 #include "lib/param/param_global.h"
80 struct loadparm_service *lpcfg_default_service(struct loadparm_context *lp_ctx)
82 return lp_ctx->sDefault;
86 * Convenience routine to grab string parameters into temporary memory
87 * and run standard_sub_basic on them.
89 * The buffers can be written to by
90 * callers without affecting the source string.
93 static const char *lpcfg_string(const char *s)
95 #if 0 /* until REWRITE done to make thread-safe */
96 size_t len = s ? strlen(s) : 0;
100 /* The follow debug is useful for tracking down memory problems
101 especially if you have an inner loop that is calling a lp_*()
102 function that returns a string. Perhaps this debug should be
103 present all the time? */
106 DEBUG(10, ("lpcfg_string(%s)\n", s));
109 #if 0 /* until REWRITE done to make thread-safe */
111 lp_talloc = talloc_init("lp_talloc");
113 ret = talloc_array(lp_talloc, char, len + 100); /* leave room for substitution */
121 strlcpy(ret, s, len);
123 if (trim_string(ret, "\"", "\"")) {
124 if (strchr(ret,'"') != NULL)
125 strlcpy(ret, s, len);
128 standard_sub_basic(ret,len+100);
135 In this section all the functions that are used to access the
136 parameters from the rest of the program are defined
140 * the creation of separate lpcfg_*() and lp_*() functions is to allow
141 * for code compatibility between existing Samba4 and Samba3 code.
144 /* this global context supports the lp_*() function varients */
145 static struct loadparm_context *global_loadparm_context;
147 #define FN_GLOBAL_STRING(fn_name,var_name) \
148 _PUBLIC_ char *lpcfg_ ## fn_name(struct loadparm_context *lp_ctx, TALLOC_CTX *ctx) {\
149 if (lp_ctx == NULL) return NULL; \
150 if (lp_ctx->s3_fns) { \
151 return lp_ctx->globals->var_name ? lp_ctx->s3_fns->lp_string(ctx, lp_ctx->globals->var_name) : talloc_strdup(ctx, ""); \
153 return lp_ctx->globals->var_name ? talloc_strdup(ctx, lpcfg_string(lp_ctx->globals->var_name)) : talloc_strdup(ctx, ""); \
156 #define FN_GLOBAL_CONST_STRING(fn_name,var_name) \
157 _PUBLIC_ const char *lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) { \
158 if (lp_ctx == NULL) return NULL; \
159 return lp_ctx->globals->var_name ? lpcfg_string(lp_ctx->globals->var_name) : ""; \
162 #define FN_GLOBAL_LIST(fn_name,var_name) \
163 _PUBLIC_ const char **lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) { \
164 if (lp_ctx == NULL) return NULL; \
165 return lp_ctx->globals->var_name; \
168 #define FN_GLOBAL_BOOL(fn_name,var_name) \
169 _PUBLIC_ bool lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) {\
170 if (lp_ctx == NULL) return false; \
171 return lp_ctx->globals->var_name; \
174 #define FN_GLOBAL_INTEGER(fn_name,var_name) \
175 _PUBLIC_ int lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) { \
176 return lp_ctx->globals->var_name; \
179 /* Local parameters don't need the ->s3_fns because the struct
180 * loadparm_service is shared and lpcfg_service() checks the ->s3_fns
182 #define FN_LOCAL_STRING(fn_name,val) \
183 _PUBLIC_ char *lpcfg_ ## fn_name(struct loadparm_service *service, \
184 struct loadparm_service *sDefault, TALLOC_CTX *ctx) { \
185 return(talloc_strdup(ctx, lpcfg_string((const char *)((service != NULL && service->val != NULL) ? service->val : sDefault->val)))); \
188 #define FN_LOCAL_CONST_STRING(fn_name,val) \
189 _PUBLIC_ const char *lpcfg_ ## fn_name(struct loadparm_service *service, \
190 struct loadparm_service *sDefault) { \
191 return((const char *)((service != NULL && service->val != NULL) ? service->val : sDefault->val)); \
194 #define FN_LOCAL_LIST(fn_name,val) \
195 _PUBLIC_ const char **lpcfg_ ## fn_name(struct loadparm_service *service, \
196 struct loadparm_service *sDefault) {\
197 return(const char **)(service != NULL && service->val != NULL? service->val : sDefault->val); \
200 #define FN_LOCAL_PARM_BOOL(fn_name, val) FN_LOCAL_BOOL(fn_name, val)
202 #define FN_LOCAL_BOOL(fn_name,val) \
203 _PUBLIC_ bool lpcfg_ ## fn_name(struct loadparm_service *service, \
204 struct loadparm_service *sDefault) { \
205 return((service != NULL)? service->val : sDefault->val); \
208 #define FN_LOCAL_INTEGER(fn_name,val) \
209 _PUBLIC_ int lpcfg_ ## fn_name(struct loadparm_service *service, \
210 struct loadparm_service *sDefault) { \
211 return((service != NULL)? service->val : sDefault->val); \
214 #define FN_LOCAL_PARM_INTEGER(fn_name, val) FN_LOCAL_INTEGER(fn_name, val)
216 #define FN_LOCAL_CHAR(fn_name,val) \
217 _PUBLIC_ char lpcfg_ ## fn_name(struct loadparm_service *service, \
218 struct loadparm_service *sDefault) { \
219 return((service != NULL)? service->val : sDefault->val); \
222 #define FN_LOCAL_PARM_CHAR(fn_name,val) FN_LOCAL_CHAR(fn_name, val)
224 #include "lib/param/param_functions.c"
226 /* These functions cannot be auto-generated */
227 FN_LOCAL_BOOL(autoloaded, autoloaded)
228 FN_GLOBAL_CONST_STRING(dnsdomain, dnsdomain)
230 /* local prototypes */
231 static struct loadparm_service *lpcfg_getservicebyname(struct loadparm_context *lp_ctx,
232 const char *pszServiceName);
233 static bool do_section(const char *pszSectionName, void *);
234 static bool set_variable_helper(TALLOC_CTX *mem_ctx, int parmnum, void *parm_ptr,
235 const char *pszParmName, const char *pszParmValue);
236 static bool lp_do_parameter_parametric(struct loadparm_context *lp_ctx,
237 struct loadparm_service *service,
238 const char *pszParmName,
239 const char *pszParmValue, int flags);
241 /* The following are helper functions for parametrical options support. */
242 /* It returns a pointer to parametrical option value if it exists or NULL otherwise */
243 /* Actual parametrical functions are quite simple */
244 struct parmlist_entry *get_parametric_helper(struct loadparm_service *service,
245 const char *type, const char *option,
246 struct parmlist_entry *global_opts)
248 size_t type_len = strlen(type);
249 size_t option_len = strlen(option);
250 char param_key[type_len + option_len + 2];
251 struct parmlist_entry *data = NULL;
253 snprintf(param_key, sizeof(param_key), "%s:%s", type, option);
256 * Try to fetch the option from the data.
258 if (service != NULL) {
259 data = service->param_opt;
260 while (data != NULL) {
261 if (strwicmp(data->key, param_key) == 0) {
269 * Fall back to fetching from the globals.
272 while (data != NULL) {
273 if (strwicmp(data->key, param_key) == 0) {
282 const char *lpcfg_get_parametric(struct loadparm_context *lp_ctx,
283 struct loadparm_service *service,
284 const char *type, const char *option)
286 struct parmlist_entry *data;
291 data = get_parametric_helper(service,
292 type, option, lp_ctx->globals->param_opt);
303 * convenience routine to return int parameters.
305 int lp_int(const char *s)
309 DEBUG(0,("lp_int(%s): is called with NULL!\n",s));
313 return strtol(s, NULL, 0);
317 * convenience routine to return unsigned long parameters.
319 unsigned long lp_ulong(const char *s)
323 DEBUG(0,("lp_ulong(%s): is called with NULL!\n",s));
327 return strtoul(s, NULL, 0);
331 * convenience routine to return unsigned long parameters.
333 static long lp_long(const char *s)
337 DEBUG(0,("lp_long(%s): is called with NULL!\n",s));
341 return strtol(s, NULL, 0);
345 * convenience routine to return unsigned long parameters.
347 static double lp_double(const char *s)
351 DEBUG(0,("lp_double(%s): is called with NULL!\n",s));
355 return strtod(s, NULL);
359 * convenience routine to return boolean parameters.
361 bool lp_bool(const char *s)
366 DEBUG(0,("lp_bool(%s): is called with NULL!\n",s));
370 if (!set_boolean(s, &ret)) {
371 DEBUG(0,("lp_bool(%s): value is not boolean!\n",s));
379 * Return parametric option from a given service. Type is a part of option before ':'
380 * Parametric option has following syntax: 'Type: option = value'
381 * Returned value is allocated in 'lp_talloc' context
384 const char *lpcfg_parm_string(struct loadparm_context *lp_ctx,
385 struct loadparm_service *service, const char *type,
388 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
391 return lpcfg_string(value);
397 * Return parametric option from a given service. Type is a part of option before ':'
398 * Parametric option has following syntax: 'Type: option = value'
399 * Returned value is allocated in 'lp_talloc' context
402 const char **lpcfg_parm_string_list(TALLOC_CTX *mem_ctx,
403 struct loadparm_context *lp_ctx,
404 struct loadparm_service *service,
406 const char *option, const char *separator)
408 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
411 char **l = str_list_make(mem_ctx, value, separator);
412 return discard_const_p(const char *, l);
419 * Return parametric option from a given service. Type is a part of option before ':'
420 * Parametric option has following syntax: 'Type: option = value'
423 int lpcfg_parm_int(struct loadparm_context *lp_ctx,
424 struct loadparm_service *service, const char *type,
425 const char *option, int default_v)
427 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
430 return lp_int(value);
436 * Return parametric option from a given service. Type is a part of
438 * Parametric option has following syntax: 'Type: option = value'.
441 int lpcfg_parm_bytes(struct loadparm_context *lp_ctx,
442 struct loadparm_service *service, const char *type,
443 const char *option, int default_v)
447 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
449 if (value && conv_str_size_error(value, &bval)) {
450 if (bval <= INT_MAX) {
459 * Return parametric option from a given service.
460 * Type is a part of option before ':'
461 * Parametric option has following syntax: 'Type: option = value'
463 unsigned long lpcfg_parm_ulong(struct loadparm_context *lp_ctx,
464 struct loadparm_service *service, const char *type,
465 const char *option, unsigned long default_v)
467 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
470 return lp_ulong(value);
475 long lpcfg_parm_long(struct loadparm_context *lp_ctx,
476 struct loadparm_service *service, const char *type,
477 const char *option, long default_v)
479 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
482 return lp_long(value);
487 double lpcfg_parm_double(struct loadparm_context *lp_ctx,
488 struct loadparm_service *service, const char *type,
489 const char *option, double default_v)
491 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
494 return lp_double(value);
500 * Return parametric option from a given service. Type is a part of option before ':'
501 * Parametric option has following syntax: 'Type: option = value'
504 bool lpcfg_parm_bool(struct loadparm_context *lp_ctx,
505 struct loadparm_service *service, const char *type,
506 const char *option, bool default_v)
508 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
511 return lp_bool(value);
518 * Set a string value, deallocating any existing space, and allocing the space
521 bool lpcfg_string_set(TALLOC_CTX *mem_ctx, char **dest, const char *src)
528 *dest = talloc_strdup(mem_ctx, src);
529 if ((*dest) == NULL) {
530 DEBUG(0,("Out of memory in string_set\n"));
538 * Set a string value, deallocating any existing space, and allocing the space
541 bool lpcfg_string_set_upper(TALLOC_CTX *mem_ctx, char **dest, const char *src)
548 *dest = strupper_talloc(mem_ctx, src);
549 if ((*dest) == NULL) {
550 DEBUG(0,("Out of memory in string_set_upper\n"));
560 * Add a new service to the services array initialising it with the given
564 struct loadparm_service *lpcfg_add_service(struct loadparm_context *lp_ctx,
565 const struct loadparm_service *pservice,
569 int num_to_alloc = lp_ctx->iNumServices + 1;
570 struct parmlist_entry *data, *pdata;
572 if (lp_ctx->s3_fns != NULL) {
573 smb_panic("Add a service should not be called on an s3 loadparm ctx");
576 if (pservice == NULL) {
577 pservice = lp_ctx->sDefault;
580 /* it might already exist */
582 struct loadparm_service *service = lpcfg_getservicebyname(lp_ctx,
584 if (service != NULL) {
585 /* Clean all parametric options for service */
586 /* They will be added during parsing again */
587 data = service->param_opt;
593 service->param_opt = NULL;
598 /* find an invalid one */
599 for (i = 0; i < lp_ctx->iNumServices; i++)
600 if (lp_ctx->services[i] == NULL)
603 /* if not, then create one */
604 if (i == lp_ctx->iNumServices) {
605 struct loadparm_service **tsp;
607 tsp = talloc_realloc(lp_ctx, lp_ctx->services, struct loadparm_service *, num_to_alloc);
610 DEBUG(0,("lpcfg_add_service: failed to enlarge services!\n"));
613 lp_ctx->services = tsp;
614 lp_ctx->services[lp_ctx->iNumServices] = NULL;
617 lp_ctx->iNumServices++;
620 lp_ctx->services[i] = talloc_zero(lp_ctx->services, struct loadparm_service);
621 if (lp_ctx->services[i] == NULL) {
622 DEBUG(0,("lpcfg_add_service: out of memory!\n"));
625 copy_service(lp_ctx->services[i], pservice, NULL);
627 lpcfg_string_set(lp_ctx->services[i], &lp_ctx->services[i]->szService, name);
628 return lp_ctx->services[i];
632 * Add a new home service, with the specified home directory, defaults coming
633 * from service ifrom.
636 bool lpcfg_add_home(struct loadparm_context *lp_ctx,
637 const char *pszHomename,
638 struct loadparm_service *default_service,
639 const char *user, const char *pszHomedir)
641 struct loadparm_service *service;
643 service = lpcfg_add_service(lp_ctx, default_service, pszHomename);
648 if (!(*(default_service->path))
649 || strequal(default_service->path, lp_ctx->sDefault->path)) {
650 service->path = talloc_strdup(service, pszHomedir);
652 service->path = string_sub_talloc(service, lpcfg_path(default_service, lp_ctx->sDefault, service), "%H", pszHomedir);
655 if (!(*(service->comment))) {
656 service->comment = talloc_asprintf(service, "Home directory of %s", user);
658 service->available = default_service->available;
659 service->browseable = default_service->browseable;
661 DEBUG(3, ("adding home's share [%s] for user '%s' at '%s'\n",
662 pszHomename, user, service->path));
668 * Add a new printer service, with defaults coming from service iFrom.
671 bool lpcfg_add_printer(struct loadparm_context *lp_ctx,
672 const char *pszPrintername,
673 struct loadparm_service *default_service)
675 const char *comment = "From Printcap";
676 struct loadparm_service *service;
677 service = lpcfg_add_service(lp_ctx, default_service, pszPrintername);
682 /* note that we do NOT default the availability flag to True - */
683 /* we take it from the default service passed. This allows all */
684 /* dynamic printers to be disabled by disabling the [printers] */
685 /* entry (if/when the 'available' keyword is implemented!). */
687 /* the printer name is set to the service name. */
688 lpcfg_string_set(service, &service->_printername, pszPrintername);
689 lpcfg_string_set(service, &service->comment, comment);
690 service->browseable = default_service->browseable;
691 /* Printers cannot be read_only. */
692 service->read_only = false;
693 /* Printer services must be printable. */
694 service->printable = true;
696 DEBUG(3, ("adding printer service %s\n", pszPrintername));
702 * Map a parameter's string representation to something we can use.
703 * Returns False if the parameter string is not recognised, else TRUE.
706 int lpcfg_map_parameter(const char *pszParmName)
710 for (iIndex = 0; parm_table[iIndex].label; iIndex++)
711 if (strwicmp(parm_table[iIndex].label, pszParmName) == 0)
714 /* Warn only if it isn't parametric option */
715 if (strchr(pszParmName, ':') == NULL)
716 DEBUG(0, ("Unknown parameter encountered: \"%s\"\n", pszParmName));
717 /* We do return 'fail' for parametric options as well because they are
718 stored in different storage
725 return the parameter structure for a parameter
727 struct parm_struct *lpcfg_parm_struct(struct loadparm_context *lp_ctx, const char *name)
729 int num = lpcfg_map_parameter(name);
735 return &parm_table[num];
739 return the parameter pointer for a parameter
741 void *lpcfg_parm_ptr(struct loadparm_context *lp_ctx,
742 struct loadparm_service *service, struct parm_struct *parm)
744 if (lp_ctx->s3_fns) {
745 return lp_ctx->s3_fns->get_parm_ptr(service, parm);
748 if (service == NULL) {
749 if (parm->p_class == P_LOCAL)
750 return ((char *)lp_ctx->sDefault)+parm->offset;
751 else if (parm->p_class == P_GLOBAL)
752 return ((char *)lp_ctx->globals)+parm->offset;
755 return ((char *)service) + parm->offset;
760 return the parameter pointer for a parameter
762 bool lpcfg_parm_is_cmdline(struct loadparm_context *lp_ctx, const char *name)
766 parmnum = lpcfg_map_parameter(name);
767 if (parmnum == -1) return false;
769 return lp_ctx->flags[parmnum] & FLAG_CMDLINE;
773 * Find a service by name. Otherwise works like get_service.
776 static struct loadparm_service *lpcfg_getservicebyname(struct loadparm_context *lp_ctx,
777 const char *pszServiceName)
781 if (lp_ctx->s3_fns) {
782 return lp_ctx->s3_fns->get_service(pszServiceName);
785 for (iService = lp_ctx->iNumServices - 1; iService >= 0; iService--)
786 if (lp_ctx->services[iService] != NULL &&
787 strwicmp(lp_ctx->services[iService]->szService, pszServiceName) == 0) {
788 return lp_ctx->services[iService];
795 * Add a parametric option to a parmlist_entry,
796 * replacing old value, if already present.
798 void set_param_opt(TALLOC_CTX *mem_ctx,
799 struct parmlist_entry **opt_list,
800 const char *opt_name,
801 const char *opt_value,
804 struct parmlist_entry *new_opt, *opt;
808 /* Traverse destination */
810 /* If we already have same option, override it */
811 if (strwicmp(opt->key, opt_name) == 0) {
812 if ((opt->priority & FLAG_CMDLINE) &&
813 !(priority & FLAG_CMDLINE)) {
814 /* it's been marked as not to be
818 TALLOC_FREE(opt->value);
819 TALLOC_FREE(opt->list);
820 opt->value = talloc_strdup(opt, opt_value);
821 opt->priority = priority;
827 new_opt = talloc_pooled_object(
828 mem_ctx, struct parmlist_entry,
829 2, strlen(opt_name) + 1 + strlen(opt_value) + 1);
830 if (new_opt == NULL) {
833 new_opt->key = talloc_strdup(new_opt, opt_name);
834 new_opt->value = talloc_strdup(new_opt, opt_value);
836 new_opt->list = NULL;
837 new_opt->priority = priority;
838 DLIST_ADD(*opt_list, new_opt);
842 * Copy a service structure to another.
843 * If pcopymapDest is NULL then copy all fields
846 void copy_service(struct loadparm_service *pserviceDest,
847 const struct loadparm_service *pserviceSource,
848 struct bitmap *pcopymapDest)
851 bool bcopyall = (pcopymapDest == NULL);
852 struct parmlist_entry *data;
854 for (i = 0; parm_table[i].label; i++)
855 if (parm_table[i].p_class == P_LOCAL &&
856 (bcopyall || bitmap_query(pcopymapDest, i))) {
857 const void *src_ptr =
858 ((const char *)pserviceSource) + parm_table[i].offset;
860 ((char *)pserviceDest) + parm_table[i].offset;
862 switch (parm_table[i].type) {
865 *(bool *)dest_ptr = *(const bool *)src_ptr;
872 *(int *)dest_ptr = *(const int *)src_ptr;
876 *(char *)dest_ptr = *(const char *)src_ptr;
880 lpcfg_string_set(pserviceDest,
882 *(const char * const *)src_ptr);
886 lpcfg_string_set_upper(pserviceDest,
888 *(const char * const *)src_ptr);
892 TALLOC_FREE(*((char ***)dest_ptr));
893 *(char ***)dest_ptr = str_list_copy(pserviceDest,
894 *discard_const_p(const char **, src_ptr));
902 init_copymap(pserviceDest);
903 if (pserviceSource->copymap)
904 bitmap_copy(pserviceDest->copymap,
905 pserviceSource->copymap);
908 for (data = pserviceSource->param_opt; data != NULL; data = data->next) {
909 set_param_opt(pserviceDest, &pserviceDest->param_opt,
910 data->key, data->value, data->priority);
915 * Check a service for consistency. Return False if the service is in any way
916 * incomplete or faulty, else True.
918 bool lpcfg_service_ok(struct loadparm_service *service)
923 if (service->szService[0] == '\0') {
924 DEBUG(0, ("The following message indicates an internal error:\n"));
925 DEBUG(0, ("No service name in service entry.\n"));
929 /* The [printers] entry MUST be printable. I'm all for flexibility, but */
930 /* I can't see why you'd want a non-printable printer service... */
931 if (strwicmp(service->szService, PRINTERS_NAME) == 0) {
932 if (!service->printable) {
933 DEBUG(0, ("WARNING: [%s] service MUST be printable!\n",
934 service->szService));
935 service->printable = true;
937 /* [printers] service must also be non-browsable. */
938 if (service->browseable)
939 service->browseable = false;
942 if (service->path[0] == '\0' &&
943 strwicmp(service->szService, HOMES_NAME) != 0 &&
944 service->msdfs_proxy[0] == '\0')
946 DEBUG(0, ("WARNING: No path in service %s - making it unavailable!\n",
947 service->szService));
948 service->available = false;
951 if (!service->available)
952 DEBUG(1, ("NOTE: Service %s is flagged unavailable.\n",
953 service->szService));
959 /*******************************************************************
960 Keep a linked list of all config files so we know when one has changed
961 it's date and needs to be reloaded.
962 ********************************************************************/
964 void add_to_file_list(TALLOC_CTX *mem_ctx, struct file_lists **list,
965 const char *fname, const char *subfname)
967 struct file_lists *f = *list;
970 if (f->name && !strcmp(f->name, fname))
976 f = talloc(mem_ctx, struct file_lists);
980 f->name = talloc_strdup(f, fname);
985 f->subfname = talloc_strdup(f, subfname);
991 f->modtime = file_modtime(subfname);
993 time_t t = file_modtime(subfname);
1000 DEBUG(0, ("Unable to add file to file list: %s\n", fname));
1004 /*******************************************************************
1005 Check if a config file has changed date.
1006 ********************************************************************/
1007 bool lpcfg_file_list_changed(struct loadparm_context *lp_ctx)
1009 struct file_lists *f;
1010 DEBUG(6, ("lpcfg_file_list_changed()\n"));
1012 for (f = lp_ctx->file_lists; f != NULL; f = f->next) {
1016 n2 = standard_sub_basic(lp_ctx, f->name);
1018 DEBUGADD(6, ("file %s -> %s last mod_time: %s\n",
1019 f->name, n2, ctime(&f->modtime)));
1021 mod_time = file_modtime(n2);
1023 if (mod_time && ((f->modtime != mod_time) || (f->subfname == NULL) || (strcmp(n2, f->subfname) != 0))) {
1024 DEBUGADD(6, ("file %s modified: %s\n", n2,
1026 f->modtime = mod_time;
1027 talloc_free(f->subfname);
1028 f->subfname = talloc_strdup(f, n2);
1038 * set the value for a P_ENUM
1040 bool lp_set_enum_parm( struct parm_struct *parm, const char *pszParmValue,
1045 for (i = 0; parm->enum_list[i].name; i++) {
1046 if (strwicmp(pszParmValue, parm->enum_list[i].name) == 0) {
1047 *ptr = parm->enum_list[i].value;
1051 DEBUG(0, ("WARNING: Ignoring invalid value '%s' for parameter '%s'\n",
1052 pszParmValue, parm->label));
1057 /***************************************************************************
1058 Handle the "realm" parameter
1059 ***************************************************************************/
1061 bool handle_realm(struct loadparm_context *lp_ctx, struct loadparm_service *service,
1062 const char *pszParmValue, char **ptr)
1067 upper = strupper_talloc(lp_ctx, pszParmValue);
1068 if (upper == NULL) {
1072 lower = strlower_talloc(lp_ctx, pszParmValue);
1073 if (lower == NULL) {
1078 lpcfg_string_set(lp_ctx->globals->ctx, &lp_ctx->globals->realm_original, pszParmValue);
1079 lpcfg_string_set(lp_ctx->globals->ctx, &lp_ctx->globals->realm, upper);
1080 lpcfg_string_set(lp_ctx->globals->ctx, &lp_ctx->globals->dnsdomain, lower);
1085 /***************************************************************************
1086 Handle the include operation.
1087 ***************************************************************************/
1089 bool handle_include(struct loadparm_context *lp_ctx, struct loadparm_service *service,
1090 const char *pszParmValue, char **ptr)
1094 if (lp_ctx->s3_fns) {
1095 return lp_ctx->s3_fns->lp_include(lp_ctx, service, pszParmValue, ptr);
1098 fname = standard_sub_basic(lp_ctx, pszParmValue);
1100 add_to_file_list(lp_ctx, &lp_ctx->file_lists, pszParmValue, fname);
1102 lpcfg_string_set(lp_ctx, ptr, fname);
1104 if (file_exist(fname))
1105 return pm_process(fname, do_section, lpcfg_do_parameter, lp_ctx);
1107 DEBUG(2, ("Can't find include file %s\n", fname));
1112 /***************************************************************************
1113 Handle the interpretation of the copy parameter.
1114 ***************************************************************************/
1116 bool handle_copy(struct loadparm_context *lp_ctx, struct loadparm_service *service,
1117 const char *pszParmValue, char **ptr)
1120 struct loadparm_service *serviceTemp = NULL;
1124 DEBUG(3, ("Copying service from service %s\n", pszParmValue));
1126 serviceTemp = lpcfg_getservicebyname(lp_ctx, pszParmValue);
1128 if (service == NULL) {
1129 DEBUG(0, ("Unable to copy service - invalid service destination.\n"));
1133 if (serviceTemp != NULL) {
1134 if (serviceTemp == service) {
1135 DEBUG(0, ("Can't copy service %s - unable to copy self!\n", pszParmValue));
1137 copy_service(service,
1140 lpcfg_string_set(service, ptr, pszParmValue);
1145 DEBUG(0, ("Unable to copy service - source not found: %s\n",
1153 bool handle_debug_list(struct loadparm_context *lp_ctx, struct loadparm_service *service,
1154 const char *pszParmValue, char **ptr)
1156 lpcfg_string_set(lp_ctx->globals->ctx, ptr, pszParmValue);
1158 return debug_parse_levels(pszParmValue);
1161 bool handle_logfile(struct loadparm_context *lp_ctx, struct loadparm_service *service,
1162 const char *pszParmValue, char **ptr)
1164 if (lp_ctx->s3_fns == NULL) {
1165 debug_set_logfile(pszParmValue);
1168 lpcfg_string_set(lp_ctx->globals->ctx, ptr, pszParmValue);
1174 * These special charset handling methods only run in the source3 code.
1177 bool handle_charset(struct loadparm_context *lp_ctx, struct loadparm_service *service,
1178 const char *pszParmValue, char **ptr)
1180 if (lp_ctx->s3_fns) {
1181 if (*ptr == NULL || strcmp(*ptr, pszParmValue) != 0) {
1182 global_iconv_handle = smb_iconv_handle_reinit(NULL,
1183 lpcfg_dos_charset(lp_ctx),
1184 lpcfg_unix_charset(lp_ctx),
1185 true, global_iconv_handle);
1189 return lpcfg_string_set(lp_ctx->globals->ctx, ptr, pszParmValue);
1193 bool handle_dos_charset(struct loadparm_context *lp_ctx, struct loadparm_service *service,
1194 const char *pszParmValue, char **ptr)
1196 bool is_utf8 = false;
1197 size_t len = strlen(pszParmValue);
1199 if (lp_ctx->s3_fns) {
1200 if (len == 4 || len == 5) {
1201 /* Don't use StrCaseCmp here as we don't want to
1202 initialize iconv. */
1203 if ((toupper_m(pszParmValue[0]) == 'U') &&
1204 (toupper_m(pszParmValue[1]) == 'T') &&
1205 (toupper_m(pszParmValue[2]) == 'F')) {
1207 if (pszParmValue[3] == '8') {
1211 if (pszParmValue[3] == '-' &&
1212 pszParmValue[4] == '8') {
1219 if (*ptr == NULL || strcmp(*ptr, pszParmValue) != 0) {
1221 DEBUG(0,("ERROR: invalid DOS charset: 'dos charset' must not "
1222 "be UTF8, using (default value) %s instead.\n",
1223 DEFAULT_DOS_CHARSET));
1224 pszParmValue = DEFAULT_DOS_CHARSET;
1226 global_iconv_handle = smb_iconv_handle_reinit(NULL,
1227 lpcfg_dos_charset(lp_ctx),
1228 lpcfg_unix_charset(lp_ctx),
1229 true, global_iconv_handle);
1233 return lpcfg_string_set(lp_ctx->globals->ctx, ptr, pszParmValue);
1236 bool handle_printing(struct loadparm_context *lp_ctx, struct loadparm_service *service,
1237 const char *pszParmValue, char **ptr)
1239 static int parm_num = -1;
1241 if (parm_num == -1) {
1242 parm_num = lpcfg_map_parameter("printing");
1245 if (!lp_set_enum_parm(&parm_table[parm_num], pszParmValue, (int*)ptr)) {
1249 if (lp_ctx->s3_fns) {
1250 if (service == NULL) {
1251 init_printer_values(lp_ctx, lp_ctx->globals->ctx, lp_ctx->sDefault);
1253 init_printer_values(lp_ctx, service, service);
1260 bool handle_ldap_debug_level(struct loadparm_context *lp_ctx, struct loadparm_service *service,
1261 const char *pszParmValue, char **ptr)
1263 lp_ctx->globals->ldap_debug_level = lp_int(pszParmValue);
1265 if (lp_ctx->s3_fns) {
1266 lp_ctx->s3_fns->init_ldap_debugging();
1271 bool handle_netbios_aliases(struct loadparm_context *lp_ctx, struct loadparm_service *service,
1272 const char *pszParmValue, char **ptr)
1274 TALLOC_FREE(lp_ctx->globals->netbios_aliases);
1275 lp_ctx->globals->netbios_aliases = str_list_make_v3_const(lp_ctx->globals->ctx,
1276 pszParmValue, NULL);
1278 if (lp_ctx->s3_fns) {
1279 return lp_ctx->s3_fns->set_netbios_aliases(lp_ctx->globals->netbios_aliases);
1285 * idmap related parameters
1288 bool handle_idmap_backend(struct loadparm_context *lp_ctx, struct loadparm_service *service,
1289 const char *pszParmValue, char **ptr)
1291 if (lp_ctx->s3_fns) {
1292 lp_do_parameter_parametric(lp_ctx, service, "idmap config * : backend",
1296 return lpcfg_string_set(lp_ctx->globals->ctx, ptr, pszParmValue);
1299 bool handle_idmap_uid(struct loadparm_context *lp_ctx, struct loadparm_service *service,
1300 const char *pszParmValue, char **ptr)
1302 if (lp_ctx->s3_fns) {
1303 lp_do_parameter_parametric(lp_ctx, service, "idmap config * : range",
1307 return lpcfg_string_set(lp_ctx->globals->ctx, ptr, pszParmValue);
1310 bool handle_idmap_gid(struct loadparm_context *lp_ctx, struct loadparm_service *service,
1311 const char *pszParmValue, char **ptr)
1313 if (lp_ctx->s3_fns) {
1314 lp_do_parameter_parametric(lp_ctx, service, "idmap config * : range",
1318 return lpcfg_string_set(lp_ctx->globals->ctx, ptr, pszParmValue);
1321 bool handle_smb_ports(struct loadparm_context *lp_ctx, struct loadparm_service *service,
1322 const char *pszParmValue, char **ptr)
1324 static int parm_num = -1;
1328 if (!pszParmValue || !*pszParmValue) {
1332 if (parm_num == -1) {
1333 parm_num = lpcfg_map_parameter("smb ports");
1334 if (parm_num == -1) {
1339 if(!set_variable_helper(lp_ctx->globals->ctx, parm_num, ptr, "smb ports",
1344 list = lp_ctx->globals->smb_ports;
1349 /* Check that each port is a valid integer and within range */
1350 for (i = 0; list[i] != NULL; i++) {
1353 port = strtol(list[i], &end, 10);
1354 if (*end != '\0' || port <= 0 || port > 65535) {
1363 bool handle_smb2_max_credits(struct loadparm_context *lp_ctx,
1364 struct loadparm_service *service,
1365 const char *pszParmValue, char **ptr)
1367 int value = lp_int(pszParmValue);
1370 value = DEFAULT_SMB2_MAX_CREDITS;
1373 *(int *)ptr = value;
1378 bool handle_cups_encrypt(struct loadparm_context *lp_ctx,
1379 struct loadparm_service *service,
1380 const char *pszParmValue, char **ptr)
1383 #ifdef HAVE_HTTPCONNECTENCRYPT
1384 int value = lp_int(pszParmValue);
1388 result = HTTP_ENCRYPT_REQUIRED;
1391 result = HTTP_ENCRYPT_ALWAYS;
1394 result = HTTP_ENCRYPT_NEVER;
1401 *(int *)ptr = result;
1406 /***************************************************************************
1407 Initialise a copymap.
1408 ***************************************************************************/
1411 * Initializes service copymap
1412 * Note: pservice *must* be valid TALLOC_CTX
1414 void init_copymap(struct loadparm_service *pservice)
1418 TALLOC_FREE(pservice->copymap);
1420 pservice->copymap = bitmap_talloc(pservice, num_parameters());
1421 if (!pservice->copymap) {
1423 ("Couldn't allocate copymap!! (size %d)\n",
1424 (int)num_parameters()));
1426 for (i = 0; i < num_parameters(); i++) {
1427 bitmap_set(pservice->copymap, i);
1433 * Process a parametric option
1435 static bool lp_do_parameter_parametric(struct loadparm_context *lp_ctx,
1436 struct loadparm_service *service,
1437 const char *pszParmName,
1438 const char *pszParmValue, int flags)
1440 struct parmlist_entry **data;
1442 TALLOC_CTX *mem_ctx;
1444 while (isspace((unsigned char)*pszParmName)) {
1448 name = strlower_talloc(lp_ctx, pszParmName);
1449 if (!name) return false;
1451 if (service == NULL) {
1452 data = &lp_ctx->globals->param_opt;
1454 * s3 code cannot deal with parametric options stored on the globals ctx.
1456 if (lp_ctx->s3_fns != NULL) {
1459 mem_ctx = lp_ctx->globals->ctx;
1462 data = &service->param_opt;
1466 set_param_opt(mem_ctx, data, name, pszParmValue, flags);
1473 static bool set_variable_helper(TALLOC_CTX *mem_ctx, int parmnum, void *parm_ptr,
1474 const char *pszParmName, const char *pszParmValue)
1478 /* switch on the type of variable it is */
1479 switch (parm_table[parmnum].type)
1483 if (!set_boolean(pszParmValue, &b)) {
1484 DEBUG(0, ("set_variable_helper(%s): value is not "
1485 "boolean!\n", pszParmValue));
1488 *(bool *)parm_ptr = b;
1494 if (!set_boolean(pszParmValue, &b)) {
1495 DEBUG(0, ("set_variable_helper(%s): value is not "
1496 "boolean!\n", pszParmValue));
1499 *(bool *)parm_ptr = !b;
1504 *(int *)parm_ptr = lp_int(pszParmValue);
1508 *(char *)parm_ptr = *pszParmValue;
1512 i = sscanf(pszParmValue, "%o", (int *)parm_ptr);
1514 DEBUG ( 0, ("Invalid octal number %s\n", pszParmName ));
1522 if (conv_str_size_error(pszParmValue, &val)) {
1523 if (val <= INT_MAX) {
1524 *(int *)parm_ptr = (int)val;
1529 DEBUG(0, ("set_variable_helper(%s): value is not "
1530 "a valid size specifier!\n", pszParmValue));
1535 TALLOC_FREE(*(char ***)parm_ptr);
1536 *(char ***)parm_ptr = str_list_make_v3(mem_ctx,
1537 pszParmValue, NULL);
1542 char **new_list = str_list_make_v3(mem_ctx,
1543 pszParmValue, NULL);
1544 if (new_list == NULL) {
1548 for (i=0; new_list[i]; i++) {
1549 if (*(const char ***)parm_ptr != NULL &&
1550 new_list[i][0] == '+' &&
1553 if (!str_list_check(*(const char ***)parm_ptr,
1555 *(const char ***)parm_ptr = str_list_add(*(const char ***)parm_ptr,
1558 } else if (*(const char ***)parm_ptr != NULL &&
1559 new_list[i][0] == '-' &&
1562 str_list_remove(*(const char ***)parm_ptr,
1566 DEBUG(0, ("Unsupported list syntax for: %s = %s\n",
1567 pszParmName, pszParmValue));
1570 *(char ***)parm_ptr = new_list;
1578 lpcfg_string_set(mem_ctx, (char **)parm_ptr, pszParmValue);
1582 lpcfg_string_set_upper(mem_ctx, (char **)parm_ptr, pszParmValue);
1586 if (!lp_set_enum_parm(&parm_table[parmnum], pszParmValue, (int*)parm_ptr)) {
1597 static bool set_variable(TALLOC_CTX *mem_ctx, struct loadparm_service *service,
1598 int parmnum, void *parm_ptr,
1599 const char *pszParmName, const char *pszParmValue,
1600 struct loadparm_context *lp_ctx, bool on_globals)
1605 /* if it is a special case then go ahead */
1606 if (parm_table[parmnum].special) {
1607 ok = parm_table[parmnum].special(lp_ctx, service, pszParmValue,
1610 ok = set_variable_helper(mem_ctx, parmnum, parm_ptr,
1611 pszParmName, pszParmValue);
1618 if (on_globals && (lp_ctx->flags[parmnum] & FLAG_DEFAULT)) {
1619 lp_ctx->flags[parmnum] &= ~FLAG_DEFAULT;
1620 /* we have to also unset FLAG_DEFAULT on aliases */
1621 for (i=parmnum-1;i>=0 && parm_table[i].offset == parm_table[parmnum].offset;i--) {
1622 lp_ctx->flags[i] &= ~FLAG_DEFAULT;
1624 for (i=parmnum+1;i<num_parameters() && parm_table[i].offset == parm_table[parmnum].offset;i++) {
1625 lp_ctx->flags[i] &= ~FLAG_DEFAULT;
1632 bool lpcfg_do_global_parameter(struct loadparm_context *lp_ctx,
1633 const char *pszParmName, const char *pszParmValue)
1635 int parmnum = lpcfg_map_parameter(pszParmName);
1639 if (strchr(pszParmName, ':')) {
1640 return lp_do_parameter_parametric(lp_ctx, NULL, pszParmName, pszParmValue, 0);
1642 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName));
1646 /* if the flag has been set on the command line, then don't allow override,
1647 but don't report an error */
1648 if (lp_ctx->flags[parmnum] & FLAG_CMDLINE) {
1652 if (parm_table[parmnum].flags & FLAG_DEPRECATED) {
1653 DEBUG(1, ("WARNING: The \"%s\" option is deprecated\n",
1657 parm_ptr = lpcfg_parm_ptr(lp_ctx, NULL, &parm_table[parmnum]);
1659 return set_variable(lp_ctx->globals->ctx, NULL, parmnum, parm_ptr,
1660 pszParmName, pszParmValue, lp_ctx, true);
1663 bool lpcfg_do_service_parameter(struct loadparm_context *lp_ctx,
1664 struct loadparm_service *service,
1665 const char *pszParmName, const char *pszParmValue)
1669 int parmnum = lpcfg_map_parameter(pszParmName);
1672 if (strchr(pszParmName, ':')) {
1673 return lp_do_parameter_parametric(lp_ctx, service, pszParmName, pszParmValue, 0);
1675 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName));
1679 /* if the flag has been set on the command line, then don't allow override,
1680 but don't report an error */
1681 if (lp_ctx->flags[parmnum] & FLAG_CMDLINE) {
1685 if (parm_table[parmnum].flags & FLAG_DEPRECATED) {
1686 DEBUG(1, ("WARNING: The \"%s\" option is deprecated\n",
1690 if (parm_table[parmnum].p_class == P_GLOBAL) {
1692 ("Global parameter %s found in service section!\n",
1696 parm_ptr = ((char *)service) + parm_table[parmnum].offset;
1698 if (!service->copymap)
1699 init_copymap(service);
1701 /* this handles the aliases - set the copymap for other
1702 * entries with the same data pointer */
1703 for (i = 0; parm_table[i].label; i++)
1704 if (parm_table[i].offset == parm_table[parmnum].offset &&
1705 parm_table[i].p_class == parm_table[parmnum].p_class)
1706 bitmap_clear(service->copymap, i);
1708 return set_variable(service, service, parmnum, parm_ptr, pszParmName,
1709 pszParmValue, lp_ctx, false);
1713 * Process a parameter.
1716 bool lpcfg_do_parameter(const char *pszParmName, const char *pszParmValue,
1719 struct loadparm_context *lp_ctx = (struct loadparm_context *)userdata;
1721 if (lp_ctx->bInGlobalSection)
1722 return lpcfg_do_global_parameter(lp_ctx, pszParmName,
1725 return lpcfg_do_service_parameter(lp_ctx, lp_ctx->currentService,
1726 pszParmName, pszParmValue);
1730 variable argument do parameter
1732 bool lpcfg_do_global_parameter_var(struct loadparm_context *lp_ctx, const char *pszParmName, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4);
1733 bool lpcfg_do_global_parameter_var(struct loadparm_context *lp_ctx,
1734 const char *pszParmName, const char *fmt, ...)
1741 s = talloc_vasprintf(NULL, fmt, ap);
1743 ret = lpcfg_do_global_parameter(lp_ctx, pszParmName, s);
1750 set a parameter from the commandline - this is called from command line parameter
1751 parsing code. It sets the parameter then marks the parameter as unable to be modified
1752 by smb.conf processing
1754 bool lpcfg_set_cmdline(struct loadparm_context *lp_ctx, const char *pszParmName,
1755 const char *pszParmValue)
1760 while (isspace((unsigned char)*pszParmValue)) pszParmValue++;
1762 parmnum = lpcfg_map_parameter(pszParmName);
1764 if (parmnum < 0 && strchr(pszParmName, ':')) {
1765 /* set a parametric option */
1767 ok = lp_do_parameter_parametric(lp_ctx, NULL, pszParmName,
1768 pszParmValue, FLAG_CMDLINE);
1769 if (lp_ctx->s3_fns != NULL) {
1771 lp_ctx->s3_fns->store_cmdline(pszParmName, pszParmValue);
1778 DEBUG(0,("Unknown option '%s'\n", pszParmName));
1782 /* reset the CMDLINE flag in case this has been called before */
1783 lp_ctx->flags[parmnum] &= ~FLAG_CMDLINE;
1785 if (!lpcfg_do_global_parameter(lp_ctx, pszParmName, pszParmValue)) {
1789 lp_ctx->flags[parmnum] |= FLAG_CMDLINE;
1791 /* we have to also set FLAG_CMDLINE on aliases */
1793 i>=0 && parm_table[i].p_class == parm_table[parmnum].p_class &&
1794 parm_table[i].offset == parm_table[parmnum].offset;
1796 lp_ctx->flags[i] |= FLAG_CMDLINE;
1799 i<num_parameters() &&
1800 parm_table[i].p_class == parm_table[parmnum].p_class &&
1801 parm_table[i].offset == parm_table[parmnum].offset;
1803 lp_ctx->flags[i] |= FLAG_CMDLINE;
1806 if (lp_ctx->s3_fns != NULL) {
1807 lp_ctx->s3_fns->store_cmdline(pszParmName, pszParmValue);
1814 set a option from the commandline in 'a=b' format. Use to support --option
1816 bool lpcfg_set_option(struct loadparm_context *lp_ctx, const char *option)
1821 s = talloc_strdup(NULL, option);
1834 ret = lpcfg_set_cmdline(lp_ctx, s, p+1);
1840 #define BOOLSTR(b) ((b) ? "Yes" : "No")
1843 * Print a parameter of the specified type.
1846 void lpcfg_print_parameter(struct parm_struct *p, void *ptr, FILE * f)
1848 /* For the seperation of lists values that we print below */
1849 const char *list_sep = ", ";
1854 for (i = 0; p->enum_list[i].name; i++) {
1855 if (*(int *)ptr == p->enum_list[i].value) {
1857 p->enum_list[i].name);
1864 fprintf(f, "%s", BOOLSTR(*(bool *)ptr));
1868 fprintf(f, "%s", BOOLSTR(!*(bool *)ptr));
1873 fprintf(f, "%d", *(int *)ptr);
1877 fprintf(f, "%c", *(char *)ptr);
1881 int val = *(int *)ptr;
1885 fprintf(f, "0%03o", val);
1894 if ((char ***)ptr && *(char ***)ptr) {
1895 char **list = *(char ***)ptr;
1896 for (; *list; list++) {
1897 /* surround strings with whitespace in double quotes */
1898 if (*(list+1) == NULL) {
1899 /* last item, no extra separator */
1902 if ( strchr_m( *list, ' ' ) ) {
1903 fprintf(f, "\"%s\"%s", *list, list_sep);
1905 fprintf(f, "%s%s", *list, list_sep);
1913 if (*(char **)ptr) {
1914 fprintf(f, "%s", *(char **)ptr);
1921 * Check if two parameters are equal.
1924 static bool lpcfg_equal_parameter(parm_type type, void *ptr1, void *ptr2)
1929 return (*((bool *)ptr1) == *((bool *)ptr2));
1935 return (*((int *)ptr1) == *((int *)ptr2));
1938 return (*((char *)ptr1) == *((char *)ptr2));
1942 return str_list_equal(*(const char ***)ptr1, *(const char ***)ptr2);
1947 char *p1 = *(char **)ptr1, *p2 = *(char **)ptr2;
1952 return (p1 == p2 || strequal(p1, p2));
1959 * Process a new section (service).
1961 * At this stage all sections are services.
1962 * Later we'll have special sections that permit server parameters to be set.
1963 * Returns True on success, False on failure.
1966 static bool do_section(const char *pszSectionName, void *userdata)
1968 struct loadparm_context *lp_ctx = (struct loadparm_context *)userdata;
1972 if (lp_ctx->s3_fns != NULL) {
1973 return lp_ctx->s3_fns->do_section(pszSectionName, lp_ctx);
1976 isglobal = ((strwicmp(pszSectionName, GLOBAL_NAME) == 0) ||
1977 (strwicmp(pszSectionName, GLOBAL_NAME2) == 0));
1981 /* if we've just struck a global section, note the fact. */
1982 lp_ctx->bInGlobalSection = isglobal;
1984 /* check for multiple global sections */
1985 if (lp_ctx->bInGlobalSection) {
1986 DEBUG(4, ("Processing section \"[%s]\"\n", pszSectionName));
1990 /* if we have a current service, tidy it up before moving on */
1993 if (lp_ctx->currentService != NULL)
1994 bRetval = lpcfg_service_ok(lp_ctx->currentService);
1996 /* if all is still well, move to the next record in the services array */
1998 /* We put this here to avoid an odd message order if messages are */
1999 /* issued by the post-processing of a previous section. */
2000 DEBUG(4, ("Processing section \"[%s]\"\n", pszSectionName));
2002 if ((lp_ctx->currentService = lpcfg_add_service(lp_ctx, lp_ctx->sDefault,
2005 DEBUG(0, ("Failed to add a new service\n"));
2015 * Determine if a particular base parameter is currently set to the default value.
2018 static bool is_default(void *base_structure, int i)
2020 void *def_ptr = ((char *)base_structure) + parm_table[i].offset;
2021 switch (parm_table[i].type) {
2024 return str_list_equal((const char * const *)parm_table[i].def.lvalue,
2025 *(const char * const **)def_ptr);
2028 return strequal(parm_table[i].def.svalue,
2032 return parm_table[i].def.bvalue ==
2039 return parm_table[i].def.ivalue ==
2046 *Display the contents of the global structure.
2049 void lpcfg_dump_globals(struct loadparm_context *lp_ctx, FILE *f,
2053 struct parmlist_entry *data;
2055 fprintf(f, "# Global parameters\n[global]\n");
2057 for (i = 0; parm_table[i].label; i++) {
2058 if (parm_table[i].p_class != P_GLOBAL) {
2062 if (parm_table[i].flags & FLAG_SYNONYM) {
2066 if (!show_defaults) {
2067 if (lp_ctx->flags && (lp_ctx->flags[i] & FLAG_DEFAULT)) {
2071 if (is_default(lp_ctx->globals, i)) {
2076 fprintf(f, "\t%s = ", parm_table[i].label);
2077 lpcfg_print_parameter(&parm_table[i], lpcfg_parm_ptr(lp_ctx, NULL, &parm_table[i]), f);
2080 if (lp_ctx->globals->param_opt != NULL) {
2081 for (data = lp_ctx->globals->param_opt; data;
2082 data = data->next) {
2083 if (!show_defaults && (data->priority & FLAG_DEFAULT)) {
2086 fprintf(f, "\t%s = %s\n", data->key, data->value);
2093 * Display the contents of a single services record.
2096 void lpcfg_dump_a_service(struct loadparm_service * pService, struct loadparm_service *sDefault, FILE * f,
2097 unsigned int *flags, bool show_defaults)
2100 struct parmlist_entry *data;
2102 if (pService != sDefault)
2103 fprintf(f, "\n[%s]\n", pService->szService);
2105 for (i = 0; parm_table[i].label; i++) {
2106 if (parm_table[i].p_class != P_LOCAL) {
2110 if (parm_table[i].flags & FLAG_SYNONYM) {
2114 if (*parm_table[i].label == '-') {
2118 if (pService == sDefault) {
2119 if (!show_defaults) {
2120 if (flags && (flags[i] & FLAG_DEFAULT)) {
2124 if (is_default(sDefault, i)) {
2131 equal = lpcfg_equal_parameter(parm_table[i].type,
2132 ((char *)pService) +
2133 parm_table[i].offset,
2134 ((char *)sDefault) +
2135 parm_table[i].offset);
2141 fprintf(f, "\t%s = ", parm_table[i].label);
2142 lpcfg_print_parameter(&parm_table[i],
2143 ((char *)pService) + parm_table[i].offset, f);
2146 if (pService->param_opt != NULL) {
2147 for (data = pService->param_opt; data; data = data->next) {
2148 if (!show_defaults && (data->priority & FLAG_DEFAULT)) {
2151 fprintf(f, "\t%s = %s\n", data->key, data->value);
2156 bool lpcfg_dump_a_parameter(struct loadparm_context *lp_ctx,
2157 struct loadparm_service *service,
2158 const char *parm_name, FILE * f)
2160 struct parm_struct *parm;
2162 char *local_parm_name;
2164 const char *parm_opt_value;
2166 /* check for parametrical option */
2167 local_parm_name = talloc_strdup(lp_ctx, parm_name);
2168 if (local_parm_name == NULL) {
2172 parm_opt = strchr( local_parm_name, ':');
2177 if (strlen(parm_opt)) {
2178 parm_opt_value = lpcfg_parm_string(lp_ctx, service,
2179 local_parm_name, parm_opt);
2180 if (parm_opt_value) {
2181 fprintf(f, "%s\n", parm_opt_value);
2188 /* parameter is not parametric, search the table */
2189 parm = lpcfg_parm_struct(lp_ctx, parm_name);
2194 if (service != NULL && parm->p_class == P_GLOBAL) {
2198 ptr = lpcfg_parm_ptr(lp_ctx, service,parm);
2200 lpcfg_print_parameter(parm, ptr, f);
2206 * Auto-load some home services.
2208 static void lpcfg_add_auto_services(struct loadparm_context *lp_ctx,
2214 /***************************************************************************
2215 Initialise the sDefault parameter structure for the printer values.
2216 ***************************************************************************/
2218 void init_printer_values(struct loadparm_context *lp_ctx, TALLOC_CTX *ctx,
2219 struct loadparm_service *pService)
2221 /* choose defaults depending on the type of printing */
2222 switch (pService->printing) {
2227 lpcfg_string_set(ctx, &pService->lpq_command, "lpq -P'%p'");
2228 lpcfg_string_set(ctx, &pService->lprm_command, "lprm -P'%p' %j");
2229 lpcfg_string_set(ctx, &pService->print_command, "lpr -r -P'%p' %s");
2234 lpcfg_string_set(ctx, &pService->lpq_command, "lpq -P'%p'");
2235 lpcfg_string_set(ctx, &pService->lprm_command, "lprm -P'%p' %j");
2236 lpcfg_string_set(ctx, &pService->print_command, "lpr -r -P'%p' %s");
2237 lpcfg_string_set(ctx, &pService->queuepause_command, "lpc stop '%p'");
2238 lpcfg_string_set(ctx, &pService->queueresume_command, "lpc start '%p'");
2239 lpcfg_string_set(ctx, &pService->lppause_command, "lpc hold '%p' %j");
2240 lpcfg_string_set(ctx, &pService->lpresume_command, "lpc release '%p' %j");
2245 /* set the lpq command to contain the destination printer
2246 name only. This is used by cups_queue_get() */
2247 lpcfg_string_set(ctx, &pService->lpq_command, "%p");
2248 lpcfg_string_set(ctx, &pService->lprm_command, "");
2249 lpcfg_string_set(ctx, &pService->print_command, "");
2250 lpcfg_string_set(ctx, &pService->lppause_command, "");
2251 lpcfg_string_set(ctx, &pService->lpresume_command, "");
2252 lpcfg_string_set(ctx, &pService->queuepause_command, "");
2253 lpcfg_string_set(ctx, &pService->queueresume_command, "");
2258 lpcfg_string_set(ctx, &pService->lpq_command, "lpstat -o%p");
2259 lpcfg_string_set(ctx, &pService->lprm_command, "cancel %p-%j");
2260 lpcfg_string_set(ctx, &pService->print_command, "lp -c -d%p %s; rm %s");
2261 lpcfg_string_set(ctx, &pService->queuepause_command, "disable %p");
2262 lpcfg_string_set(ctx, &pService->queueresume_command, "enable %p");
2264 lpcfg_string_set(ctx, &pService->lppause_command, "lp -i %p-%j -H hold");
2265 lpcfg_string_set(ctx, &pService->lpresume_command, "lp -i %p-%j -H resume");
2270 lpcfg_string_set(ctx, &pService->lpq_command, "lpq -P%p");
2271 lpcfg_string_set(ctx, &pService->lprm_command, "lprm -P%p %j");
2272 lpcfg_string_set(ctx, &pService->print_command, "lp -r -P%p %s");
2275 #if defined(DEVELOPER) || defined(ENABLE_SELFTEST)
2279 const char *tdbfile;
2280 TALLOC_CTX *tmp_ctx = talloc_new(ctx);
2283 tmp = lpcfg_parm_string(lp_ctx, NULL, "vlp", "tdbfile");
2285 tmp = "/tmp/vlp.tdb";
2288 tdbfile = talloc_asprintf(tmp_ctx, "tdbfile=%s", tmp);
2289 if (tdbfile == NULL) {
2290 tdbfile="tdbfile=/tmp/vlp.tdb";
2293 tmp = talloc_asprintf(tmp_ctx, "vlp %s print %%p %%s",
2295 lpcfg_string_set(ctx, &pService->print_command,
2296 tmp ? tmp : "vlp print %p %s");
2298 tmp = talloc_asprintf(tmp_ctx, "vlp %s lpq %%p",
2300 lpcfg_string_set(ctx, &pService->lpq_command,
2301 tmp ? tmp : "vlp lpq %p");
2303 tmp = talloc_asprintf(tmp_ctx, "vlp %s lprm %%p %%j",
2305 lpcfg_string_set(ctx, &pService->lprm_command,
2306 tmp ? tmp : "vlp lprm %p %j");
2308 tmp = talloc_asprintf(tmp_ctx, "vlp %s lppause %%p %%j",
2310 lpcfg_string_set(ctx, &pService->lppause_command,
2311 tmp ? tmp : "vlp lppause %p %j");
2313 tmp = talloc_asprintf(tmp_ctx, "vlp %s lpresume %%p %%j",
2315 lpcfg_string_set(ctx, &pService->lpresume_command,
2316 tmp ? tmp : "vlp lpresume %p %j");
2318 tmp = talloc_asprintf(tmp_ctx, "vlp %s queuepause %%p",
2320 lpcfg_string_set(ctx, &pService->queuepause_command,
2321 tmp ? tmp : "vlp queuepause %p");
2323 tmp = talloc_asprintf(tmp_ctx, "vlp %s queueresume %%p",
2325 lpcfg_string_set(ctx, &pService->queueresume_command,
2326 tmp ? tmp : "vlp queueresume %p");
2327 TALLOC_FREE(tmp_ctx);
2331 #endif /* DEVELOPER */
2337 * Unload unused services.
2340 void lpcfg_killunused(struct loadparm_context *lp_ctx,
2341 struct smbsrv_connection *smb,
2342 bool (*snumused) (struct smbsrv_connection *, int))
2346 if (lp_ctx->s3_fns != NULL) {
2347 smb_panic("Cannot be used from an s3 loadparm ctx");
2350 for (i = 0; i < lp_ctx->iNumServices; i++) {
2351 if (lp_ctx->services[i] == NULL)
2354 if (!snumused || !snumused(smb, i)) {
2355 talloc_free(lp_ctx->services[i]);
2356 lp_ctx->services[i] = NULL;
2362 static int lpcfg_destructor(struct loadparm_context *lp_ctx)
2364 struct parmlist_entry *data;
2366 if (lp_ctx->refuse_free) {
2367 /* someone is trying to free the
2368 global_loadparm_context.
2369 We can't allow that. */
2373 if (lp_ctx->globals->param_opt != NULL) {
2374 struct parmlist_entry *next;
2375 for (data = lp_ctx->globals->param_opt; data; data=next) {
2377 if (data->priority & FLAG_CMDLINE) continue;
2378 DLIST_REMOVE(lp_ctx->globals->param_opt, data);
2386 struct defaults_hook_data {
2388 lpcfg_defaults_hook hook;
2389 struct defaults_hook_data *prev, *next;
2390 } *defaults_hooks = NULL;
2393 bool lpcfg_register_defaults_hook(const char *name, lpcfg_defaults_hook hook)
2395 struct defaults_hook_data *hook_data = talloc(talloc_autofree_context(),
2396 struct defaults_hook_data);
2397 hook_data->name = talloc_strdup(hook_data, name);
2398 hook_data->hook = hook;
2399 DLIST_ADD(defaults_hooks, hook_data);
2404 * Initialise the global parameter structure.
2406 * Note that most callers should use loadparm_init_global() instead
2408 struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
2412 struct loadparm_context *lp_ctx;
2413 struct parmlist_entry *parm;
2415 struct defaults_hook_data *defaults_hook;
2417 lp_ctx = talloc_zero(mem_ctx, struct loadparm_context);
2421 talloc_set_destructor(lp_ctx, lpcfg_destructor);
2422 lp_ctx->bInGlobalSection = true;
2423 lp_ctx->globals = talloc_zero(lp_ctx, struct loadparm_global);
2424 /* This appears odd, but globals in s3 isn't a pointer */
2425 lp_ctx->globals->ctx = lp_ctx->globals;
2426 lp_ctx->sDefault = talloc_zero(lp_ctx, struct loadparm_service);
2427 lp_ctx->flags = talloc_zero_array(lp_ctx, unsigned int, num_parameters());
2429 lp_ctx->sDefault->max_print_jobs = 1000;
2430 lp_ctx->sDefault->available = true;
2431 lp_ctx->sDefault->browseable = true;
2432 lp_ctx->sDefault->read_only = true;
2433 lp_ctx->sDefault->map_archive = true;
2434 lp_ctx->sDefault->strict_locking = true;
2435 lp_ctx->sDefault->oplocks = true;
2436 lp_ctx->sDefault->create_mask = 0744;
2437 lp_ctx->sDefault->force_create_mode = 0000;
2438 lp_ctx->sDefault->directory_mask = 0755;
2439 lp_ctx->sDefault->force_directory_mode = 0000;
2441 DEBUG(3, ("Initialising global parameters\n"));
2443 for (i = 0; parm_table[i].label; i++) {
2444 if ((parm_table[i].type == P_STRING ||
2445 parm_table[i].type == P_USTRING) &&
2446 !(lp_ctx->flags[i] & FLAG_CMDLINE)) {
2448 if (parm_table[i].p_class == P_LOCAL) {
2449 r = (char **)(((char *)lp_ctx->sDefault) + parm_table[i].offset);
2451 r = (char **)(((char *)lp_ctx->globals) + parm_table[i].offset);
2453 *r = talloc_strdup(lp_ctx, "");
2457 logfile = talloc_asprintf(lp_ctx, "%s/log.samba", dyn_LOGFILEBASE);
2458 lpcfg_do_global_parameter(lp_ctx, "log file", logfile);
2459 talloc_free(logfile);
2461 lpcfg_do_global_parameter(lp_ctx, "log level", "0");
2463 lpcfg_do_global_parameter(lp_ctx, "syslog", "1");
2464 lpcfg_do_global_parameter(lp_ctx, "syslog only", "No");
2465 lpcfg_do_global_parameter(lp_ctx, "debug timestamp", "Yes");
2466 lpcfg_do_global_parameter(lp_ctx, "debug prefix timestamp", "No");
2467 lpcfg_do_global_parameter(lp_ctx, "debug hires timestamp", "Yes");
2468 lpcfg_do_global_parameter(lp_ctx, "debug pid", "No");
2469 lpcfg_do_global_parameter(lp_ctx, "debug uid", "No");
2470 lpcfg_do_global_parameter(lp_ctx, "debug class", "No");
2472 lpcfg_do_global_parameter(lp_ctx, "share backend", "classic");
2474 lpcfg_do_global_parameter(lp_ctx, "server role", "auto");
2475 lpcfg_do_global_parameter(lp_ctx, "domain logons", "No");
2476 lpcfg_do_global_parameter(lp_ctx, "domain master", "Auto");
2478 /* options that can be set on the command line must be initialised via
2479 the slower lpcfg_do_global_parameter() to ensure that FLAG_CMDLINE is obeyed */
2481 lpcfg_do_global_parameter(lp_ctx, "socket options", "TCP_NODELAY");
2483 lpcfg_do_global_parameter(lp_ctx, "workgroup", DEFAULT_WORKGROUP);
2484 myname = get_myname(lp_ctx);
2485 lpcfg_do_global_parameter(lp_ctx, "netbios name", myname);
2486 talloc_free(myname);
2487 lpcfg_do_global_parameter(lp_ctx, "name resolve order", "lmhosts wins host bcast");
2489 lpcfg_do_global_parameter(lp_ctx, "fstype", "NTFS");
2491 lpcfg_do_global_parameter(lp_ctx, "ntvfs handler", "unixuid default");
2492 lpcfg_do_global_parameter(lp_ctx, "max connections", "0");
2494 lpcfg_do_global_parameter(lp_ctx, "dcerpc endpoint servers", "epmapper wkssvc rpcecho samr netlogon lsarpc spoolss drsuapi dssetup unixinfo browser eventlog6 backupkey dnsserver");
2495 lpcfg_do_global_parameter(lp_ctx, "server services", "s3fs rpc nbt wrepl ldap cldap kdc drepl winbindd ntp_signd kcc dnsupdate dns");
2496 lpcfg_do_global_parameter(lp_ctx, "kccsrv:samba_kcc", "false");
2497 /* the winbind method for domain controllers is for both RODC
2498 auth forwarding and for trusted domains */
2499 lpcfg_do_global_parameter(lp_ctx, "private dir", dyn_PRIVATE_DIR);
2500 lpcfg_do_global_parameter(lp_ctx, "registry:HKEY_LOCAL_MACHINE", "hklm.ldb");
2502 /* This hive should be dynamically generated by Samba using
2503 data from the sam, but for the moment leave it in a tdb to
2504 keep regedt32 from popping up an annoying dialog. */
2505 lpcfg_do_global_parameter(lp_ctx, "registry:HKEY_USERS", "hku.ldb");
2507 /* using UTF8 by default allows us to support all chars */
2508 lpcfg_do_global_parameter(lp_ctx, "unix charset", "UTF-8");
2510 /* Use codepage 850 as a default for the dos character set */
2511 lpcfg_do_global_parameter(lp_ctx, "dos charset", "CP850");
2514 * Allow the default PASSWD_CHAT to be overridden in local.h.
2516 lpcfg_do_global_parameter(lp_ctx, "passwd chat", DEFAULT_PASSWD_CHAT);
2518 lpcfg_do_global_parameter(lp_ctx, "pid directory", dyn_PIDDIR);
2519 lpcfg_do_global_parameter(lp_ctx, "lock dir", dyn_LOCKDIR);
2520 lpcfg_do_global_parameter(lp_ctx, "state directory", dyn_STATEDIR);
2521 lpcfg_do_global_parameter(lp_ctx, "cache directory", dyn_CACHEDIR);
2522 lpcfg_do_global_parameter(lp_ctx, "ncalrpc dir", dyn_NCALRPCDIR);
2524 lpcfg_do_global_parameter(lp_ctx, "nbt client socket address", "0.0.0.0");
2525 lpcfg_do_global_parameter_var(lp_ctx, "server string",
2526 "Samba %s", SAMBA_VERSION_STRING);
2528 lpcfg_do_global_parameter(lp_ctx, "password server", "*");
2530 lpcfg_do_global_parameter(lp_ctx, "max mux", "50");
2531 lpcfg_do_global_parameter(lp_ctx, "max xmit", "16644");
2532 lpcfg_do_global_parameter(lp_ctx, "host msdfs", "true");
2534 lpcfg_do_global_parameter(lp_ctx, "LargeReadwrite", "True");
2535 lpcfg_do_global_parameter(lp_ctx, "server min protocol", "LANMAN1");
2536 lpcfg_do_global_parameter(lp_ctx, "server max protocol", "SMB3");
2537 lpcfg_do_global_parameter(lp_ctx, "client min protocol", "CORE");
2538 lpcfg_do_global_parameter(lp_ctx, "client max protocol", "default");
2539 lpcfg_do_global_parameter(lp_ctx, "security", "AUTO");
2540 lpcfg_do_global_parameter(lp_ctx, "EncryptPasswords", "True");
2541 lpcfg_do_global_parameter(lp_ctx, "ReadRaw", "True");
2542 lpcfg_do_global_parameter(lp_ctx, "WriteRaw", "True");
2543 lpcfg_do_global_parameter(lp_ctx, "NullPasswords", "False");
2544 lpcfg_do_global_parameter(lp_ctx, "old password allowed period", "60");
2545 lpcfg_do_global_parameter(lp_ctx, "ObeyPamRestrictions", "False");
2547 lpcfg_do_global_parameter(lp_ctx, "TimeServer", "False");
2548 lpcfg_do_global_parameter(lp_ctx, "BindInterfacesOnly", "False");
2549 lpcfg_do_global_parameter(lp_ctx, "Unicode", "True");
2550 lpcfg_do_global_parameter(lp_ctx, "ClientLanManAuth", "False");
2551 lpcfg_do_global_parameter(lp_ctx, "ClientNTLMv2Auth", "True");
2552 lpcfg_do_global_parameter(lp_ctx, "LanmanAuth", "False");
2553 lpcfg_do_global_parameter(lp_ctx, "NTLMAuth", "True");
2554 lpcfg_do_global_parameter(lp_ctx, "client use spnego principal", "False");
2556 lpcfg_do_global_parameter(lp_ctx, "UnixExtensions", "True");
2558 lpcfg_do_global_parameter(lp_ctx, "PreferredMaster", "Auto");
2559 lpcfg_do_global_parameter(lp_ctx, "LocalMaster", "True");
2561 lpcfg_do_global_parameter(lp_ctx, "wins support", "False");
2562 lpcfg_do_global_parameter(lp_ctx, "dns proxy", "True");
2564 lpcfg_do_global_parameter(lp_ctx, "winbind separator", "\\");
2565 lpcfg_do_global_parameter(lp_ctx, "winbind sealed pipes", "True");
2566 lpcfg_do_global_parameter(lp_ctx, "require strong key", "True");
2567 lpcfg_do_global_parameter(lp_ctx, "winbindd socket directory", dyn_WINBINDD_SOCKET_DIR);
2568 lpcfg_do_global_parameter(lp_ctx, "winbindd privileged socket directory", dyn_WINBINDD_PRIVILEGED_SOCKET_DIR);
2569 lpcfg_do_global_parameter(lp_ctx, "ntp signd socket directory", dyn_NTP_SIGND_SOCKET_DIR);
2570 lpcfg_do_global_parameter_var(lp_ctx, "dns update command", "%s/samba_dnsupdate", dyn_SCRIPTSBINDIR);
2571 lpcfg_do_global_parameter_var(lp_ctx, "spn update command", "%s/samba_spnupdate", dyn_SCRIPTSBINDIR);
2572 lpcfg_do_global_parameter_var(lp_ctx, "samba kcc command",
2573 "%s/samba_kcc", dyn_SCRIPTSBINDIR);
2574 lpcfg_do_global_parameter(lp_ctx, "template shell", "/bin/false");
2575 lpcfg_do_global_parameter(lp_ctx, "template homedir", "/home/%D/%U");
2577 lpcfg_do_global_parameter(lp_ctx, "client signing", "default");
2578 lpcfg_do_global_parameter(lp_ctx, "server signing", "default");
2580 lpcfg_do_global_parameter(lp_ctx, "use spnego", "True");
2582 lpcfg_do_global_parameter(lp_ctx, "use mmap", "True");
2584 lpcfg_do_global_parameter(lp_ctx, "smb ports", "445 139");
2585 lpcfg_do_global_parameter_var(lp_ctx, "nbt port", "%d", NBT_NAME_SERVICE_PORT);
2586 lpcfg_do_global_parameter_var(lp_ctx, "dgram port", "%d", NBT_DGRAM_SERVICE_PORT);
2587 lpcfg_do_global_parameter(lp_ctx, "cldap port", "389");
2588 lpcfg_do_global_parameter(lp_ctx, "krb5 port", "88");
2589 lpcfg_do_global_parameter(lp_ctx, "kpasswd port", "464");
2590 lpcfg_do_global_parameter(lp_ctx, "web port", "901");
2592 lpcfg_do_global_parameter(lp_ctx, "nt status support", "True");
2594 lpcfg_do_global_parameter(lp_ctx, "max wins ttl", "518400"); /* 6 days */
2595 lpcfg_do_global_parameter(lp_ctx, "min wins ttl", "21600");
2597 lpcfg_do_global_parameter(lp_ctx, "tls enabled", "True");
2598 lpcfg_do_global_parameter(lp_ctx, "tls keyfile", "tls/key.pem");
2599 lpcfg_do_global_parameter(lp_ctx, "tls certfile", "tls/cert.pem");
2600 lpcfg_do_global_parameter(lp_ctx, "tls cafile", "tls/ca.pem");
2601 lpcfg_do_global_parameter(lp_ctx, "tls priority", "NORMAL:-VERS-SSL3.0");
2602 lpcfg_do_global_parameter(lp_ctx, "prefork children:smb", "4");
2604 lpcfg_do_global_parameter(lp_ctx, "rndc command", "/usr/sbin/rndc");
2605 lpcfg_do_global_parameter(lp_ctx, "nsupdate command", "/usr/bin/nsupdate -g");
2607 lpcfg_do_global_parameter(lp_ctx, "allow dns updates", "secure only");
2608 lpcfg_do_global_parameter(lp_ctx, "dns forwarder", "");
2610 lpcfg_do_global_parameter(lp_ctx, "algorithmic rid base", "1000");
2612 lpcfg_do_global_parameter(lp_ctx, "enhanced browsing", "True");
2614 lpcfg_do_global_parameter(lp_ctx, "winbind nss info", "template");
2616 lpcfg_do_global_parameter(lp_ctx, "server schannel", "Auto");
2618 lpcfg_do_global_parameter(lp_ctx, "short preserve case", "True");
2620 lpcfg_do_global_parameter(lp_ctx, "max open files", "16384");
2622 lpcfg_do_global_parameter(lp_ctx, "cups connection timeout", "30");
2624 lpcfg_do_global_parameter(lp_ctx, "locking", "True");
2626 lpcfg_do_global_parameter(lp_ctx, "block size", "1024");
2628 lpcfg_do_global_parameter(lp_ctx, "client use spnego", "True");
2630 lpcfg_do_global_parameter(lp_ctx, "change notify", "True");
2632 lpcfg_do_global_parameter(lp_ctx, "name cache timeout", "660");
2634 lpcfg_do_global_parameter(lp_ctx, "defer sharing violations", "True");
2636 lpcfg_do_global_parameter(lp_ctx, "ldap replication sleep", "1000");
2638 lpcfg_do_global_parameter(lp_ctx, "idmap backend", "tdb");
2640 lpcfg_do_global_parameter(lp_ctx, "enable privileges", "True");
2642 lpcfg_do_global_parameter_var(lp_ctx, "smb2 max write", "%u", DEFAULT_SMB2_MAX_WRITE);
2644 lpcfg_do_global_parameter(lp_ctx, "passdb backend", "tdbsam");
2646 lpcfg_do_global_parameter(lp_ctx, "getwd cache", "True");
2648 lpcfg_do_global_parameter(lp_ctx, "winbind nested groups", "True");
2650 lpcfg_do_global_parameter(lp_ctx, "mangled names", "True");
2652 lpcfg_do_global_parameter_var(lp_ctx, "smb2 max credits", "%u", DEFAULT_SMB2_MAX_CREDITS);
2654 lpcfg_do_global_parameter(lp_ctx, "ldap ssl", "start tls");
2656 lpcfg_do_global_parameter(lp_ctx, "ldap deref", "auto");
2658 lpcfg_do_global_parameter(lp_ctx, "lm interval", "60");
2660 lpcfg_do_global_parameter(lp_ctx, "mangling method", "hash2");
2662 lpcfg_do_global_parameter(lp_ctx, "hide dot files", "True");
2664 lpcfg_do_global_parameter(lp_ctx, "browse list", "True");
2666 lpcfg_do_global_parameter(lp_ctx, "passwd chat timeout", "2");
2668 lpcfg_do_global_parameter(lp_ctx, "guest account", GUEST_ACCOUNT);
2670 lpcfg_do_global_parameter(lp_ctx, "client schannel", "auto");
2672 lpcfg_do_global_parameter(lp_ctx, "smb encrypt", "default");
2674 lpcfg_do_global_parameter(lp_ctx, "max log size", "5000");
2676 lpcfg_do_global_parameter(lp_ctx, "idmap negative cache time", "120");
2678 lpcfg_do_global_parameter(lp_ctx, "ldap follow referral", "auto");
2680 lpcfg_do_global_parameter(lp_ctx, "multicast dns register", "yes");
2682 lpcfg_do_global_parameter(lp_ctx, "winbind reconnect delay", "30");
2684 lpcfg_do_global_parameter(lp_ctx, "winbind request timeout", "60");
2686 lpcfg_do_global_parameter(lp_ctx, "nt acl support", "yes");
2688 lpcfg_do_global_parameter(lp_ctx, "acl check permissions", "yes");
2690 lpcfg_do_global_parameter(lp_ctx, "keepalive", "300");
2692 lpcfg_do_global_parameter(lp_ctx, "smbd profiling level", "off");
2694 lpcfg_do_global_parameter(lp_ctx, "winbind cache time", "300");
2696 lpcfg_do_global_parameter(lp_ctx, "level2 oplocks", "yes");
2698 lpcfg_do_global_parameter(lp_ctx, "show add printer wizard", "yes");
2700 lpcfg_do_global_parameter(lp_ctx, "allocation roundup size", "1048576");
2702 lpcfg_do_global_parameter(lp_ctx, "ldap page size", "1024");
2704 lpcfg_do_global_parameter(lp_ctx, "kernel share modes", "yes");
2706 lpcfg_do_global_parameter(lp_ctx, "strict locking", "Auto");
2708 lpcfg_do_global_parameter(lp_ctx, "map readonly", "yes");
2710 lpcfg_do_global_parameter(lp_ctx, "allow trusted domains", "yes");
2712 lpcfg_do_global_parameter(lp_ctx, "default devmode", "yes");
2714 lpcfg_do_global_parameter(lp_ctx, "os level", "20");
2716 lpcfg_do_global_parameter(lp_ctx, "dos filetimes", "yes");
2718 lpcfg_do_global_parameter(lp_ctx, "mangling char", "~");
2720 lpcfg_do_global_parameter(lp_ctx, "printcap cache time", "750");
2722 lpcfg_do_global_parameter(lp_ctx, "create krb5 conf", "yes");
2724 lpcfg_do_global_parameter(lp_ctx, "winbind max clients", "200");
2726 lpcfg_do_global_parameter(lp_ctx, "acl map full control", "yes");
2728 lpcfg_do_global_parameter(lp_ctx, "nt pipe support", "yes");
2730 lpcfg_do_global_parameter(lp_ctx, "ldap debug threshold", "10");
2732 lpcfg_do_global_parameter(lp_ctx, "client ldap sasl wrapping", "sign");
2734 lpcfg_do_global_parameter(lp_ctx, "follow symlinks", "yes");
2736 lpcfg_do_global_parameter(lp_ctx, "machine password timeout", "604800");
2738 lpcfg_do_global_parameter(lp_ctx, "ldap connection timeout", "2");
2740 lpcfg_do_global_parameter(lp_ctx, "winbind expand groups", "0");
2742 lpcfg_do_global_parameter(lp_ctx, "stat cache", "yes");
2744 lpcfg_do_global_parameter(lp_ctx, "lpq cache time", "30");
2746 lpcfg_do_global_parameter_var(lp_ctx, "smb2 max trans", "%u", DEFAULT_SMB2_MAX_TRANSACT);
2748 lpcfg_do_global_parameter_var(lp_ctx, "smb2 max read", "%u", DEFAULT_SMB2_MAX_READ);
2750 lpcfg_do_global_parameter(lp_ctx, "durable handles", "yes");
2752 lpcfg_do_global_parameter(lp_ctx, "max stat cache size", "256");
2754 lpcfg_do_global_parameter(lp_ctx, "ldap passwd sync", "no");
2756 lpcfg_do_global_parameter(lp_ctx, "kernel change notify", "yes");
2758 lpcfg_do_global_parameter(lp_ctx, "max ttl", "259200");
2760 lpcfg_do_global_parameter(lp_ctx, "blocking locks", "yes");
2762 lpcfg_do_global_parameter(lp_ctx, "oplock contention limit", "2");
2764 lpcfg_do_global_parameter(lp_ctx, "load printers", "yes");
2766 lpcfg_do_global_parameter(lp_ctx, "idmap cache time", "604800");
2768 lpcfg_do_global_parameter(lp_ctx, "preserve case", "yes");
2770 lpcfg_do_global_parameter(lp_ctx, "lm announce", "auto");
2772 lpcfg_do_global_parameter(lp_ctx, "afs token lifetime", "604800");
2774 lpcfg_do_global_parameter(lp_ctx, "enable core files", "yes");
2776 lpcfg_do_global_parameter(lp_ctx, "winbind max domain connections", "1");
2778 lpcfg_do_global_parameter(lp_ctx, "case sensitive", "auto");
2780 lpcfg_do_global_parameter(lp_ctx, "ldap timeout", "15");
2782 lpcfg_do_global_parameter(lp_ctx, "mangle prefix", "1");
2784 lpcfg_do_global_parameter(lp_ctx, "posix locking", "yes");
2786 lpcfg_do_global_parameter(lp_ctx, "lock spin time", "200");
2788 lpcfg_do_global_parameter(lp_ctx, "directory name cache size", "100");
2790 lpcfg_do_global_parameter(lp_ctx, "nmbd bind explicit broadcast", "yes");
2792 lpcfg_do_global_parameter(lp_ctx, "init logon delay", "100");
2794 lpcfg_do_global_parameter(lp_ctx, "usershare owner only", "yes");
2796 lpcfg_do_global_parameter(lp_ctx, "-valid", "yes");
2798 lpcfg_do_global_parameter_var(lp_ctx, "usershare path", "%s/usershares", get_dyn_STATEDIR());
2801 lpcfg_do_global_parameter_var(lp_ctx, "panic action", "/bin/sleep 999999999");
2804 lpcfg_do_global_parameter(lp_ctx, "smb passwd file", get_dyn_SMB_PASSWD_FILE());
2806 lpcfg_do_global_parameter(lp_ctx, "logon home", "\\\\%N\\%U");
2808 lpcfg_do_global_parameter(lp_ctx, "logon path", "\\\\%N\\%U\\profile");
2810 lpcfg_do_global_parameter(lp_ctx, "printjob username", "%U");
2812 /* Allow modules to adjust defaults */
2813 for (defaults_hook = defaults_hooks; defaults_hook;
2814 defaults_hook = defaults_hook->next) {
2817 ret = defaults_hook->hook(lp_ctx);
2819 DEBUG(1, ("Defaults hook %s failed to run.",
2820 defaults_hook->name));
2821 talloc_free(lp_ctx);
2826 for (i = 0; parm_table[i].label; i++) {
2827 if (!(lp_ctx->flags[i] & FLAG_CMDLINE)) {
2828 lp_ctx->flags[i] |= FLAG_DEFAULT;
2832 for (parm=lp_ctx->globals->param_opt; parm; parm=parm->next) {
2833 if (!(parm->priority & FLAG_CMDLINE)) {
2834 parm->priority |= FLAG_DEFAULT;
2838 for (parm=lp_ctx->sDefault->param_opt; parm; parm=parm->next) {
2839 if (!(parm->priority & FLAG_CMDLINE)) {
2840 parm->priority |= FLAG_DEFAULT;
2848 * Initialise the global parameter structure.
2850 struct loadparm_context *loadparm_init_global(bool load_default)
2852 if (global_loadparm_context == NULL) {
2853 global_loadparm_context = loadparm_init(NULL);
2855 if (global_loadparm_context == NULL) {
2858 global_loadparm_context->global = true;
2859 if (load_default && !global_loadparm_context->loaded) {
2860 lpcfg_load_default(global_loadparm_context);
2862 global_loadparm_context->refuse_free = true;
2863 return global_loadparm_context;
2867 * Initialise the global parameter structure.
2869 struct loadparm_context *loadparm_init_s3(TALLOC_CTX *mem_ctx,
2870 const struct loadparm_s3_helpers *s3_fns)
2872 struct loadparm_context *loadparm_context = talloc_zero(mem_ctx, struct loadparm_context);
2873 if (!loadparm_context) {
2876 loadparm_context->s3_fns = s3_fns;
2877 loadparm_context->globals = s3_fns->globals;
2878 loadparm_context->flags = s3_fns->flags;
2880 return loadparm_context;
2883 const char *lpcfg_configfile(struct loadparm_context *lp_ctx)
2885 return lp_ctx->szConfigFile;
2888 const char *lp_default_path(void)
2890 if (getenv("SMB_CONF_PATH"))
2891 return getenv("SMB_CONF_PATH");
2893 return dyn_CONFIGFILE;
2897 * Update the internal state of a loadparm context after settings
2900 static bool lpcfg_update(struct loadparm_context *lp_ctx)
2902 struct debug_settings settings;
2903 TALLOC_CTX *tmp_ctx;
2905 tmp_ctx = talloc_new(lp_ctx);
2906 if (tmp_ctx == NULL) {
2910 lpcfg_add_auto_services(lp_ctx, lpcfg_auto_services(lp_ctx, tmp_ctx));
2912 if (!lp_ctx->globals->wins_server_list && lp_ctx->globals->we_are_a_wins_server) {
2913 lpcfg_do_global_parameter(lp_ctx, "wins server", "127.0.0.1");
2916 if (!lp_ctx->global) {
2917 TALLOC_FREE(tmp_ctx);
2921 panic_action = lp_ctx->globals->panic_action;
2923 reload_charcnv(lp_ctx);
2925 ZERO_STRUCT(settings);
2926 /* Add any more debug-related smb.conf parameters created in
2928 settings.timestamp_logs = lp_ctx->globals->timestamp_logs;
2929 settings.debug_prefix_timestamp = lp_ctx->globals->debug_prefix_timestamp;
2930 settings.debug_hires_timestamp = lp_ctx->globals->debug_hires_timestamp;
2931 settings.debug_pid = lp_ctx->globals->debug_pid;
2932 settings.debug_uid = lp_ctx->globals->debug_uid;
2933 settings.debug_class = lp_ctx->globals->debug_class;
2934 debug_set_settings(&settings, lp_ctx->globals->logging,
2935 lp_ctx->globals->syslog,
2936 lp_ctx->globals->syslog_only);
2938 /* FIXME: This is a bit of a hack, but we can't use a global, since
2939 * not everything that uses lp also uses the socket library */
2940 if (lpcfg_parm_bool(lp_ctx, NULL, "socket", "testnonblock", false)) {
2941 setenv("SOCKET_TESTNONBLOCK", "1", 1);
2943 unsetenv("SOCKET_TESTNONBLOCK");
2946 TALLOC_FREE(tmp_ctx);
2950 bool lpcfg_load_default(struct loadparm_context *lp_ctx)
2954 path = lp_default_path();
2956 if (!file_exist(path)) {
2957 /* We allow the default smb.conf file to not exist,
2958 * basically the equivalent of an empty file. */
2959 return lpcfg_update(lp_ctx);
2962 return lpcfg_load(lp_ctx, path);
2966 * Load the services array from the services file.
2968 * Return True on success, False on failure.
2970 bool lpcfg_load(struct loadparm_context *lp_ctx, const char *filename)
2975 filename = talloc_strdup(lp_ctx, filename);
2977 lp_ctx->szConfigFile = filename;
2979 if (lp_ctx->s3_fns) {
2980 return lp_ctx->s3_fns->load(filename);
2983 lp_ctx->bInGlobalSection = true;
2984 n2 = standard_sub_basic(lp_ctx, lp_ctx->szConfigFile);
2985 DEBUG(2, ("lpcfg_load: refreshing parameters from %s\n", n2));
2987 add_to_file_list(lp_ctx, &lp_ctx->file_lists, lp_ctx->szConfigFile, n2);
2989 /* We get sections first, so have to start 'behind' to make up */
2990 lp_ctx->currentService = NULL;
2991 bRetval = pm_process(n2, do_section, lpcfg_do_parameter, lp_ctx);
2993 /* finish up the last section */
2994 DEBUG(4, ("pm_process() returned %s\n", BOOLSTR(bRetval)));
2996 if (lp_ctx->currentService != NULL)
2997 bRetval = lpcfg_service_ok(lp_ctx->currentService);
2999 bRetval = bRetval && lpcfg_update(lp_ctx);
3001 /* we do this unconditionally, so that it happens even
3002 for a missing smb.conf */
3003 reload_charcnv(lp_ctx);
3005 if (bRetval == true) {
3006 /* set this up so that any child python tasks will
3007 find the right smb.conf */
3008 setenv("SMB_CONF_PATH", filename, 1);
3010 /* set the context used by the lp_*() function
3012 global_loadparm_context = lp_ctx;
3013 lp_ctx->loaded = true;
3020 * Return the max number of services.
3023 int lpcfg_numservices(struct loadparm_context *lp_ctx)
3025 if (lp_ctx->s3_fns) {
3026 return lp_ctx->s3_fns->get_numservices();
3029 return lp_ctx->iNumServices;
3033 * Display the contents of the services array in human-readable form.
3036 void lpcfg_dump(struct loadparm_context *lp_ctx, FILE *f, bool show_defaults,
3041 if (lp_ctx->s3_fns) {
3042 lp_ctx->s3_fns->dump(f, show_defaults, maxtoprint);
3046 lpcfg_dump_globals(lp_ctx, f, show_defaults);
3048 lpcfg_dump_a_service(lp_ctx->sDefault, lp_ctx->sDefault, f, lp_ctx->flags, show_defaults);
3050 for (iService = 0; iService < maxtoprint; iService++)
3051 lpcfg_dump_one(f, show_defaults, lp_ctx->services[iService], lp_ctx->sDefault);
3055 * Display the contents of one service in human-readable form.
3057 void lpcfg_dump_one(FILE *f, bool show_defaults, struct loadparm_service *service, struct loadparm_service *sDefault)
3059 if (service != NULL) {
3060 if (service->szService[0] == '\0')
3062 lpcfg_dump_a_service(service, sDefault, f, NULL, show_defaults);
3066 struct loadparm_service *lpcfg_servicebynum(struct loadparm_context *lp_ctx,
3069 if (lp_ctx->s3_fns) {
3070 return lp_ctx->s3_fns->get_servicebynum(snum);
3073 return lp_ctx->services[snum];
3076 struct loadparm_service *lpcfg_service(struct loadparm_context *lp_ctx,
3077 const char *service_name)
3082 if (lp_ctx->s3_fns) {
3083 return lp_ctx->s3_fns->get_service(service_name);
3086 for (iService = lp_ctx->iNumServices - 1; iService >= 0; iService--) {
3087 if (lp_ctx->services[iService] &&
3088 lp_ctx->services[iService]->szService) {
3090 * The substitution here is used to support %U is
3093 serviceName = standard_sub_basic(
3094 lp_ctx->services[iService],
3095 lp_ctx->services[iService]->szService);
3096 if (strequal(serviceName, service_name)) {
3097 talloc_free(serviceName);
3098 return lp_ctx->services[iService];
3100 talloc_free(serviceName);
3104 DEBUG(7,("lpcfg_servicenumber: couldn't find %s\n", service_name));
3108 const char *lpcfg_servicename(const struct loadparm_service *service)
3110 return lpcfg_string((const char *)service->szService);
3114 * A useful volume label function.
3116 const char *lpcfg_volume_label(struct loadparm_service *service, struct loadparm_service *sDefault)
3119 ret = lpcfg_string((const char *)((service != NULL && service->volume != NULL) ?
3120 service->volume : sDefault->volume));
3122 return lpcfg_servicename(service);
3127 * Return the correct printer name.
3129 const char *lpcfg_printername(struct loadparm_service *service, struct loadparm_service *sDefault)
3132 ret = lpcfg_string((const char *)((service != NULL && service->_printername != NULL) ?
3133 service->_printername : sDefault->_printername));
3134 if (ret == NULL || (ret != NULL && *ret == '\0'))
3135 ret = lpcfg_servicename(service);
3142 * Return the max print jobs per queue.
3144 int lpcfg_maxprintjobs(struct loadparm_service *service, struct loadparm_service *sDefault)
3146 int maxjobs = lpcfg_max_print_jobs(service, sDefault);
3148 if (maxjobs <= 0 || maxjobs >= PRINT_MAX_JOBID)
3149 maxjobs = PRINT_MAX_JOBID - 1;
3154 struct smb_iconv_handle *lpcfg_iconv_handle(struct loadparm_context *lp_ctx)
3156 if (lp_ctx == NULL) {
3157 return get_iconv_handle();
3159 return lp_ctx->iconv_handle;
3162 _PUBLIC_ void reload_charcnv(struct loadparm_context *lp_ctx)
3164 struct smb_iconv_handle *old_ic = lp_ctx->iconv_handle;
3165 if (!lp_ctx->global) {
3169 if (old_ic == NULL) {
3170 old_ic = global_iconv_handle;
3172 lp_ctx->iconv_handle = smb_iconv_handle_reinit_lp(lp_ctx, lp_ctx, old_ic);
3173 global_iconv_handle = lp_ctx->iconv_handle;
3176 _PUBLIC_ char *lpcfg_tls_keyfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
3178 return lpcfg_private_path(mem_ctx, lp_ctx, lpcfg__tls_keyfile(lp_ctx));
3181 _PUBLIC_ char *lpcfg_tls_certfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
3183 return lpcfg_private_path(mem_ctx, lp_ctx, lpcfg__tls_certfile(lp_ctx));
3186 _PUBLIC_ char *lpcfg_tls_cafile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
3188 return lpcfg_private_path(mem_ctx, lp_ctx, lpcfg__tls_cafile(lp_ctx));
3191 _PUBLIC_ char *lpcfg_tls_crlfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
3193 return lpcfg_private_path(mem_ctx, lp_ctx, lpcfg__tls_crlfile(lp_ctx));
3196 _PUBLIC_ char *lpcfg_tls_dhpfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
3198 return lpcfg_private_path(mem_ctx, lp_ctx, lpcfg__tls_dhpfile(lp_ctx));
3201 struct gensec_settings *lpcfg_gensec_settings(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
3203 struct gensec_settings *settings = talloc_zero(mem_ctx, struct gensec_settings);
3204 if (settings == NULL)
3206 SMB_ASSERT(lp_ctx != NULL);
3207 settings->lp_ctx = talloc_reference(settings, lp_ctx);
3208 settings->target_hostname = lpcfg_parm_string(lp_ctx, NULL, "gensec", "target_hostname");
3212 int lpcfg_server_role(struct loadparm_context *lp_ctx)
3214 int domain_master = lpcfg__domain_master(lp_ctx);
3216 return lp_find_server_role(lpcfg__server_role(lp_ctx),
3217 lpcfg__security(lp_ctx),
3218 lpcfg__domain_logons(lp_ctx),
3219 (domain_master == true) ||
3220 (domain_master == Auto));
3223 int lpcfg_security(struct loadparm_context *lp_ctx)
3225 return lp_find_security(lpcfg__server_role(lp_ctx),
3226 lpcfg__security(lp_ctx));
3229 int lpcfg_client_max_protocol(struct loadparm_context *lp_ctx)
3231 int client_max_protocol = lpcfg__client_max_protocol(lp_ctx);
3232 if (client_max_protocol == PROTOCOL_DEFAULT) {
3233 return PROTOCOL_NT1;
3235 return client_max_protocol;
3238 bool lpcfg_server_signing_allowed(struct loadparm_context *lp_ctx, bool *mandatory)
3240 bool allowed = true;
3241 enum smb_signing_setting signing_setting = lpcfg_server_signing(lp_ctx);
3245 if (signing_setting == SMB_SIGNING_DEFAULT) {
3247 * If we are a domain controller, SMB signing is
3248 * really important, as it can prevent a number of
3249 * attacks on communications between us and the
3252 * However, it really sucks (no sendfile, CPU
3253 * overhead) performance-wise when used on a
3254 * file server, so disable it by default
3258 if (lpcfg_server_role(lp_ctx) >= ROLE_ACTIVE_DIRECTORY_DC) {
3259 signing_setting = SMB_SIGNING_REQUIRED;
3261 signing_setting = SMB_SIGNING_OFF;
3265 switch (signing_setting) {
3266 case SMB_SIGNING_REQUIRED:
3269 case SMB_SIGNING_DESIRED:
3270 case SMB_SIGNING_IF_REQUIRED:
3272 case SMB_SIGNING_DEFAULT:
3273 case SMB_SIGNING_OFF:
3281 int lpcfg_tdb_hash_size(struct loadparm_context *lp_ctx, const char *name)
3289 base = strrchr_m(name, '/');
3295 return lpcfg_parm_int(lp_ctx, NULL, "tdb_hashsize", base, 0);
3299 int lpcfg_tdb_flags(struct loadparm_context *lp_ctx, int tdb_flags)
3301 if (!lpcfg_use_mmap(lp_ctx)) {
3302 tdb_flags |= TDB_NOMMAP;