s3-utils: net - Fix one error/usage message
[Samba/gebeck_regimport.git] / lib / param / loadparm.c
blob4274e9bca3e32ef3f56fecb52c38dc59a14c67c8
1 /*
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
15 This program is free software; you can redistribute it and/or modify
16 it under the terms of the GNU General Public License as published by
17 the Free Software Foundation; either version 3 of the License, or
18 (at your option) any later version.
20 This program is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
25 You should have received a copy of the GNU General Public License
26 along with this program. If not, see <http://www.gnu.org/licenses/>.
30 * Load parameters.
32 * This module provides suitable callback functions for the params
33 * module. It builds the internal table of service details which is
34 * then used by the rest of the server.
36 * To add a parameter:
38 * 1) add it to the global or service structure definition
39 * 2) add it to the parm_table
40 * 3) add it to the list of available functions (eg: using FN_GLOBAL_STRING())
41 * 4) If it's a global then initialise it in init_globals. If a local
42 * (ie. service) parameter then initialise it in the sDefault structure
45 * Notes:
46 * The configuration file is processed sequentially for speed. It is NOT
47 * accessed randomly as happens in 'real' Windows. For this reason, there
48 * is a fair bit of sequence-dependent code here - ie., code which assumes
49 * that certain things happen before others. In particular, the code which
50 * happens at the boundary between sections is delicately poised, so be
51 * careful!
55 #include "includes.h"
56 #include "version.h"
57 #include "dynconfig/dynconfig.h"
58 #include "system/time.h"
59 #include "system/locale.h"
60 #include "system/network.h" /* needed for TCP_NODELAY */
61 #include "../lib/util/dlinklist.h"
62 #include "lib/param/param.h"
63 #include "lib/param/loadparm.h"
64 #include "auth/gensec/gensec.h"
65 #include "s3_param.h"
66 #include "lib/util/bitmap.h"
67 #include "libcli/smb/smb_constants.h"
69 #define standard_sub_basic talloc_strdup
71 static bool do_parameter(const char *, const char *, void *);
72 static bool defaults_saved = false;
74 #define LOADPARM_EXTRA_GLOBALS \
75 struct parmlist_entry *param_opt; \
76 char *szRealm; \
77 char *tls_keyfile; \
78 char *tls_certfile; \
79 char *tls_cafile; \
80 char *tls_crlfile; \
81 char *tls_dhpfile; \
82 char *loglevel; \
83 char *panic_action; \
84 int bPreferredMaster;
86 #include "param_global.h"
88 #define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
91 /* prototypes for the special type handlers */
92 static bool handle_include(struct loadparm_context *lp_ctx, int unused,
93 const char *pszParmValue, char **ptr);
94 static bool handle_realm(struct loadparm_context *lp_ctx, int unused,
95 const char *pszParmValue, char **ptr);
96 static bool handle_copy(struct loadparm_context *lp_ctx, int unused,
97 const char *pszParmValue, char **ptr);
98 static bool handle_debuglevel(struct loadparm_context *lp_ctx, int unused,
99 const char *pszParmValue, char **ptr);
100 static bool handle_logfile(struct loadparm_context *lp_ctx, int unused,
101 const char *pszParmValue, char **ptr);
103 static const struct enum_list enum_protocol[] = {
104 {PROTOCOL_SMB2_02, "SMB2"},
105 {PROTOCOL_SMB2_02, "SMB2_02"},
106 {PROTOCOL_NT1, "NT1"},
107 {PROTOCOL_LANMAN2, "LANMAN2"},
108 {PROTOCOL_LANMAN1, "LANMAN1"},
109 {PROTOCOL_CORE, "CORE"},
110 {PROTOCOL_COREPLUS, "COREPLUS"},
111 {PROTOCOL_COREPLUS, "CORE+"},
112 {-1, NULL}
115 static const struct enum_list enum_security[] = {
116 {SEC_SHARE, "SHARE"},
117 {SEC_USER, "USER"},
118 {SEC_ADS, "ADS"},
119 {-1, NULL}
122 static const struct enum_list enum_bool_auto[] = {
123 {false, "No"},
124 {false, "False"},
125 {false, "0"},
126 {true, "Yes"},
127 {true, "True"},
128 {true, "1"},
129 {Auto, "Auto"},
130 {-1, NULL}
133 /* Client-side offline caching policy types */
135 static const struct enum_list enum_csc_policy[] = {
136 {CSC_POLICY_MANUAL, "manual"},
137 {CSC_POLICY_DOCUMENTS, "documents"},
138 {CSC_POLICY_PROGRAMS, "programs"},
139 {CSC_POLICY_DISABLE, "disable"},
140 {-1, NULL}
143 /* SMB signing types. */
144 static const struct enum_list enum_smb_signing_vals[] = {
145 {SMB_SIGNING_OFF, "No"},
146 {SMB_SIGNING_OFF, "False"},
147 {SMB_SIGNING_OFF, "0"},
148 {SMB_SIGNING_OFF, "Off"},
149 {SMB_SIGNING_OFF, "disabled"},
150 {SMB_SIGNING_SUPPORTED, "Yes"},
151 {SMB_SIGNING_SUPPORTED, "True"},
152 {SMB_SIGNING_SUPPORTED, "1"},
153 {SMB_SIGNING_SUPPORTED, "On"},
154 {SMB_SIGNING_SUPPORTED, "enabled"},
155 {SMB_SIGNING_REQUIRED, "required"},
156 {SMB_SIGNING_REQUIRED, "mandatory"},
157 {SMB_SIGNING_REQUIRED, "force"},
158 {SMB_SIGNING_REQUIRED, "forced"},
159 {SMB_SIGNING_REQUIRED, "enforced"},
160 {SMB_SIGNING_AUTO, "auto"},
161 {-1, NULL}
164 static const struct enum_list enum_server_role[] = {
165 {ROLE_STANDALONE, "standalone"},
166 {ROLE_DOMAIN_MEMBER, "member server"},
167 {ROLE_DOMAIN_MEMBER, "member"},
168 {ROLE_DOMAIN_CONTROLLER, "domain controller"},
169 {ROLE_DOMAIN_CONTROLLER, "dc"},
170 {-1, NULL}
173 #define GLOBAL_VAR(name) offsetof(struct loadparm_global, name)
174 #define LOCAL_VAR(name) offsetof(struct loadparm_service, name)
176 static struct parm_struct parm_table[] = {
178 .label = "server role",
179 .type = P_ENUM,
180 .p_class = P_GLOBAL,
181 .offset = GLOBAL_VAR(server_role),
182 .special = NULL,
183 .enum_list = enum_server_role
186 .label = "dos charset",
187 .type = P_STRING,
188 .p_class = P_GLOBAL,
189 .offset = GLOBAL_VAR(dos_charset),
190 .special = NULL,
191 .enum_list = NULL
194 .label = "unix charset",
195 .type = P_STRING,
196 .p_class = P_GLOBAL,
197 .offset = GLOBAL_VAR(unix_charset),
198 .special = NULL,
199 .enum_list = NULL
202 .label = "ncalrpc dir",
203 .type = P_STRING,
204 .p_class = P_GLOBAL,
205 .offset = GLOBAL_VAR(ncalrpc_dir),
206 .special = NULL,
207 .enum_list = NULL
210 .label = "comment",
211 .type = P_STRING,
212 .p_class = P_LOCAL,
213 .offset = LOCAL_VAR(comment),
214 .special = NULL,
215 .enum_list = NULL
218 .label = "path",
219 .type = P_STRING,
220 .p_class = P_LOCAL,
221 .offset = LOCAL_VAR(szPath),
222 .special = NULL,
223 .enum_list = NULL
226 .label = "directory",
227 .type = P_STRING,
228 .p_class = P_LOCAL,
229 .offset = LOCAL_VAR(szPath),
230 .special = NULL,
231 .enum_list = NULL
234 .label = "workgroup",
235 .type = P_USTRING,
236 .p_class = P_GLOBAL,
237 .offset = GLOBAL_VAR(szWorkgroup),
238 .special = NULL,
239 .enum_list = NULL
242 .label = "realm",
243 .type = P_STRING,
244 .p_class = P_GLOBAL,
245 .offset = GLOBAL_VAR(szRealm),
246 .special = handle_realm,
247 .enum_list = NULL
250 .label = "netbios name",
251 .type = P_USTRING,
252 .p_class = P_GLOBAL,
253 .offset = GLOBAL_VAR(szNetbiosName),
254 .special = NULL,
255 .enum_list = NULL
258 .label = "netbios aliases",
259 .type = P_LIST,
260 .p_class = P_GLOBAL,
261 .offset = GLOBAL_VAR(szNetbiosAliases),
262 .special = NULL,
263 .enum_list = NULL
266 .label = "netbios scope",
267 .type = P_USTRING,
268 .p_class = P_GLOBAL,
269 .offset = GLOBAL_VAR(szNetbiosScope),
270 .special = NULL,
271 .enum_list = NULL
274 .label = "server string",
275 .type = P_STRING,
276 .p_class = P_GLOBAL,
277 .offset = GLOBAL_VAR(szServerString),
278 .special = NULL,
279 .enum_list = NULL
282 .label = "interfaces",
283 .type = P_LIST,
284 .p_class = P_GLOBAL,
285 .offset = GLOBAL_VAR(szInterfaces),
286 .special = NULL,
287 .enum_list = NULL
290 .label = "bind interfaces only",
291 .type = P_BOOL,
292 .p_class = P_GLOBAL,
293 .offset = GLOBAL_VAR(bBindInterfacesOnly),
294 .special = NULL,
295 .enum_list = NULL
298 .label = "ntvfs handler",
299 .type = P_LIST,
300 .p_class = P_LOCAL,
301 .offset = LOCAL_VAR(ntvfs_handler),
302 .special = NULL,
303 .enum_list = NULL
306 .label = "ntptr providor",
307 .type = P_STRING,
308 .p_class = P_GLOBAL,
309 .offset = GLOBAL_VAR(ntptr_providor),
310 .special = NULL,
311 .enum_list = NULL
314 .label = "passdb backend",
315 .type = P_STRING,
316 .p_class = P_GLOBAL,
317 .offset = GLOBAL_VAR(passdb_backend),
318 .special = NULL,
319 .enum_list = NULL
322 .label = "dcerpc endpoint servers",
323 .type = P_LIST,
324 .p_class = P_GLOBAL,
325 .offset = GLOBAL_VAR(dcerpc_ep_servers),
326 .special = NULL,
327 .enum_list = NULL
330 .label = "server services",
331 .type = P_LIST,
332 .p_class = P_GLOBAL,
333 .offset = GLOBAL_VAR(server_services),
334 .special = NULL,
335 .enum_list = NULL
339 .label = "security",
340 .type = P_ENUM,
341 .p_class = P_GLOBAL,
342 .offset = GLOBAL_VAR(security),
343 .special = NULL,
344 .enum_list = enum_security
347 .label = "encrypt passwords",
348 .type = P_BOOL,
349 .p_class = P_GLOBAL,
350 .offset = GLOBAL_VAR(bEncryptPasswords),
351 .special = NULL,
352 .enum_list = NULL
355 .label = "null passwords",
356 .type = P_BOOL,
357 .p_class = P_GLOBAL,
358 .offset = GLOBAL_VAR(bNullPasswords),
359 .special = NULL,
360 .enum_list = NULL
363 .label = "obey pam restrictions",
364 .type = P_BOOL,
365 .p_class = P_GLOBAL,
366 .offset = GLOBAL_VAR(bObeyPamRestrictions),
367 .special = NULL,
368 .enum_list = NULL
371 .label = "password server",
372 .type = P_LIST,
373 .p_class = P_GLOBAL,
374 .offset = GLOBAL_VAR(szPasswordServers),
375 .special = NULL,
376 .enum_list = NULL
379 .label = "private dir",
380 .type = P_STRING,
381 .p_class = P_GLOBAL,
382 .offset = GLOBAL_VAR(szPrivateDir),
383 .special = NULL,
384 .enum_list = NULL
387 .label = "passwd chat",
388 .type = P_STRING,
389 .p_class = P_GLOBAL,
390 .offset = GLOBAL_VAR(szPasswdChat),
391 .special = NULL,
392 .enum_list = NULL
395 .label = "password level",
396 .type = P_INTEGER,
397 .p_class = P_GLOBAL,
398 .offset = GLOBAL_VAR(pwordlevel),
399 .special = NULL,
400 .enum_list = NULL
403 .label = "lanman auth",
404 .type = P_BOOL,
405 .p_class = P_GLOBAL,
406 .offset = GLOBAL_VAR(bLanmanAuth),
407 .special = NULL,
408 .enum_list = NULL
411 .label = "ntlm auth",
412 .type = P_BOOL,
413 .p_class = P_GLOBAL,
414 .offset = GLOBAL_VAR(bNTLMAuth),
415 .special = NULL,
416 .enum_list = NULL
419 .label = "client NTLMv2 auth",
420 .type = P_BOOL,
421 .p_class = P_GLOBAL,
422 .offset = GLOBAL_VAR(bClientNTLMv2Auth),
423 .special = NULL,
424 .enum_list = NULL
427 .label = "client lanman auth",
428 .type = P_BOOL,
429 .p_class = P_GLOBAL,
430 .offset = GLOBAL_VAR(bClientLanManAuth),
431 .special = NULL,
432 .enum_list = NULL
435 .label = "client plaintext auth",
436 .type = P_BOOL,
437 .p_class = P_GLOBAL,
438 .offset = GLOBAL_VAR(bClientPlaintextAuth),
439 .special = NULL,
440 .enum_list = NULL
443 .label = "client use spnego principal",
444 .type = P_BOOL,
445 .p_class = P_GLOBAL,
446 .offset = GLOBAL_VAR(client_use_spnego_principal),
447 .special = NULL,
448 .enum_list = NULL
452 .label = "read only",
453 .type = P_BOOL,
454 .p_class = P_LOCAL,
455 .offset = LOCAL_VAR(bRead_only),
456 .special = NULL,
457 .enum_list = NULL
461 .label = "create mask",
462 .type = P_OCTAL,
463 .p_class = P_LOCAL,
464 .offset = LOCAL_VAR(iCreate_mask),
465 .special = NULL,
466 .enum_list = NULL
469 .label = "force create mode",
470 .type = P_OCTAL,
471 .p_class = P_LOCAL,
472 .offset = LOCAL_VAR(iCreate_force_mode),
473 .special = NULL,
474 .enum_list = NULL
477 .label = "directory mask",
478 .type = P_OCTAL,
479 .p_class = P_LOCAL,
480 .offset = LOCAL_VAR(iDir_mask),
481 .special = NULL,
482 .enum_list = NULL
485 .label = "force directory mode",
486 .type = P_OCTAL,
487 .p_class = P_LOCAL,
488 .offset = LOCAL_VAR(iDir_force_mode),
489 .special = NULL,
490 .enum_list = NULL
494 .label = "hosts allow",
495 .type = P_LIST,
496 .p_class = P_LOCAL,
497 .offset = LOCAL_VAR(szHostsallow),
498 .special = NULL,
499 .enum_list = NULL
502 .label = "hosts deny",
503 .type = P_LIST,
504 .p_class = P_LOCAL,
505 .offset = LOCAL_VAR(szHostsdeny),
506 .special = NULL,
507 .enum_list = NULL
511 .label = "log level",
512 .type = P_STRING,
513 .p_class = P_GLOBAL,
514 .offset = GLOBAL_VAR(loglevel),
515 .special = handle_debuglevel,
516 .enum_list = NULL
519 .label = "debuglevel",
520 .type = P_STRING,
521 .p_class = P_GLOBAL,
522 .offset = GLOBAL_VAR(loglevel),
523 .special = handle_debuglevel,
524 .enum_list = NULL
527 .label = "log file",
528 .type = P_STRING,
529 .p_class = P_GLOBAL,
530 .offset = GLOBAL_VAR(logfile),
531 .special = handle_logfile,
532 .enum_list = NULL
536 .label = "smb ports",
537 .type = P_LIST,
538 .p_class = P_GLOBAL,
539 .offset = GLOBAL_VAR(smb_ports),
540 .special = NULL,
541 .enum_list = NULL
544 .label = "nbt port",
545 .type = P_INTEGER,
546 .p_class = P_GLOBAL,
547 .offset = GLOBAL_VAR(nbt_port),
548 .special = NULL,
549 .enum_list = NULL
552 .label = "dgram port",
553 .type = P_INTEGER,
554 .p_class = P_GLOBAL,
555 .offset = GLOBAL_VAR(dgram_port),
556 .special = NULL,
557 .enum_list = NULL
560 .label = "cldap port",
561 .type = P_INTEGER,
562 .p_class = P_GLOBAL,
563 .offset = GLOBAL_VAR(cldap_port),
564 .special = NULL,
565 .enum_list = NULL
568 .label = "krb5 port",
569 .type = P_INTEGER,
570 .p_class = P_GLOBAL,
571 .offset = GLOBAL_VAR(krb5_port),
572 .special = NULL,
573 .enum_list = NULL
576 .label = "kpasswd port",
577 .type = P_INTEGER,
578 .p_class = P_GLOBAL,
579 .offset = GLOBAL_VAR(kpasswd_port),
580 .special = NULL,
581 .enum_list = NULL
584 .label = "web port",
585 .type = P_INTEGER,
586 .p_class = P_GLOBAL,
587 .offset = GLOBAL_VAR(web_port),
588 .special = NULL,
589 .enum_list = NULL
592 .label = "tls enabled",
593 .type = P_BOOL,
594 .p_class = P_GLOBAL,
595 .offset = GLOBAL_VAR(tls_enabled),
596 .special = NULL,
597 .enum_list = NULL
600 .label = "tls keyfile",
601 .type = P_STRING,
602 .p_class = P_GLOBAL,
603 .offset = GLOBAL_VAR(tls_keyfile),
604 .special = NULL,
605 .enum_list = NULL
608 .label = "tls certfile",
609 .type = P_STRING,
610 .p_class = P_GLOBAL,
611 .offset = GLOBAL_VAR(tls_certfile),
612 .special = NULL,
613 .enum_list = NULL
616 .label = "tls cafile",
617 .type = P_STRING,
618 .p_class = P_GLOBAL,
619 .offset = GLOBAL_VAR(tls_cafile),
620 .special = NULL,
621 .enum_list = NULL
624 .label = "tls crlfile",
625 .type = P_STRING,
626 .p_class = P_GLOBAL,
627 .offset = GLOBAL_VAR(tls_crlfile),
628 .special = NULL,
629 .enum_list = NULL
632 .label = "tls dh params file",
633 .type = P_STRING,
634 .p_class = P_GLOBAL,
635 .offset = GLOBAL_VAR(tls_dhpfile),
636 .special = NULL,
637 .enum_list = NULL
640 .label = "large readwrite",
641 .type = P_BOOL,
642 .p_class = P_GLOBAL,
643 .offset = GLOBAL_VAR(bLargeReadwrite),
644 .special = NULL,
645 .enum_list = NULL
648 .label = "server max protocol",
649 .type = P_ENUM,
650 .p_class = P_GLOBAL,
651 .offset = GLOBAL_VAR(srv_maxprotocol),
652 .special = NULL,
653 .enum_list = enum_protocol
656 .label = "server min protocol",
657 .type = P_ENUM,
658 .p_class = P_GLOBAL,
659 .offset = GLOBAL_VAR(srv_minprotocol),
660 .special = NULL,
661 .enum_list = enum_protocol
664 .label = "client max protocol",
665 .type = P_ENUM,
666 .p_class = P_GLOBAL,
667 .offset = GLOBAL_VAR(cli_maxprotocol),
668 .special = NULL,
669 .enum_list = enum_protocol
672 .label = "client min protocol",
673 .type = P_ENUM,
674 .p_class = P_GLOBAL,
675 .offset = GLOBAL_VAR(cli_minprotocol),
676 .special = NULL,
677 .enum_list = enum_protocol
680 .label = "unicode",
681 .type = P_BOOL,
682 .p_class = P_GLOBAL,
683 .offset = GLOBAL_VAR(bUnicode),
684 .special = NULL,
685 .enum_list = NULL
688 .label = "read raw",
689 .type = P_BOOL,
690 .p_class = P_GLOBAL,
691 .offset = GLOBAL_VAR(bReadRaw),
692 .special = NULL,
693 .enum_list = NULL
696 .label = "write raw",
697 .type = P_BOOL,
698 .p_class = P_GLOBAL,
699 .offset = GLOBAL_VAR(bWriteRaw),
700 .special = NULL,
701 .enum_list = NULL
704 .label = "disable netbios",
705 .type = P_BOOL,
706 .p_class = P_GLOBAL,
707 .offset = GLOBAL_VAR(bDisableNetbios),
708 .special = NULL,
709 .enum_list = NULL
713 .label = "nt status support",
714 .type = P_BOOL,
715 .p_class = P_GLOBAL,
716 .offset = GLOBAL_VAR(bNTStatusSupport),
717 .special = NULL,
718 .enum_list = NULL
722 .label = "max mux",
723 .type = P_INTEGER,
724 .p_class = P_GLOBAL,
725 .offset = GLOBAL_VAR(max_mux),
726 .special = NULL,
727 .enum_list = NULL
730 .label = "max xmit",
731 .type = P_BYTES,
732 .p_class = P_GLOBAL,
733 .offset = GLOBAL_VAR(max_xmit),
734 .special = NULL,
735 .enum_list = NULL
739 .label = "name resolve order",
740 .type = P_LIST,
741 .p_class = P_GLOBAL,
742 .offset = GLOBAL_VAR(szNameResolveOrder),
743 .special = NULL,
744 .enum_list = NULL
747 .label = "max wins ttl",
748 .type = P_INTEGER,
749 .p_class = P_GLOBAL,
750 .offset = GLOBAL_VAR(max_wins_ttl),
751 .special = NULL,
752 .enum_list = NULL
755 .label = "min wins ttl",
756 .type = P_INTEGER,
757 .p_class = P_GLOBAL,
758 .offset = GLOBAL_VAR(min_wins_ttl),
759 .special = NULL,
760 .enum_list = NULL
763 .label = "time server",
764 .type = P_BOOL,
765 .p_class = P_GLOBAL,
766 .offset = GLOBAL_VAR(bTimeServer),
767 .special = NULL,
768 .enum_list = NULL
771 .label = "unix extensions",
772 .type = P_BOOL,
773 .p_class = P_GLOBAL,
774 .offset = GLOBAL_VAR(bUnixExtensions),
775 .special = NULL,
776 .enum_list = NULL
779 .label = "use spnego",
780 .type = P_BOOL,
781 .p_class = P_GLOBAL,
782 .offset = GLOBAL_VAR(bUseSpnego),
783 .special = NULL,
784 .enum_list = NULL
787 .label = "server signing",
788 .type = P_ENUM,
789 .p_class = P_GLOBAL,
790 .offset = GLOBAL_VAR(server_signing),
791 .special = NULL,
792 .enum_list = enum_smb_signing_vals
795 .label = "client signing",
796 .type = P_ENUM,
797 .p_class = P_GLOBAL,
798 .offset = GLOBAL_VAR(client_signing),
799 .special = NULL,
800 .enum_list = enum_smb_signing_vals
803 .label = "rpc big endian",
804 .type = P_BOOL,
805 .p_class = P_GLOBAL,
806 .offset = GLOBAL_VAR(bRpcBigEndian),
807 .special = NULL,
808 .enum_list = NULL
812 .label = "max connections",
813 .type = P_INTEGER,
814 .p_class = P_LOCAL,
815 .offset = LOCAL_VAR(iMaxConnections),
816 .special = NULL,
817 .enum_list = NULL
820 .label = "paranoid server security",
821 .type = P_BOOL,
822 .p_class = P_GLOBAL,
823 .offset = GLOBAL_VAR(paranoid_server_security),
824 .special = NULL,
825 .enum_list = NULL
828 .label = "socket options",
829 .type = P_STRING,
830 .p_class = P_GLOBAL,
831 .offset = GLOBAL_VAR(socket_options),
832 .special = NULL,
833 .enum_list = NULL
837 .label = "strict sync",
838 .type = P_BOOL,
839 .p_class = P_LOCAL,
840 .offset = LOCAL_VAR(bStrictSync),
841 .special = NULL,
842 .enum_list = NULL
845 .label = "use mmap",
846 .type = P_BOOL,
847 .p_class = P_GLOBAL,
848 .offset = GLOBAL_VAR(bUseMmap),
849 .special = NULL,
850 .enum_list = NULL,
851 .flags = FLAG_ADVANCED,
854 .label = "case insensitive filesystem",
855 .type = P_BOOL,
856 .p_class = P_LOCAL,
857 .offset = LOCAL_VAR(bCIFileSystem),
858 .special = NULL,
859 .enum_list = NULL
863 .label = "max print jobs",
864 .type = P_INTEGER,
865 .p_class = P_LOCAL,
866 .offset = LOCAL_VAR(iMaxPrintJobs),
867 .special = NULL,
868 .enum_list = NULL
871 .label = "printable",
872 .type = P_BOOL,
873 .p_class = P_LOCAL,
874 .offset = LOCAL_VAR(bPrint_ok),
875 .special = NULL,
876 .enum_list = NULL
879 .label = "print ok",
880 .type = P_BOOL,
881 .p_class = P_LOCAL,
882 .offset = LOCAL_VAR(bPrint_ok),
883 .special = NULL,
884 .enum_list = NULL
888 .label = "printer name",
889 .type = P_STRING,
890 .p_class = P_LOCAL,
891 .offset = LOCAL_VAR(szPrintername),
892 .special = NULL,
893 .enum_list = NULL
896 .label = "printer",
897 .type = P_STRING,
898 .p_class = P_LOCAL,
899 .offset = LOCAL_VAR(szPrintername),
900 .special = NULL,
901 .enum_list = NULL
905 .label = "map system",
906 .type = P_BOOL,
907 .p_class = P_LOCAL,
908 .offset = LOCAL_VAR(bMap_system),
909 .special = NULL,
910 .enum_list = NULL
913 .label = "map hidden",
914 .type = P_BOOL,
915 .p_class = P_LOCAL,
916 .offset = LOCAL_VAR(bMap_hidden),
917 .special = NULL,
918 .enum_list = NULL
921 .label = "map archive",
922 .type = P_BOOL,
923 .p_class = P_LOCAL,
924 .offset = LOCAL_VAR(bMap_archive),
925 .special = NULL,
926 .enum_list = NULL
930 .label = "preferred master",
931 .type = P_ENUM,
932 .p_class = P_GLOBAL,
933 .offset = GLOBAL_VAR(bPreferredMaster),
934 .special = NULL,
935 .enum_list = enum_bool_auto
938 .label = "prefered master",
939 .type = P_ENUM,
940 .p_class = P_GLOBAL,
941 .offset = GLOBAL_VAR(bPreferredMaster),
942 .special = NULL,
943 .enum_list = enum_bool_auto
946 .label = "local master",
947 .type = P_BOOL,
948 .p_class = P_GLOBAL,
949 .offset = GLOBAL_VAR(bLocalMaster),
950 .special = NULL,
951 .enum_list = NULL
954 .label = "browseable",
955 .type = P_BOOL,
956 .p_class = P_LOCAL,
957 .offset = LOCAL_VAR(bBrowseable),
958 .special = NULL,
959 .enum_list = NULL
962 .label = "browsable",
963 .type = P_BOOL,
964 .p_class = P_LOCAL,
965 .offset = LOCAL_VAR(bBrowseable),
966 .special = NULL,
967 .enum_list = NULL
971 .label = "wins server",
972 .type = P_LIST,
973 .p_class = P_GLOBAL,
974 .offset = GLOBAL_VAR(szWINSservers),
975 .special = NULL,
976 .enum_list = NULL
979 .label = "wins support",
980 .type = P_BOOL,
981 .p_class = P_GLOBAL,
982 .offset = GLOBAL_VAR(bWINSsupport),
983 .special = NULL,
984 .enum_list = NULL
987 .label = "dns proxy",
988 .type = P_BOOL,
989 .p_class = P_GLOBAL,
990 .offset = GLOBAL_VAR(bWINSdnsProxy),
991 .special = NULL,
992 .enum_list = NULL
995 .label = "wins hook",
996 .type = P_STRING,
997 .p_class = P_GLOBAL,
998 .offset = GLOBAL_VAR(szWINSHook),
999 .special = NULL,
1000 .enum_list = NULL
1004 .label = "csc policy",
1005 .type = P_ENUM,
1006 .p_class = P_LOCAL,
1007 .offset = LOCAL_VAR(iCSCPolicy),
1008 .special = NULL,
1009 .enum_list = enum_csc_policy
1013 .label = "strict locking",
1014 .type = P_BOOL,
1015 .p_class = P_LOCAL,
1016 .offset = LOCAL_VAR(iStrictLocking),
1017 .special = NULL,
1018 .enum_list = NULL
1021 .label = "oplocks",
1022 .type = P_BOOL,
1023 .p_class = P_LOCAL,
1024 .offset = LOCAL_VAR(bOpLocks),
1025 .special = NULL,
1026 .enum_list = NULL
1030 .label = "share backend",
1031 .type = P_STRING,
1032 .p_class = P_GLOBAL,
1033 .offset = GLOBAL_VAR(szShareBackend),
1034 .special = NULL,
1035 .enum_list = NULL
1038 .label = "preload",
1039 .type = P_STRING,
1040 .p_class = P_GLOBAL,
1041 .offset = GLOBAL_VAR(szAutoServices),
1042 .special = NULL,
1043 .enum_list = NULL
1046 .label = "auto services",
1047 .type = P_STRING,
1048 .p_class = P_GLOBAL,
1049 .offset = GLOBAL_VAR(szAutoServices),
1050 .special = NULL,
1051 .enum_list = NULL
1054 .label = "lock dir",
1055 .type = P_STRING,
1056 .p_class = P_GLOBAL,
1057 .offset = GLOBAL_VAR(szLockDir),
1058 .special = NULL,
1059 .enum_list = NULL
1062 .label = "lock directory",
1063 .type = P_STRING,
1064 .p_class = P_GLOBAL,
1065 .offset = GLOBAL_VAR(szLockDir),
1066 .special = NULL,
1067 .enum_list = NULL
1070 .label = "state directory",
1071 .type = P_STRING,
1072 .p_class = P_GLOBAL,
1073 .offset = GLOBAL_VAR(szStateDir),
1074 .special = NULL,
1075 .enum_list = NULL
1078 .label = "cache directory",
1079 .type = P_STRING,
1080 .p_class = P_GLOBAL,
1081 .offset = GLOBAL_VAR(szCacheDir),
1082 .special = NULL,
1083 .enum_list = NULL
1086 .label = "pid directory",
1087 .type = P_STRING,
1088 .p_class = P_GLOBAL,
1089 .offset = GLOBAL_VAR(szPidDir),
1090 .special = NULL,
1091 .enum_list = NULL
1095 .label = "socket address",
1096 .type = P_STRING,
1097 .p_class = P_GLOBAL,
1098 .offset = GLOBAL_VAR(szSocketAddress),
1099 .special = NULL,
1100 .enum_list = NULL
1103 .label = "copy",
1104 .type = P_STRING,
1105 .p_class = P_LOCAL,
1106 .offset = LOCAL_VAR(szCopy),
1107 .special = handle_copy,
1108 .enum_list = NULL
1111 .label = "include",
1112 .type = P_STRING,
1113 .p_class = P_LOCAL,
1114 .offset = LOCAL_VAR(szInclude),
1115 .special = handle_include,
1116 .enum_list = NULL
1120 .label = "available",
1121 .type = P_BOOL,
1122 .p_class = P_LOCAL,
1123 .offset = LOCAL_VAR(bAvailable),
1124 .special = NULL,
1125 .enum_list = NULL
1128 .label = "volume",
1129 .type = P_STRING,
1130 .p_class = P_LOCAL,
1131 .offset = LOCAL_VAR(volume),
1132 .special = NULL,
1133 .enum_list = NULL
1136 .label = "fstype",
1137 .type = P_STRING,
1138 .p_class = P_LOCAL,
1139 .offset = LOCAL_VAR(fstype),
1140 .special = NULL,
1141 .enum_list = NULL
1145 .label = "panic action",
1146 .type = P_STRING,
1147 .p_class = P_GLOBAL,
1148 .offset = GLOBAL_VAR(panic_action),
1149 .special = NULL,
1150 .enum_list = NULL
1154 .label = "msdfs root",
1155 .type = P_BOOL,
1156 .p_class = P_LOCAL,
1157 .offset = LOCAL_VAR(bMSDfsRoot),
1158 .special = NULL,
1159 .enum_list = NULL
1162 .label = "host msdfs",
1163 .type = P_BOOL,
1164 .p_class = P_GLOBAL,
1165 .offset = GLOBAL_VAR(bHostMSDfs),
1166 .special = NULL,
1167 .enum_list = NULL
1170 .label = "winbind separator",
1171 .type = P_STRING,
1172 .p_class = P_GLOBAL,
1173 .offset = GLOBAL_VAR(szWinbindSeparator),
1174 .special = NULL,
1175 .enum_list = NULL
1178 .label = "winbindd socket directory",
1179 .type = P_STRING,
1180 .p_class = P_GLOBAL,
1181 .offset = GLOBAL_VAR(szWinbinddSocketDirectory),
1182 .special = NULL,
1183 .enum_list = NULL
1186 .label = "winbindd privileged socket directory",
1187 .type = P_STRING,
1188 .p_class = P_GLOBAL,
1189 .offset = GLOBAL_VAR(szWinbinddPrivilegedSocketDirectory),
1190 .special = NULL,
1191 .enum_list = NULL
1194 .label = "winbind sealed pipes",
1195 .type = P_BOOL,
1196 .p_class = P_GLOBAL,
1197 .offset = GLOBAL_VAR(bWinbindSealedPipes),
1198 .special = NULL,
1199 .enum_list = NULL
1202 .label = "template shell",
1203 .type = P_STRING,
1204 .p_class = P_GLOBAL,
1205 .offset = GLOBAL_VAR(szTemplateShell),
1206 .special = NULL,
1207 .enum_list = NULL
1210 .label = "template homedir",
1211 .type = P_STRING,
1212 .p_class = P_GLOBAL,
1213 .offset = GLOBAL_VAR(szTemplateHomedir),
1214 .special = NULL,
1215 .enum_list = NULL
1218 .label = "idmap trusted only",
1219 .type = P_BOOL,
1220 .p_class = P_GLOBAL,
1221 .offset = GLOBAL_VAR(bIdmapTrustedOnly),
1222 .special = NULL,
1223 .enum_list = NULL
1227 .label = "ntp signd socket directory",
1228 .type = P_STRING,
1229 .p_class = P_GLOBAL,
1230 .offset = GLOBAL_VAR(szNTPSignDSocketDirectory),
1231 .special = NULL,
1232 .enum_list = NULL
1235 .label = "rndc command",
1236 .type = P_CMDLIST,
1237 .p_class = P_GLOBAL,
1238 .offset = GLOBAL_VAR(szRNDCCommand),
1239 .special = NULL,
1240 .enum_list = NULL
1243 .label = "dns update command",
1244 .type = P_CMDLIST,
1245 .p_class = P_GLOBAL,
1246 .offset = GLOBAL_VAR(szDNSUpdateCommand),
1247 .special = NULL,
1248 .enum_list = NULL
1251 .label = "spn update command",
1252 .type = P_CMDLIST,
1253 .p_class = P_GLOBAL,
1254 .offset = GLOBAL_VAR(szSPNUpdateCommand),
1255 .special = NULL,
1256 .enum_list = NULL
1259 .label = "nsupdate command",
1260 .type = P_CMDLIST,
1261 .p_class = P_GLOBAL,
1262 .offset = GLOBAL_VAR(szNSUpdateCommand),
1263 .special = NULL,
1264 .enum_list = NULL
1267 {NULL, P_BOOL, P_NONE, 0, NULL, NULL, 0}
1271 /* local variables */
1272 struct loadparm_context {
1273 const char *szConfigFile;
1274 struct loadparm_global *globals;
1275 struct loadparm_service **services;
1276 struct loadparm_service *sDefault;
1277 struct smb_iconv_handle *iconv_handle;
1278 int iNumServices;
1279 struct loadparm_service *currentService;
1280 bool bInGlobalSection;
1281 struct file_lists {
1282 struct file_lists *next;
1283 char *name;
1284 char *subfname;
1285 time_t modtime;
1286 } *file_lists;
1287 unsigned int flags[NUMPARAMETERS];
1288 bool loaded;
1289 bool refuse_free;
1290 bool global; /* Is this the global context, which may set
1291 * global variables such as debug level etc? */
1292 const struct loadparm_s3_context *s3_fns;
1296 struct loadparm_service *lpcfg_default_service(struct loadparm_context *lp_ctx)
1298 if (lp_ctx->s3_fns) {
1299 return lp_ctx->s3_fns->get_default_loadparm_service();
1301 return lp_ctx->sDefault;
1305 * Convenience routine to grab string parameters into temporary memory
1306 * and run standard_sub_basic on them.
1308 * The buffers can be written to by
1309 * callers without affecting the source string.
1312 static const char *lp_string(const char *s)
1314 #if 0 /* until REWRITE done to make thread-safe */
1315 size_t len = s ? strlen(s) : 0;
1316 char *ret;
1317 #endif
1319 /* The follow debug is useful for tracking down memory problems
1320 especially if you have an inner loop that is calling a lp_*()
1321 function that returns a string. Perhaps this debug should be
1322 present all the time? */
1324 #if 0
1325 DEBUG(10, ("lp_string(%s)\n", s));
1326 #endif
1328 #if 0 /* until REWRITE done to make thread-safe */
1329 if (!lp_talloc)
1330 lp_talloc = talloc_init("lp_talloc");
1332 ret = talloc_array(lp_talloc, char, len + 100); /* leave room for substitution */
1334 if (!ret)
1335 return NULL;
1337 if (!s)
1338 *ret = 0;
1339 else
1340 strlcpy(ret, s, len);
1342 if (trim_string(ret, "\"", "\"")) {
1343 if (strchr(ret,'"') != NULL)
1344 strlcpy(ret, s, len);
1347 standard_sub_basic(ret,len+100);
1348 return (ret);
1349 #endif
1350 return s;
1354 In this section all the functions that are used to access the
1355 parameters from the rest of the program are defined
1359 * the creation of separate lpcfg_*() and lp_*() functions is to allow
1360 * for code compatibility between existing Samba4 and Samba3 code.
1363 /* this global context supports the lp_*() function varients */
1364 static struct loadparm_context *global_loadparm_context;
1366 #define lpcfg_default_service global_loadparm_context->sDefault
1367 #define lpcfg_global_service(i) global_loadparm_context->services[i]
1369 #define FN_GLOBAL_STRING(fn_name,var_name) \
1370 _PUBLIC_ const char *lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) { \
1371 if (lp_ctx == NULL) return NULL; \
1372 if (lp_ctx->s3_fns) { \
1373 SMB_ASSERT(lp_ctx->s3_fns->fn_name); \
1374 return lp_ctx->s3_fns->fn_name(); \
1376 return lp_ctx->globals->var_name ? lp_string(lp_ctx->globals->var_name) : ""; \
1379 #define FN_GLOBAL_CONST_STRING(fn_name,var_name) \
1380 _PUBLIC_ const char *lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) {\
1381 if (lp_ctx == NULL) return NULL; \
1382 if (lp_ctx->s3_fns) { \
1383 SMB_ASSERT(lp_ctx->s3_fns->fn_name); \
1384 return lp_ctx->s3_fns->fn_name(); \
1386 return lp_ctx->globals->var_name ? lp_string(lp_ctx->globals->var_name) : ""; \
1389 #define FN_GLOBAL_LIST(fn_name,var_name) \
1390 _PUBLIC_ const char **lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) { \
1391 if (lp_ctx == NULL) return NULL; \
1392 if (lp_ctx->s3_fns) { \
1393 SMB_ASSERT(lp_ctx->s3_fns->fn_name); \
1394 return lp_ctx->s3_fns->fn_name(); \
1396 return lp_ctx->globals->var_name; \
1399 #define FN_GLOBAL_BOOL(fn_name,var_name) \
1400 _PUBLIC_ bool lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) {\
1401 if (lp_ctx == NULL) return false; \
1402 if (lp_ctx->s3_fns) { \
1403 SMB_ASSERT(lp_ctx->s3_fns->fn_name); \
1404 return lp_ctx->s3_fns->fn_name(); \
1406 return lp_ctx->globals->var_name; \
1409 #define FN_GLOBAL_INTEGER(fn_name,var_name) \
1410 _PUBLIC_ int lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) { \
1411 if (lp_ctx->s3_fns) { \
1412 SMB_ASSERT(lp_ctx->s3_fns->fn_name); \
1413 return lp_ctx->s3_fns->fn_name(); \
1415 return lp_ctx->globals->var_name; \
1418 /* Local parameters don't need the ->s3_fns because the struct
1419 * loadparm_service is shared and lpcfg_service() checks the ->s3_fns
1420 * hook */
1421 #define FN_LOCAL_STRING(fn_name,val) \
1422 _PUBLIC_ const char *lpcfg_ ## fn_name(struct loadparm_service *service, \
1423 struct loadparm_service *sDefault) { \
1424 return(lp_string((const char *)((service != NULL && service->val != NULL) ? service->val : sDefault->val))); \
1427 #define FN_LOCAL_CONST_STRING(fn_name,val) FN_LOCAL_STRING(fn_name, val)
1429 #define FN_LOCAL_LIST(fn_name,val) \
1430 _PUBLIC_ const char **lpcfg_ ## fn_name(struct loadparm_service *service, \
1431 struct loadparm_service *sDefault) {\
1432 return(const char **)(service != NULL && service->val != NULL? service->val : sDefault->val); \
1435 #define FN_LOCAL_PARM_BOOL(fn_name, val) FN_LOCAL_BOOL(fn_name, val)
1437 #define FN_LOCAL_BOOL(fn_name,val) \
1438 _PUBLIC_ bool lpcfg_ ## fn_name(struct loadparm_service *service, \
1439 struct loadparm_service *sDefault) { \
1440 return((service != NULL)? service->val : sDefault->val); \
1443 #define FN_LOCAL_INTEGER(fn_name,val) \
1444 _PUBLIC_ int lpcfg_ ## fn_name(struct loadparm_service *service, \
1445 struct loadparm_service *sDefault) { \
1446 return((service != NULL)? service->val : sDefault->val); \
1449 #define FN_LOCAL_PARM_INTEGER(fn_name, val) FN_LOCAL_INTEGER(fn_name, val)
1451 #define FN_LOCAL_PARM_CHAR(fn_name, val) FN_LOCAL_CHAR(fn_name, val)
1453 #define FN_LOCAL_CHAR(fn_name,val) \
1454 _PUBLIC_ char lpcfg_ ## fn_name(struct loadparm_service *service, \
1455 struct loadparm_service *sDefault) { \
1456 return((service != NULL)? service->val : sDefault->val); \
1459 #include "lib/param/param_functions.c"
1461 FN_GLOBAL_INTEGER(server_role, server_role)
1462 FN_GLOBAL_LIST(smb_ports, smb_ports)
1463 FN_GLOBAL_INTEGER(nbt_port, nbt_port)
1464 FN_GLOBAL_INTEGER(dgram_port, dgram_port)
1465 FN_GLOBAL_INTEGER(cldap_port, cldap_port)
1466 FN_GLOBAL_INTEGER(krb5_port, krb5_port)
1467 FN_GLOBAL_INTEGER(kpasswd_port, kpasswd_port)
1468 FN_GLOBAL_INTEGER(web_port, web_port)
1469 FN_GLOBAL_BOOL(tls_enabled, tls_enabled)
1470 FN_GLOBAL_STRING(logfile, logfile)
1471 FN_GLOBAL_STRING(share_backend, szShareBackend)
1472 FN_GLOBAL_CONST_STRING(winbind_separator, szWinbindSeparator)
1473 FN_GLOBAL_CONST_STRING(winbindd_socket_directory, szWinbinddSocketDirectory)
1474 FN_GLOBAL_CONST_STRING(winbindd_privileged_socket_directory, szWinbinddPrivilegedSocketDirectory)
1475 FN_GLOBAL_CONST_STRING(template_shell, szTemplateShell)
1476 FN_GLOBAL_CONST_STRING(template_homedir, szTemplateHomedir)
1477 FN_GLOBAL_BOOL(winbind_sealed_pipes, bWinbindSealedPipes)
1478 FN_GLOBAL_BOOL(idmap_trusted_only, bIdmapTrustedOnly)
1479 FN_GLOBAL_STRING(private_dir, szPrivateDir)
1480 FN_GLOBAL_STRING(serverstring, szServerString)
1481 FN_GLOBAL_STRING(lockdir, szLockDir)
1482 FN_GLOBAL_STRING(statedir, szStateDir)
1483 FN_GLOBAL_STRING(cachedir, szCacheDir)
1484 FN_GLOBAL_STRING(ncalrpc_dir, ncalrpc_dir)
1485 FN_GLOBAL_STRING(dos_charset, dos_charset)
1486 FN_GLOBAL_STRING(unix_charset, unix_charset)
1487 FN_GLOBAL_STRING(piddir, szPidDir)
1488 FN_GLOBAL_LIST(rndc_command, szRNDCCommand)
1489 FN_GLOBAL_LIST(dns_update_command, szDNSUpdateCommand)
1490 FN_GLOBAL_LIST(spn_update_command, szSPNUpdateCommand)
1491 FN_GLOBAL_LIST(nsupdate_command, szNSUpdateCommand)
1492 FN_GLOBAL_LIST(dcerpc_endpoint_servers, dcerpc_ep_servers)
1493 FN_GLOBAL_LIST(server_services, server_services)
1494 FN_GLOBAL_STRING(ntptr_providor, ntptr_providor)
1495 FN_GLOBAL_STRING(passdb_backend, passdb_backend)
1496 FN_GLOBAL_STRING(auto_services, szAutoServices)
1497 FN_GLOBAL_STRING(passwd_chat, szPasswdChat)
1498 FN_GLOBAL_LIST(passwordserver, szPasswordServers)
1499 FN_GLOBAL_LIST(name_resolve_order, szNameResolveOrder)
1500 FN_GLOBAL_STRING(realm, szRealm_upper)
1501 FN_GLOBAL_STRING(dnsdomain, szRealm_lower)
1502 FN_GLOBAL_STRING(socket_options, socket_options)
1503 FN_GLOBAL_STRING(workgroup, szWorkgroup)
1504 FN_GLOBAL_STRING(netbios_name, szNetbiosName)
1505 FN_GLOBAL_STRING(netbios_scope, szNetbiosScope)
1506 FN_GLOBAL_LIST(wins_server_list, szWINSservers)
1507 FN_GLOBAL_LIST(interfaces, szInterfaces)
1508 FN_GLOBAL_STRING(socket_address, szSocketAddress)
1509 FN_GLOBAL_LIST(netbios_aliases, szNetbiosAliases)
1510 FN_GLOBAL_BOOL(disable_netbios, bDisableNetbios)
1511 FN_GLOBAL_BOOL(we_are_a_wins_server, bWINSsupport)
1512 FN_GLOBAL_BOOL(wins_dns_proxy, bWINSdnsProxy)
1513 FN_GLOBAL_STRING(wins_hook, szWINSHook)
1514 FN_GLOBAL_BOOL(local_master, bLocalMaster)
1515 FN_GLOBAL_BOOL(readraw, bReadRaw)
1516 FN_GLOBAL_BOOL(large_readwrite, bLargeReadwrite)
1517 FN_GLOBAL_BOOL(writeraw, bWriteRaw)
1518 FN_GLOBAL_BOOL(null_passwords, bNullPasswords)
1519 FN_GLOBAL_BOOL(obey_pam_restrictions, bObeyPamRestrictions)
1520 FN_GLOBAL_BOOL(encrypted_passwords, bEncryptPasswords)
1521 FN_GLOBAL_BOOL(time_server, bTimeServer)
1522 FN_GLOBAL_BOOL(bind_interfaces_only, bBindInterfacesOnly)
1523 FN_GLOBAL_BOOL(unicode, bUnicode)
1524 FN_GLOBAL_BOOL(nt_status_support, bNTStatusSupport)
1525 FN_GLOBAL_BOOL(lanman_auth, bLanmanAuth)
1526 FN_GLOBAL_BOOL(ntlm_auth, bNTLMAuth)
1527 FN_GLOBAL_BOOL(client_plaintext_auth, bClientPlaintextAuth)
1528 FN_GLOBAL_BOOL(client_lanman_auth, bClientLanManAuth)
1529 FN_GLOBAL_BOOL(client_ntlmv2_auth, bClientNTLMv2Auth)
1530 FN_GLOBAL_BOOL(client_use_spnego_principal, client_use_spnego_principal)
1531 FN_GLOBAL_BOOL(host_msdfs, bHostMSDfs)
1532 FN_GLOBAL_BOOL(unix_extensions, bUnixExtensions)
1533 FN_GLOBAL_BOOL(use_spnego, bUseSpnego)
1534 FN_GLOBAL_BOOL(use_mmap, bUseMmap)
1535 FN_GLOBAL_BOOL(rpc_big_endian, bRpcBigEndian)
1536 FN_GLOBAL_INTEGER(max_wins_ttl, max_wins_ttl)
1537 FN_GLOBAL_INTEGER(min_wins_ttl, min_wins_ttl)
1538 FN_GLOBAL_INTEGER(maxmux, max_mux)
1539 FN_GLOBAL_INTEGER(max_xmit, max_xmit)
1540 FN_GLOBAL_INTEGER(passwordlevel, pwordlevel)
1541 FN_GLOBAL_INTEGER(srv_maxprotocol, srv_maxprotocol)
1542 FN_GLOBAL_INTEGER(srv_minprotocol, srv_minprotocol)
1543 FN_GLOBAL_INTEGER(cli_maxprotocol, cli_maxprotocol)
1544 FN_GLOBAL_INTEGER(cli_minprotocol, cli_minprotocol)
1545 FN_GLOBAL_INTEGER(security, security)
1546 FN_GLOBAL_BOOL(paranoid_server_security, paranoid_server_security)
1548 FN_GLOBAL_INTEGER(server_signing, server_signing)
1549 FN_GLOBAL_INTEGER(client_signing, client_signing)
1551 FN_GLOBAL_CONST_STRING(ntp_signd_socket_directory, szNTPSignDSocketDirectory)
1553 /* local prototypes */
1554 static int map_parameter(const char *pszParmName);
1555 static struct loadparm_service *getservicebyname(struct loadparm_context *lp_ctx,
1556 const char *pszServiceName);
1557 static void copy_service(struct loadparm_service *pserviceDest,
1558 struct loadparm_service *pserviceSource,
1559 struct bitmap *pcopymapDest);
1560 static bool lpcfg_service_ok(struct loadparm_service *service);
1561 static bool do_section(const char *pszSectionName, void *);
1562 static void init_copymap(struct loadparm_service *pservice);
1564 /* This is a helper function for parametrical options support. */
1565 /* It returns a pointer to parametrical option value if it exists or NULL otherwise */
1566 /* Actual parametrical functions are quite simple */
1567 const char *lpcfg_get_parametric(struct loadparm_context *lp_ctx,
1568 struct loadparm_service *service,
1569 const char *type, const char *option)
1571 char *vfskey_tmp = NULL;
1572 char *vfskey = NULL;
1573 struct parmlist_entry *data;
1575 if (lp_ctx == NULL)
1576 return NULL;
1578 if (lp_ctx->s3_fns) {
1579 return lp_ctx->s3_fns->get_parametric(service, type, option);
1582 data = (service == NULL ? lp_ctx->globals->param_opt : service->param_opt);
1584 vfskey_tmp = talloc_asprintf(NULL, "%s:%s", type, option);
1585 if (vfskey_tmp == NULL) return NULL;
1586 vfskey = strlower_talloc(NULL, vfskey_tmp);
1587 talloc_free(vfskey_tmp);
1589 while (data) {
1590 if (strcmp(data->key, vfskey) == 0) {
1591 talloc_free(vfskey);
1592 return data->value;
1594 data = data->next;
1597 if (service != NULL) {
1598 /* Try to fetch the same option but from globals */
1599 /* but only if we are not already working with globals */
1600 for (data = lp_ctx->globals->param_opt; data;
1601 data = data->next) {
1602 if (strcmp(data->key, vfskey) == 0) {
1603 talloc_free(vfskey);
1604 return data->value;
1609 talloc_free(vfskey);
1611 return NULL;
1616 * convenience routine to return int parameters.
1618 static int lp_int(const char *s)
1621 if (!s) {
1622 DEBUG(0,("lp_int(%s): is called with NULL!\n",s));
1623 return -1;
1626 return strtol(s, NULL, 0);
1630 * convenience routine to return unsigned long parameters.
1632 static int lp_ulong(const char *s)
1635 if (!s) {
1636 DEBUG(0,("lp_int(%s): is called with NULL!\n",s));
1637 return -1;
1640 return strtoul(s, NULL, 0);
1644 * convenience routine to return unsigned long parameters.
1646 static double lp_double(const char *s)
1649 if (!s) {
1650 DEBUG(0,("lp_double(%s): is called with NULL!\n",s));
1651 return -1;
1654 return strtod(s, NULL);
1658 * convenience routine to return boolean parameters.
1660 static bool lp_bool(const char *s)
1662 bool ret = false;
1664 if (!s) {
1665 DEBUG(0,("lp_bool(%s): is called with NULL!\n",s));
1666 return false;
1669 if (!set_boolean(s, &ret)) {
1670 DEBUG(0,("lp_bool(%s): value is not boolean!\n",s));
1671 return false;
1674 return ret;
1679 * Return parametric option from a given service. Type is a part of option before ':'
1680 * Parametric option has following syntax: 'Type: option = value'
1681 * Returned value is allocated in 'lp_talloc' context
1684 const char *lpcfg_parm_string(struct loadparm_context *lp_ctx,
1685 struct loadparm_service *service, const char *type,
1686 const char *option)
1688 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
1690 if (value)
1691 return lp_string(value);
1693 return NULL;
1697 * Return parametric option from a given service. Type is a part of option before ':'
1698 * Parametric option has following syntax: 'Type: option = value'
1699 * Returned value is allocated in 'lp_talloc' context
1702 const char **lpcfg_parm_string_list(TALLOC_CTX *mem_ctx,
1703 struct loadparm_context *lp_ctx,
1704 struct loadparm_service *service,
1705 const char *type,
1706 const char *option, const char *separator)
1708 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
1710 if (value != NULL)
1711 return (const char **)str_list_make(mem_ctx, value, separator);
1713 return NULL;
1717 * Return parametric option from a given service. Type is a part of option before ':'
1718 * Parametric option has following syntax: 'Type: option = value'
1721 int lpcfg_parm_int(struct loadparm_context *lp_ctx,
1722 struct loadparm_service *service, const char *type,
1723 const char *option, int default_v)
1725 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
1727 if (value)
1728 return lp_int(value);
1730 return default_v;
1734 * Return parametric option from a given service. Type is a part of
1735 * option before ':'.
1736 * Parametric option has following syntax: 'Type: option = value'.
1739 int lpcfg_parm_bytes(struct loadparm_context *lp_ctx,
1740 struct loadparm_service *service, const char *type,
1741 const char *option, int default_v)
1743 uint64_t bval;
1745 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
1747 if (value && conv_str_size_error(value, &bval)) {
1748 if (bval <= INT_MAX) {
1749 return (int)bval;
1753 return default_v;
1757 * Return parametric option from a given service.
1758 * Type is a part of option before ':'
1759 * Parametric option has following syntax: 'Type: option = value'
1761 unsigned long lpcfg_parm_ulong(struct loadparm_context *lp_ctx,
1762 struct loadparm_service *service, const char *type,
1763 const char *option, unsigned long default_v)
1765 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
1767 if (value)
1768 return lp_ulong(value);
1770 return default_v;
1774 double lpcfg_parm_double(struct loadparm_context *lp_ctx,
1775 struct loadparm_service *service, const char *type,
1776 const char *option, double default_v)
1778 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
1780 if (value != NULL)
1781 return lp_double(value);
1783 return default_v;
1787 * Return parametric option from a given service. Type is a part of option before ':'
1788 * Parametric option has following syntax: 'Type: option = value'
1791 bool lpcfg_parm_bool(struct loadparm_context *lp_ctx,
1792 struct loadparm_service *service, const char *type,
1793 const char *option, bool default_v)
1795 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
1797 if (value != NULL)
1798 return lp_bool(value);
1800 return default_v;
1805 * Initialise a service to the defaults.
1808 static struct loadparm_service *init_service(TALLOC_CTX *mem_ctx, struct loadparm_service *sDefault)
1810 struct loadparm_service *pservice =
1811 talloc_zero(mem_ctx, struct loadparm_service);
1812 copy_service(pservice, sDefault, NULL);
1813 return pservice;
1817 * Set a string value, deallocating any existing space, and allocing the space
1818 * for the string
1820 static bool lpcfg_string_set(TALLOC_CTX *mem_ctx, char **dest, const char *src)
1822 talloc_free(*dest);
1824 if (src == NULL)
1825 src = "";
1827 *dest = talloc_strdup(mem_ctx, src);
1828 if ((*dest) == NULL) {
1829 DEBUG(0,("Out of memory in string_set\n"));
1830 return false;
1833 return true;
1837 * Set a string value, deallocating any existing space, and allocing the space
1838 * for the string
1840 static bool lpcfg_string_set_upper(TALLOC_CTX *mem_ctx, char **dest, const char *src)
1842 talloc_free(*dest);
1844 if (src == NULL)
1845 src = "";
1847 *dest = strupper_talloc(mem_ctx, src);
1848 if ((*dest) == NULL) {
1849 DEBUG(0,("Out of memory in string_set_upper\n"));
1850 return false;
1853 return true;
1859 * Add a new service to the services array initialising it with the given
1860 * service.
1863 struct loadparm_service *lpcfg_add_service(struct loadparm_context *lp_ctx,
1864 const struct loadparm_service *pservice,
1865 const char *name)
1867 int i;
1868 struct loadparm_service tservice;
1869 int num_to_alloc = lp_ctx->iNumServices + 1;
1870 struct parmlist_entry *data, *pdata;
1872 if (pservice == NULL) {
1873 pservice = lp_ctx->sDefault;
1876 tservice = *pservice;
1878 /* it might already exist */
1879 if (name) {
1880 struct loadparm_service *service = getservicebyname(lp_ctx,
1881 name);
1882 if (service != NULL) {
1883 /* Clean all parametric options for service */
1884 /* They will be added during parsing again */
1885 data = service->param_opt;
1886 while (data) {
1887 pdata = data->next;
1888 talloc_free(data);
1889 data = pdata;
1891 service->param_opt = NULL;
1892 return service;
1896 /* find an invalid one */
1897 for (i = 0; i < lp_ctx->iNumServices; i++)
1898 if (lp_ctx->services[i] == NULL)
1899 break;
1901 /* if not, then create one */
1902 if (i == lp_ctx->iNumServices) {
1903 struct loadparm_service **tsp;
1905 tsp = talloc_realloc(lp_ctx, lp_ctx->services, struct loadparm_service *, num_to_alloc);
1907 if (!tsp) {
1908 DEBUG(0,("lpcfg_add_service: failed to enlarge services!\n"));
1909 return NULL;
1910 } else {
1911 lp_ctx->services = tsp;
1912 lp_ctx->services[lp_ctx->iNumServices] = NULL;
1915 lp_ctx->iNumServices++;
1918 lp_ctx->services[i] = init_service(lp_ctx->services, lp_ctx->sDefault);
1919 if (lp_ctx->services[i] == NULL) {
1920 DEBUG(0,("lpcfg_add_service: out of memory!\n"));
1921 return NULL;
1923 copy_service(lp_ctx->services[i], &tservice, NULL);
1924 if (name != NULL)
1925 lpcfg_string_set(lp_ctx->services[i], &lp_ctx->services[i]->szService, name);
1926 return lp_ctx->services[i];
1930 * Add a new home service, with the specified home directory, defaults coming
1931 * from service ifrom.
1934 bool lpcfg_add_home(struct loadparm_context *lp_ctx,
1935 const char *pszHomename,
1936 struct loadparm_service *default_service,
1937 const char *user, const char *pszHomedir)
1939 struct loadparm_service *service;
1941 service = lpcfg_add_service(lp_ctx, default_service, pszHomename);
1943 if (service == NULL)
1944 return false;
1946 if (!(*(default_service->szPath))
1947 || strequal(default_service->szPath, lp_ctx->sDefault->szPath)) {
1948 service->szPath = talloc_strdup(service, pszHomedir);
1949 } else {
1950 service->szPath = string_sub_talloc(service, lpcfg_pathname(default_service, lp_ctx->sDefault), "%H", pszHomedir);
1953 if (!(*(service->comment))) {
1954 service->comment = talloc_asprintf(service, "Home directory of %s", user);
1956 service->bAvailable = default_service->bAvailable;
1957 service->bBrowseable = default_service->bBrowseable;
1959 DEBUG(3, ("adding home's share [%s] for user '%s' at '%s'\n",
1960 pszHomename, user, service->szPath));
1962 return true;
1966 * Add a new printer service, with defaults coming from service iFrom.
1969 bool lpcfg_add_printer(struct loadparm_context *lp_ctx,
1970 const char *pszPrintername,
1971 struct loadparm_service *default_service)
1973 const char *comment = "From Printcap";
1974 struct loadparm_service *service;
1975 service = lpcfg_add_service(lp_ctx, default_service, pszPrintername);
1977 if (service == NULL)
1978 return false;
1980 /* note that we do NOT default the availability flag to True - */
1981 /* we take it from the default service passed. This allows all */
1982 /* dynamic printers to be disabled by disabling the [printers] */
1983 /* entry (if/when the 'available' keyword is implemented!). */
1985 /* the printer name is set to the service name. */
1986 lpcfg_string_set(service, &service->szPrintername, pszPrintername);
1987 lpcfg_string_set(service, &service->comment, comment);
1988 service->bBrowseable = default_service->bBrowseable;
1989 /* Printers cannot be read_only. */
1990 service->bRead_only = false;
1991 /* Printer services must be printable. */
1992 service->bPrint_ok = true;
1994 DEBUG(3, ("adding printer service %s\n", pszPrintername));
1996 return true;
2000 * Map a parameter's string representation to something we can use.
2001 * Returns False if the parameter string is not recognised, else TRUE.
2004 static int map_parameter(const char *pszParmName)
2006 int iIndex;
2008 if (*pszParmName == '-')
2009 return -1;
2011 for (iIndex = 0; parm_table[iIndex].label; iIndex++)
2012 if (strwicmp(parm_table[iIndex].label, pszParmName) == 0)
2013 return iIndex;
2015 /* Warn only if it isn't parametric option */
2016 if (strchr(pszParmName, ':') == NULL)
2017 DEBUG(0, ("Unknown parameter encountered: \"%s\"\n", pszParmName));
2018 /* We do return 'fail' for parametric options as well because they are
2019 stored in different storage
2021 return -1;
2026 return the parameter structure for a parameter
2028 struct parm_struct *lpcfg_parm_struct(struct loadparm_context *lp_ctx, const char *name)
2030 int parmnum;
2032 if (lp_ctx->s3_fns) {
2033 return lp_ctx->s3_fns->get_parm_struct(name);
2036 parmnum = map_parameter(name);
2037 if (parmnum == -1) return NULL;
2038 return &parm_table[parmnum];
2042 return the parameter pointer for a parameter
2044 void *lpcfg_parm_ptr(struct loadparm_context *lp_ctx,
2045 struct loadparm_service *service, struct parm_struct *parm)
2047 if (lp_ctx->s3_fns) {
2048 return lp_ctx->s3_fns->get_parm_ptr(service, parm);
2051 if (service == NULL) {
2052 if (parm->p_class == P_LOCAL)
2053 return ((char *)lp_ctx->sDefault)+parm->offset;
2054 else if (parm->p_class == P_GLOBAL)
2055 return ((char *)lp_ctx->globals)+parm->offset;
2056 else return NULL;
2057 } else {
2058 return ((char *)service) + parm->offset;
2063 return the parameter pointer for a parameter
2065 bool lpcfg_parm_is_cmdline(struct loadparm_context *lp_ctx, const char *name)
2067 int parmnum;
2069 if (lp_ctx->s3_fns) {
2070 struct parm_struct *parm = lp_ctx->s3_fns->get_parm_struct(name);
2071 if (parm) {
2072 return parm->flags & FLAG_CMDLINE;
2074 return false;
2077 parmnum = map_parameter(name);
2078 if (parmnum == -1) return false;
2080 return lp_ctx->flags[parmnum] & FLAG_CMDLINE;
2084 * Find a service by name. Otherwise works like get_service.
2087 static struct loadparm_service *getservicebyname(struct loadparm_context *lp_ctx,
2088 const char *pszServiceName)
2090 int iService;
2092 if (lp_ctx->s3_fns) {
2093 return lp_ctx->s3_fns->get_service(pszServiceName);
2096 for (iService = lp_ctx->iNumServices - 1; iService >= 0; iService--)
2097 if (lp_ctx->services[iService] != NULL &&
2098 strwicmp(lp_ctx->services[iService]->szService, pszServiceName) == 0) {
2099 return lp_ctx->services[iService];
2102 return NULL;
2106 * Copy a service structure to another.
2107 * If pcopymapDest is NULL then copy all fields
2110 static void copy_service(struct loadparm_service *pserviceDest,
2111 struct loadparm_service *pserviceSource,
2112 struct bitmap *pcopymapDest)
2114 int i;
2115 bool bcopyall = (pcopymapDest == NULL);
2116 struct parmlist_entry *data, *pdata, *paramo;
2117 bool not_added;
2119 for (i = 0; parm_table[i].label; i++)
2120 if (parm_table[i].p_class == P_LOCAL &&
2121 (bcopyall || bitmap_query(pcopymapDest, i))) {
2122 void *src_ptr =
2123 ((char *)pserviceSource) + parm_table[i].offset;
2124 void *dest_ptr =
2125 ((char *)pserviceDest) + parm_table[i].offset;
2127 switch (parm_table[i].type) {
2128 case P_BOOL:
2129 *(bool *)dest_ptr = *(bool *)src_ptr;
2130 break;
2132 case P_INTEGER:
2133 case P_OCTAL:
2134 case P_ENUM:
2135 *(int *)dest_ptr = *(int *)src_ptr;
2136 break;
2138 case P_STRING:
2139 lpcfg_string_set(pserviceDest,
2140 (char **)dest_ptr,
2141 *(char **)src_ptr);
2142 break;
2144 case P_USTRING:
2145 lpcfg_string_set_upper(pserviceDest,
2146 (char **)dest_ptr,
2147 *(char **)src_ptr);
2148 break;
2149 case P_LIST:
2150 *(const char ***)dest_ptr = (const char **)str_list_copy(pserviceDest,
2151 *(const char ***)src_ptr);
2152 break;
2153 default:
2154 break;
2158 if (bcopyall) {
2159 init_copymap(pserviceDest);
2160 if (pserviceSource->copymap)
2161 bitmap_copy(pserviceDest->copymap,
2162 pserviceSource->copymap);
2165 data = pserviceSource->param_opt;
2166 while (data) {
2167 not_added = true;
2168 pdata = pserviceDest->param_opt;
2169 /* Traverse destination */
2170 while (pdata) {
2171 /* If we already have same option, override it */
2172 if (strcmp(pdata->key, data->key) == 0) {
2173 talloc_free(pdata->value);
2174 pdata->value = talloc_reference(pdata,
2175 data->value);
2176 not_added = false;
2177 break;
2179 pdata = pdata->next;
2181 if (not_added) {
2182 paramo = talloc_zero(pserviceDest, struct parmlist_entry);
2183 if (paramo == NULL)
2184 smb_panic("OOM");
2185 paramo->key = talloc_reference(paramo, data->key);
2186 paramo->value = talloc_reference(paramo, data->value);
2187 DLIST_ADD(pserviceDest->param_opt, paramo);
2189 data = data->next;
2194 * Check a service for consistency. Return False if the service is in any way
2195 * incomplete or faulty, else True.
2197 static bool lpcfg_service_ok(struct loadparm_service *service)
2199 bool bRetval;
2201 bRetval = true;
2202 if (service->szService[0] == '\0') {
2203 DEBUG(0, ("The following message indicates an internal error:\n"));
2204 DEBUG(0, ("No service name in service entry.\n"));
2205 bRetval = false;
2208 /* The [printers] entry MUST be printable. I'm all for flexibility, but */
2209 /* I can't see why you'd want a non-printable printer service... */
2210 if (strwicmp(service->szService, PRINTERS_NAME) == 0) {
2211 if (!service->bPrint_ok) {
2212 DEBUG(0, ("WARNING: [%s] service MUST be printable!\n",
2213 service->szService));
2214 service->bPrint_ok = true;
2216 /* [printers] service must also be non-browsable. */
2217 if (service->bBrowseable)
2218 service->bBrowseable = false;
2221 /* If a service is flagged unavailable, log the fact at level 0. */
2222 if (!service->bAvailable)
2223 DEBUG(1, ("NOTE: Service %s is flagged unavailable.\n",
2224 service->szService));
2226 return bRetval;
2230 /*******************************************************************
2231 Keep a linked list of all config files so we know when one has changed
2232 it's date and needs to be reloaded.
2233 ********************************************************************/
2235 static void add_to_file_list(struct loadparm_context *lp_ctx,
2236 const char *fname, const char *subfname)
2238 struct file_lists *f = lp_ctx->file_lists;
2240 while (f) {
2241 if (f->name && !strcmp(f->name, fname))
2242 break;
2243 f = f->next;
2246 if (!f) {
2247 f = talloc(lp_ctx, struct file_lists);
2248 if (!f)
2249 return;
2250 f->next = lp_ctx->file_lists;
2251 f->name = talloc_strdup(f, fname);
2252 if (!f->name) {
2253 talloc_free(f);
2254 return;
2256 f->subfname = talloc_strdup(f, subfname);
2257 if (!f->subfname) {
2258 talloc_free(f);
2259 return;
2261 lp_ctx->file_lists = f;
2262 f->modtime = file_modtime(subfname);
2263 } else {
2264 time_t t = file_modtime(subfname);
2265 if (t)
2266 f->modtime = t;
2270 /*******************************************************************
2271 Check if a config file has changed date.
2272 ********************************************************************/
2273 bool lpcfg_file_list_changed(struct loadparm_context *lp_ctx)
2275 struct file_lists *f;
2276 DEBUG(6, ("lp_file_list_changed()\n"));
2278 for (f = lp_ctx->file_lists; f != NULL; f = f->next) {
2279 char *n2;
2280 time_t mod_time;
2282 n2 = standard_sub_basic(lp_ctx, f->name);
2284 DEBUGADD(6, ("file %s -> %s last mod_time: %s\n",
2285 f->name, n2, ctime(&f->modtime)));
2287 mod_time = file_modtime(n2);
2289 if (mod_time && ((f->modtime != mod_time) || (f->subfname == NULL) || (strcmp(n2, f->subfname) != 0))) {
2290 DEBUGADD(6, ("file %s modified: %s\n", n2,
2291 ctime(&mod_time)));
2292 f->modtime = mod_time;
2293 talloc_free(f->subfname);
2294 f->subfname = talloc_strdup(f, n2);
2295 return true;
2298 return false;
2301 /***************************************************************************
2302 Handle the "realm" parameter
2303 ***************************************************************************/
2305 static bool handle_realm(struct loadparm_context *lp_ctx, int unused,
2306 const char *pszParmValue, char **ptr)
2308 lpcfg_string_set(lp_ctx, ptr, pszParmValue);
2310 talloc_free(lp_ctx->globals->szRealm_upper);
2311 talloc_free(lp_ctx->globals->szRealm_lower);
2313 lp_ctx->globals->szRealm_upper = strupper_talloc(lp_ctx, pszParmValue);
2314 lp_ctx->globals->szRealm_lower = strlower_talloc(lp_ctx, pszParmValue);
2316 return true;
2319 /***************************************************************************
2320 Handle the include operation.
2321 ***************************************************************************/
2323 static bool handle_include(struct loadparm_context *lp_ctx, int unused,
2324 const char *pszParmValue, char **ptr)
2326 char *fname = standard_sub_basic(lp_ctx, pszParmValue);
2328 add_to_file_list(lp_ctx, pszParmValue, fname);
2330 lpcfg_string_set(lp_ctx, ptr, fname);
2332 if (file_exist(fname))
2333 return pm_process(fname, do_section, do_parameter, lp_ctx);
2335 DEBUG(2, ("Can't find include file %s\n", fname));
2337 return false;
2340 /***************************************************************************
2341 Handle the interpretation of the copy parameter.
2342 ***************************************************************************/
2344 static bool handle_copy(struct loadparm_context *lp_ctx, int unused,
2345 const char *pszParmValue, char **ptr)
2347 bool bRetval;
2348 struct loadparm_service *serviceTemp;
2350 lpcfg_string_set(lp_ctx, ptr, pszParmValue);
2352 bRetval = false;
2354 DEBUG(3, ("Copying service from service %s\n", pszParmValue));
2356 if ((serviceTemp = getservicebyname(lp_ctx, pszParmValue)) != NULL) {
2357 if (serviceTemp == lp_ctx->currentService) {
2358 DEBUG(0, ("Can't copy service %s - unable to copy self!\n", pszParmValue));
2359 } else {
2360 copy_service(lp_ctx->currentService,
2361 serviceTemp,
2362 lp_ctx->currentService->copymap);
2363 bRetval = true;
2365 } else {
2366 DEBUG(0, ("Unable to copy service - source not found: %s\n",
2367 pszParmValue));
2368 bRetval = false;
2371 return bRetval;
2374 static bool handle_debuglevel(struct loadparm_context *lp_ctx, int unused,
2375 const char *pszParmValue, char **ptr)
2378 lpcfg_string_set(lp_ctx, ptr, pszParmValue);
2379 if (lp_ctx->global) {
2380 return debug_parse_levels(pszParmValue);
2382 return true;
2385 static bool handle_logfile(struct loadparm_context *lp_ctx, int unused,
2386 const char *pszParmValue, char **ptr)
2388 debug_set_logfile(pszParmValue);
2389 if (lp_ctx->global) {
2390 lpcfg_string_set(lp_ctx, ptr, pszParmValue);
2392 return true;
2395 /***************************************************************************
2396 Initialise a copymap.
2397 ***************************************************************************/
2399 static void init_copymap(struct loadparm_service *pservice)
2401 int i;
2403 TALLOC_FREE(pservice->copymap);
2405 pservice->copymap = bitmap_talloc(NULL, NUMPARAMETERS);
2406 if (!pservice->copymap)
2407 DEBUG(0,
2408 ("Couldn't allocate copymap!! (size %d)\n",
2409 (int)NUMPARAMETERS));
2410 else
2411 for (i = 0; i < NUMPARAMETERS; i++)
2412 bitmap_set(pservice->copymap, i);
2416 * Process a parametric option
2418 static bool lp_do_parameter_parametric(struct loadparm_context *lp_ctx,
2419 struct loadparm_service *service,
2420 const char *pszParmName,
2421 const char *pszParmValue, int flags)
2423 struct parmlist_entry *paramo, *data;
2424 char *name;
2425 TALLOC_CTX *mem_ctx;
2427 while (isspace((unsigned char)*pszParmName)) {
2428 pszParmName++;
2431 name = strlower_talloc(lp_ctx, pszParmName);
2432 if (!name) return false;
2434 if (service == NULL) {
2435 data = lp_ctx->globals->param_opt;
2436 mem_ctx = lp_ctx->globals;
2437 } else {
2438 data = service->param_opt;
2439 mem_ctx = service;
2442 /* Traverse destination */
2443 for (paramo=data; paramo; paramo=paramo->next) {
2444 /* If we already have the option set, override it unless
2445 it was a command line option and the new one isn't */
2446 if (strcmp(paramo->key, name) == 0) {
2447 if ((paramo->priority & FLAG_CMDLINE) &&
2448 !(flags & FLAG_CMDLINE)) {
2449 talloc_free(name);
2450 return true;
2453 talloc_free(paramo->value);
2454 paramo->value = talloc_strdup(paramo, pszParmValue);
2455 paramo->priority = flags;
2456 talloc_free(name);
2457 return true;
2461 paramo = talloc_zero(mem_ctx, struct parmlist_entry);
2462 if (!paramo)
2463 smb_panic("OOM");
2464 paramo->key = talloc_strdup(paramo, name);
2465 paramo->value = talloc_strdup(paramo, pszParmValue);
2466 paramo->priority = flags;
2467 if (service == NULL) {
2468 DLIST_ADD(lp_ctx->globals->param_opt, paramo);
2469 } else {
2470 DLIST_ADD(service->param_opt, paramo);
2473 talloc_free(name);
2475 return true;
2478 static bool set_variable(TALLOC_CTX *mem_ctx, int parmnum, void *parm_ptr,
2479 const char *pszParmName, const char *pszParmValue,
2480 struct loadparm_context *lp_ctx, bool on_globals)
2482 int i;
2483 /* if it is a special case then go ahead */
2484 if (parm_table[parmnum].special) {
2485 bool ret;
2486 ret = parm_table[parmnum].special(lp_ctx, -1, pszParmValue,
2487 (char **)parm_ptr);
2488 if (!ret) {
2489 return false;
2491 goto mark_non_default;
2494 /* now switch on the type of variable it is */
2495 switch (parm_table[parmnum].type)
2497 case P_BOOL: {
2498 bool b;
2499 if (!set_boolean(pszParmValue, &b)) {
2500 DEBUG(0,("lp_do_parameter(%s): value is not boolean!\n", pszParmValue));
2501 return false;
2503 *(bool *)parm_ptr = b;
2505 break;
2507 case P_BOOLREV: {
2508 bool b;
2509 if (!set_boolean(pszParmValue, &b)) {
2510 DEBUG(0,("lp_do_parameter(%s): value is not boolean!\n", pszParmValue));
2511 return false;
2513 *(bool *)parm_ptr = !b;
2515 break;
2517 case P_INTEGER:
2518 *(int *)parm_ptr = atoi(pszParmValue);
2519 break;
2521 case P_CHAR:
2522 *(char *)parm_ptr = *pszParmValue;
2523 break;
2525 case P_OCTAL:
2526 *(int *)parm_ptr = strtol(pszParmValue, NULL, 8);
2527 break;
2529 case P_BYTES:
2531 uint64_t val;
2532 if (conv_str_size_error(pszParmValue, &val)) {
2533 if (val <= INT_MAX) {
2534 *(int *)parm_ptr = (int)val;
2535 break;
2539 DEBUG(0,("lp_do_parameter(%s): value is not "
2540 "a valid size specifier!\n", pszParmValue));
2541 return false;
2544 case P_CMDLIST:
2545 *(const char ***)parm_ptr = (const char **)str_list_make(mem_ctx,
2546 pszParmValue, NULL);
2547 break;
2548 case P_LIST:
2550 char **new_list = str_list_make(mem_ctx,
2551 pszParmValue, NULL);
2552 for (i=0; new_list[i]; i++) {
2553 if (new_list[i][0] == '+' && new_list[i][1] &&
2554 (!str_list_check(*(const char ***)parm_ptr,
2555 &new_list[i][1]))) {
2556 *(const char ***)parm_ptr = str_list_add(*(const char ***)parm_ptr,
2557 &new_list[i][1]);
2558 } else if (new_list[i][0] == '-' && new_list[i][1]) {
2559 #if 0 /* This is commented out because we sometimes parse the list
2560 * twice, and so we can't assert on this */
2561 if (!str_list_check(*(const char ***)parm_ptr,
2562 &new_list[i][1])) {
2563 DEBUG(0, ("Unsupported value for: %s = %s, %s is not in the original list [%s]\n",
2564 pszParmName, pszParmValue, new_list[i],
2565 str_list_join_shell(mem_ctx, *(const char ***)parm_ptr, ' ')));
2566 return false;
2569 #endif
2570 str_list_remove(*(const char ***)parm_ptr,
2571 &new_list[i][1]);
2572 } else {
2573 if (i != 0) {
2574 DEBUG(0, ("Unsupported list syntax for: %s = %s\n",
2575 pszParmName, pszParmValue));
2576 return false;
2578 *(const char ***)parm_ptr = (const char **) new_list;
2579 break;
2582 break;
2584 case P_STRING:
2585 lpcfg_string_set(mem_ctx, (char **)parm_ptr, pszParmValue);
2586 break;
2588 case P_USTRING:
2589 lpcfg_string_set_upper(mem_ctx, (char **)parm_ptr, pszParmValue);
2590 break;
2592 case P_ENUM:
2593 for (i = 0; parm_table[parmnum].enum_list[i].name; i++) {
2594 if (strequal
2595 (pszParmValue,
2596 parm_table[parmnum].enum_list[i].name)) {
2597 *(int *)parm_ptr =
2598 parm_table[parmnum].
2599 enum_list[i].value;
2600 break;
2603 if (!parm_table[parmnum].enum_list[i].name) {
2604 DEBUG(0,("Unknown enumerated value '%s' for '%s'\n",
2605 pszParmValue, pszParmName));
2606 return false;
2608 break;
2611 mark_non_default:
2612 if (on_globals && (lp_ctx->flags[parmnum] & FLAG_DEFAULT)) {
2613 lp_ctx->flags[parmnum] &= ~FLAG_DEFAULT;
2614 /* we have to also unset FLAG_DEFAULT on aliases */
2615 for (i=parmnum-1;i>=0 && parm_table[i].offset == parm_table[parmnum].offset;i--) {
2616 lp_ctx->flags[i] &= ~FLAG_DEFAULT;
2618 for (i=parmnum+1;i<NUMPARAMETERS && parm_table[i].offset == parm_table[parmnum].offset;i++) {
2619 lp_ctx->flags[i] &= ~FLAG_DEFAULT;
2622 return true;
2626 bool lpcfg_do_global_parameter(struct loadparm_context *lp_ctx,
2627 const char *pszParmName, const char *pszParmValue)
2629 int parmnum = map_parameter(pszParmName);
2630 void *parm_ptr;
2632 if (parmnum < 0) {
2633 if (strchr(pszParmName, ':')) {
2634 return lp_do_parameter_parametric(lp_ctx, NULL, pszParmName, pszParmValue, 0);
2636 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName));
2637 return true;
2640 /* if the flag has been set on the command line, then don't allow override,
2641 but don't report an error */
2642 if (lp_ctx->flags[parmnum] & FLAG_CMDLINE) {
2643 return true;
2646 parm_ptr = lpcfg_parm_ptr(lp_ctx, NULL, &parm_table[parmnum]);
2648 return set_variable(lp_ctx->globals, parmnum, parm_ptr,
2649 pszParmName, pszParmValue, lp_ctx, true);
2652 bool lpcfg_do_service_parameter(struct loadparm_context *lp_ctx,
2653 struct loadparm_service *service,
2654 const char *pszParmName, const char *pszParmValue)
2656 void *parm_ptr;
2657 int i;
2658 int parmnum = map_parameter(pszParmName);
2660 if (parmnum < 0) {
2661 if (strchr(pszParmName, ':')) {
2662 return lp_do_parameter_parametric(lp_ctx, service, pszParmName, pszParmValue, 0);
2664 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName));
2665 return true;
2668 /* if the flag has been set on the command line, then don't allow override,
2669 but don't report an error */
2670 if (lp_ctx->flags[parmnum] & FLAG_CMDLINE) {
2671 return true;
2674 if (parm_table[parmnum].p_class == P_GLOBAL) {
2675 DEBUG(0,
2676 ("Global parameter %s found in service section!\n",
2677 pszParmName));
2678 return true;
2680 parm_ptr = ((char *)service) + parm_table[parmnum].offset;
2682 if (!service->copymap)
2683 init_copymap(service);
2685 /* this handles the aliases - set the copymap for other
2686 * entries with the same data pointer */
2687 for (i = 0; parm_table[i].label; i++)
2688 if (parm_table[i].offset == parm_table[parmnum].offset &&
2689 parm_table[i].p_class == parm_table[parmnum].p_class)
2690 bitmap_clear(service->copymap, i);
2692 return set_variable(service, parmnum, parm_ptr, pszParmName,
2693 pszParmValue, lp_ctx, false);
2697 * Process a parameter.
2700 static bool do_parameter(const char *pszParmName, const char *pszParmValue,
2701 void *userdata)
2703 struct loadparm_context *lp_ctx = (struct loadparm_context *)userdata;
2705 if (lp_ctx->bInGlobalSection)
2706 return lpcfg_do_global_parameter(lp_ctx, pszParmName,
2707 pszParmValue);
2708 else
2709 return lpcfg_do_service_parameter(lp_ctx, lp_ctx->currentService,
2710 pszParmName, pszParmValue);
2714 variable argument do parameter
2716 bool lpcfg_do_global_parameter_var(struct loadparm_context *lp_ctx, const char *pszParmName, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4);
2717 bool lpcfg_do_global_parameter_var(struct loadparm_context *lp_ctx,
2718 const char *pszParmName, const char *fmt, ...)
2720 char *s;
2721 bool ret;
2722 va_list ap;
2724 va_start(ap, fmt);
2725 s = talloc_vasprintf(NULL, fmt, ap);
2726 va_end(ap);
2727 ret = lpcfg_do_global_parameter(lp_ctx, pszParmName, s);
2728 talloc_free(s);
2729 return ret;
2734 set a parameter from the commandline - this is called from command line parameter
2735 parsing code. It sets the parameter then marks the parameter as unable to be modified
2736 by smb.conf processing
2738 bool lpcfg_set_cmdline(struct loadparm_context *lp_ctx, const char *pszParmName,
2739 const char *pszParmValue)
2741 int parmnum;
2742 int i;
2744 if (lp_ctx->s3_fns) {
2745 return lp_ctx->s3_fns->set_cmdline(pszParmName, pszParmValue);
2748 parmnum = map_parameter(pszParmName);
2750 while (isspace((unsigned char)*pszParmValue)) pszParmValue++;
2753 if (parmnum < 0 && strchr(pszParmName, ':')) {
2754 /* set a parametric option */
2755 return lp_do_parameter_parametric(lp_ctx, NULL, pszParmName,
2756 pszParmValue, FLAG_CMDLINE);
2759 if (parmnum < 0) {
2760 DEBUG(0,("Unknown option '%s'\n", pszParmName));
2761 return false;
2764 /* reset the CMDLINE flag in case this has been called before */
2765 lp_ctx->flags[parmnum] &= ~FLAG_CMDLINE;
2767 if (!lpcfg_do_global_parameter(lp_ctx, pszParmName, pszParmValue)) {
2768 return false;
2771 lp_ctx->flags[parmnum] |= FLAG_CMDLINE;
2773 /* we have to also set FLAG_CMDLINE on aliases */
2774 for (i=parmnum-1;i>=0 && parm_table[i].offset == parm_table[parmnum].offset;i--) {
2775 lp_ctx->flags[i] |= FLAG_CMDLINE;
2777 for (i=parmnum+1;i<NUMPARAMETERS && parm_table[i].offset == parm_table[parmnum].offset;i++) {
2778 lp_ctx->flags[i] |= FLAG_CMDLINE;
2781 return true;
2785 set a option from the commandline in 'a=b' format. Use to support --option
2787 bool lpcfg_set_option(struct loadparm_context *lp_ctx, const char *option)
2789 char *p, *s;
2790 bool ret;
2792 s = talloc_strdup(NULL, option);
2793 if (!s) {
2794 return false;
2797 p = strchr(s, '=');
2798 if (!p) {
2799 talloc_free(s);
2800 return false;
2803 *p = 0;
2805 ret = lpcfg_set_cmdline(lp_ctx, s, p+1);
2806 talloc_free(s);
2807 return ret;
2811 #define BOOLSTR(b) ((b) ? "Yes" : "No")
2814 * Print a parameter of the specified type.
2817 static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
2819 /* For the seperation of lists values that we print below */
2820 const char *list_sep = ", ";
2821 int i;
2822 switch (p->type)
2824 case P_ENUM:
2825 for (i = 0; p->enum_list[i].name; i++) {
2826 if (*(int *)ptr == p->enum_list[i].value) {
2827 fprintf(f, "%s",
2828 p->enum_list[i].name);
2829 break;
2832 break;
2834 case P_BOOL:
2835 fprintf(f, "%s", BOOLSTR(*(bool *)ptr));
2836 break;
2838 case P_BOOLREV:
2839 fprintf(f, "%s", BOOLSTR(!*(bool *)ptr));
2840 break;
2842 case P_INTEGER:
2843 case P_BYTES:
2844 fprintf(f, "%d", *(int *)ptr);
2845 break;
2847 case P_CHAR:
2848 fprintf(f, "%c", *(char *)ptr);
2849 break;
2851 case P_OCTAL: {
2852 int val = *(int *)ptr;
2853 if (val == -1) {
2854 fprintf(f, "-1");
2855 } else {
2856 fprintf(f, "0%o", val);
2858 break;
2861 case P_CMDLIST:
2862 list_sep = " ";
2863 /* fall through */
2864 case P_LIST:
2865 if ((char ***)ptr && *(char ***)ptr) {
2866 char **list = *(char ***)ptr;
2867 for (; *list; list++) {
2868 /* surround strings with whitespace in double quotes */
2869 if (*(list+1) == NULL) {
2870 /* last item, no extra separator */
2871 list_sep = "";
2873 if ( strchr_m( *list, ' ' ) ) {
2874 fprintf(f, "\"%s\"%s", *list, list_sep);
2875 } else {
2876 fprintf(f, "%s%s", *list, list_sep);
2880 break;
2882 case P_STRING:
2883 case P_USTRING:
2884 if (*(char **)ptr) {
2885 fprintf(f, "%s", *(char **)ptr);
2887 break;
2888 case P_SEP:
2889 break;
2894 * Check if two parameters are equal.
2897 static bool equal_parameter(parm_type type, void *ptr1, void *ptr2)
2899 switch (type) {
2900 case P_BOOL:
2901 case P_BOOLREV:
2902 return (*((bool *)ptr1) == *((bool *)ptr2));
2904 case P_INTEGER:
2905 case P_ENUM:
2906 case P_OCTAL:
2907 case P_BYTES:
2908 return (*((int *)ptr1) == *((int *)ptr2));
2910 case P_CHAR:
2911 return (*((char *)ptr1) == *((char *)ptr2));
2913 case P_LIST:
2914 case P_CMDLIST:
2915 return str_list_equal(*(const char ***)ptr1, *(const char ***)ptr2);
2917 case P_STRING:
2918 case P_USTRING:
2920 char *p1 = *(char **)ptr1, *p2 = *(char **)ptr2;
2921 if (p1 && !*p1)
2922 p1 = NULL;
2923 if (p2 && !*p2)
2924 p2 = NULL;
2925 return (p1 == p2 || strequal(p1, p2));
2927 case P_SEP:
2928 break;
2930 return false;
2934 * Process a new section (service).
2936 * At this stage all sections are services.
2937 * Later we'll have special sections that permit server parameters to be set.
2938 * Returns True on success, False on failure.
2941 static bool do_section(const char *pszSectionName, void *userdata)
2943 struct loadparm_context *lp_ctx = (struct loadparm_context *)userdata;
2944 bool bRetval;
2945 bool isglobal = ((strwicmp(pszSectionName, GLOBAL_NAME) == 0) ||
2946 (strwicmp(pszSectionName, GLOBAL_NAME2) == 0));
2947 bRetval = false;
2949 /* if we've just struck a global section, note the fact. */
2950 lp_ctx->bInGlobalSection = isglobal;
2952 /* check for multiple global sections */
2953 if (lp_ctx->bInGlobalSection) {
2954 DEBUG(4, ("Processing section \"[%s]\"\n", pszSectionName));
2955 return true;
2958 /* if we have a current service, tidy it up before moving on */
2959 bRetval = true;
2961 if (lp_ctx->currentService != NULL)
2962 bRetval = lpcfg_service_ok(lp_ctx->currentService);
2964 /* if all is still well, move to the next record in the services array */
2965 if (bRetval) {
2966 /* We put this here to avoid an odd message order if messages are */
2967 /* issued by the post-processing of a previous section. */
2968 DEBUG(4, ("Processing section \"[%s]\"\n", pszSectionName));
2970 if ((lp_ctx->currentService = lpcfg_add_service(lp_ctx, lp_ctx->sDefault,
2971 pszSectionName))
2972 == NULL) {
2973 DEBUG(0, ("Failed to add a new service\n"));
2974 return false;
2978 return bRetval;
2983 * Determine if a particular base parameter is currently set to the default value.
2986 static bool is_default(struct loadparm_service *sDefault, int i)
2988 void *def_ptr = ((char *)sDefault) + parm_table[i].offset;
2989 if (!defaults_saved)
2990 return false;
2991 switch (parm_table[i].type) {
2992 case P_CMDLIST:
2993 case P_LIST:
2994 return str_list_equal((const char **)parm_table[i].def.lvalue,
2995 (const char **)def_ptr);
2996 case P_STRING:
2997 case P_USTRING:
2998 return strequal(parm_table[i].def.svalue,
2999 *(char **)def_ptr);
3000 case P_BOOL:
3001 case P_BOOLREV:
3002 return parm_table[i].def.bvalue ==
3003 *(bool *)def_ptr;
3004 case P_INTEGER:
3005 case P_CHAR:
3006 case P_OCTAL:
3007 case P_BYTES:
3008 case P_ENUM:
3009 return parm_table[i].def.ivalue ==
3010 *(int *)def_ptr;
3012 return false;
3016 *Display the contents of the global structure.
3019 static void dump_globals(struct loadparm_context *lp_ctx, FILE *f,
3020 bool show_defaults)
3022 int i;
3023 struct parmlist_entry *data;
3025 fprintf(f, "# Global parameters\n[global]\n");
3027 for (i = 0; parm_table[i].label; i++)
3028 if (parm_table[i].p_class == P_GLOBAL &&
3029 (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset))) {
3030 if (!show_defaults && (lp_ctx->flags[i] & FLAG_DEFAULT))
3031 continue;
3032 fprintf(f, "\t%s = ", parm_table[i].label);
3033 print_parameter(&parm_table[i], lpcfg_parm_ptr(lp_ctx, NULL, &parm_table[i]), f);
3034 fprintf(f, "\n");
3036 if (lp_ctx->globals->param_opt != NULL) {
3037 for (data = lp_ctx->globals->param_opt; data;
3038 data = data->next) {
3039 if (!show_defaults && (data->priority & FLAG_DEFAULT)) {
3040 continue;
3042 fprintf(f, "\t%s = %s\n", data->key, data->value);
3049 * Display the contents of a single services record.
3052 static void dump_a_service(struct loadparm_service * pService, struct loadparm_service *sDefault, FILE * f,
3053 unsigned int *flags)
3055 int i;
3056 struct parmlist_entry *data;
3058 if (pService != sDefault)
3059 fprintf(f, "\n[%s]\n", pService->szService);
3061 for (i = 0; parm_table[i].label; i++) {
3062 if (parm_table[i].p_class == P_LOCAL &&
3063 (*parm_table[i].label != '-') &&
3064 (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset)))
3066 if (pService == sDefault) {
3067 if (flags && (flags[i] & FLAG_DEFAULT)) {
3068 continue;
3070 if (defaults_saved) {
3071 if (is_default(sDefault, i)) {
3072 continue;
3075 } else {
3076 if (equal_parameter(parm_table[i].type,
3077 ((char *)pService) +
3078 parm_table[i].offset,
3079 ((char *)sDefault) +
3080 parm_table[i].offset))
3081 continue;
3084 fprintf(f, "\t%s = ", parm_table[i].label);
3085 print_parameter(&parm_table[i],
3086 ((char *)pService) + parm_table[i].offset, f);
3087 fprintf(f, "\n");
3090 if (pService->param_opt != NULL) {
3091 for (data = pService->param_opt; data; data = data->next) {
3092 fprintf(f, "\t%s = %s\n", data->key, data->value);
3097 bool lpcfg_dump_a_parameter(struct loadparm_context *lp_ctx,
3098 struct loadparm_service *service,
3099 const char *parm_name, FILE * f)
3101 struct parm_struct *parm;
3102 void *ptr;
3104 parm = lpcfg_parm_struct(lp_ctx, parm_name);
3105 if (!parm) {
3106 return false;
3109 ptr = lpcfg_parm_ptr(lp_ctx, service,parm);
3111 print_parameter(parm, ptr, f);
3112 fprintf(f, "\n");
3113 return true;
3117 * Return info about the next parameter in a service.
3118 * snum==-1 gives the globals.
3119 * Return NULL when out of parameters.
3123 struct parm_struct *lpcfg_next_parameter(struct loadparm_context *lp_ctx, int snum, int *i,
3124 int allparameters)
3126 if (snum == -1) {
3127 /* do the globals */
3128 for (; parm_table[*i].label; (*i)++) {
3129 if ((*parm_table[*i].label == '-'))
3130 continue;
3132 if ((*i) > 0
3133 && (parm_table[*i].offset ==
3134 parm_table[(*i) - 1].offset)
3135 && (parm_table[*i].p_class ==
3136 parm_table[(*i) - 1].p_class))
3137 continue;
3139 return &parm_table[(*i)++];
3141 } else {
3142 struct loadparm_service *pService = lp_ctx->services[snum];
3144 for (; parm_table[*i].label; (*i)++) {
3145 if (parm_table[*i].p_class == P_LOCAL &&
3146 (*parm_table[*i].label != '-') &&
3147 ((*i) == 0 ||
3148 (parm_table[*i].offset !=
3149 parm_table[(*i) - 1].offset)))
3151 if (allparameters ||
3152 !equal_parameter(parm_table[*i].type,
3153 ((char *)pService) +
3154 parm_table[*i].offset,
3155 ((char *)lp_ctx->sDefault) +
3156 parm_table[*i].offset))
3158 return &parm_table[(*i)++];
3164 return NULL;
3169 * Auto-load some home services.
3171 static void lpcfg_add_auto_services(struct loadparm_context *lp_ctx,
3172 const char *str)
3174 return;
3179 * Unload unused services.
3182 void lpcfg_killunused(struct loadparm_context *lp_ctx,
3183 struct smbsrv_connection *smb,
3184 bool (*snumused) (struct smbsrv_connection *, int))
3186 int i;
3187 for (i = 0; i < lp_ctx->iNumServices; i++) {
3188 if (lp_ctx->services[i] == NULL)
3189 continue;
3191 if (!snumused || !snumused(smb, i)) {
3192 talloc_free(lp_ctx->services[i]);
3193 lp_ctx->services[i] = NULL;
3199 static int lpcfg_destructor(struct loadparm_context *lp_ctx)
3201 struct parmlist_entry *data;
3203 if (lp_ctx->refuse_free) {
3204 /* someone is trying to free the
3205 global_loadparm_context.
3206 We can't allow that. */
3207 return -1;
3210 if (lp_ctx->globals->param_opt != NULL) {
3211 struct parmlist_entry *next;
3212 for (data = lp_ctx->globals->param_opt; data; data=next) {
3213 next = data->next;
3214 if (data->priority & FLAG_CMDLINE) continue;
3215 DLIST_REMOVE(lp_ctx->globals->param_opt, data);
3216 talloc_free(data);
3220 return 0;
3224 * Initialise the global parameter structure.
3226 * Note that most callers should use loadparm_init_global() instead
3228 struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
3230 int i;
3231 char *myname;
3232 struct loadparm_context *lp_ctx;
3233 struct parmlist_entry *parm;
3234 char *logfile;
3236 lp_ctx = talloc_zero(mem_ctx, struct loadparm_context);
3237 if (lp_ctx == NULL)
3238 return NULL;
3240 talloc_set_destructor(lp_ctx, lpcfg_destructor);
3241 lp_ctx->bInGlobalSection = true;
3242 lp_ctx->globals = talloc_zero(lp_ctx, struct loadparm_global);
3243 lp_ctx->sDefault = talloc_zero(lp_ctx, struct loadparm_service);
3245 lp_ctx->sDefault->iMaxPrintJobs = 1000;
3246 lp_ctx->sDefault->bAvailable = true;
3247 lp_ctx->sDefault->bBrowseable = true;
3248 lp_ctx->sDefault->bRead_only = true;
3249 lp_ctx->sDefault->bMap_archive = true;
3250 lp_ctx->sDefault->iStrictLocking = true;
3251 lp_ctx->sDefault->bOpLocks = true;
3252 lp_ctx->sDefault->iCreate_mask = 0744;
3253 lp_ctx->sDefault->iCreate_force_mode = 0000;
3254 lp_ctx->sDefault->iDir_mask = 0755;
3255 lp_ctx->sDefault->iDir_force_mode = 0000;
3257 DEBUG(3, ("Initialising global parameters\n"));
3259 for (i = 0; parm_table[i].label; i++) {
3260 if ((parm_table[i].type == P_STRING ||
3261 parm_table[i].type == P_USTRING) &&
3262 !(lp_ctx->flags[i] & FLAG_CMDLINE)) {
3263 char **r;
3264 if (parm_table[i].p_class == P_LOCAL) {
3265 r = (char **)(((char *)lp_ctx->sDefault) + parm_table[i].offset);
3266 } else {
3267 r = (char **)(((char *)lp_ctx->globals) + parm_table[i].offset);
3269 *r = talloc_strdup(lp_ctx, "");
3273 logfile = talloc_asprintf(lp_ctx, "%s/log.samba", dyn_LOGFILEBASE);
3274 lpcfg_do_global_parameter(lp_ctx, "log file", logfile);
3275 talloc_free(logfile);
3277 lpcfg_do_global_parameter(lp_ctx, "log level", "0");
3279 lpcfg_do_global_parameter(lp_ctx, "share backend", "classic");
3281 lpcfg_do_global_parameter(lp_ctx, "share backend", "classic");
3283 lpcfg_do_global_parameter(lp_ctx, "server role", "standalone");
3285 /* options that can be set on the command line must be initialised via
3286 the slower lpcfg_do_global_parameter() to ensure that FLAG_CMDLINE is obeyed */
3287 #ifdef TCP_NODELAY
3288 lpcfg_do_global_parameter(lp_ctx, "socket options", "TCP_NODELAY");
3289 #endif
3290 lpcfg_do_global_parameter(lp_ctx, "workgroup", DEFAULT_WORKGROUP);
3291 myname = get_myname(lp_ctx);
3292 lpcfg_do_global_parameter(lp_ctx, "netbios name", myname);
3293 talloc_free(myname);
3294 lpcfg_do_global_parameter(lp_ctx, "name resolve order", "wins host bcast");
3296 lpcfg_do_global_parameter(lp_ctx, "fstype", "NTFS");
3298 lpcfg_do_global_parameter(lp_ctx, "ntvfs handler", "unixuid default");
3299 lpcfg_do_global_parameter(lp_ctx, "max connections", "-1");
3301 lpcfg_do_global_parameter(lp_ctx, "dcerpc endpoint servers", "epmapper srvsvc wkssvc rpcecho samr netlogon lsarpc spoolss drsuapi winreg dssetup unixinfo browser eventlog6 backupkey dnsserver");
3302 lpcfg_do_global_parameter(lp_ctx, "server services", "smb rpc nbt wrepl ldap cldap kdc drepl winbind ntp_signd kcc dnsupdate");
3303 lpcfg_do_global_parameter(lp_ctx, "ntptr providor", "simple_ldb");
3304 /* the winbind method for domain controllers is for both RODC
3305 auth forwarding and for trusted domains */
3306 lpcfg_do_global_parameter(lp_ctx, "private dir", dyn_PRIVATE_DIR);
3307 lpcfg_do_global_parameter(lp_ctx, "registry:HKEY_LOCAL_MACHINE", "hklm.ldb");
3309 /* This hive should be dynamically generated by Samba using
3310 data from the sam, but for the moment leave it in a tdb to
3311 keep regedt32 from popping up an annoying dialog. */
3312 lpcfg_do_global_parameter(lp_ctx, "registry:HKEY_USERS", "hku.ldb");
3314 /* using UTF8 by default allows us to support all chars */
3315 lpcfg_do_global_parameter(lp_ctx, "unix charset", "UTF8");
3317 /* Use codepage 850 as a default for the dos character set */
3318 lpcfg_do_global_parameter(lp_ctx, "dos charset", "CP850");
3321 * Allow the default PASSWD_CHAT to be overridden in local.h.
3323 lpcfg_do_global_parameter(lp_ctx, "passwd chat", DEFAULT_PASSWD_CHAT);
3325 lpcfg_do_global_parameter(lp_ctx, "pid directory", dyn_PIDDIR);
3326 lpcfg_do_global_parameter(lp_ctx, "lock dir", dyn_LOCKDIR);
3327 lpcfg_do_global_parameter(lp_ctx, "state directory", dyn_STATEDIR);
3328 lpcfg_do_global_parameter(lp_ctx, "cache directory", dyn_CACHEDIR);
3329 lpcfg_do_global_parameter(lp_ctx, "ncalrpc dir", dyn_NCALRPCDIR);
3331 lpcfg_do_global_parameter(lp_ctx, "socket address", "");
3332 lpcfg_do_global_parameter_var(lp_ctx, "server string",
3333 "Samba %s", SAMBA_VERSION_STRING);
3335 lpcfg_do_global_parameter(lp_ctx, "password server", "*");
3337 lpcfg_do_global_parameter(lp_ctx, "max mux", "50");
3338 lpcfg_do_global_parameter(lp_ctx, "max xmit", "12288");
3339 lpcfg_do_global_parameter(lp_ctx, "password level", "0");
3340 lpcfg_do_global_parameter(lp_ctx, "LargeReadwrite", "True");
3341 lpcfg_do_global_parameter(lp_ctx, "server min protocol", "CORE");
3342 lpcfg_do_global_parameter(lp_ctx, "server max protocol", "NT1");
3343 lpcfg_do_global_parameter(lp_ctx, "client min protocol", "CORE");
3344 lpcfg_do_global_parameter(lp_ctx, "client max protocol", "NT1");
3345 lpcfg_do_global_parameter(lp_ctx, "security", "USER");
3346 lpcfg_do_global_parameter(lp_ctx, "paranoid server security", "True");
3347 lpcfg_do_global_parameter(lp_ctx, "EncryptPasswords", "True");
3348 lpcfg_do_global_parameter(lp_ctx, "ReadRaw", "True");
3349 lpcfg_do_global_parameter(lp_ctx, "WriteRaw", "True");
3350 lpcfg_do_global_parameter(lp_ctx, "NullPasswords", "False");
3351 lpcfg_do_global_parameter(lp_ctx, "ObeyPamRestrictions", "False");
3353 lpcfg_do_global_parameter(lp_ctx, "TimeServer", "False");
3354 lpcfg_do_global_parameter(lp_ctx, "BindInterfacesOnly", "False");
3355 lpcfg_do_global_parameter(lp_ctx, "Unicode", "True");
3356 lpcfg_do_global_parameter(lp_ctx, "ClientLanManAuth", "False");
3357 lpcfg_do_global_parameter(lp_ctx, "ClientNTLMv2Auth", "True");
3358 lpcfg_do_global_parameter(lp_ctx, "LanmanAuth", "False");
3359 lpcfg_do_global_parameter(lp_ctx, "NTLMAuth", "True");
3360 lpcfg_do_global_parameter(lp_ctx, "client use spnego principal", "False");
3362 lpcfg_do_global_parameter(lp_ctx, "UnixExtensions", "False");
3364 lpcfg_do_global_parameter(lp_ctx, "PreferredMaster", "Auto");
3365 lpcfg_do_global_parameter(lp_ctx, "LocalMaster", "True");
3367 lpcfg_do_global_parameter(lp_ctx, "wins support", "False");
3368 lpcfg_do_global_parameter(lp_ctx, "dns proxy", "True");
3370 lpcfg_do_global_parameter(lp_ctx, "winbind separator", "\\");
3371 lpcfg_do_global_parameter(lp_ctx, "winbind sealed pipes", "True");
3372 lpcfg_do_global_parameter(lp_ctx, "winbindd socket directory", dyn_WINBINDD_SOCKET_DIR);
3373 #if _SAMBA_BUILD_ >= 4
3374 lpcfg_do_global_parameter(lp_ctx, "winbindd privileged socket directory", dyn_WINBINDD_PRIVILEGED_SOCKET_DIR);
3375 lpcfg_do_global_parameter(lp_ctx, "ntp signd socket directory", dyn_NTP_SIGND_SOCKET_DIR);
3376 lpcfg_do_global_parameter_var(lp_ctx, "dns update command", "%s/samba_dnsupdate", dyn_SCRIPTSBINDIR);
3377 lpcfg_do_global_parameter_var(lp_ctx, "spn update command", "%s/samba_spnupdate", dyn_SCRIPTSBINDIR);
3378 #endif
3379 lpcfg_do_global_parameter(lp_ctx, "template shell", "/bin/false");
3380 lpcfg_do_global_parameter(lp_ctx, "template homedir", "/home/%WORKGROUP%/%ACCOUNTNAME%");
3381 lpcfg_do_global_parameter(lp_ctx, "idmap trusted only", "False");
3383 lpcfg_do_global_parameter(lp_ctx, "client signing", "Yes");
3384 lpcfg_do_global_parameter(lp_ctx, "server signing", "auto");
3386 lpcfg_do_global_parameter(lp_ctx, "use spnego", "True");
3388 lpcfg_do_global_parameter(lp_ctx, "use mmap", "True");
3390 lpcfg_do_global_parameter(lp_ctx, "smb ports", "445 139");
3391 lpcfg_do_global_parameter(lp_ctx, "nbt port", "137");
3392 lpcfg_do_global_parameter(lp_ctx, "dgram port", "138");
3393 lpcfg_do_global_parameter(lp_ctx, "cldap port", "389");
3394 lpcfg_do_global_parameter(lp_ctx, "krb5 port", "88");
3395 lpcfg_do_global_parameter(lp_ctx, "kpasswd port", "464");
3396 lpcfg_do_global_parameter(lp_ctx, "web port", "901");
3398 lpcfg_do_global_parameter(lp_ctx, "nt status support", "True");
3400 lpcfg_do_global_parameter(lp_ctx, "max wins ttl", "518400"); /* 6 days */
3401 lpcfg_do_global_parameter(lp_ctx, "min wins ttl", "10");
3403 lpcfg_do_global_parameter(lp_ctx, "tls enabled", "True");
3404 lpcfg_do_global_parameter(lp_ctx, "tls keyfile", "tls/key.pem");
3405 lpcfg_do_global_parameter(lp_ctx, "tls certfile", "tls/cert.pem");
3406 lpcfg_do_global_parameter(lp_ctx, "tls cafile", "tls/ca.pem");
3407 lpcfg_do_global_parameter(lp_ctx, "prefork children:smb", "4");
3409 lpcfg_do_global_parameter(lp_ctx, "rndc command", "/usr/sbin/rndc");
3410 lpcfg_do_global_parameter(lp_ctx, "nsupdate command", "/usr/bin/nsupdate -g");
3412 for (i = 0; parm_table[i].label; i++) {
3413 if (!(lp_ctx->flags[i] & FLAG_CMDLINE)) {
3414 lp_ctx->flags[i] |= FLAG_DEFAULT;
3418 for (parm=lp_ctx->globals->param_opt; parm; parm=parm->next) {
3419 if (!(parm->priority & FLAG_CMDLINE)) {
3420 parm->priority |= FLAG_DEFAULT;
3424 return lp_ctx;
3428 * Initialise the global parameter structure.
3430 struct loadparm_context *loadparm_init_global(bool load_default)
3432 if (global_loadparm_context == NULL) {
3433 global_loadparm_context = loadparm_init(NULL);
3435 if (global_loadparm_context == NULL) {
3436 return NULL;
3438 global_loadparm_context->global = true;
3439 if (load_default && !global_loadparm_context->loaded) {
3440 lpcfg_load_default(global_loadparm_context);
3442 global_loadparm_context->refuse_free = true;
3443 return global_loadparm_context;
3447 * Initialise the global parameter structure.
3449 struct loadparm_context *loadparm_init_s3(TALLOC_CTX *mem_ctx,
3450 const struct loadparm_s3_context *s3_fns)
3452 struct loadparm_context *loadparm_context = talloc_zero(mem_ctx, struct loadparm_context);
3453 if (!loadparm_context) {
3454 return NULL;
3456 loadparm_context->s3_fns = s3_fns;
3457 return loadparm_context;
3460 const char *lpcfg_configfile(struct loadparm_context *lp_ctx)
3462 return lp_ctx->szConfigFile;
3465 const char *lp_default_path(void)
3467 if (getenv("SMB_CONF_PATH"))
3468 return getenv("SMB_CONF_PATH");
3469 else
3470 return dyn_CONFIGFILE;
3474 * Update the internal state of a loadparm context after settings
3475 * have changed.
3477 static bool lpcfg_update(struct loadparm_context *lp_ctx)
3479 struct debug_settings settings;
3480 lpcfg_add_auto_services(lp_ctx, lpcfg_auto_services(lp_ctx));
3482 if (!lp_ctx->globals->szWINSservers && lp_ctx->globals->bWINSsupport) {
3483 lpcfg_do_global_parameter(lp_ctx, "wins server", "127.0.0.1");
3486 if (!lp_ctx->global) {
3487 return true;
3490 panic_action = lp_ctx->globals->panic_action;
3492 reload_charcnv(lp_ctx);
3494 ZERO_STRUCT(settings);
3495 /* Add any more debug-related smb.conf parameters created in
3496 * future here */
3497 settings.timestamp_logs = true;
3498 debug_set_settings(&settings);
3500 /* FIXME: This is a bit of a hack, but we can't use a global, since
3501 * not everything that uses lp also uses the socket library */
3502 if (lpcfg_parm_bool(lp_ctx, NULL, "socket", "testnonblock", false)) {
3503 setenv("SOCKET_TESTNONBLOCK", "1", 1);
3504 } else {
3505 unsetenv("SOCKET_TESTNONBLOCK");
3508 return true;
3511 bool lpcfg_load_default(struct loadparm_context *lp_ctx)
3513 const char *path;
3515 path = lp_default_path();
3517 if (!file_exist(path)) {
3518 /* We allow the default smb.conf file to not exist,
3519 * basically the equivalent of an empty file. */
3520 return lpcfg_update(lp_ctx);
3523 return lpcfg_load(lp_ctx, path);
3527 * Load the services array from the services file.
3529 * Return True on success, False on failure.
3531 bool lpcfg_load(struct loadparm_context *lp_ctx, const char *filename)
3533 char *n2;
3534 bool bRetval;
3536 filename = talloc_strdup(lp_ctx, filename);
3538 lp_ctx->szConfigFile = filename;
3540 if (lp_ctx->s3_fns) {
3541 return lp_ctx->s3_fns->load(filename);
3544 lp_ctx->bInGlobalSection = true;
3545 n2 = standard_sub_basic(lp_ctx, lp_ctx->szConfigFile);
3546 DEBUG(2, ("lpcfg_load: refreshing parameters from %s\n", n2));
3548 add_to_file_list(lp_ctx, lp_ctx->szConfigFile, n2);
3550 /* We get sections first, so have to start 'behind' to make up */
3551 lp_ctx->currentService = NULL;
3552 bRetval = pm_process(n2, do_section, do_parameter, lp_ctx);
3554 /* finish up the last section */
3555 DEBUG(4, ("pm_process() returned %s\n", BOOLSTR(bRetval)));
3556 if (bRetval)
3557 if (lp_ctx->currentService != NULL)
3558 bRetval = lpcfg_service_ok(lp_ctx->currentService);
3560 bRetval = bRetval && lpcfg_update(lp_ctx);
3562 /* we do this unconditionally, so that it happens even
3563 for a missing smb.conf */
3564 reload_charcnv(lp_ctx);
3566 if (bRetval == true) {
3567 /* set this up so that any child python tasks will
3568 find the right smb.conf */
3569 setenv("SMB_CONF_PATH", filename, 1);
3571 /* set the context used by the lp_*() function
3572 varients */
3573 global_loadparm_context = lp_ctx;
3574 lp_ctx->loaded = true;
3577 return bRetval;
3581 * Return the max number of services.
3584 int lpcfg_numservices(struct loadparm_context *lp_ctx)
3586 if (lp_ctx->s3_fns) {
3587 return lp_ctx->s3_fns->get_numservices();
3590 return lp_ctx->iNumServices;
3594 * Display the contents of the services array in human-readable form.
3597 void lpcfg_dump(struct loadparm_context *lp_ctx, FILE *f, bool show_defaults,
3598 int maxtoprint)
3600 int iService;
3602 if (lp_ctx->s3_fns) {
3603 lp_ctx->s3_fns->dump(f, show_defaults, maxtoprint);
3604 return;
3607 defaults_saved = !show_defaults;
3609 dump_globals(lp_ctx, f, show_defaults);
3611 dump_a_service(lp_ctx->sDefault, lp_ctx->sDefault, f, lp_ctx->flags);
3613 for (iService = 0; iService < maxtoprint; iService++)
3614 lpcfg_dump_one(f, show_defaults, lp_ctx->services[iService], lp_ctx->sDefault);
3618 * Display the contents of one service in human-readable form.
3620 void lpcfg_dump_one(FILE *f, bool show_defaults, struct loadparm_service *service, struct loadparm_service *sDefault)
3622 if (service != NULL) {
3623 if (service->szService[0] == '\0')
3624 return;
3625 dump_a_service(service, sDefault, f, NULL);
3629 struct loadparm_service *lpcfg_servicebynum(struct loadparm_context *lp_ctx,
3630 int snum)
3632 if (lp_ctx->s3_fns) {
3633 return lp_ctx->s3_fns->get_servicebynum(snum);
3636 return lp_ctx->services[snum];
3639 struct loadparm_service *lpcfg_service(struct loadparm_context *lp_ctx,
3640 const char *service_name)
3642 int iService;
3643 char *serviceName;
3645 if (lp_ctx->s3_fns) {
3646 return lp_ctx->s3_fns->get_service(service_name);
3649 for (iService = lp_ctx->iNumServices - 1; iService >= 0; iService--) {
3650 if (lp_ctx->services[iService] &&
3651 lp_ctx->services[iService]->szService) {
3653 * The substitution here is used to support %U is
3654 * service names
3656 serviceName = standard_sub_basic(
3657 lp_ctx->services[iService],
3658 lp_ctx->services[iService]->szService);
3659 if (strequal(serviceName, service_name)) {
3660 talloc_free(serviceName);
3661 return lp_ctx->services[iService];
3663 talloc_free(serviceName);
3667 DEBUG(7,("lpcfg_servicenumber: couldn't find %s\n", service_name));
3668 return NULL;
3671 const char *lpcfg_servicename(const struct loadparm_service *service)
3673 return lp_string((const char *)service->szService);
3677 * A useful volume label function.
3679 const char *lpcfg_volume_label(struct loadparm_service *service, struct loadparm_service *sDefault)
3681 const char *ret;
3682 ret = lp_string((const char *)((service != NULL && service->volume != NULL) ?
3683 service->volume : sDefault->volume));
3684 if (!*ret)
3685 return lpcfg_servicename(service);
3686 return ret;
3690 * If we are PDC then prefer us as DMB
3692 const char *lpcfg_printername(struct loadparm_service *service, struct loadparm_service *sDefault)
3694 const char *ret;
3695 ret = lp_string((const char *)((service != NULL && service->szPrintername != NULL) ?
3696 service->szPrintername : sDefault->szPrintername));
3697 if (ret == NULL || (ret != NULL && *ret == '\0'))
3698 ret = lpcfg_servicename(service);
3700 return ret;
3705 * Return the max print jobs per queue.
3707 int lpcfg_maxprintjobs(struct loadparm_service *service, struct loadparm_service *sDefault)
3709 int maxjobs = (service != NULL) ? service->iMaxPrintJobs : sDefault->iMaxPrintJobs;
3710 if (maxjobs <= 0 || maxjobs >= PRINT_MAX_JOBID)
3711 maxjobs = PRINT_MAX_JOBID - 1;
3713 return maxjobs;
3716 struct smb_iconv_handle *lpcfg_iconv_handle(struct loadparm_context *lp_ctx)
3718 if (lp_ctx == NULL) {
3719 return get_iconv_handle();
3721 return lp_ctx->iconv_handle;
3724 _PUBLIC_ void reload_charcnv(struct loadparm_context *lp_ctx)
3726 struct smb_iconv_handle *old_ic = lp_ctx->iconv_handle;
3727 if (!lp_ctx->global) {
3728 return;
3731 if (old_ic == NULL) {
3732 old_ic = global_iconv_handle;
3734 lp_ctx->iconv_handle = smb_iconv_handle_reinit_lp(lp_ctx, lp_ctx, old_ic);
3735 global_iconv_handle = lp_ctx->iconv_handle;
3738 _PUBLIC_ char *lpcfg_tls_keyfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
3740 return lpcfg_private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_keyfile);
3743 _PUBLIC_ char *lpcfg_tls_certfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
3745 return lpcfg_private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_certfile);
3748 _PUBLIC_ char *lpcfg_tls_cafile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
3750 return lpcfg_private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_cafile);
3753 _PUBLIC_ char *lpcfg_tls_crlfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
3755 return lpcfg_private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_crlfile);
3758 _PUBLIC_ char *lpcfg_tls_dhpfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
3760 return lpcfg_private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_dhpfile);
3763 struct gensec_settings *lpcfg_gensec_settings(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
3765 struct gensec_settings *settings = talloc(mem_ctx, struct gensec_settings);
3766 if (settings == NULL)
3767 return NULL;
3768 SMB_ASSERT(lp_ctx != NULL);
3769 settings->lp_ctx = talloc_reference(settings, lp_ctx);
3770 settings->target_hostname = lpcfg_parm_string(lp_ctx, NULL, "gensec", "target_hostname");
3771 return settings;