s4:torture: cleanup after smb2 setinfo scan
[Samba/gebeck_regimport.git] / lib / param / loadparm.c
blobbb59a79d0ccdae76b7055715d3ef3878018e72a0
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"
68 #include "source4/dns_server/dns_update.h"
70 #define standard_sub_basic talloc_strdup
72 static bool do_parameter(const char *, const char *, void *);
73 static bool defaults_saved = false;
75 #define LOADPARM_EXTRA_GLOBALS \
76 struct parmlist_entry *param_opt; \
77 char *szRealm; \
78 char *tls_keyfile; \
79 char *tls_certfile; \
80 char *tls_cafile; \
81 char *tls_crlfile; \
82 char *tls_dhpfile; \
83 char *loglevel; \
84 char *panic_action; \
85 int server_role; \
86 int security; \
87 int domain_master; \
88 int domain_logons; \
89 int bPreferredMaster;
91 #include "param_global.h"
93 #define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
96 /* prototypes for the special type handlers */
97 static bool handle_include(struct loadparm_context *lp_ctx, int unused,
98 const char *pszParmValue, char **ptr);
99 static bool handle_realm(struct loadparm_context *lp_ctx, int unused,
100 const char *pszParmValue, char **ptr);
101 static bool handle_copy(struct loadparm_context *lp_ctx, int unused,
102 const char *pszParmValue, char **ptr);
103 static bool handle_debuglevel(struct loadparm_context *lp_ctx, int unused,
104 const char *pszParmValue, char **ptr);
105 static bool handle_logfile(struct loadparm_context *lp_ctx, int unused,
106 const char *pszParmValue, char **ptr);
108 #include "param_enums.c"
110 #define GLOBAL_VAR(name) offsetof(struct loadparm_global, name)
111 #define LOCAL_VAR(name) offsetof(struct loadparm_service, name)
113 static struct parm_struct parm_table[] = {
115 .label = "server role",
116 .type = P_ENUM,
117 .p_class = P_GLOBAL,
118 .offset = GLOBAL_VAR(server_role),
119 .special = NULL,
120 .enum_list = enum_server_role
123 .label = "domain logons",
124 .type = P_ENUM,
125 .p_class = P_GLOBAL,
126 .offset = GLOBAL_VAR(domain_logons),
127 .special = NULL,
128 .enum_list = enum_bool_auto
131 .label = "domain master",
132 .type = P_ENUM,
133 .p_class = P_GLOBAL,
134 .offset = GLOBAL_VAR(domain_master),
135 .special = NULL,
136 .enum_list = enum_bool_auto
139 .label = "dos charset",
140 .type = P_STRING,
141 .p_class = P_GLOBAL,
142 .offset = GLOBAL_VAR(dos_charset),
143 .special = NULL,
144 .enum_list = NULL
147 .label = "unix charset",
148 .type = P_STRING,
149 .p_class = P_GLOBAL,
150 .offset = GLOBAL_VAR(unix_charset),
151 .special = NULL,
152 .enum_list = NULL
155 .label = "ncalrpc dir",
156 .type = P_STRING,
157 .p_class = P_GLOBAL,
158 .offset = GLOBAL_VAR(ncalrpc_dir),
159 .special = NULL,
160 .enum_list = NULL
163 .label = "comment",
164 .type = P_STRING,
165 .p_class = P_LOCAL,
166 .offset = LOCAL_VAR(comment),
167 .special = NULL,
168 .enum_list = NULL
171 .label = "path",
172 .type = P_STRING,
173 .p_class = P_LOCAL,
174 .offset = LOCAL_VAR(szPath),
175 .special = NULL,
176 .enum_list = NULL
179 .label = "directory",
180 .type = P_STRING,
181 .p_class = P_LOCAL,
182 .offset = LOCAL_VAR(szPath),
183 .special = NULL,
184 .enum_list = NULL
187 .label = "workgroup",
188 .type = P_USTRING,
189 .p_class = P_GLOBAL,
190 .offset = GLOBAL_VAR(szWorkgroup),
191 .special = NULL,
192 .enum_list = NULL
195 .label = "realm",
196 .type = P_STRING,
197 .p_class = P_GLOBAL,
198 .offset = GLOBAL_VAR(szRealm),
199 .special = handle_realm,
200 .enum_list = NULL
203 .label = "netbios name",
204 .type = P_USTRING,
205 .p_class = P_GLOBAL,
206 .offset = GLOBAL_VAR(szNetbiosName),
207 .special = NULL,
208 .enum_list = NULL
211 .label = "netbios aliases",
212 .type = P_LIST,
213 .p_class = P_GLOBAL,
214 .offset = GLOBAL_VAR(szNetbiosAliases),
215 .special = NULL,
216 .enum_list = NULL
219 .label = "netbios scope",
220 .type = P_USTRING,
221 .p_class = P_GLOBAL,
222 .offset = GLOBAL_VAR(szNetbiosScope),
223 .special = NULL,
224 .enum_list = NULL
227 .label = "server string",
228 .type = P_STRING,
229 .p_class = P_GLOBAL,
230 .offset = GLOBAL_VAR(szServerString),
231 .special = NULL,
232 .enum_list = NULL
235 .label = "interfaces",
236 .type = P_LIST,
237 .p_class = P_GLOBAL,
238 .offset = GLOBAL_VAR(szInterfaces),
239 .special = NULL,
240 .enum_list = NULL
243 .label = "bind interfaces only",
244 .type = P_BOOL,
245 .p_class = P_GLOBAL,
246 .offset = GLOBAL_VAR(bBindInterfacesOnly),
247 .special = NULL,
248 .enum_list = NULL
251 .label = "ntvfs handler",
252 .type = P_LIST,
253 .p_class = P_LOCAL,
254 .offset = LOCAL_VAR(ntvfs_handler),
255 .special = NULL,
256 .enum_list = NULL
259 .label = "ntptr providor",
260 .type = P_STRING,
261 .p_class = P_GLOBAL,
262 .offset = GLOBAL_VAR(ntptr_providor),
263 .special = NULL,
264 .enum_list = NULL
267 .label = "passdb backend",
268 .type = P_STRING,
269 .p_class = P_GLOBAL,
270 .offset = GLOBAL_VAR(passdb_backend),
271 .special = NULL,
272 .enum_list = NULL
275 .label = "dcerpc endpoint servers",
276 .type = P_LIST,
277 .p_class = P_GLOBAL,
278 .offset = GLOBAL_VAR(dcerpc_ep_servers),
279 .special = NULL,
280 .enum_list = NULL
283 .label = "server services",
284 .type = P_LIST,
285 .p_class = P_GLOBAL,
286 .offset = GLOBAL_VAR(server_services),
287 .special = NULL,
288 .enum_list = NULL
292 .label = "security",
293 .type = P_ENUM,
294 .p_class = P_GLOBAL,
295 .offset = GLOBAL_VAR(security),
296 .special = NULL,
297 .enum_list = enum_security
300 .label = "encrypt passwords",
301 .type = P_BOOL,
302 .p_class = P_GLOBAL,
303 .offset = GLOBAL_VAR(bEncryptPasswords),
304 .special = NULL,
305 .enum_list = NULL
308 .label = "null passwords",
309 .type = P_BOOL,
310 .p_class = P_GLOBAL,
311 .offset = GLOBAL_VAR(bNullPasswords),
312 .special = NULL,
313 .enum_list = NULL
316 .label = "obey pam restrictions",
317 .type = P_BOOL,
318 .p_class = P_GLOBAL,
319 .offset = GLOBAL_VAR(bObeyPamRestrictions),
320 .special = NULL,
321 .enum_list = NULL
324 .label = "password server",
325 .type = P_LIST,
326 .p_class = P_GLOBAL,
327 .offset = GLOBAL_VAR(szPasswordServers),
328 .special = NULL,
329 .enum_list = NULL
332 .label = "private dir",
333 .type = P_STRING,
334 .p_class = P_GLOBAL,
335 .offset = GLOBAL_VAR(szPrivateDir),
336 .special = NULL,
337 .enum_list = NULL
340 .label = "passwd chat",
341 .type = P_STRING,
342 .p_class = P_GLOBAL,
343 .offset = GLOBAL_VAR(szPasswdChat),
344 .special = NULL,
345 .enum_list = NULL
348 .label = "password level",
349 .type = P_INTEGER,
350 .p_class = P_GLOBAL,
351 .offset = GLOBAL_VAR(pwordlevel),
352 .special = NULL,
353 .enum_list = NULL
356 .label = "lanman auth",
357 .type = P_BOOL,
358 .p_class = P_GLOBAL,
359 .offset = GLOBAL_VAR(bLanmanAuth),
360 .special = NULL,
361 .enum_list = NULL
364 .label = "ntlm auth",
365 .type = P_BOOL,
366 .p_class = P_GLOBAL,
367 .offset = GLOBAL_VAR(bNTLMAuth),
368 .special = NULL,
369 .enum_list = NULL
372 .label = "client NTLMv2 auth",
373 .type = P_BOOL,
374 .p_class = P_GLOBAL,
375 .offset = GLOBAL_VAR(bClientNTLMv2Auth),
376 .special = NULL,
377 .enum_list = NULL
380 .label = "client lanman auth",
381 .type = P_BOOL,
382 .p_class = P_GLOBAL,
383 .offset = GLOBAL_VAR(bClientLanManAuth),
384 .special = NULL,
385 .enum_list = NULL
388 .label = "client plaintext auth",
389 .type = P_BOOL,
390 .p_class = P_GLOBAL,
391 .offset = GLOBAL_VAR(bClientPlaintextAuth),
392 .special = NULL,
393 .enum_list = NULL
396 .label = "client use spnego principal",
397 .type = P_BOOL,
398 .p_class = P_GLOBAL,
399 .offset = GLOBAL_VAR(client_use_spnego_principal),
400 .special = NULL,
401 .enum_list = NULL
405 .label = "read only",
406 .type = P_BOOL,
407 .p_class = P_LOCAL,
408 .offset = LOCAL_VAR(bRead_only),
409 .special = NULL,
410 .enum_list = NULL
414 .label = "create mask",
415 .type = P_OCTAL,
416 .p_class = P_LOCAL,
417 .offset = LOCAL_VAR(iCreate_mask),
418 .special = NULL,
419 .enum_list = NULL
422 .label = "force create mode",
423 .type = P_OCTAL,
424 .p_class = P_LOCAL,
425 .offset = LOCAL_VAR(iCreate_force_mode),
426 .special = NULL,
427 .enum_list = NULL
430 .label = "directory mask",
431 .type = P_OCTAL,
432 .p_class = P_LOCAL,
433 .offset = LOCAL_VAR(iDir_mask),
434 .special = NULL,
435 .enum_list = NULL
438 .label = "force directory mode",
439 .type = P_OCTAL,
440 .p_class = P_LOCAL,
441 .offset = LOCAL_VAR(iDir_force_mode),
442 .special = NULL,
443 .enum_list = NULL
447 .label = "hosts allow",
448 .type = P_LIST,
449 .p_class = P_LOCAL,
450 .offset = LOCAL_VAR(szHostsallow),
451 .special = NULL,
452 .enum_list = NULL
455 .label = "hosts deny",
456 .type = P_LIST,
457 .p_class = P_LOCAL,
458 .offset = LOCAL_VAR(szHostsdeny),
459 .special = NULL,
460 .enum_list = NULL
464 .label = "log level",
465 .type = P_STRING,
466 .p_class = P_GLOBAL,
467 .offset = GLOBAL_VAR(loglevel),
468 .special = handle_debuglevel,
469 .enum_list = NULL
472 .label = "debuglevel",
473 .type = P_STRING,
474 .p_class = P_GLOBAL,
475 .offset = GLOBAL_VAR(loglevel),
476 .special = handle_debuglevel,
477 .enum_list = NULL
480 .label = "log file",
481 .type = P_STRING,
482 .p_class = P_GLOBAL,
483 .offset = GLOBAL_VAR(logfile),
484 .special = handle_logfile,
485 .enum_list = NULL
489 .label = "smb ports",
490 .type = P_LIST,
491 .p_class = P_GLOBAL,
492 .offset = GLOBAL_VAR(smb_ports),
493 .special = NULL,
494 .enum_list = NULL
497 .label = "nbt port",
498 .type = P_INTEGER,
499 .p_class = P_GLOBAL,
500 .offset = GLOBAL_VAR(nbt_port),
501 .special = NULL,
502 .enum_list = NULL
505 .label = "dgram port",
506 .type = P_INTEGER,
507 .p_class = P_GLOBAL,
508 .offset = GLOBAL_VAR(dgram_port),
509 .special = NULL,
510 .enum_list = NULL
513 .label = "cldap port",
514 .type = P_INTEGER,
515 .p_class = P_GLOBAL,
516 .offset = GLOBAL_VAR(cldap_port),
517 .special = NULL,
518 .enum_list = NULL
521 .label = "krb5 port",
522 .type = P_INTEGER,
523 .p_class = P_GLOBAL,
524 .offset = GLOBAL_VAR(krb5_port),
525 .special = NULL,
526 .enum_list = NULL
529 .label = "kpasswd port",
530 .type = P_INTEGER,
531 .p_class = P_GLOBAL,
532 .offset = GLOBAL_VAR(kpasswd_port),
533 .special = NULL,
534 .enum_list = NULL
537 .label = "web port",
538 .type = P_INTEGER,
539 .p_class = P_GLOBAL,
540 .offset = GLOBAL_VAR(web_port),
541 .special = NULL,
542 .enum_list = NULL
545 .label = "tls enabled",
546 .type = P_BOOL,
547 .p_class = P_GLOBAL,
548 .offset = GLOBAL_VAR(tls_enabled),
549 .special = NULL,
550 .enum_list = NULL
553 .label = "tls keyfile",
554 .type = P_STRING,
555 .p_class = P_GLOBAL,
556 .offset = GLOBAL_VAR(tls_keyfile),
557 .special = NULL,
558 .enum_list = NULL
561 .label = "tls certfile",
562 .type = P_STRING,
563 .p_class = P_GLOBAL,
564 .offset = GLOBAL_VAR(tls_certfile),
565 .special = NULL,
566 .enum_list = NULL
569 .label = "tls cafile",
570 .type = P_STRING,
571 .p_class = P_GLOBAL,
572 .offset = GLOBAL_VAR(tls_cafile),
573 .special = NULL,
574 .enum_list = NULL
577 .label = "tls crlfile",
578 .type = P_STRING,
579 .p_class = P_GLOBAL,
580 .offset = GLOBAL_VAR(tls_crlfile),
581 .special = NULL,
582 .enum_list = NULL
585 .label = "tls dh params file",
586 .type = P_STRING,
587 .p_class = P_GLOBAL,
588 .offset = GLOBAL_VAR(tls_dhpfile),
589 .special = NULL,
590 .enum_list = NULL
593 .label = "large readwrite",
594 .type = P_BOOL,
595 .p_class = P_GLOBAL,
596 .offset = GLOBAL_VAR(bLargeReadwrite),
597 .special = NULL,
598 .enum_list = NULL
601 .label = "server max protocol",
602 .type = P_ENUM,
603 .p_class = P_GLOBAL,
604 .offset = GLOBAL_VAR(srv_maxprotocol),
605 .special = NULL,
606 .enum_list = enum_protocol
609 .label = "max protocol",
610 .type = P_ENUM,
611 .p_class = P_GLOBAL,
612 .offset = GLOBAL_VAR(srv_maxprotocol),
613 .special = NULL,
614 .enum_list = enum_protocol
617 .label = "protocol",
618 .type = P_ENUM,
619 .p_class = P_GLOBAL,
620 .offset = GLOBAL_VAR(srv_maxprotocol),
621 .special = NULL,
622 .enum_list = enum_protocol
625 .label = "server min protocol",
626 .type = P_ENUM,
627 .p_class = P_GLOBAL,
628 .offset = GLOBAL_VAR(srv_minprotocol),
629 .special = NULL,
630 .enum_list = enum_protocol
633 .label = "min protocol",
634 .type = P_ENUM,
635 .p_class = P_GLOBAL,
636 .offset = GLOBAL_VAR(srv_minprotocol),
637 .special = NULL,
638 .enum_list = enum_protocol
641 .label = "client max protocol",
642 .type = P_ENUM,
643 .p_class = P_GLOBAL,
644 .offset = GLOBAL_VAR(cli_maxprotocol),
645 .special = NULL,
646 .enum_list = enum_protocol
649 .label = "client min protocol",
650 .type = P_ENUM,
651 .p_class = P_GLOBAL,
652 .offset = GLOBAL_VAR(cli_minprotocol),
653 .special = NULL,
654 .enum_list = enum_protocol
657 .label = "unicode",
658 .type = P_BOOL,
659 .p_class = P_GLOBAL,
660 .offset = GLOBAL_VAR(bUnicode),
661 .special = NULL,
662 .enum_list = NULL
665 .label = "read raw",
666 .type = P_BOOL,
667 .p_class = P_GLOBAL,
668 .offset = GLOBAL_VAR(bReadRaw),
669 .special = NULL,
670 .enum_list = NULL
673 .label = "write raw",
674 .type = P_BOOL,
675 .p_class = P_GLOBAL,
676 .offset = GLOBAL_VAR(bWriteRaw),
677 .special = NULL,
678 .enum_list = NULL
681 .label = "disable netbios",
682 .type = P_BOOL,
683 .p_class = P_GLOBAL,
684 .offset = GLOBAL_VAR(bDisableNetbios),
685 .special = NULL,
686 .enum_list = NULL
690 .label = "nt status support",
691 .type = P_BOOL,
692 .p_class = P_GLOBAL,
693 .offset = GLOBAL_VAR(bNTStatusSupport),
694 .special = NULL,
695 .enum_list = NULL
699 .label = "max mux",
700 .type = P_INTEGER,
701 .p_class = P_GLOBAL,
702 .offset = GLOBAL_VAR(max_mux),
703 .special = NULL,
704 .enum_list = NULL
707 .label = "max xmit",
708 .type = P_BYTES,
709 .p_class = P_GLOBAL,
710 .offset = GLOBAL_VAR(max_xmit),
711 .special = NULL,
712 .enum_list = NULL
716 .label = "name resolve order",
717 .type = P_LIST,
718 .p_class = P_GLOBAL,
719 .offset = GLOBAL_VAR(szNameResolveOrder),
720 .special = NULL,
721 .enum_list = NULL
724 .label = "max wins ttl",
725 .type = P_INTEGER,
726 .p_class = P_GLOBAL,
727 .offset = GLOBAL_VAR(max_wins_ttl),
728 .special = NULL,
729 .enum_list = NULL
732 .label = "min wins ttl",
733 .type = P_INTEGER,
734 .p_class = P_GLOBAL,
735 .offset = GLOBAL_VAR(min_wins_ttl),
736 .special = NULL,
737 .enum_list = NULL
740 .label = "time server",
741 .type = P_BOOL,
742 .p_class = P_GLOBAL,
743 .offset = GLOBAL_VAR(bTimeServer),
744 .special = NULL,
745 .enum_list = NULL
748 .label = "unix extensions",
749 .type = P_BOOL,
750 .p_class = P_GLOBAL,
751 .offset = GLOBAL_VAR(bUnixExtensions),
752 .special = NULL,
753 .enum_list = NULL
756 .label = "use spnego",
757 .type = P_BOOL,
758 .p_class = P_GLOBAL,
759 .offset = GLOBAL_VAR(bUseSpnego),
760 .special = NULL,
761 .enum_list = NULL
764 .label = "server signing",
765 .type = P_ENUM,
766 .p_class = P_GLOBAL,
767 .offset = GLOBAL_VAR(server_signing),
768 .special = NULL,
769 .enum_list = enum_smb_signing_vals
772 .label = "client signing",
773 .type = P_ENUM,
774 .p_class = P_GLOBAL,
775 .offset = GLOBAL_VAR(client_signing),
776 .special = NULL,
777 .enum_list = enum_smb_signing_vals
780 .label = "rpc big endian",
781 .type = P_BOOL,
782 .p_class = P_GLOBAL,
783 .offset = GLOBAL_VAR(bRpcBigEndian),
784 .special = NULL,
785 .enum_list = NULL
789 .label = "max connections",
790 .type = P_INTEGER,
791 .p_class = P_LOCAL,
792 .offset = LOCAL_VAR(iMaxConnections),
793 .special = NULL,
794 .enum_list = NULL
797 .label = "paranoid server security",
798 .type = P_BOOL,
799 .p_class = P_GLOBAL,
800 .offset = GLOBAL_VAR(paranoid_server_security),
801 .special = NULL,
802 .enum_list = NULL
805 .label = "socket options",
806 .type = P_STRING,
807 .p_class = P_GLOBAL,
808 .offset = GLOBAL_VAR(socket_options),
809 .special = NULL,
810 .enum_list = NULL
814 .label = "strict sync",
815 .type = P_BOOL,
816 .p_class = P_LOCAL,
817 .offset = LOCAL_VAR(bStrictSync),
818 .special = NULL,
819 .enum_list = NULL
822 .label = "use mmap",
823 .type = P_BOOL,
824 .p_class = P_GLOBAL,
825 .offset = GLOBAL_VAR(bUseMmap),
826 .special = NULL,
827 .enum_list = NULL,
828 .flags = FLAG_ADVANCED,
831 .label = "case insensitive filesystem",
832 .type = P_BOOL,
833 .p_class = P_LOCAL,
834 .offset = LOCAL_VAR(bCIFileSystem),
835 .special = NULL,
836 .enum_list = NULL
840 .label = "max print jobs",
841 .type = P_INTEGER,
842 .p_class = P_LOCAL,
843 .offset = LOCAL_VAR(iMaxPrintJobs),
844 .special = NULL,
845 .enum_list = NULL
848 .label = "printable",
849 .type = P_BOOL,
850 .p_class = P_LOCAL,
851 .offset = LOCAL_VAR(bPrint_ok),
852 .special = NULL,
853 .enum_list = NULL
856 .label = "print ok",
857 .type = P_BOOL,
858 .p_class = P_LOCAL,
859 .offset = LOCAL_VAR(bPrint_ok),
860 .special = NULL,
861 .enum_list = NULL
865 .label = "printer name",
866 .type = P_STRING,
867 .p_class = P_LOCAL,
868 .offset = LOCAL_VAR(szPrintername),
869 .special = NULL,
870 .enum_list = NULL
873 .label = "printer",
874 .type = P_STRING,
875 .p_class = P_LOCAL,
876 .offset = LOCAL_VAR(szPrintername),
877 .special = NULL,
878 .enum_list = NULL
882 .label = "map system",
883 .type = P_BOOL,
884 .p_class = P_LOCAL,
885 .offset = LOCAL_VAR(bMap_system),
886 .special = NULL,
887 .enum_list = NULL
890 .label = "map hidden",
891 .type = P_BOOL,
892 .p_class = P_LOCAL,
893 .offset = LOCAL_VAR(bMap_hidden),
894 .special = NULL,
895 .enum_list = NULL
898 .label = "map archive",
899 .type = P_BOOL,
900 .p_class = P_LOCAL,
901 .offset = LOCAL_VAR(bMap_archive),
902 .special = NULL,
903 .enum_list = NULL
907 .label = "preferred master",
908 .type = P_ENUM,
909 .p_class = P_GLOBAL,
910 .offset = GLOBAL_VAR(bPreferredMaster),
911 .special = NULL,
912 .enum_list = enum_bool_auto
915 .label = "prefered master",
916 .type = P_ENUM,
917 .p_class = P_GLOBAL,
918 .offset = GLOBAL_VAR(bPreferredMaster),
919 .special = NULL,
920 .enum_list = enum_bool_auto
923 .label = "local master",
924 .type = P_BOOL,
925 .p_class = P_GLOBAL,
926 .offset = GLOBAL_VAR(bLocalMaster),
927 .special = NULL,
928 .enum_list = NULL
931 .label = "browseable",
932 .type = P_BOOL,
933 .p_class = P_LOCAL,
934 .offset = LOCAL_VAR(bBrowseable),
935 .special = NULL,
936 .enum_list = NULL
939 .label = "browsable",
940 .type = P_BOOL,
941 .p_class = P_LOCAL,
942 .offset = LOCAL_VAR(bBrowseable),
943 .special = NULL,
944 .enum_list = NULL
948 .label = "wins server",
949 .type = P_LIST,
950 .p_class = P_GLOBAL,
951 .offset = GLOBAL_VAR(szWINSservers),
952 .special = NULL,
953 .enum_list = NULL
956 .label = "wins support",
957 .type = P_BOOL,
958 .p_class = P_GLOBAL,
959 .offset = GLOBAL_VAR(bWINSsupport),
960 .special = NULL,
961 .enum_list = NULL
964 .label = "dns proxy",
965 .type = P_BOOL,
966 .p_class = P_GLOBAL,
967 .offset = GLOBAL_VAR(bWINSdnsProxy),
968 .special = NULL,
969 .enum_list = NULL
972 .label = "wins hook",
973 .type = P_STRING,
974 .p_class = P_GLOBAL,
975 .offset = GLOBAL_VAR(szWINSHook),
976 .special = NULL,
977 .enum_list = NULL
981 .label = "csc policy",
982 .type = P_ENUM,
983 .p_class = P_LOCAL,
984 .offset = LOCAL_VAR(iCSCPolicy),
985 .special = NULL,
986 .enum_list = enum_csc_policy
990 .label = "strict locking",
991 .type = P_BOOL,
992 .p_class = P_LOCAL,
993 .offset = LOCAL_VAR(iStrictLocking),
994 .special = NULL,
995 .enum_list = NULL
998 .label = "oplocks",
999 .type = P_BOOL,
1000 .p_class = P_LOCAL,
1001 .offset = LOCAL_VAR(bOpLocks),
1002 .special = NULL,
1003 .enum_list = NULL
1007 .label = "share backend",
1008 .type = P_STRING,
1009 .p_class = P_GLOBAL,
1010 .offset = GLOBAL_VAR(szShareBackend),
1011 .special = NULL,
1012 .enum_list = NULL
1015 .label = "preload",
1016 .type = P_STRING,
1017 .p_class = P_GLOBAL,
1018 .offset = GLOBAL_VAR(szAutoServices),
1019 .special = NULL,
1020 .enum_list = NULL
1023 .label = "auto services",
1024 .type = P_STRING,
1025 .p_class = P_GLOBAL,
1026 .offset = GLOBAL_VAR(szAutoServices),
1027 .special = NULL,
1028 .enum_list = NULL
1031 .label = "lock dir",
1032 .type = P_STRING,
1033 .p_class = P_GLOBAL,
1034 .offset = GLOBAL_VAR(szLockDir),
1035 .special = NULL,
1036 .enum_list = NULL
1039 .label = "lock directory",
1040 .type = P_STRING,
1041 .p_class = P_GLOBAL,
1042 .offset = GLOBAL_VAR(szLockDir),
1043 .special = NULL,
1044 .enum_list = NULL
1047 .label = "state directory",
1048 .type = P_STRING,
1049 .p_class = P_GLOBAL,
1050 .offset = GLOBAL_VAR(szStateDir),
1051 .special = NULL,
1052 .enum_list = NULL
1055 .label = "cache directory",
1056 .type = P_STRING,
1057 .p_class = P_GLOBAL,
1058 .offset = GLOBAL_VAR(szCacheDir),
1059 .special = NULL,
1060 .enum_list = NULL
1063 .label = "pid directory",
1064 .type = P_STRING,
1065 .p_class = P_GLOBAL,
1066 .offset = GLOBAL_VAR(szPidDir),
1067 .special = NULL,
1068 .enum_list = NULL
1072 .label = "socket address",
1073 .type = P_STRING,
1074 .p_class = P_GLOBAL,
1075 .offset = GLOBAL_VAR(szSocketAddress),
1076 .special = NULL,
1077 .enum_list = NULL
1080 .label = "copy",
1081 .type = P_STRING,
1082 .p_class = P_LOCAL,
1083 .offset = LOCAL_VAR(szCopy),
1084 .special = handle_copy,
1085 .enum_list = NULL
1088 .label = "include",
1089 .type = P_STRING,
1090 .p_class = P_LOCAL,
1091 .offset = LOCAL_VAR(szInclude),
1092 .special = handle_include,
1093 .enum_list = NULL
1097 .label = "available",
1098 .type = P_BOOL,
1099 .p_class = P_LOCAL,
1100 .offset = LOCAL_VAR(bAvailable),
1101 .special = NULL,
1102 .enum_list = NULL
1105 .label = "volume",
1106 .type = P_STRING,
1107 .p_class = P_LOCAL,
1108 .offset = LOCAL_VAR(volume),
1109 .special = NULL,
1110 .enum_list = NULL
1113 .label = "fstype",
1114 .type = P_STRING,
1115 .p_class = P_LOCAL,
1116 .offset = LOCAL_VAR(fstype),
1117 .special = NULL,
1118 .enum_list = NULL
1122 .label = "panic action",
1123 .type = P_STRING,
1124 .p_class = P_GLOBAL,
1125 .offset = GLOBAL_VAR(panic_action),
1126 .special = NULL,
1127 .enum_list = NULL
1131 .label = "msdfs root",
1132 .type = P_BOOL,
1133 .p_class = P_LOCAL,
1134 .offset = LOCAL_VAR(bMSDfsRoot),
1135 .special = NULL,
1136 .enum_list = NULL
1139 .label = "host msdfs",
1140 .type = P_BOOL,
1141 .p_class = P_GLOBAL,
1142 .offset = GLOBAL_VAR(bHostMSDfs),
1143 .special = NULL,
1144 .enum_list = NULL
1147 .label = "winbind separator",
1148 .type = P_STRING,
1149 .p_class = P_GLOBAL,
1150 .offset = GLOBAL_VAR(szWinbindSeparator),
1151 .special = NULL,
1152 .enum_list = NULL
1155 .label = "winbindd socket directory",
1156 .type = P_STRING,
1157 .p_class = P_GLOBAL,
1158 .offset = GLOBAL_VAR(szWinbinddSocketDirectory),
1159 .special = NULL,
1160 .enum_list = NULL
1163 .label = "winbindd privileged socket directory",
1164 .type = P_STRING,
1165 .p_class = P_GLOBAL,
1166 .offset = GLOBAL_VAR(szWinbinddPrivilegedSocketDirectory),
1167 .special = NULL,
1168 .enum_list = NULL
1171 .label = "winbind sealed pipes",
1172 .type = P_BOOL,
1173 .p_class = P_GLOBAL,
1174 .offset = GLOBAL_VAR(bWinbindSealedPipes),
1175 .special = NULL,
1176 .enum_list = NULL
1179 .label = "template shell",
1180 .type = P_STRING,
1181 .p_class = P_GLOBAL,
1182 .offset = GLOBAL_VAR(szTemplateShell),
1183 .special = NULL,
1184 .enum_list = NULL
1187 .label = "template homedir",
1188 .type = P_STRING,
1189 .p_class = P_GLOBAL,
1190 .offset = GLOBAL_VAR(szTemplateHomedir),
1191 .special = NULL,
1192 .enum_list = NULL
1195 .label = "idmap trusted only",
1196 .type = P_BOOL,
1197 .p_class = P_GLOBAL,
1198 .offset = GLOBAL_VAR(bIdmapTrustedOnly),
1199 .special = NULL,
1200 .enum_list = NULL
1204 .label = "ntp signd socket directory",
1205 .type = P_STRING,
1206 .p_class = P_GLOBAL,
1207 .offset = GLOBAL_VAR(szNTPSignDSocketDirectory),
1208 .special = NULL,
1209 .enum_list = NULL
1212 .label = "rndc command",
1213 .type = P_CMDLIST,
1214 .p_class = P_GLOBAL,
1215 .offset = GLOBAL_VAR(szRNDCCommand),
1216 .special = NULL,
1217 .enum_list = NULL
1220 .label = "dns update command",
1221 .type = P_CMDLIST,
1222 .p_class = P_GLOBAL,
1223 .offset = GLOBAL_VAR(szDNSUpdateCommand),
1224 .special = NULL,
1225 .enum_list = NULL
1228 .label = "spn update command",
1229 .type = P_CMDLIST,
1230 .p_class = P_GLOBAL,
1231 .offset = GLOBAL_VAR(szSPNUpdateCommand),
1232 .special = NULL,
1233 .enum_list = NULL
1236 .label = "samba kcc command",
1237 .type = P_CMDLIST,
1238 .p_class = P_GLOBAL,
1239 .offset = GLOBAL_VAR(szSambaKCCCommand),
1240 .special = NULL,
1241 .enum_list = NULL
1244 .label = "nsupdate command",
1245 .type = P_CMDLIST,
1246 .p_class = P_GLOBAL,
1247 .offset = GLOBAL_VAR(szNSUpdateCommand),
1248 .special = NULL,
1249 .enum_list = NULL
1252 .label = "allow dns updates",
1253 .type = P_ENUM,
1254 .p_class = P_GLOBAL,
1255 .offset = GLOBAL_VAR(allow_dns_updates),
1256 .special = NULL,
1257 .enum_list = enum_dns_update_settings
1260 {NULL, P_BOOL, P_NONE, 0, NULL, NULL, 0}
1264 /* local variables */
1265 struct loadparm_context {
1266 const char *szConfigFile;
1267 struct loadparm_global *globals;
1268 struct loadparm_service **services;
1269 struct loadparm_service *sDefault;
1270 struct smb_iconv_handle *iconv_handle;
1271 int iNumServices;
1272 struct loadparm_service *currentService;
1273 bool bInGlobalSection;
1274 struct file_lists {
1275 struct file_lists *next;
1276 char *name;
1277 char *subfname;
1278 time_t modtime;
1279 } *file_lists;
1280 unsigned int flags[NUMPARAMETERS];
1281 bool loaded;
1282 bool refuse_free;
1283 bool global; /* Is this the global context, which may set
1284 * global variables such as debug level etc? */
1285 const struct loadparm_s3_context *s3_fns;
1289 struct loadparm_service *lpcfg_default_service(struct loadparm_context *lp_ctx)
1291 if (lp_ctx->s3_fns) {
1292 return lp_ctx->s3_fns->get_default_loadparm_service();
1294 return lp_ctx->sDefault;
1298 * Convenience routine to grab string parameters into temporary memory
1299 * and run standard_sub_basic on them.
1301 * The buffers can be written to by
1302 * callers without affecting the source string.
1305 static const char *lp_string(const char *s)
1307 #if 0 /* until REWRITE done to make thread-safe */
1308 size_t len = s ? strlen(s) : 0;
1309 char *ret;
1310 #endif
1312 /* The follow debug is useful for tracking down memory problems
1313 especially if you have an inner loop that is calling a lp_*()
1314 function that returns a string. Perhaps this debug should be
1315 present all the time? */
1317 #if 0
1318 DEBUG(10, ("lp_string(%s)\n", s));
1319 #endif
1321 #if 0 /* until REWRITE done to make thread-safe */
1322 if (!lp_talloc)
1323 lp_talloc = talloc_init("lp_talloc");
1325 ret = talloc_array(lp_talloc, char, len + 100); /* leave room for substitution */
1327 if (!ret)
1328 return NULL;
1330 if (!s)
1331 *ret = 0;
1332 else
1333 strlcpy(ret, s, len);
1335 if (trim_string(ret, "\"", "\"")) {
1336 if (strchr(ret,'"') != NULL)
1337 strlcpy(ret, s, len);
1340 standard_sub_basic(ret,len+100);
1341 return (ret);
1342 #endif
1343 return s;
1347 In this section all the functions that are used to access the
1348 parameters from the rest of the program are defined
1352 * the creation of separate lpcfg_*() and lp_*() functions is to allow
1353 * for code compatibility between existing Samba4 and Samba3 code.
1356 /* this global context supports the lp_*() function varients */
1357 static struct loadparm_context *global_loadparm_context;
1359 #define lpcfg_default_service global_loadparm_context->sDefault
1360 #define lpcfg_global_service(i) global_loadparm_context->services[i]
1362 #define FN_GLOBAL_STRING(fn_name,var_name) \
1363 _PUBLIC_ const char *lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) { \
1364 if (lp_ctx == NULL) return NULL; \
1365 if (lp_ctx->s3_fns) { \
1366 SMB_ASSERT(lp_ctx->s3_fns->fn_name); \
1367 return lp_ctx->s3_fns->fn_name(); \
1369 return lp_ctx->globals->var_name ? lp_string(lp_ctx->globals->var_name) : ""; \
1372 #define FN_GLOBAL_CONST_STRING(fn_name,var_name) \
1373 _PUBLIC_ const char *lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) {\
1374 if (lp_ctx == NULL) return NULL; \
1375 if (lp_ctx->s3_fns) { \
1376 SMB_ASSERT(lp_ctx->s3_fns->fn_name); \
1377 return lp_ctx->s3_fns->fn_name(); \
1379 return lp_ctx->globals->var_name ? lp_string(lp_ctx->globals->var_name) : ""; \
1382 #define FN_GLOBAL_LIST(fn_name,var_name) \
1383 _PUBLIC_ const char **lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) { \
1384 if (lp_ctx == NULL) return NULL; \
1385 if (lp_ctx->s3_fns) { \
1386 SMB_ASSERT(lp_ctx->s3_fns->fn_name); \
1387 return lp_ctx->s3_fns->fn_name(); \
1389 return lp_ctx->globals->var_name; \
1392 #define FN_GLOBAL_BOOL(fn_name,var_name) \
1393 _PUBLIC_ bool lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) {\
1394 if (lp_ctx == NULL) return false; \
1395 if (lp_ctx->s3_fns) { \
1396 SMB_ASSERT(lp_ctx->s3_fns->fn_name); \
1397 return lp_ctx->s3_fns->fn_name(); \
1399 return lp_ctx->globals->var_name; \
1402 #define FN_GLOBAL_INTEGER(fn_name,var_name) \
1403 _PUBLIC_ int lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) { \
1404 if (lp_ctx->s3_fns) { \
1405 SMB_ASSERT(lp_ctx->s3_fns->fn_name); \
1406 return lp_ctx->s3_fns->fn_name(); \
1408 return lp_ctx->globals->var_name; \
1411 /* Local parameters don't need the ->s3_fns because the struct
1412 * loadparm_service is shared and lpcfg_service() checks the ->s3_fns
1413 * hook */
1414 #define FN_LOCAL_STRING(fn_name,val) \
1415 _PUBLIC_ const char *lpcfg_ ## fn_name(struct loadparm_service *service, \
1416 struct loadparm_service *sDefault) { \
1417 return(lp_string((const char *)((service != NULL && service->val != NULL) ? service->val : sDefault->val))); \
1420 #define FN_LOCAL_CONST_STRING(fn_name,val) FN_LOCAL_STRING(fn_name, val)
1422 #define FN_LOCAL_LIST(fn_name,val) \
1423 _PUBLIC_ const char **lpcfg_ ## fn_name(struct loadparm_service *service, \
1424 struct loadparm_service *sDefault) {\
1425 return(const char **)(service != NULL && service->val != NULL? service->val : sDefault->val); \
1428 #define FN_LOCAL_PARM_BOOL(fn_name, val) FN_LOCAL_BOOL(fn_name, val)
1430 #define FN_LOCAL_BOOL(fn_name,val) \
1431 _PUBLIC_ bool lpcfg_ ## fn_name(struct loadparm_service *service, \
1432 struct loadparm_service *sDefault) { \
1433 return((service != NULL)? service->val : sDefault->val); \
1436 #define FN_LOCAL_INTEGER(fn_name,val) \
1437 _PUBLIC_ int lpcfg_ ## fn_name(struct loadparm_service *service, \
1438 struct loadparm_service *sDefault) { \
1439 return((service != NULL)? service->val : sDefault->val); \
1442 #define FN_LOCAL_PARM_INTEGER(fn_name, val) FN_LOCAL_INTEGER(fn_name, val)
1444 #define FN_LOCAL_PARM_CHAR(fn_name, val) FN_LOCAL_CHAR(fn_name, val)
1446 #define FN_LOCAL_CHAR(fn_name,val) \
1447 _PUBLIC_ char lpcfg_ ## fn_name(struct loadparm_service *service, \
1448 struct loadparm_service *sDefault) { \
1449 return((service != NULL)? service->val : sDefault->val); \
1452 #include "lib/param/param_functions.c"
1454 FN_GLOBAL_LIST(smb_ports, smb_ports)
1455 FN_GLOBAL_INTEGER(nbt_port, nbt_port)
1456 FN_GLOBAL_INTEGER(dgram_port, dgram_port)
1457 FN_GLOBAL_INTEGER(cldap_port, cldap_port)
1458 FN_GLOBAL_INTEGER(krb5_port, krb5_port)
1459 FN_GLOBAL_INTEGER(kpasswd_port, kpasswd_port)
1460 FN_GLOBAL_INTEGER(web_port, web_port)
1461 FN_GLOBAL_BOOL(tls_enabled, tls_enabled)
1462 FN_GLOBAL_STRING(logfile, logfile)
1463 FN_GLOBAL_STRING(share_backend, szShareBackend)
1464 FN_GLOBAL_CONST_STRING(winbind_separator, szWinbindSeparator)
1465 FN_GLOBAL_CONST_STRING(winbindd_socket_directory, szWinbinddSocketDirectory)
1466 FN_GLOBAL_CONST_STRING(winbindd_privileged_socket_directory, szWinbinddPrivilegedSocketDirectory)
1467 FN_GLOBAL_CONST_STRING(template_shell, szTemplateShell)
1468 FN_GLOBAL_CONST_STRING(template_homedir, szTemplateHomedir)
1469 FN_GLOBAL_BOOL(winbind_sealed_pipes, bWinbindSealedPipes)
1470 FN_GLOBAL_BOOL(idmap_trusted_only, bIdmapTrustedOnly)
1471 FN_GLOBAL_STRING(private_dir, szPrivateDir)
1472 FN_GLOBAL_STRING(serverstring, szServerString)
1473 FN_GLOBAL_STRING(lockdir, szLockDir)
1474 FN_GLOBAL_STRING(statedir, szStateDir)
1475 FN_GLOBAL_STRING(cachedir, szCacheDir)
1476 FN_GLOBAL_STRING(ncalrpc_dir, ncalrpc_dir)
1477 FN_GLOBAL_STRING(dos_charset, dos_charset)
1478 FN_GLOBAL_STRING(unix_charset, unix_charset)
1479 FN_GLOBAL_STRING(piddir, szPidDir)
1480 FN_GLOBAL_LIST(rndc_command, szRNDCCommand)
1481 FN_GLOBAL_LIST(dns_update_command, szDNSUpdateCommand)
1482 FN_GLOBAL_LIST(spn_update_command, szSPNUpdateCommand)
1483 FN_GLOBAL_LIST(samba_kcc_command, szSambaKCCCommand)
1484 FN_GLOBAL_LIST(nsupdate_command, szNSUpdateCommand)
1485 FN_GLOBAL_LIST(dcerpc_endpoint_servers, dcerpc_ep_servers)
1486 FN_GLOBAL_LIST(server_services, server_services)
1487 FN_GLOBAL_STRING(ntptr_providor, ntptr_providor)
1488 FN_GLOBAL_STRING(passdb_backend, passdb_backend)
1489 FN_GLOBAL_STRING(auto_services, szAutoServices)
1490 FN_GLOBAL_STRING(passwd_chat, szPasswdChat)
1491 FN_GLOBAL_LIST(passwordserver, szPasswordServers)
1492 FN_GLOBAL_LIST(name_resolve_order, szNameResolveOrder)
1493 FN_GLOBAL_STRING(realm, szRealm_upper)
1494 FN_GLOBAL_STRING(dnsdomain, szRealm_lower)
1495 FN_GLOBAL_STRING(socket_options, socket_options)
1496 FN_GLOBAL_STRING(workgroup, szWorkgroup)
1497 FN_GLOBAL_STRING(netbios_name, szNetbiosName)
1498 FN_GLOBAL_STRING(netbios_scope, szNetbiosScope)
1499 FN_GLOBAL_LIST(wins_server_list, szWINSservers)
1500 FN_GLOBAL_LIST(interfaces, szInterfaces)
1501 FN_GLOBAL_STRING(socket_address, szSocketAddress)
1502 FN_GLOBAL_LIST(netbios_aliases, szNetbiosAliases)
1503 FN_GLOBAL_BOOL(disable_netbios, bDisableNetbios)
1504 FN_GLOBAL_BOOL(we_are_a_wins_server, bWINSsupport)
1505 FN_GLOBAL_BOOL(wins_dns_proxy, bWINSdnsProxy)
1506 FN_GLOBAL_STRING(wins_hook, szWINSHook)
1507 FN_GLOBAL_BOOL(local_master, bLocalMaster)
1508 FN_GLOBAL_BOOL(readraw, bReadRaw)
1509 FN_GLOBAL_BOOL(large_readwrite, bLargeReadwrite)
1510 FN_GLOBAL_BOOL(writeraw, bWriteRaw)
1511 FN_GLOBAL_BOOL(null_passwords, bNullPasswords)
1512 FN_GLOBAL_BOOL(obey_pam_restrictions, bObeyPamRestrictions)
1513 FN_GLOBAL_BOOL(encrypted_passwords, bEncryptPasswords)
1514 FN_GLOBAL_BOOL(time_server, bTimeServer)
1515 FN_GLOBAL_BOOL(bind_interfaces_only, bBindInterfacesOnly)
1516 FN_GLOBAL_BOOL(unicode, bUnicode)
1517 FN_GLOBAL_BOOL(nt_status_support, bNTStatusSupport)
1518 FN_GLOBAL_BOOL(lanman_auth, bLanmanAuth)
1519 FN_GLOBAL_BOOL(ntlm_auth, bNTLMAuth)
1520 FN_GLOBAL_BOOL(client_plaintext_auth, bClientPlaintextAuth)
1521 FN_GLOBAL_BOOL(client_lanman_auth, bClientLanManAuth)
1522 FN_GLOBAL_BOOL(client_ntlmv2_auth, bClientNTLMv2Auth)
1523 FN_GLOBAL_BOOL(client_use_spnego_principal, client_use_spnego_principal)
1524 FN_GLOBAL_BOOL(host_msdfs, bHostMSDfs)
1525 FN_GLOBAL_BOOL(unix_extensions, bUnixExtensions)
1526 FN_GLOBAL_BOOL(use_spnego, bUseSpnego)
1527 FN_GLOBAL_BOOL(use_mmap, bUseMmap)
1528 FN_GLOBAL_BOOL(rpc_big_endian, bRpcBigEndian)
1529 FN_GLOBAL_INTEGER(max_wins_ttl, max_wins_ttl)
1530 FN_GLOBAL_INTEGER(min_wins_ttl, min_wins_ttl)
1531 FN_GLOBAL_INTEGER(maxmux, max_mux)
1532 FN_GLOBAL_INTEGER(max_xmit, max_xmit)
1533 FN_GLOBAL_INTEGER(passwordlevel, pwordlevel)
1534 FN_GLOBAL_INTEGER(srv_maxprotocol, srv_maxprotocol)
1535 FN_GLOBAL_INTEGER(srv_minprotocol, srv_minprotocol)
1536 FN_GLOBAL_INTEGER(cli_maxprotocol, cli_maxprotocol)
1537 FN_GLOBAL_INTEGER(cli_minprotocol, cli_minprotocol)
1538 FN_GLOBAL_BOOL(paranoid_server_security, paranoid_server_security)
1539 FN_GLOBAL_INTEGER(allow_dns_updates, allow_dns_updates)
1541 FN_GLOBAL_INTEGER(server_signing, server_signing)
1542 FN_GLOBAL_INTEGER(client_signing, client_signing)
1544 FN_GLOBAL_CONST_STRING(ntp_signd_socket_directory, szNTPSignDSocketDirectory)
1546 /* local prototypes */
1547 static int map_parameter(const char *pszParmName);
1548 static struct loadparm_service *getservicebyname(struct loadparm_context *lp_ctx,
1549 const char *pszServiceName);
1550 static void copy_service(struct loadparm_service *pserviceDest,
1551 struct loadparm_service *pserviceSource,
1552 struct bitmap *pcopymapDest);
1553 static bool lpcfg_service_ok(struct loadparm_service *service);
1554 static bool do_section(const char *pszSectionName, void *);
1555 static void init_copymap(struct loadparm_service *pservice);
1557 /* This is a helper function for parametrical options support. */
1558 /* It returns a pointer to parametrical option value if it exists or NULL otherwise */
1559 /* Actual parametrical functions are quite simple */
1560 const char *lpcfg_get_parametric(struct loadparm_context *lp_ctx,
1561 struct loadparm_service *service,
1562 const char *type, const char *option)
1564 char *vfskey_tmp = NULL;
1565 char *vfskey = NULL;
1566 struct parmlist_entry *data;
1568 if (lp_ctx == NULL)
1569 return NULL;
1571 if (lp_ctx->s3_fns) {
1572 return lp_ctx->s3_fns->get_parametric(service, type, option);
1575 data = (service == NULL ? lp_ctx->globals->param_opt : service->param_opt);
1577 vfskey_tmp = talloc_asprintf(NULL, "%s:%s", type, option);
1578 if (vfskey_tmp == NULL) return NULL;
1579 vfskey = strlower_talloc(NULL, vfskey_tmp);
1580 talloc_free(vfskey_tmp);
1582 while (data) {
1583 if (strcmp(data->key, vfskey) == 0) {
1584 talloc_free(vfskey);
1585 return data->value;
1587 data = data->next;
1590 if (service != NULL) {
1591 /* Try to fetch the same option but from globals */
1592 /* but only if we are not already working with globals */
1593 for (data = lp_ctx->globals->param_opt; data;
1594 data = data->next) {
1595 if (strcmp(data->key, vfskey) == 0) {
1596 talloc_free(vfskey);
1597 return data->value;
1602 talloc_free(vfskey);
1604 return NULL;
1609 * convenience routine to return int parameters.
1611 static int lp_int(const char *s)
1614 if (!s) {
1615 DEBUG(0,("lp_int(%s): is called with NULL!\n",s));
1616 return -1;
1619 return strtol(s, NULL, 0);
1623 * convenience routine to return unsigned long parameters.
1625 static int lp_ulong(const char *s)
1628 if (!s) {
1629 DEBUG(0,("lp_int(%s): is called with NULL!\n",s));
1630 return -1;
1633 return strtoul(s, NULL, 0);
1637 * convenience routine to return unsigned long parameters.
1639 static double lp_double(const char *s)
1642 if (!s) {
1643 DEBUG(0,("lp_double(%s): is called with NULL!\n",s));
1644 return -1;
1647 return strtod(s, NULL);
1651 * convenience routine to return boolean parameters.
1653 static bool lp_bool(const char *s)
1655 bool ret = false;
1657 if (!s) {
1658 DEBUG(0,("lp_bool(%s): is called with NULL!\n",s));
1659 return false;
1662 if (!set_boolean(s, &ret)) {
1663 DEBUG(0,("lp_bool(%s): value is not boolean!\n",s));
1664 return false;
1667 return ret;
1672 * Return parametric option from a given service. Type is a part of option before ':'
1673 * Parametric option has following syntax: 'Type: option = value'
1674 * Returned value is allocated in 'lp_talloc' context
1677 const char *lpcfg_parm_string(struct loadparm_context *lp_ctx,
1678 struct loadparm_service *service, const char *type,
1679 const char *option)
1681 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
1683 if (value)
1684 return lp_string(value);
1686 return NULL;
1690 * Return parametric option from a given service. Type is a part of option before ':'
1691 * Parametric option has following syntax: 'Type: option = value'
1692 * Returned value is allocated in 'lp_talloc' context
1695 const char **lpcfg_parm_string_list(TALLOC_CTX *mem_ctx,
1696 struct loadparm_context *lp_ctx,
1697 struct loadparm_service *service,
1698 const char *type,
1699 const char *option, const char *separator)
1701 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
1703 if (value != NULL)
1704 return (const char **)str_list_make(mem_ctx, value, separator);
1706 return NULL;
1710 * Return parametric option from a given service. Type is a part of option before ':'
1711 * Parametric option has following syntax: 'Type: option = value'
1714 int lpcfg_parm_int(struct loadparm_context *lp_ctx,
1715 struct loadparm_service *service, const char *type,
1716 const char *option, int default_v)
1718 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
1720 if (value)
1721 return lp_int(value);
1723 return default_v;
1727 * Return parametric option from a given service. Type is a part of
1728 * option before ':'.
1729 * Parametric option has following syntax: 'Type: option = value'.
1732 int lpcfg_parm_bytes(struct loadparm_context *lp_ctx,
1733 struct loadparm_service *service, const char *type,
1734 const char *option, int default_v)
1736 uint64_t bval;
1738 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
1740 if (value && conv_str_size_error(value, &bval)) {
1741 if (bval <= INT_MAX) {
1742 return (int)bval;
1746 return default_v;
1750 * Return parametric option from a given service.
1751 * Type is a part of option before ':'
1752 * Parametric option has following syntax: 'Type: option = value'
1754 unsigned long lpcfg_parm_ulong(struct loadparm_context *lp_ctx,
1755 struct loadparm_service *service, const char *type,
1756 const char *option, unsigned long default_v)
1758 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
1760 if (value)
1761 return lp_ulong(value);
1763 return default_v;
1767 double lpcfg_parm_double(struct loadparm_context *lp_ctx,
1768 struct loadparm_service *service, const char *type,
1769 const char *option, double default_v)
1771 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
1773 if (value != NULL)
1774 return lp_double(value);
1776 return default_v;
1780 * Return parametric option from a given service. Type is a part of option before ':'
1781 * Parametric option has following syntax: 'Type: option = value'
1784 bool lpcfg_parm_bool(struct loadparm_context *lp_ctx,
1785 struct loadparm_service *service, const char *type,
1786 const char *option, bool default_v)
1788 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
1790 if (value != NULL)
1791 return lp_bool(value);
1793 return default_v;
1798 * Initialise a service to the defaults.
1801 static struct loadparm_service *init_service(TALLOC_CTX *mem_ctx, struct loadparm_service *sDefault)
1803 struct loadparm_service *pservice =
1804 talloc_zero(mem_ctx, struct loadparm_service);
1805 copy_service(pservice, sDefault, NULL);
1806 return pservice;
1810 * Set a string value, deallocating any existing space, and allocing the space
1811 * for the string
1813 static bool lpcfg_string_set(TALLOC_CTX *mem_ctx, char **dest, const char *src)
1815 talloc_free(*dest);
1817 if (src == NULL)
1818 src = "";
1820 *dest = talloc_strdup(mem_ctx, src);
1821 if ((*dest) == NULL) {
1822 DEBUG(0,("Out of memory in string_set\n"));
1823 return false;
1826 return true;
1830 * Set a string value, deallocating any existing space, and allocing the space
1831 * for the string
1833 static bool lpcfg_string_set_upper(TALLOC_CTX *mem_ctx, char **dest, const char *src)
1835 talloc_free(*dest);
1837 if (src == NULL)
1838 src = "";
1840 *dest = strupper_talloc(mem_ctx, src);
1841 if ((*dest) == NULL) {
1842 DEBUG(0,("Out of memory in string_set_upper\n"));
1843 return false;
1846 return true;
1852 * Add a new service to the services array initialising it with the given
1853 * service.
1856 struct loadparm_service *lpcfg_add_service(struct loadparm_context *lp_ctx,
1857 const struct loadparm_service *pservice,
1858 const char *name)
1860 int i;
1861 struct loadparm_service tservice;
1862 int num_to_alloc = lp_ctx->iNumServices + 1;
1863 struct parmlist_entry *data, *pdata;
1865 if (pservice == NULL) {
1866 pservice = lp_ctx->sDefault;
1869 tservice = *pservice;
1871 /* it might already exist */
1872 if (name) {
1873 struct loadparm_service *service = getservicebyname(lp_ctx,
1874 name);
1875 if (service != NULL) {
1876 /* Clean all parametric options for service */
1877 /* They will be added during parsing again */
1878 data = service->param_opt;
1879 while (data) {
1880 pdata = data->next;
1881 talloc_free(data);
1882 data = pdata;
1884 service->param_opt = NULL;
1885 return service;
1889 /* find an invalid one */
1890 for (i = 0; i < lp_ctx->iNumServices; i++)
1891 if (lp_ctx->services[i] == NULL)
1892 break;
1894 /* if not, then create one */
1895 if (i == lp_ctx->iNumServices) {
1896 struct loadparm_service **tsp;
1898 tsp = talloc_realloc(lp_ctx, lp_ctx->services, struct loadparm_service *, num_to_alloc);
1900 if (!tsp) {
1901 DEBUG(0,("lpcfg_add_service: failed to enlarge services!\n"));
1902 return NULL;
1903 } else {
1904 lp_ctx->services = tsp;
1905 lp_ctx->services[lp_ctx->iNumServices] = NULL;
1908 lp_ctx->iNumServices++;
1911 lp_ctx->services[i] = init_service(lp_ctx->services, lp_ctx->sDefault);
1912 if (lp_ctx->services[i] == NULL) {
1913 DEBUG(0,("lpcfg_add_service: out of memory!\n"));
1914 return NULL;
1916 copy_service(lp_ctx->services[i], &tservice, NULL);
1917 if (name != NULL)
1918 lpcfg_string_set(lp_ctx->services[i], &lp_ctx->services[i]->szService, name);
1919 return lp_ctx->services[i];
1923 * Add a new home service, with the specified home directory, defaults coming
1924 * from service ifrom.
1927 bool lpcfg_add_home(struct loadparm_context *lp_ctx,
1928 const char *pszHomename,
1929 struct loadparm_service *default_service,
1930 const char *user, const char *pszHomedir)
1932 struct loadparm_service *service;
1934 service = lpcfg_add_service(lp_ctx, default_service, pszHomename);
1936 if (service == NULL)
1937 return false;
1939 if (!(*(default_service->szPath))
1940 || strequal(default_service->szPath, lp_ctx->sDefault->szPath)) {
1941 service->szPath = talloc_strdup(service, pszHomedir);
1942 } else {
1943 service->szPath = string_sub_talloc(service, lpcfg_pathname(default_service, lp_ctx->sDefault), "%H", pszHomedir);
1946 if (!(*(service->comment))) {
1947 service->comment = talloc_asprintf(service, "Home directory of %s", user);
1949 service->bAvailable = default_service->bAvailable;
1950 service->bBrowseable = default_service->bBrowseable;
1952 DEBUG(3, ("adding home's share [%s] for user '%s' at '%s'\n",
1953 pszHomename, user, service->szPath));
1955 return true;
1959 * Add a new printer service, with defaults coming from service iFrom.
1962 bool lpcfg_add_printer(struct loadparm_context *lp_ctx,
1963 const char *pszPrintername,
1964 struct loadparm_service *default_service)
1966 const char *comment = "From Printcap";
1967 struct loadparm_service *service;
1968 service = lpcfg_add_service(lp_ctx, default_service, pszPrintername);
1970 if (service == NULL)
1971 return false;
1973 /* note that we do NOT default the availability flag to True - */
1974 /* we take it from the default service passed. This allows all */
1975 /* dynamic printers to be disabled by disabling the [printers] */
1976 /* entry (if/when the 'available' keyword is implemented!). */
1978 /* the printer name is set to the service name. */
1979 lpcfg_string_set(service, &service->szPrintername, pszPrintername);
1980 lpcfg_string_set(service, &service->comment, comment);
1981 service->bBrowseable = default_service->bBrowseable;
1982 /* Printers cannot be read_only. */
1983 service->bRead_only = false;
1984 /* Printer services must be printable. */
1985 service->bPrint_ok = true;
1987 DEBUG(3, ("adding printer service %s\n", pszPrintername));
1989 return true;
1993 * Map a parameter's string representation to something we can use.
1994 * Returns False if the parameter string is not recognised, else TRUE.
1997 static int map_parameter(const char *pszParmName)
1999 int iIndex;
2001 if (*pszParmName == '-')
2002 return -1;
2004 for (iIndex = 0; parm_table[iIndex].label; iIndex++)
2005 if (strwicmp(parm_table[iIndex].label, pszParmName) == 0)
2006 return iIndex;
2008 /* Warn only if it isn't parametric option */
2009 if (strchr(pszParmName, ':') == NULL)
2010 DEBUG(0, ("Unknown parameter encountered: \"%s\"\n", pszParmName));
2011 /* We do return 'fail' for parametric options as well because they are
2012 stored in different storage
2014 return -1;
2019 return the parameter structure for a parameter
2021 struct parm_struct *lpcfg_parm_struct(struct loadparm_context *lp_ctx, const char *name)
2023 int parmnum;
2025 if (lp_ctx->s3_fns) {
2026 return lp_ctx->s3_fns->get_parm_struct(name);
2029 parmnum = map_parameter(name);
2030 if (parmnum == -1) return NULL;
2031 return &parm_table[parmnum];
2035 return the parameter pointer for a parameter
2037 void *lpcfg_parm_ptr(struct loadparm_context *lp_ctx,
2038 struct loadparm_service *service, struct parm_struct *parm)
2040 if (lp_ctx->s3_fns) {
2041 return lp_ctx->s3_fns->get_parm_ptr(service, parm);
2044 if (service == NULL) {
2045 if (parm->p_class == P_LOCAL)
2046 return ((char *)lp_ctx->sDefault)+parm->offset;
2047 else if (parm->p_class == P_GLOBAL)
2048 return ((char *)lp_ctx->globals)+parm->offset;
2049 else return NULL;
2050 } else {
2051 return ((char *)service) + parm->offset;
2056 return the parameter pointer for a parameter
2058 bool lpcfg_parm_is_cmdline(struct loadparm_context *lp_ctx, const char *name)
2060 int parmnum;
2062 if (lp_ctx->s3_fns) {
2063 struct parm_struct *parm = lp_ctx->s3_fns->get_parm_struct(name);
2064 if (parm) {
2065 return parm->flags & FLAG_CMDLINE;
2067 return false;
2070 parmnum = map_parameter(name);
2071 if (parmnum == -1) return false;
2073 return lp_ctx->flags[parmnum] & FLAG_CMDLINE;
2077 * Find a service by name. Otherwise works like get_service.
2080 static struct loadparm_service *getservicebyname(struct loadparm_context *lp_ctx,
2081 const char *pszServiceName)
2083 int iService;
2085 if (lp_ctx->s3_fns) {
2086 return lp_ctx->s3_fns->get_service(pszServiceName);
2089 for (iService = lp_ctx->iNumServices - 1; iService >= 0; iService--)
2090 if (lp_ctx->services[iService] != NULL &&
2091 strwicmp(lp_ctx->services[iService]->szService, pszServiceName) == 0) {
2092 return lp_ctx->services[iService];
2095 return NULL;
2099 * Copy a service structure to another.
2100 * If pcopymapDest is NULL then copy all fields
2103 static void copy_service(struct loadparm_service *pserviceDest,
2104 struct loadparm_service *pserviceSource,
2105 struct bitmap *pcopymapDest)
2107 int i;
2108 bool bcopyall = (pcopymapDest == NULL);
2109 struct parmlist_entry *data, *pdata, *paramo;
2110 bool not_added;
2112 for (i = 0; parm_table[i].label; i++)
2113 if (parm_table[i].p_class == P_LOCAL &&
2114 (bcopyall || bitmap_query(pcopymapDest, i))) {
2115 void *src_ptr =
2116 ((char *)pserviceSource) + parm_table[i].offset;
2117 void *dest_ptr =
2118 ((char *)pserviceDest) + parm_table[i].offset;
2120 switch (parm_table[i].type) {
2121 case P_BOOL:
2122 *(bool *)dest_ptr = *(bool *)src_ptr;
2123 break;
2125 case P_INTEGER:
2126 case P_BYTES:
2127 case P_OCTAL:
2128 case P_ENUM:
2129 *(int *)dest_ptr = *(int *)src_ptr;
2130 break;
2132 case P_STRING:
2133 lpcfg_string_set(pserviceDest,
2134 (char **)dest_ptr,
2135 *(char **)src_ptr);
2136 break;
2138 case P_USTRING:
2139 lpcfg_string_set_upper(pserviceDest,
2140 (char **)dest_ptr,
2141 *(char **)src_ptr);
2142 break;
2143 case P_LIST:
2144 *(const char ***)dest_ptr = (const char **)str_list_copy(pserviceDest,
2145 *(const char ***)src_ptr);
2146 break;
2147 default:
2148 break;
2152 if (bcopyall) {
2153 init_copymap(pserviceDest);
2154 if (pserviceSource->copymap)
2155 bitmap_copy(pserviceDest->copymap,
2156 pserviceSource->copymap);
2159 data = pserviceSource->param_opt;
2160 while (data) {
2161 not_added = true;
2162 pdata = pserviceDest->param_opt;
2163 /* Traverse destination */
2164 while (pdata) {
2165 /* If we already have same option, override it */
2166 if (strcmp(pdata->key, data->key) == 0) {
2167 talloc_free(pdata->value);
2168 pdata->value = talloc_strdup(pdata,
2169 data->value);
2170 not_added = false;
2171 break;
2173 pdata = pdata->next;
2175 if (not_added) {
2176 paramo = talloc_zero(pserviceDest, struct parmlist_entry);
2177 if (paramo == NULL)
2178 smb_panic("OOM");
2179 paramo->key = talloc_strdup(paramo, data->key);
2180 paramo->value = talloc_strdup(paramo, data->value);
2181 DLIST_ADD(pserviceDest->param_opt, paramo);
2183 data = data->next;
2188 * Check a service for consistency. Return False if the service is in any way
2189 * incomplete or faulty, else True.
2191 static bool lpcfg_service_ok(struct loadparm_service *service)
2193 bool bRetval;
2195 bRetval = true;
2196 if (service->szService[0] == '\0') {
2197 DEBUG(0, ("The following message indicates an internal error:\n"));
2198 DEBUG(0, ("No service name in service entry.\n"));
2199 bRetval = false;
2202 /* The [printers] entry MUST be printable. I'm all for flexibility, but */
2203 /* I can't see why you'd want a non-printable printer service... */
2204 if (strwicmp(service->szService, PRINTERS_NAME) == 0) {
2205 if (!service->bPrint_ok) {
2206 DEBUG(0, ("WARNING: [%s] service MUST be printable!\n",
2207 service->szService));
2208 service->bPrint_ok = true;
2210 /* [printers] service must also be non-browsable. */
2211 if (service->bBrowseable)
2212 service->bBrowseable = false;
2215 /* If a service is flagged unavailable, log the fact at level 0. */
2216 if (!service->bAvailable)
2217 DEBUG(1, ("NOTE: Service %s is flagged unavailable.\n",
2218 service->szService));
2220 return bRetval;
2224 /*******************************************************************
2225 Keep a linked list of all config files so we know when one has changed
2226 it's date and needs to be reloaded.
2227 ********************************************************************/
2229 static void add_to_file_list(struct loadparm_context *lp_ctx,
2230 const char *fname, const char *subfname)
2232 struct file_lists *f = lp_ctx->file_lists;
2234 while (f) {
2235 if (f->name && !strcmp(f->name, fname))
2236 break;
2237 f = f->next;
2240 if (!f) {
2241 f = talloc(lp_ctx, struct file_lists);
2242 if (!f)
2243 return;
2244 f->next = lp_ctx->file_lists;
2245 f->name = talloc_strdup(f, fname);
2246 if (!f->name) {
2247 talloc_free(f);
2248 return;
2250 f->subfname = talloc_strdup(f, subfname);
2251 if (!f->subfname) {
2252 talloc_free(f);
2253 return;
2255 lp_ctx->file_lists = f;
2256 f->modtime = file_modtime(subfname);
2257 } else {
2258 time_t t = file_modtime(subfname);
2259 if (t)
2260 f->modtime = t;
2264 /*******************************************************************
2265 Check if a config file has changed date.
2266 ********************************************************************/
2267 bool lpcfg_file_list_changed(struct loadparm_context *lp_ctx)
2269 struct file_lists *f;
2270 DEBUG(6, ("lp_file_list_changed()\n"));
2272 for (f = lp_ctx->file_lists; f != NULL; f = f->next) {
2273 char *n2;
2274 time_t mod_time;
2276 n2 = standard_sub_basic(lp_ctx, f->name);
2278 DEBUGADD(6, ("file %s -> %s last mod_time: %s\n",
2279 f->name, n2, ctime(&f->modtime)));
2281 mod_time = file_modtime(n2);
2283 if (mod_time && ((f->modtime != mod_time) || (f->subfname == NULL) || (strcmp(n2, f->subfname) != 0))) {
2284 DEBUGADD(6, ("file %s modified: %s\n", n2,
2285 ctime(&mod_time)));
2286 f->modtime = mod_time;
2287 talloc_free(f->subfname);
2288 f->subfname = talloc_strdup(f, n2);
2289 return true;
2292 return false;
2295 /***************************************************************************
2296 Handle the "realm" parameter
2297 ***************************************************************************/
2299 static bool handle_realm(struct loadparm_context *lp_ctx, int unused,
2300 const char *pszParmValue, char **ptr)
2302 lpcfg_string_set(lp_ctx, ptr, pszParmValue);
2304 talloc_free(lp_ctx->globals->szRealm_upper);
2305 talloc_free(lp_ctx->globals->szRealm_lower);
2307 lp_ctx->globals->szRealm_upper = strupper_talloc(lp_ctx, pszParmValue);
2308 lp_ctx->globals->szRealm_lower = strlower_talloc(lp_ctx, pszParmValue);
2310 return true;
2313 /***************************************************************************
2314 Handle the include operation.
2315 ***************************************************************************/
2317 static bool handle_include(struct loadparm_context *lp_ctx, int unused,
2318 const char *pszParmValue, char **ptr)
2320 char *fname = standard_sub_basic(lp_ctx, pszParmValue);
2322 add_to_file_list(lp_ctx, pszParmValue, fname);
2324 lpcfg_string_set(lp_ctx, ptr, fname);
2326 if (file_exist(fname))
2327 return pm_process(fname, do_section, do_parameter, lp_ctx);
2329 DEBUG(2, ("Can't find include file %s\n", fname));
2331 return false;
2334 /***************************************************************************
2335 Handle the interpretation of the copy parameter.
2336 ***************************************************************************/
2338 static bool handle_copy(struct loadparm_context *lp_ctx, int unused,
2339 const char *pszParmValue, char **ptr)
2341 bool bRetval;
2342 struct loadparm_service *serviceTemp;
2344 lpcfg_string_set(lp_ctx, ptr, pszParmValue);
2346 bRetval = false;
2348 DEBUG(3, ("Copying service from service %s\n", pszParmValue));
2350 if ((serviceTemp = getservicebyname(lp_ctx, pszParmValue)) != NULL) {
2351 if (serviceTemp == lp_ctx->currentService) {
2352 DEBUG(0, ("Can't copy service %s - unable to copy self!\n", pszParmValue));
2353 } else {
2354 copy_service(lp_ctx->currentService,
2355 serviceTemp,
2356 lp_ctx->currentService->copymap);
2357 bRetval = true;
2359 } else {
2360 DEBUG(0, ("Unable to copy service - source not found: %s\n",
2361 pszParmValue));
2362 bRetval = false;
2365 return bRetval;
2368 static bool handle_debuglevel(struct loadparm_context *lp_ctx, int unused,
2369 const char *pszParmValue, char **ptr)
2372 lpcfg_string_set(lp_ctx, ptr, pszParmValue);
2373 if (lp_ctx->global) {
2374 return debug_parse_levels(pszParmValue);
2376 return true;
2379 static bool handle_logfile(struct loadparm_context *lp_ctx, int unused,
2380 const char *pszParmValue, char **ptr)
2382 debug_set_logfile(pszParmValue);
2383 if (lp_ctx->global) {
2384 lpcfg_string_set(lp_ctx, ptr, pszParmValue);
2386 return true;
2389 /***************************************************************************
2390 Initialise a copymap.
2391 ***************************************************************************/
2393 static void init_copymap(struct loadparm_service *pservice)
2395 int i;
2397 TALLOC_FREE(pservice->copymap);
2399 pservice->copymap = bitmap_talloc(NULL, NUMPARAMETERS);
2400 if (!pservice->copymap)
2401 DEBUG(0,
2402 ("Couldn't allocate copymap!! (size %d)\n",
2403 (int)NUMPARAMETERS));
2404 else
2405 for (i = 0; i < NUMPARAMETERS; i++)
2406 bitmap_set(pservice->copymap, i);
2410 * Process a parametric option
2412 static bool lp_do_parameter_parametric(struct loadparm_context *lp_ctx,
2413 struct loadparm_service *service,
2414 const char *pszParmName,
2415 const char *pszParmValue, int flags)
2417 struct parmlist_entry *paramo, *data;
2418 char *name;
2419 TALLOC_CTX *mem_ctx;
2421 while (isspace((unsigned char)*pszParmName)) {
2422 pszParmName++;
2425 name = strlower_talloc(lp_ctx, pszParmName);
2426 if (!name) return false;
2428 if (service == NULL) {
2429 data = lp_ctx->globals->param_opt;
2430 mem_ctx = lp_ctx->globals;
2431 } else {
2432 data = service->param_opt;
2433 mem_ctx = service;
2436 /* Traverse destination */
2437 for (paramo=data; paramo; paramo=paramo->next) {
2438 /* If we already have the option set, override it unless
2439 it was a command line option and the new one isn't */
2440 if (strcmp(paramo->key, name) == 0) {
2441 if ((paramo->priority & FLAG_CMDLINE) &&
2442 !(flags & FLAG_CMDLINE)) {
2443 talloc_free(name);
2444 return true;
2447 talloc_free(paramo->value);
2448 paramo->value = talloc_strdup(paramo, pszParmValue);
2449 paramo->priority = flags;
2450 talloc_free(name);
2451 return true;
2455 paramo = talloc_zero(mem_ctx, struct parmlist_entry);
2456 if (!paramo)
2457 smb_panic("OOM");
2458 paramo->key = talloc_strdup(paramo, name);
2459 paramo->value = talloc_strdup(paramo, pszParmValue);
2460 paramo->priority = flags;
2461 if (service == NULL) {
2462 DLIST_ADD(lp_ctx->globals->param_opt, paramo);
2463 } else {
2464 DLIST_ADD(service->param_opt, paramo);
2467 talloc_free(name);
2469 return true;
2472 static bool set_variable(TALLOC_CTX *mem_ctx, int parmnum, void *parm_ptr,
2473 const char *pszParmName, const char *pszParmValue,
2474 struct loadparm_context *lp_ctx, bool on_globals)
2476 int i;
2477 /* if it is a special case then go ahead */
2478 if (parm_table[parmnum].special) {
2479 bool ret;
2480 ret = parm_table[parmnum].special(lp_ctx, -1, pszParmValue,
2481 (char **)parm_ptr);
2482 if (!ret) {
2483 return false;
2485 goto mark_non_default;
2488 /* now switch on the type of variable it is */
2489 switch (parm_table[parmnum].type)
2491 case P_BOOL: {
2492 bool b;
2493 if (!set_boolean(pszParmValue, &b)) {
2494 DEBUG(0,("lp_do_parameter(%s): value is not boolean!\n", pszParmValue));
2495 return false;
2497 *(bool *)parm_ptr = b;
2499 break;
2501 case P_BOOLREV: {
2502 bool b;
2503 if (!set_boolean(pszParmValue, &b)) {
2504 DEBUG(0,("lp_do_parameter(%s): value is not boolean!\n", pszParmValue));
2505 return false;
2507 *(bool *)parm_ptr = !b;
2509 break;
2511 case P_INTEGER:
2512 *(int *)parm_ptr = atoi(pszParmValue);
2513 break;
2515 case P_CHAR:
2516 *(char *)parm_ptr = *pszParmValue;
2517 break;
2519 case P_OCTAL:
2520 *(int *)parm_ptr = strtol(pszParmValue, NULL, 8);
2521 break;
2523 case P_BYTES:
2525 uint64_t val;
2526 if (conv_str_size_error(pszParmValue, &val)) {
2527 if (val <= INT_MAX) {
2528 *(int *)parm_ptr = (int)val;
2529 break;
2533 DEBUG(0,("lp_do_parameter(%s): value is not "
2534 "a valid size specifier!\n", pszParmValue));
2535 return false;
2538 case P_CMDLIST:
2539 *(const char ***)parm_ptr = (const char **)str_list_make(mem_ctx,
2540 pszParmValue, NULL);
2541 break;
2542 case P_LIST:
2544 char **new_list = str_list_make(mem_ctx,
2545 pszParmValue, NULL);
2546 for (i=0; new_list[i]; i++) {
2547 if (new_list[i][0] == '+' && new_list[i][1]) {
2548 if (!str_list_check(*(const char ***)parm_ptr,
2549 &new_list[i][1])) {
2550 *(const char ***)parm_ptr = str_list_add(*(const char ***)parm_ptr,
2551 &new_list[i][1]);
2553 } else if (new_list[i][0] == '-' && new_list[i][1]) {
2554 str_list_remove(*(const char ***)parm_ptr,
2555 &new_list[i][1]);
2556 } else {
2557 if (i != 0) {
2558 DEBUG(0, ("Unsupported list syntax for: %s = %s\n",
2559 pszParmName, pszParmValue));
2560 return false;
2562 *(const char ***)parm_ptr = (const char **) new_list;
2563 break;
2566 break;
2568 case P_STRING:
2569 lpcfg_string_set(mem_ctx, (char **)parm_ptr, pszParmValue);
2570 break;
2572 case P_USTRING:
2573 lpcfg_string_set_upper(mem_ctx, (char **)parm_ptr, pszParmValue);
2574 break;
2576 case P_ENUM:
2577 for (i = 0; parm_table[parmnum].enum_list[i].name; i++) {
2578 if (strequal
2579 (pszParmValue,
2580 parm_table[parmnum].enum_list[i].name)) {
2581 *(int *)parm_ptr =
2582 parm_table[parmnum].
2583 enum_list[i].value;
2584 break;
2587 if (!parm_table[parmnum].enum_list[i].name) {
2588 DEBUG(0,("Unknown enumerated value '%s' for '%s'\n",
2589 pszParmValue, pszParmName));
2590 return false;
2592 break;
2594 case P_SEP:
2595 break;
2598 mark_non_default:
2599 if (on_globals && (lp_ctx->flags[parmnum] & FLAG_DEFAULT)) {
2600 lp_ctx->flags[parmnum] &= ~FLAG_DEFAULT;
2601 /* we have to also unset FLAG_DEFAULT on aliases */
2602 for (i=parmnum-1;i>=0 && parm_table[i].offset == parm_table[parmnum].offset;i--) {
2603 lp_ctx->flags[i] &= ~FLAG_DEFAULT;
2605 for (i=parmnum+1;i<NUMPARAMETERS && parm_table[i].offset == parm_table[parmnum].offset;i++) {
2606 lp_ctx->flags[i] &= ~FLAG_DEFAULT;
2609 return true;
2613 bool lpcfg_do_global_parameter(struct loadparm_context *lp_ctx,
2614 const char *pszParmName, const char *pszParmValue)
2616 int parmnum = map_parameter(pszParmName);
2617 void *parm_ptr;
2619 if (parmnum < 0) {
2620 if (strchr(pszParmName, ':')) {
2621 return lp_do_parameter_parametric(lp_ctx, NULL, pszParmName, pszParmValue, 0);
2623 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName));
2624 return true;
2627 /* if the flag has been set on the command line, then don't allow override,
2628 but don't report an error */
2629 if (lp_ctx->flags[parmnum] & FLAG_CMDLINE) {
2630 return true;
2633 parm_ptr = lpcfg_parm_ptr(lp_ctx, NULL, &parm_table[parmnum]);
2635 return set_variable(lp_ctx->globals, parmnum, parm_ptr,
2636 pszParmName, pszParmValue, lp_ctx, true);
2639 bool lpcfg_do_service_parameter(struct loadparm_context *lp_ctx,
2640 struct loadparm_service *service,
2641 const char *pszParmName, const char *pszParmValue)
2643 void *parm_ptr;
2644 int i;
2645 int parmnum = map_parameter(pszParmName);
2647 if (parmnum < 0) {
2648 if (strchr(pszParmName, ':')) {
2649 return lp_do_parameter_parametric(lp_ctx, service, pszParmName, pszParmValue, 0);
2651 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName));
2652 return true;
2655 /* if the flag has been set on the command line, then don't allow override,
2656 but don't report an error */
2657 if (lp_ctx->flags[parmnum] & FLAG_CMDLINE) {
2658 return true;
2661 if (parm_table[parmnum].p_class == P_GLOBAL) {
2662 DEBUG(0,
2663 ("Global parameter %s found in service section!\n",
2664 pszParmName));
2665 return true;
2667 parm_ptr = ((char *)service) + parm_table[parmnum].offset;
2669 if (!service->copymap)
2670 init_copymap(service);
2672 /* this handles the aliases - set the copymap for other
2673 * entries with the same data pointer */
2674 for (i = 0; parm_table[i].label; i++)
2675 if (parm_table[i].offset == parm_table[parmnum].offset &&
2676 parm_table[i].p_class == parm_table[parmnum].p_class)
2677 bitmap_clear(service->copymap, i);
2679 return set_variable(service, parmnum, parm_ptr, pszParmName,
2680 pszParmValue, lp_ctx, false);
2684 * Process a parameter.
2687 static bool do_parameter(const char *pszParmName, const char *pszParmValue,
2688 void *userdata)
2690 struct loadparm_context *lp_ctx = (struct loadparm_context *)userdata;
2692 if (lp_ctx->bInGlobalSection)
2693 return lpcfg_do_global_parameter(lp_ctx, pszParmName,
2694 pszParmValue);
2695 else
2696 return lpcfg_do_service_parameter(lp_ctx, lp_ctx->currentService,
2697 pszParmName, pszParmValue);
2701 variable argument do parameter
2703 bool lpcfg_do_global_parameter_var(struct loadparm_context *lp_ctx, const char *pszParmName, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4);
2704 bool lpcfg_do_global_parameter_var(struct loadparm_context *lp_ctx,
2705 const char *pszParmName, const char *fmt, ...)
2707 char *s;
2708 bool ret;
2709 va_list ap;
2711 va_start(ap, fmt);
2712 s = talloc_vasprintf(NULL, fmt, ap);
2713 va_end(ap);
2714 ret = lpcfg_do_global_parameter(lp_ctx, pszParmName, s);
2715 talloc_free(s);
2716 return ret;
2721 set a parameter from the commandline - this is called from command line parameter
2722 parsing code. It sets the parameter then marks the parameter as unable to be modified
2723 by smb.conf processing
2725 bool lpcfg_set_cmdline(struct loadparm_context *lp_ctx, const char *pszParmName,
2726 const char *pszParmValue)
2728 int parmnum;
2729 int i;
2731 if (lp_ctx->s3_fns) {
2732 return lp_ctx->s3_fns->set_cmdline(pszParmName, pszParmValue);
2735 parmnum = map_parameter(pszParmName);
2737 while (isspace((unsigned char)*pszParmValue)) pszParmValue++;
2740 if (parmnum < 0 && strchr(pszParmName, ':')) {
2741 /* set a parametric option */
2742 return lp_do_parameter_parametric(lp_ctx, NULL, pszParmName,
2743 pszParmValue, FLAG_CMDLINE);
2746 if (parmnum < 0) {
2747 DEBUG(0,("Unknown option '%s'\n", pszParmName));
2748 return false;
2751 /* reset the CMDLINE flag in case this has been called before */
2752 lp_ctx->flags[parmnum] &= ~FLAG_CMDLINE;
2754 if (!lpcfg_do_global_parameter(lp_ctx, pszParmName, pszParmValue)) {
2755 return false;
2758 lp_ctx->flags[parmnum] |= FLAG_CMDLINE;
2760 /* we have to also set FLAG_CMDLINE on aliases */
2761 for (i=parmnum-1;i>=0 && parm_table[i].offset == parm_table[parmnum].offset;i--) {
2762 lp_ctx->flags[i] |= FLAG_CMDLINE;
2764 for (i=parmnum+1;i<NUMPARAMETERS && parm_table[i].offset == parm_table[parmnum].offset;i++) {
2765 lp_ctx->flags[i] |= FLAG_CMDLINE;
2768 return true;
2772 set a option from the commandline in 'a=b' format. Use to support --option
2774 bool lpcfg_set_option(struct loadparm_context *lp_ctx, const char *option)
2776 char *p, *s;
2777 bool ret;
2779 s = talloc_strdup(NULL, option);
2780 if (!s) {
2781 return false;
2784 p = strchr(s, '=');
2785 if (!p) {
2786 talloc_free(s);
2787 return false;
2790 *p = 0;
2792 ret = lpcfg_set_cmdline(lp_ctx, s, p+1);
2793 talloc_free(s);
2794 return ret;
2798 #define BOOLSTR(b) ((b) ? "Yes" : "No")
2801 * Print a parameter of the specified type.
2804 static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
2806 /* For the seperation of lists values that we print below */
2807 const char *list_sep = ", ";
2808 int i;
2809 switch (p->type)
2811 case P_ENUM:
2812 for (i = 0; p->enum_list[i].name; i++) {
2813 if (*(int *)ptr == p->enum_list[i].value) {
2814 fprintf(f, "%s",
2815 p->enum_list[i].name);
2816 break;
2819 break;
2821 case P_BOOL:
2822 fprintf(f, "%s", BOOLSTR(*(bool *)ptr));
2823 break;
2825 case P_BOOLREV:
2826 fprintf(f, "%s", BOOLSTR(!*(bool *)ptr));
2827 break;
2829 case P_INTEGER:
2830 case P_BYTES:
2831 fprintf(f, "%d", *(int *)ptr);
2832 break;
2834 case P_CHAR:
2835 fprintf(f, "%c", *(char *)ptr);
2836 break;
2838 case P_OCTAL: {
2839 int val = *(int *)ptr;
2840 if (val == -1) {
2841 fprintf(f, "-1");
2842 } else {
2843 fprintf(f, "0%o", val);
2845 break;
2848 case P_CMDLIST:
2849 list_sep = " ";
2850 /* fall through */
2851 case P_LIST:
2852 if ((char ***)ptr && *(char ***)ptr) {
2853 char **list = *(char ***)ptr;
2854 for (; *list; list++) {
2855 /* surround strings with whitespace in double quotes */
2856 if (*(list+1) == NULL) {
2857 /* last item, no extra separator */
2858 list_sep = "";
2860 if ( strchr_m( *list, ' ' ) ) {
2861 fprintf(f, "\"%s\"%s", *list, list_sep);
2862 } else {
2863 fprintf(f, "%s%s", *list, list_sep);
2867 break;
2869 case P_STRING:
2870 case P_USTRING:
2871 if (*(char **)ptr) {
2872 fprintf(f, "%s", *(char **)ptr);
2874 break;
2875 case P_SEP:
2876 break;
2881 * Check if two parameters are equal.
2884 static bool equal_parameter(parm_type type, void *ptr1, void *ptr2)
2886 switch (type) {
2887 case P_BOOL:
2888 case P_BOOLREV:
2889 return (*((bool *)ptr1) == *((bool *)ptr2));
2891 case P_INTEGER:
2892 case P_ENUM:
2893 case P_OCTAL:
2894 case P_BYTES:
2895 return (*((int *)ptr1) == *((int *)ptr2));
2897 case P_CHAR:
2898 return (*((char *)ptr1) == *((char *)ptr2));
2900 case P_LIST:
2901 case P_CMDLIST:
2902 return str_list_equal(*(const char ***)ptr1, *(const char ***)ptr2);
2904 case P_STRING:
2905 case P_USTRING:
2907 char *p1 = *(char **)ptr1, *p2 = *(char **)ptr2;
2908 if (p1 && !*p1)
2909 p1 = NULL;
2910 if (p2 && !*p2)
2911 p2 = NULL;
2912 return (p1 == p2 || strequal(p1, p2));
2914 case P_SEP:
2915 break;
2917 return false;
2921 * Process a new section (service).
2923 * At this stage all sections are services.
2924 * Later we'll have special sections that permit server parameters to be set.
2925 * Returns True on success, False on failure.
2928 static bool do_section(const char *pszSectionName, void *userdata)
2930 struct loadparm_context *lp_ctx = (struct loadparm_context *)userdata;
2931 bool bRetval;
2932 bool isglobal = ((strwicmp(pszSectionName, GLOBAL_NAME) == 0) ||
2933 (strwicmp(pszSectionName, GLOBAL_NAME2) == 0));
2934 bRetval = false;
2936 /* if we've just struck a global section, note the fact. */
2937 lp_ctx->bInGlobalSection = isglobal;
2939 /* check for multiple global sections */
2940 if (lp_ctx->bInGlobalSection) {
2941 DEBUG(4, ("Processing section \"[%s]\"\n", pszSectionName));
2942 return true;
2945 /* if we have a current service, tidy it up before moving on */
2946 bRetval = true;
2948 if (lp_ctx->currentService != NULL)
2949 bRetval = lpcfg_service_ok(lp_ctx->currentService);
2951 /* if all is still well, move to the next record in the services array */
2952 if (bRetval) {
2953 /* We put this here to avoid an odd message order if messages are */
2954 /* issued by the post-processing of a previous section. */
2955 DEBUG(4, ("Processing section \"[%s]\"\n", pszSectionName));
2957 if ((lp_ctx->currentService = lpcfg_add_service(lp_ctx, lp_ctx->sDefault,
2958 pszSectionName))
2959 == NULL) {
2960 DEBUG(0, ("Failed to add a new service\n"));
2961 return false;
2965 return bRetval;
2970 * Determine if a particular base parameter is currently set to the default value.
2973 static bool is_default(struct loadparm_service *sDefault, int i)
2975 void *def_ptr = ((char *)sDefault) + parm_table[i].offset;
2976 if (!defaults_saved)
2977 return false;
2978 switch (parm_table[i].type) {
2979 case P_CMDLIST:
2980 case P_LIST:
2981 return str_list_equal((const char **)parm_table[i].def.lvalue,
2982 (const char **)def_ptr);
2983 case P_STRING:
2984 case P_USTRING:
2985 return strequal(parm_table[i].def.svalue,
2986 *(char **)def_ptr);
2987 case P_BOOL:
2988 case P_BOOLREV:
2989 return parm_table[i].def.bvalue ==
2990 *(bool *)def_ptr;
2991 case P_INTEGER:
2992 case P_CHAR:
2993 case P_OCTAL:
2994 case P_BYTES:
2995 case P_ENUM:
2996 return parm_table[i].def.ivalue ==
2997 *(int *)def_ptr;
2998 case P_SEP:
2999 break;
3001 return false;
3005 *Display the contents of the global structure.
3008 static void dump_globals(struct loadparm_context *lp_ctx, FILE *f,
3009 bool show_defaults)
3011 int i;
3012 struct parmlist_entry *data;
3014 fprintf(f, "# Global parameters\n[global]\n");
3016 for (i = 0; parm_table[i].label; i++)
3017 if (parm_table[i].p_class == P_GLOBAL &&
3018 (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset))) {
3019 if (!show_defaults && (lp_ctx->flags[i] & FLAG_DEFAULT))
3020 continue;
3021 fprintf(f, "\t%s = ", parm_table[i].label);
3022 print_parameter(&parm_table[i], lpcfg_parm_ptr(lp_ctx, NULL, &parm_table[i]), f);
3023 fprintf(f, "\n");
3025 if (lp_ctx->globals->param_opt != NULL) {
3026 for (data = lp_ctx->globals->param_opt; data;
3027 data = data->next) {
3028 if (!show_defaults && (data->priority & FLAG_DEFAULT)) {
3029 continue;
3031 fprintf(f, "\t%s = %s\n", data->key, data->value);
3038 * Display the contents of a single services record.
3041 static void dump_a_service(struct loadparm_service * pService, struct loadparm_service *sDefault, FILE * f,
3042 unsigned int *flags)
3044 int i;
3045 struct parmlist_entry *data;
3047 if (pService != sDefault)
3048 fprintf(f, "\n[%s]\n", pService->szService);
3050 for (i = 0; parm_table[i].label; i++) {
3051 if (parm_table[i].p_class == P_LOCAL &&
3052 (*parm_table[i].label != '-') &&
3053 (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset)))
3055 if (pService == sDefault) {
3056 if (flags && (flags[i] & FLAG_DEFAULT)) {
3057 continue;
3059 if (defaults_saved) {
3060 if (is_default(sDefault, i)) {
3061 continue;
3064 } else {
3065 if (equal_parameter(parm_table[i].type,
3066 ((char *)pService) +
3067 parm_table[i].offset,
3068 ((char *)sDefault) +
3069 parm_table[i].offset))
3070 continue;
3073 fprintf(f, "\t%s = ", parm_table[i].label);
3074 print_parameter(&parm_table[i],
3075 ((char *)pService) + parm_table[i].offset, f);
3076 fprintf(f, "\n");
3079 if (pService->param_opt != NULL) {
3080 for (data = pService->param_opt; data; data = data->next) {
3081 fprintf(f, "\t%s = %s\n", data->key, data->value);
3086 bool lpcfg_dump_a_parameter(struct loadparm_context *lp_ctx,
3087 struct loadparm_service *service,
3088 const char *parm_name, FILE * f)
3090 struct parm_struct *parm;
3091 void *ptr;
3093 parm = lpcfg_parm_struct(lp_ctx, parm_name);
3094 if (!parm) {
3095 return false;
3098 ptr = lpcfg_parm_ptr(lp_ctx, service,parm);
3100 print_parameter(parm, ptr, f);
3101 fprintf(f, "\n");
3102 return true;
3106 * Return info about the next parameter in a service.
3107 * snum==-1 gives the globals.
3108 * Return NULL when out of parameters.
3112 struct parm_struct *lpcfg_next_parameter(struct loadparm_context *lp_ctx, int snum, int *i,
3113 int allparameters)
3115 if (snum == -1) {
3116 /* do the globals */
3117 for (; parm_table[*i].label; (*i)++) {
3118 if ((*parm_table[*i].label == '-'))
3119 continue;
3121 if ((*i) > 0
3122 && (parm_table[*i].offset ==
3123 parm_table[(*i) - 1].offset)
3124 && (parm_table[*i].p_class ==
3125 parm_table[(*i) - 1].p_class))
3126 continue;
3128 return &parm_table[(*i)++];
3130 } else {
3131 struct loadparm_service *pService = lp_ctx->services[snum];
3133 for (; parm_table[*i].label; (*i)++) {
3134 if (parm_table[*i].p_class == P_LOCAL &&
3135 (*parm_table[*i].label != '-') &&
3136 ((*i) == 0 ||
3137 (parm_table[*i].offset !=
3138 parm_table[(*i) - 1].offset)))
3140 if (allparameters ||
3141 !equal_parameter(parm_table[*i].type,
3142 ((char *)pService) +
3143 parm_table[*i].offset,
3144 ((char *)lp_ctx->sDefault) +
3145 parm_table[*i].offset))
3147 return &parm_table[(*i)++];
3153 return NULL;
3158 * Auto-load some home services.
3160 static void lpcfg_add_auto_services(struct loadparm_context *lp_ctx,
3161 const char *str)
3163 return;
3168 * Unload unused services.
3171 void lpcfg_killunused(struct loadparm_context *lp_ctx,
3172 struct smbsrv_connection *smb,
3173 bool (*snumused) (struct smbsrv_connection *, int))
3175 int i;
3176 for (i = 0; i < lp_ctx->iNumServices; i++) {
3177 if (lp_ctx->services[i] == NULL)
3178 continue;
3180 if (!snumused || !snumused(smb, i)) {
3181 talloc_free(lp_ctx->services[i]);
3182 lp_ctx->services[i] = NULL;
3188 static int lpcfg_destructor(struct loadparm_context *lp_ctx)
3190 struct parmlist_entry *data;
3192 if (lp_ctx->refuse_free) {
3193 /* someone is trying to free the
3194 global_loadparm_context.
3195 We can't allow that. */
3196 return -1;
3199 if (lp_ctx->globals->param_opt != NULL) {
3200 struct parmlist_entry *next;
3201 for (data = lp_ctx->globals->param_opt; data; data=next) {
3202 next = data->next;
3203 if (data->priority & FLAG_CMDLINE) continue;
3204 DLIST_REMOVE(lp_ctx->globals->param_opt, data);
3205 talloc_free(data);
3209 return 0;
3213 * Initialise the global parameter structure.
3215 * Note that most callers should use loadparm_init_global() instead
3217 struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
3219 int i;
3220 char *myname;
3221 struct loadparm_context *lp_ctx;
3222 struct parmlist_entry *parm;
3223 char *logfile;
3225 lp_ctx = talloc_zero(mem_ctx, struct loadparm_context);
3226 if (lp_ctx == NULL)
3227 return NULL;
3229 talloc_set_destructor(lp_ctx, lpcfg_destructor);
3230 lp_ctx->bInGlobalSection = true;
3231 lp_ctx->globals = talloc_zero(lp_ctx, struct loadparm_global);
3232 lp_ctx->sDefault = talloc_zero(lp_ctx, struct loadparm_service);
3234 lp_ctx->sDefault->iMaxPrintJobs = 1000;
3235 lp_ctx->sDefault->bAvailable = true;
3236 lp_ctx->sDefault->bBrowseable = true;
3237 lp_ctx->sDefault->bRead_only = true;
3238 lp_ctx->sDefault->bMap_archive = true;
3239 lp_ctx->sDefault->iStrictLocking = true;
3240 lp_ctx->sDefault->bOpLocks = true;
3241 lp_ctx->sDefault->iCreate_mask = 0744;
3242 lp_ctx->sDefault->iCreate_force_mode = 0000;
3243 lp_ctx->sDefault->iDir_mask = 0755;
3244 lp_ctx->sDefault->iDir_force_mode = 0000;
3246 DEBUG(3, ("Initialising global parameters\n"));
3248 for (i = 0; parm_table[i].label; i++) {
3249 if ((parm_table[i].type == P_STRING ||
3250 parm_table[i].type == P_USTRING) &&
3251 !(lp_ctx->flags[i] & FLAG_CMDLINE)) {
3252 char **r;
3253 if (parm_table[i].p_class == P_LOCAL) {
3254 r = (char **)(((char *)lp_ctx->sDefault) + parm_table[i].offset);
3255 } else {
3256 r = (char **)(((char *)lp_ctx->globals) + parm_table[i].offset);
3258 *r = talloc_strdup(lp_ctx, "");
3262 logfile = talloc_asprintf(lp_ctx, "%s/log.samba", dyn_LOGFILEBASE);
3263 lpcfg_do_global_parameter(lp_ctx, "log file", logfile);
3264 talloc_free(logfile);
3266 lpcfg_do_global_parameter(lp_ctx, "log level", "0");
3268 lpcfg_do_global_parameter(lp_ctx, "share backend", "classic");
3270 lpcfg_do_global_parameter(lp_ctx, "server role", "auto");
3271 lpcfg_do_global_parameter(lp_ctx, "domain logons", "No");
3272 lpcfg_do_global_parameter(lp_ctx, "domain master", "Auto");
3274 /* options that can be set on the command line must be initialised via
3275 the slower lpcfg_do_global_parameter() to ensure that FLAG_CMDLINE is obeyed */
3276 #ifdef TCP_NODELAY
3277 lpcfg_do_global_parameter(lp_ctx, "socket options", "TCP_NODELAY");
3278 #endif
3279 lpcfg_do_global_parameter(lp_ctx, "workgroup", DEFAULT_WORKGROUP);
3280 myname = get_myname(lp_ctx);
3281 lpcfg_do_global_parameter(lp_ctx, "netbios name", myname);
3282 talloc_free(myname);
3283 lpcfg_do_global_parameter(lp_ctx, "name resolve order", "wins host bcast");
3285 lpcfg_do_global_parameter(lp_ctx, "fstype", "NTFS");
3287 lpcfg_do_global_parameter(lp_ctx, "ntvfs handler", "unixuid default");
3288 lpcfg_do_global_parameter(lp_ctx, "max connections", "-1");
3290 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");
3291 lpcfg_do_global_parameter(lp_ctx, "server services", "smb rpc nbt wrepl ldap cldap kdc drepl winbind ntp_signd kcc dnsupdate");
3292 lpcfg_do_global_parameter(lp_ctx, "ntptr providor", "simple_ldb");
3293 /* the winbind method for domain controllers is for both RODC
3294 auth forwarding and for trusted domains */
3295 lpcfg_do_global_parameter(lp_ctx, "private dir", dyn_PRIVATE_DIR);
3296 lpcfg_do_global_parameter(lp_ctx, "registry:HKEY_LOCAL_MACHINE", "hklm.ldb");
3298 /* This hive should be dynamically generated by Samba using
3299 data from the sam, but for the moment leave it in a tdb to
3300 keep regedt32 from popping up an annoying dialog. */
3301 lpcfg_do_global_parameter(lp_ctx, "registry:HKEY_USERS", "hku.ldb");
3303 /* using UTF8 by default allows us to support all chars */
3304 lpcfg_do_global_parameter(lp_ctx, "unix charset", "UTF8");
3306 /* Use codepage 850 as a default for the dos character set */
3307 lpcfg_do_global_parameter(lp_ctx, "dos charset", "CP850");
3310 * Allow the default PASSWD_CHAT to be overridden in local.h.
3312 lpcfg_do_global_parameter(lp_ctx, "passwd chat", DEFAULT_PASSWD_CHAT);
3314 lpcfg_do_global_parameter(lp_ctx, "pid directory", dyn_PIDDIR);
3315 lpcfg_do_global_parameter(lp_ctx, "lock dir", dyn_LOCKDIR);
3316 lpcfg_do_global_parameter(lp_ctx, "state directory", dyn_STATEDIR);
3317 lpcfg_do_global_parameter(lp_ctx, "cache directory", dyn_CACHEDIR);
3318 lpcfg_do_global_parameter(lp_ctx, "ncalrpc dir", dyn_NCALRPCDIR);
3320 lpcfg_do_global_parameter(lp_ctx, "socket address", "");
3321 lpcfg_do_global_parameter_var(lp_ctx, "server string",
3322 "Samba %s", SAMBA_VERSION_STRING);
3324 lpcfg_do_global_parameter(lp_ctx, "password server", "*");
3326 lpcfg_do_global_parameter(lp_ctx, "max mux", "50");
3327 lpcfg_do_global_parameter(lp_ctx, "max xmit", "12288");
3328 lpcfg_do_global_parameter(lp_ctx, "host msdfs", "true");
3330 lpcfg_do_global_parameter(lp_ctx, "password level", "0");
3331 lpcfg_do_global_parameter(lp_ctx, "LargeReadwrite", "True");
3332 lpcfg_do_global_parameter(lp_ctx, "server min protocol", "CORE");
3333 lpcfg_do_global_parameter(lp_ctx, "server max protocol", "NT1");
3334 lpcfg_do_global_parameter(lp_ctx, "client min protocol", "CORE");
3335 lpcfg_do_global_parameter(lp_ctx, "client max protocol", "NT1");
3336 lpcfg_do_global_parameter(lp_ctx, "security", "AUTO");
3337 lpcfg_do_global_parameter(lp_ctx, "paranoid server security", "True");
3338 lpcfg_do_global_parameter(lp_ctx, "EncryptPasswords", "True");
3339 lpcfg_do_global_parameter(lp_ctx, "ReadRaw", "True");
3340 lpcfg_do_global_parameter(lp_ctx, "WriteRaw", "True");
3341 lpcfg_do_global_parameter(lp_ctx, "NullPasswords", "False");
3342 lpcfg_do_global_parameter(lp_ctx, "ObeyPamRestrictions", "False");
3344 lpcfg_do_global_parameter(lp_ctx, "TimeServer", "False");
3345 lpcfg_do_global_parameter(lp_ctx, "BindInterfacesOnly", "False");
3346 lpcfg_do_global_parameter(lp_ctx, "Unicode", "True");
3347 lpcfg_do_global_parameter(lp_ctx, "ClientLanManAuth", "False");
3348 lpcfg_do_global_parameter(lp_ctx, "ClientNTLMv2Auth", "True");
3349 lpcfg_do_global_parameter(lp_ctx, "LanmanAuth", "False");
3350 lpcfg_do_global_parameter(lp_ctx, "NTLMAuth", "True");
3351 lpcfg_do_global_parameter(lp_ctx, "client use spnego principal", "False");
3353 lpcfg_do_global_parameter(lp_ctx, "UnixExtensions", "False");
3355 lpcfg_do_global_parameter(lp_ctx, "PreferredMaster", "Auto");
3356 lpcfg_do_global_parameter(lp_ctx, "LocalMaster", "True");
3358 lpcfg_do_global_parameter(lp_ctx, "wins support", "False");
3359 lpcfg_do_global_parameter(lp_ctx, "dns proxy", "True");
3361 lpcfg_do_global_parameter(lp_ctx, "winbind separator", "\\");
3362 lpcfg_do_global_parameter(lp_ctx, "winbind sealed pipes", "True");
3363 lpcfg_do_global_parameter(lp_ctx, "winbindd socket directory", dyn_WINBINDD_SOCKET_DIR);
3364 #if _SAMBA_BUILD_ >= 4
3365 lpcfg_do_global_parameter(lp_ctx, "winbindd privileged socket directory", dyn_WINBINDD_PRIVILEGED_SOCKET_DIR);
3366 lpcfg_do_global_parameter(lp_ctx, "ntp signd socket directory", dyn_NTP_SIGND_SOCKET_DIR);
3367 lpcfg_do_global_parameter_var(lp_ctx, "dns update command", "%s/samba_dnsupdate", dyn_SCRIPTSBINDIR);
3368 lpcfg_do_global_parameter_var(lp_ctx, "spn update command", "%s/samba_spnupdate", dyn_SCRIPTSBINDIR);
3369 lpcfg_do_global_parameter_var(lp_ctx, "samba kcc command",
3370 "%s/samba_kcc", dyn_SCRIPTSBINDIR);
3371 #endif
3372 lpcfg_do_global_parameter(lp_ctx, "template shell", "/bin/false");
3373 lpcfg_do_global_parameter(lp_ctx, "template homedir", "/home/%WORKGROUP%/%ACCOUNTNAME%");
3374 lpcfg_do_global_parameter(lp_ctx, "idmap trusted only", "False");
3376 lpcfg_do_global_parameter(lp_ctx, "client signing", "default");
3377 lpcfg_do_global_parameter(lp_ctx, "server signing", "default");
3379 lpcfg_do_global_parameter(lp_ctx, "use spnego", "True");
3381 lpcfg_do_global_parameter(lp_ctx, "use mmap", "True");
3383 lpcfg_do_global_parameter(lp_ctx, "smb ports", "445 139");
3384 lpcfg_do_global_parameter(lp_ctx, "nbt port", "137");
3385 lpcfg_do_global_parameter(lp_ctx, "dgram port", "138");
3386 lpcfg_do_global_parameter(lp_ctx, "cldap port", "389");
3387 lpcfg_do_global_parameter(lp_ctx, "krb5 port", "88");
3388 lpcfg_do_global_parameter(lp_ctx, "kpasswd port", "464");
3389 lpcfg_do_global_parameter(lp_ctx, "web port", "901");
3391 lpcfg_do_global_parameter(lp_ctx, "nt status support", "True");
3393 lpcfg_do_global_parameter(lp_ctx, "max wins ttl", "518400"); /* 6 days */
3394 lpcfg_do_global_parameter(lp_ctx, "min wins ttl", "10");
3396 lpcfg_do_global_parameter(lp_ctx, "tls enabled", "True");
3397 lpcfg_do_global_parameter(lp_ctx, "tls keyfile", "tls/key.pem");
3398 lpcfg_do_global_parameter(lp_ctx, "tls certfile", "tls/cert.pem");
3399 lpcfg_do_global_parameter(lp_ctx, "tls cafile", "tls/ca.pem");
3400 lpcfg_do_global_parameter(lp_ctx, "prefork children:smb", "4");
3402 lpcfg_do_global_parameter(lp_ctx, "rndc command", "/usr/sbin/rndc");
3403 lpcfg_do_global_parameter(lp_ctx, "nsupdate command", "/usr/bin/nsupdate -g");
3405 lpcfg_do_global_parameter(lp_ctx, "allow dns updates", "False");
3407 for (i = 0; parm_table[i].label; i++) {
3408 if (!(lp_ctx->flags[i] & FLAG_CMDLINE)) {
3409 lp_ctx->flags[i] |= FLAG_DEFAULT;
3413 for (parm=lp_ctx->globals->param_opt; parm; parm=parm->next) {
3414 if (!(parm->priority & FLAG_CMDLINE)) {
3415 parm->priority |= FLAG_DEFAULT;
3419 return lp_ctx;
3423 * Initialise the global parameter structure.
3425 struct loadparm_context *loadparm_init_global(bool load_default)
3427 if (global_loadparm_context == NULL) {
3428 global_loadparm_context = loadparm_init(NULL);
3430 if (global_loadparm_context == NULL) {
3431 return NULL;
3433 global_loadparm_context->global = true;
3434 if (load_default && !global_loadparm_context->loaded) {
3435 lpcfg_load_default(global_loadparm_context);
3437 global_loadparm_context->refuse_free = true;
3438 return global_loadparm_context;
3442 * Initialise the global parameter structure.
3444 struct loadparm_context *loadparm_init_s3(TALLOC_CTX *mem_ctx,
3445 const struct loadparm_s3_context *s3_fns)
3447 struct loadparm_context *loadparm_context = talloc_zero(mem_ctx, struct loadparm_context);
3448 if (!loadparm_context) {
3449 return NULL;
3451 loadparm_context->s3_fns = s3_fns;
3452 return loadparm_context;
3455 const char *lpcfg_configfile(struct loadparm_context *lp_ctx)
3457 return lp_ctx->szConfigFile;
3460 const char *lp_default_path(void)
3462 if (getenv("SMB_CONF_PATH"))
3463 return getenv("SMB_CONF_PATH");
3464 else
3465 return dyn_CONFIGFILE;
3469 * Update the internal state of a loadparm context after settings
3470 * have changed.
3472 static bool lpcfg_update(struct loadparm_context *lp_ctx)
3474 struct debug_settings settings;
3475 lpcfg_add_auto_services(lp_ctx, lpcfg_auto_services(lp_ctx));
3477 if (!lp_ctx->globals->szWINSservers && lp_ctx->globals->bWINSsupport) {
3478 lpcfg_do_global_parameter(lp_ctx, "wins server", "127.0.0.1");
3481 if (!lp_ctx->global) {
3482 return true;
3485 panic_action = lp_ctx->globals->panic_action;
3487 reload_charcnv(lp_ctx);
3489 ZERO_STRUCT(settings);
3490 /* Add any more debug-related smb.conf parameters created in
3491 * future here */
3492 settings.timestamp_logs = true;
3493 debug_set_settings(&settings);
3495 /* FIXME: This is a bit of a hack, but we can't use a global, since
3496 * not everything that uses lp also uses the socket library */
3497 if (lpcfg_parm_bool(lp_ctx, NULL, "socket", "testnonblock", false)) {
3498 setenv("SOCKET_TESTNONBLOCK", "1", 1);
3499 } else {
3500 unsetenv("SOCKET_TESTNONBLOCK");
3503 return true;
3506 bool lpcfg_load_default(struct loadparm_context *lp_ctx)
3508 const char *path;
3510 path = lp_default_path();
3512 if (!file_exist(path)) {
3513 /* We allow the default smb.conf file to not exist,
3514 * basically the equivalent of an empty file. */
3515 return lpcfg_update(lp_ctx);
3518 return lpcfg_load(lp_ctx, path);
3522 * Load the services array from the services file.
3524 * Return True on success, False on failure.
3526 bool lpcfg_load(struct loadparm_context *lp_ctx, const char *filename)
3528 char *n2;
3529 bool bRetval;
3531 filename = talloc_strdup(lp_ctx, filename);
3533 lp_ctx->szConfigFile = filename;
3535 if (lp_ctx->s3_fns) {
3536 return lp_ctx->s3_fns->load(filename);
3539 lp_ctx->bInGlobalSection = true;
3540 n2 = standard_sub_basic(lp_ctx, lp_ctx->szConfigFile);
3541 DEBUG(2, ("lpcfg_load: refreshing parameters from %s\n", n2));
3543 add_to_file_list(lp_ctx, lp_ctx->szConfigFile, n2);
3545 /* We get sections first, so have to start 'behind' to make up */
3546 lp_ctx->currentService = NULL;
3547 bRetval = pm_process(n2, do_section, do_parameter, lp_ctx);
3549 /* finish up the last section */
3550 DEBUG(4, ("pm_process() returned %s\n", BOOLSTR(bRetval)));
3551 if (bRetval)
3552 if (lp_ctx->currentService != NULL)
3553 bRetval = lpcfg_service_ok(lp_ctx->currentService);
3555 bRetval = bRetval && lpcfg_update(lp_ctx);
3557 /* we do this unconditionally, so that it happens even
3558 for a missing smb.conf */
3559 reload_charcnv(lp_ctx);
3561 if (bRetval == true) {
3562 /* set this up so that any child python tasks will
3563 find the right smb.conf */
3564 setenv("SMB_CONF_PATH", filename, 1);
3566 /* set the context used by the lp_*() function
3567 varients */
3568 global_loadparm_context = lp_ctx;
3569 lp_ctx->loaded = true;
3572 return bRetval;
3576 * Return the max number of services.
3579 int lpcfg_numservices(struct loadparm_context *lp_ctx)
3581 if (lp_ctx->s3_fns) {
3582 return lp_ctx->s3_fns->get_numservices();
3585 return lp_ctx->iNumServices;
3589 * Display the contents of the services array in human-readable form.
3592 void lpcfg_dump(struct loadparm_context *lp_ctx, FILE *f, bool show_defaults,
3593 int maxtoprint)
3595 int iService;
3597 if (lp_ctx->s3_fns) {
3598 lp_ctx->s3_fns->dump(f, show_defaults, maxtoprint);
3599 return;
3602 defaults_saved = !show_defaults;
3604 dump_globals(lp_ctx, f, show_defaults);
3606 dump_a_service(lp_ctx->sDefault, lp_ctx->sDefault, f, lp_ctx->flags);
3608 for (iService = 0; iService < maxtoprint; iService++)
3609 lpcfg_dump_one(f, show_defaults, lp_ctx->services[iService], lp_ctx->sDefault);
3613 * Display the contents of one service in human-readable form.
3615 void lpcfg_dump_one(FILE *f, bool show_defaults, struct loadparm_service *service, struct loadparm_service *sDefault)
3617 if (service != NULL) {
3618 if (service->szService[0] == '\0')
3619 return;
3620 dump_a_service(service, sDefault, f, NULL);
3624 struct loadparm_service *lpcfg_servicebynum(struct loadparm_context *lp_ctx,
3625 int snum)
3627 if (lp_ctx->s3_fns) {
3628 return lp_ctx->s3_fns->get_servicebynum(snum);
3631 return lp_ctx->services[snum];
3634 struct loadparm_service *lpcfg_service(struct loadparm_context *lp_ctx,
3635 const char *service_name)
3637 int iService;
3638 char *serviceName;
3640 if (lp_ctx->s3_fns) {
3641 return lp_ctx->s3_fns->get_service(service_name);
3644 for (iService = lp_ctx->iNumServices - 1; iService >= 0; iService--) {
3645 if (lp_ctx->services[iService] &&
3646 lp_ctx->services[iService]->szService) {
3648 * The substitution here is used to support %U is
3649 * service names
3651 serviceName = standard_sub_basic(
3652 lp_ctx->services[iService],
3653 lp_ctx->services[iService]->szService);
3654 if (strequal(serviceName, service_name)) {
3655 talloc_free(serviceName);
3656 return lp_ctx->services[iService];
3658 talloc_free(serviceName);
3662 DEBUG(7,("lpcfg_servicenumber: couldn't find %s\n", service_name));
3663 return NULL;
3666 const char *lpcfg_servicename(const struct loadparm_service *service)
3668 return lp_string((const char *)service->szService);
3672 * A useful volume label function.
3674 const char *lpcfg_volume_label(struct loadparm_service *service, struct loadparm_service *sDefault)
3676 const char *ret;
3677 ret = lp_string((const char *)((service != NULL && service->volume != NULL) ?
3678 service->volume : sDefault->volume));
3679 if (!*ret)
3680 return lpcfg_servicename(service);
3681 return ret;
3685 * If we are PDC then prefer us as DMB
3687 const char *lpcfg_printername(struct loadparm_service *service, struct loadparm_service *sDefault)
3689 const char *ret;
3690 ret = lp_string((const char *)((service != NULL && service->szPrintername != NULL) ?
3691 service->szPrintername : sDefault->szPrintername));
3692 if (ret == NULL || (ret != NULL && *ret == '\0'))
3693 ret = lpcfg_servicename(service);
3695 return ret;
3700 * Return the max print jobs per queue.
3702 int lpcfg_maxprintjobs(struct loadparm_service *service, struct loadparm_service *sDefault)
3704 int maxjobs = (service != NULL) ? service->iMaxPrintJobs : sDefault->iMaxPrintJobs;
3705 if (maxjobs <= 0 || maxjobs >= PRINT_MAX_JOBID)
3706 maxjobs = PRINT_MAX_JOBID - 1;
3708 return maxjobs;
3711 struct smb_iconv_handle *lpcfg_iconv_handle(struct loadparm_context *lp_ctx)
3713 if (lp_ctx == NULL) {
3714 return get_iconv_handle();
3716 return lp_ctx->iconv_handle;
3719 _PUBLIC_ void reload_charcnv(struct loadparm_context *lp_ctx)
3721 struct smb_iconv_handle *old_ic = lp_ctx->iconv_handle;
3722 if (!lp_ctx->global) {
3723 return;
3726 if (old_ic == NULL) {
3727 old_ic = global_iconv_handle;
3729 lp_ctx->iconv_handle = smb_iconv_handle_reinit_lp(lp_ctx, lp_ctx, old_ic);
3730 global_iconv_handle = lp_ctx->iconv_handle;
3733 _PUBLIC_ char *lpcfg_tls_keyfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
3735 return lpcfg_private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_keyfile);
3738 _PUBLIC_ char *lpcfg_tls_certfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
3740 return lpcfg_private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_certfile);
3743 _PUBLIC_ char *lpcfg_tls_cafile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
3745 return lpcfg_private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_cafile);
3748 _PUBLIC_ char *lpcfg_tls_crlfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
3750 return lpcfg_private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_crlfile);
3753 _PUBLIC_ char *lpcfg_tls_dhpfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
3755 return lpcfg_private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_dhpfile);
3758 struct gensec_settings *lpcfg_gensec_settings(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
3760 struct gensec_settings *settings = talloc_zero(mem_ctx, struct gensec_settings);
3761 if (settings == NULL)
3762 return NULL;
3763 SMB_ASSERT(lp_ctx != NULL);
3764 settings->lp_ctx = talloc_reference(settings, lp_ctx);
3765 settings->target_hostname = lpcfg_parm_string(lp_ctx, NULL, "gensec", "target_hostname");
3766 return settings;
3769 int lpcfg_server_role(struct loadparm_context *lp_ctx)
3771 if (lp_ctx->s3_fns) {
3772 return lp_ctx->s3_fns->server_role();
3775 return lp_find_server_role(lp_ctx->globals->server_role,
3776 lp_ctx->globals->security,
3777 lp_ctx->globals->domain_logons,
3778 (lp_ctx->globals->domain_master == true) ||
3779 (lp_ctx->globals->domain_master == Auto));
3782 int lpcfg_security(struct loadparm_context *lp_ctx)
3784 if (lp_ctx->s3_fns) {
3785 return lp_ctx->s3_fns->security();
3788 return lp_find_security(lp_ctx->globals->server_role,
3789 lp_ctx->globals->security);