lib/param: Merge "Ldap Options" section from source3/param
[Samba/reqa.git] / lib / param / loadparm.c
bloba17036d09b67561689a2a772f34a912bd0b7d8ef
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
14 Copyright (C) Andrew Bartlett 2011-2012
16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 3 of the License, or
19 (at your option) any later version.
21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 GNU General Public License for more details.
26 You should have received a copy of the GNU General Public License
27 along with this program. If not, see <http://www.gnu.org/licenses/>.
31 * Load parameters.
33 * This module provides suitable callback functions for the params
34 * module. It builds the internal table of service details which is
35 * then used by the rest of the server.
37 * To add a parameter:
39 * 1) add it to the global or service structure definition
40 * 2) add it to the parm_table
41 * 3) add it to the list of available functions (eg: using FN_GLOBAL_STRING())
42 * 4) If it's a global then initialise it in init_globals. If a local
43 * (ie. service) parameter then initialise it in the sDefault structure
46 * Notes:
47 * The configuration file is processed sequentially for speed. It is NOT
48 * accessed randomly as happens in 'real' Windows. For this reason, there
49 * is a fair bit of sequence-dependent code here - ie., code which assumes
50 * that certain things happen before others. In particular, the code which
51 * happens at the boundary between sections is delicately poised, so be
52 * careful!
56 #include "includes.h"
57 #include "version.h"
58 #include "dynconfig/dynconfig.h"
59 #include "system/time.h"
60 #include "system/locale.h"
61 #include "system/network.h" /* needed for TCP_NODELAY */
62 #include "../lib/util/dlinklist.h"
63 #include "lib/param/param.h"
64 #include "lib/param/loadparm.h"
65 #include "auth/gensec/gensec.h"
66 #include "lib/param/s3_param.h"
67 #include "lib/util/bitmap.h"
68 #include "libcli/smb/smb_constants.h"
69 #include "source4/dns_server/dns_update.h"
71 #define standard_sub_basic talloc_strdup
73 static bool do_parameter(const char *, const char *, void *);
74 static bool defaults_saved = false;
76 #define LOADPARM_EXTRA_GLOBALS \
77 struct parmlist_entry *param_opt; \
78 char *szRealm; \
79 char *szConfigFile; \
80 char *szLdapMachineSuffix; \
81 char *szLdapUserSuffix; \
82 char *szLdapIdmapSuffix; \
83 char *szLdapGroupSuffix; \
84 char *szUsershareTemplateShare; \
85 char *szIdmapUID; \
86 char *szIdmapGID; \
87 int winbindMaxDomainConnections; \
88 char *tls_keyfile; \
89 char *tls_certfile; \
90 char *tls_cafile; \
91 char *tls_crlfile; \
92 char *tls_dhpfile; \
93 char *loglevel; \
94 char *panic_action; \
95 int bPreferredMaster;
97 #include "lib/param/param_global.h"
99 #define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
101 /* we don't need a special handler for "dos charset" and "unix charset" */
102 #define handle_dos_charset NULL
103 #define handle_charset NULL
105 /* these are parameter handlers which are not needed in the
106 * non-source3 code
108 #define handle_netbios_aliases NULL
109 #define handle_debug_list NULL
110 #define handle_printing NULL
111 #define handle_ldap_debug_level NULL
112 #define handle_idmap_backend NULL
113 #define handle_idmap_uid NULL
114 #define handle_idmap_gid NULL
116 #ifndef N_
117 #define N_(x) x
118 #endif
120 /* prototypes for the special type handlers */
121 static bool handle_include(struct loadparm_context *lp_ctx, int unused,
122 const char *pszParmValue, char **ptr);
123 static bool handle_realm(struct loadparm_context *lp_ctx, int unused,
124 const char *pszParmValue, char **ptr);
125 static bool handle_copy(struct loadparm_context *lp_ctx, int unused,
126 const char *pszParmValue, char **ptr);
127 static bool handle_debuglevel(struct loadparm_context *lp_ctx, int unused,
128 const char *pszParmValue, char **ptr);
129 static bool handle_logfile(struct loadparm_context *lp_ctx, int unused,
130 const char *pszParmValue, char **ptr);
132 #include "lib/param/param_table.c"
134 #define GLOBAL_VAR(name) offsetof(struct loadparm_global, name)
135 #define LOCAL_VAR(name) offsetof(struct loadparm_service, name)
137 static struct parm_struct parm_table[] = {
139 .label = "server role",
140 .type = P_ENUM,
141 .p_class = P_GLOBAL,
142 .offset = GLOBAL_VAR(server_role),
143 .special = NULL,
144 .enum_list = enum_server_role
147 .label = "domain logons",
148 .type = P_ENUM,
149 .p_class = P_GLOBAL,
150 .offset = GLOBAL_VAR(bDomainLogons),
151 .special = NULL,
152 .enum_list = enum_bool_auto
155 .label = "domain master",
156 .type = P_ENUM,
157 .p_class = P_GLOBAL,
158 .offset = GLOBAL_VAR(domain_master),
159 .special = NULL,
160 .enum_list = enum_bool_auto
163 .label = "dos charset",
164 .type = P_STRING,
165 .p_class = P_GLOBAL,
166 .offset = GLOBAL_VAR(dos_charset),
167 .special = NULL,
168 .enum_list = NULL
171 .label = "unix charset",
172 .type = P_STRING,
173 .p_class = P_GLOBAL,
174 .offset = GLOBAL_VAR(unix_charset),
175 .special = NULL,
176 .enum_list = NULL
179 .label = "comment",
180 .type = P_STRING,
181 .p_class = P_LOCAL,
182 .offset = LOCAL_VAR(comment),
183 .special = NULL,
184 .enum_list = NULL,
185 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT
188 .label = "path",
189 .type = P_STRING,
190 .p_class = P_LOCAL,
191 .offset = LOCAL_VAR(szPath),
192 .special = NULL,
193 .enum_list = NULL,
194 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
197 .label = "directory",
198 .type = P_STRING,
199 .p_class = P_LOCAL,
200 .offset = LOCAL_VAR(szPath),
201 .special = NULL,
202 .enum_list = NULL,
203 .flags = FLAG_HIDE,
206 .label = "workgroup",
207 .type = P_USTRING,
208 .p_class = P_GLOBAL,
209 .offset = GLOBAL_VAR(szWorkgroup),
210 .special = NULL,
211 .enum_list = NULL,
212 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
215 .label = "realm",
216 .type = P_STRING,
217 .p_class = P_GLOBAL,
218 .offset = GLOBAL_VAR(szRealm),
219 .special = handle_realm,
220 .enum_list = NULL,
221 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
224 .label = "netbios name",
225 .type = P_USTRING,
226 .p_class = P_GLOBAL,
227 .offset = GLOBAL_VAR(szNetbiosName),
228 .special = NULL,
229 .enum_list = NULL,
230 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
233 .label = "netbios aliases",
234 .type = P_LIST,
235 .p_class = P_GLOBAL,
236 .offset = GLOBAL_VAR(szNetbiosAliases),
237 .special = NULL,
238 .enum_list = NULL
241 .label = "netbios scope",
242 .type = P_USTRING,
243 .p_class = P_GLOBAL,
244 .offset = GLOBAL_VAR(szNetbiosScope),
245 .special = NULL,
246 .enum_list = NULL,
247 .flags = FLAG_ADVANCED,
250 .label = "server string",
251 .type = P_STRING,
252 .p_class = P_GLOBAL,
253 .offset = GLOBAL_VAR(szServerString),
254 .special = NULL,
255 .enum_list = NULL,
256 .flags = FLAG_BASIC | FLAG_ADVANCED,
259 .label = "interfaces",
260 .type = P_LIST,
261 .p_class = P_GLOBAL,
262 .offset = GLOBAL_VAR(szInterfaces),
263 .special = NULL,
264 .enum_list = NULL,
265 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
268 .label = "bind interfaces only",
269 .type = P_BOOL,
270 .p_class = P_GLOBAL,
271 .offset = GLOBAL_VAR(bBindInterfacesOnly),
272 .special = NULL,
273 .enum_list = NULL,
274 .flags = FLAG_ADVANCED | FLAG_WIZARD,
277 .label = "passdb backend",
278 .type = P_STRING,
279 .p_class = P_GLOBAL,
280 .offset = GLOBAL_VAR(passdb_backend),
281 .special = NULL,
282 .enum_list = NULL
286 .label = "security",
287 .type = P_ENUM,
288 .p_class = P_GLOBAL,
289 .offset = GLOBAL_VAR(security),
290 .special = NULL,
291 .enum_list = enum_security
294 .label = "encrypt passwords",
295 .type = P_BOOL,
296 .p_class = P_GLOBAL,
297 .offset = GLOBAL_VAR(bEncryptPasswords),
298 .special = NULL,
299 .enum_list = NULL
302 .label = "null passwords",
303 .type = P_BOOL,
304 .p_class = P_GLOBAL,
305 .offset = GLOBAL_VAR(bNullPasswords),
306 .special = NULL,
307 .enum_list = NULL,
308 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
311 .label = "obey pam restrictions",
312 .type = P_BOOL,
313 .p_class = P_GLOBAL,
314 .offset = GLOBAL_VAR(bObeyPamRestrictions),
315 .special = NULL,
316 .enum_list = NULL,
317 .flags = FLAG_ADVANCED,
320 .label = "password server",
321 .type = P_STRING,
322 .p_class = P_GLOBAL,
323 .offset = GLOBAL_VAR(szPasswordServer),
324 .special = NULL,
325 .enum_list = NULL
328 .label = "private dir",
329 .type = P_STRING,
330 .p_class = P_GLOBAL,
331 .offset = GLOBAL_VAR(szPrivateDir),
332 .special = NULL,
333 .enum_list = NULL
336 .label = "passwd chat",
337 .type = P_STRING,
338 .p_class = P_GLOBAL,
339 .offset = GLOBAL_VAR(szPasswdChat),
340 .special = NULL,
341 .enum_list = NULL
344 .label = "password level",
345 .type = P_INTEGER,
346 .p_class = P_GLOBAL,
347 .offset = GLOBAL_VAR(pwordlevel),
348 .special = NULL,
349 .enum_list = NULL
352 .label = "lanman auth",
353 .type = P_BOOL,
354 .p_class = P_GLOBAL,
355 .offset = GLOBAL_VAR(bLanmanAuth),
356 .special = NULL,
357 .enum_list = NULL,
358 .flags = FLAG_ADVANCED,
361 .label = "ntlm auth",
362 .type = P_BOOL,
363 .p_class = P_GLOBAL,
364 .offset = GLOBAL_VAR(bNTLMAuth),
365 .special = NULL,
366 .enum_list = NULL,
367 .flags = FLAG_ADVANCED,
370 .label = "client NTLMv2 auth",
371 .type = P_BOOL,
372 .p_class = P_GLOBAL,
373 .offset = GLOBAL_VAR(bClientNTLMv2Auth),
374 .special = NULL,
375 .enum_list = NULL,
376 .flags = FLAG_ADVANCED,
379 .label = "client lanman auth",
380 .type = P_BOOL,
381 .p_class = P_GLOBAL,
382 .offset = GLOBAL_VAR(bClientLanManAuth),
383 .special = NULL,
384 .enum_list = NULL,
385 .flags = FLAG_ADVANCED,
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,
394 .flags = FLAG_ADVANCED,
397 .label = "client use spnego principal",
398 .type = P_BOOL,
399 .p_class = P_GLOBAL,
400 .offset = GLOBAL_VAR(client_use_spnego_principal),
401 .special = NULL,
402 .enum_list = NULL
406 .label = "read only",
407 .type = P_BOOL,
408 .p_class = P_LOCAL,
409 .offset = LOCAL_VAR(bRead_only),
410 .special = NULL,
411 .enum_list = NULL
415 .label = "create mask",
416 .type = P_OCTAL,
417 .p_class = P_LOCAL,
418 .offset = LOCAL_VAR(iCreate_mask),
419 .special = NULL,
420 .enum_list = NULL
423 .label = "force create mode",
424 .type = P_OCTAL,
425 .p_class = P_LOCAL,
426 .offset = LOCAL_VAR(iCreate_force_mode),
427 .special = NULL,
428 .enum_list = NULL
431 .label = "directory mask",
432 .type = P_OCTAL,
433 .p_class = P_LOCAL,
434 .offset = LOCAL_VAR(iDir_mask),
435 .special = NULL,
436 .enum_list = NULL
439 .label = "force directory mode",
440 .type = P_OCTAL,
441 .p_class = P_LOCAL,
442 .offset = LOCAL_VAR(iDir_force_mode),
443 .special = NULL,
444 .enum_list = NULL
448 .label = "hosts allow",
449 .type = P_LIST,
450 .p_class = P_LOCAL,
451 .offset = LOCAL_VAR(szHostsallow),
452 .special = NULL,
453 .enum_list = NULL
456 .label = "hosts deny",
457 .type = P_LIST,
458 .p_class = P_LOCAL,
459 .offset = LOCAL_VAR(szHostsdeny),
460 .special = NULL,
461 .enum_list = NULL
465 .label = "log level",
466 .type = P_STRING,
467 .p_class = P_GLOBAL,
468 .offset = GLOBAL_VAR(loglevel),
469 .special = handle_debuglevel,
470 .enum_list = NULL
473 .label = "debuglevel",
474 .type = P_STRING,
475 .p_class = P_GLOBAL,
476 .offset = GLOBAL_VAR(loglevel),
477 .special = handle_debuglevel,
478 .enum_list = NULL
481 .label = "log file",
482 .type = P_STRING,
483 .p_class = P_GLOBAL,
484 .offset = GLOBAL_VAR(logfile),
485 .special = handle_logfile,
486 .enum_list = NULL,
487 .flags = FLAG_ADVANCED,
491 .label = "smb ports",
492 .type = P_LIST,
493 .p_class = P_GLOBAL,
494 .offset = GLOBAL_VAR(smb_ports),
495 .special = NULL,
496 .enum_list = NULL
499 .label = "nbt port",
500 .type = P_INTEGER,
501 .p_class = P_GLOBAL,
502 .offset = GLOBAL_VAR(nbt_port),
503 .special = NULL,
504 .enum_list = NULL
507 .label = "dgram port",
508 .type = P_INTEGER,
509 .p_class = P_GLOBAL,
510 .offset = GLOBAL_VAR(dgram_port),
511 .special = NULL,
512 .enum_list = NULL
515 .label = "cldap port",
516 .type = P_INTEGER,
517 .p_class = P_GLOBAL,
518 .offset = GLOBAL_VAR(cldap_port),
519 .special = NULL,
520 .enum_list = NULL
523 .label = "krb5 port",
524 .type = P_INTEGER,
525 .p_class = P_GLOBAL,
526 .offset = GLOBAL_VAR(krb5_port),
527 .special = NULL,
528 .enum_list = NULL
531 .label = "kpasswd port",
532 .type = P_INTEGER,
533 .p_class = P_GLOBAL,
534 .offset = GLOBAL_VAR(kpasswd_port),
535 .special = NULL,
536 .enum_list = NULL
539 .label = "web port",
540 .type = P_INTEGER,
541 .p_class = P_GLOBAL,
542 .offset = GLOBAL_VAR(web_port),
543 .special = NULL,
544 .enum_list = NULL
547 .label = "large readwrite",
548 .type = P_BOOL,
549 .p_class = P_GLOBAL,
550 .offset = GLOBAL_VAR(bLargeReadwrite),
551 .special = NULL,
552 .enum_list = NULL,
553 .flags = FLAG_ADVANCED,
556 .label = "server max protocol",
557 .type = P_ENUM,
558 .p_class = P_GLOBAL,
559 .offset = GLOBAL_VAR(srv_maxprotocol),
560 .special = NULL,
561 .enum_list = enum_protocol,
562 .flags = FLAG_ADVANCED,
565 .label = "max protocol",
566 .type = P_ENUM,
567 .p_class = P_GLOBAL,
568 .offset = GLOBAL_VAR(srv_maxprotocol),
569 .special = NULL,
570 .enum_list = enum_protocol,
571 .flags = FLAG_ADVANCED,
574 .label = "protocol",
575 .type = P_ENUM,
576 .p_class = P_GLOBAL,
577 .offset = GLOBAL_VAR(srv_maxprotocol),
578 .special = NULL,
579 .enum_list = enum_protocol,
580 .flags = FLAG_ADVANCED,
583 .label = "server min protocol",
584 .type = P_ENUM,
585 .p_class = P_GLOBAL,
586 .offset = GLOBAL_VAR(srv_minprotocol),
587 .special = NULL,
588 .enum_list = enum_protocol,
589 .flags = FLAG_ADVANCED,
592 .label = "min protocol",
593 .type = P_ENUM,
594 .p_class = P_GLOBAL,
595 .offset = GLOBAL_VAR(srv_minprotocol),
596 .special = NULL,
597 .enum_list = enum_protocol,
598 .flags = FLAG_ADVANCED,
601 .label = "client max protocol",
602 .type = P_ENUM,
603 .p_class = P_GLOBAL,
604 .offset = GLOBAL_VAR(cli_maxprotocol),
605 .special = NULL,
606 .enum_list = enum_protocol
609 .label = "client min protocol",
610 .type = P_ENUM,
611 .p_class = P_GLOBAL,
612 .offset = GLOBAL_VAR(cli_minprotocol),
613 .special = NULL,
614 .enum_list = enum_protocol
617 .label = "unicode",
618 .type = P_BOOL,
619 .p_class = P_GLOBAL,
620 .offset = GLOBAL_VAR(bUnicode),
621 .special = NULL,
622 .enum_list = NULL
625 .label = "read raw",
626 .type = P_BOOL,
627 .p_class = P_GLOBAL,
628 .offset = GLOBAL_VAR(bReadRaw),
629 .special = NULL,
630 .enum_list = NULL
633 .label = "write raw",
634 .type = P_BOOL,
635 .p_class = P_GLOBAL,
636 .offset = GLOBAL_VAR(bWriteRaw),
637 .special = NULL,
638 .enum_list = NULL
641 .label = "disable netbios",
642 .type = P_BOOL,
643 .p_class = P_GLOBAL,
644 .offset = GLOBAL_VAR(bDisableNetbios),
645 .special = NULL,
646 .enum_list = NULL
650 .label = "nt status support",
651 .type = P_BOOL,
652 .p_class = P_GLOBAL,
653 .offset = GLOBAL_VAR(bNTStatusSupport),
654 .special = NULL,
655 .enum_list = NULL
659 .label = "max mux",
660 .type = P_INTEGER,
661 .p_class = P_GLOBAL,
662 .offset = GLOBAL_VAR(max_mux),
663 .special = NULL,
664 .enum_list = NULL,
665 .flags = FLAG_ADVANCED,
668 .label = "max xmit",
669 .type = P_BYTES,
670 .p_class = P_GLOBAL,
671 .offset = GLOBAL_VAR(max_xmit),
672 .special = NULL,
673 .enum_list = NULL,
674 .flags = FLAG_ADVANCED,
678 .label = "name resolve order",
679 .type = P_LIST,
680 .p_class = P_GLOBAL,
681 .offset = GLOBAL_VAR(szNameResolveOrder),
682 .special = NULL,
683 .enum_list = NULL
686 .label = "max wins ttl",
687 .type = P_INTEGER,
688 .p_class = P_GLOBAL,
689 .offset = GLOBAL_VAR(max_wins_ttl),
690 .special = NULL,
691 .enum_list = NULL,
692 .flags = FLAG_ADVANCED,
695 .label = "min wins ttl",
696 .type = P_INTEGER,
697 .p_class = P_GLOBAL,
698 .offset = GLOBAL_VAR(min_wins_ttl),
699 .special = NULL,
700 .enum_list = NULL,
701 .flags = FLAG_ADVANCED,
704 .label = "time server",
705 .type = P_BOOL,
706 .p_class = P_GLOBAL,
707 .offset = GLOBAL_VAR(bTimeServer),
708 .special = NULL,
709 .enum_list = NULL,
710 .flags = FLAG_ADVANCED,
713 .label = "unix extensions",
714 .type = P_BOOL,
715 .p_class = P_GLOBAL,
716 .offset = GLOBAL_VAR(bUnixExtensions),
717 .special = NULL,
718 .enum_list = NULL,
719 .flags = FLAG_ADVANCED,
722 .label = "use spnego",
723 .type = P_BOOL,
724 .p_class = P_GLOBAL,
725 .offset = GLOBAL_VAR(bUseSpnego),
726 .special = NULL,
727 .enum_list = NULL
730 .label = "server signing",
731 .type = P_ENUM,
732 .p_class = P_GLOBAL,
733 .offset = GLOBAL_VAR(server_signing),
734 .special = NULL,
735 .enum_list = enum_smb_signing_vals,
736 .flags = FLAG_ADVANCED,
739 .label = "client signing",
740 .type = P_ENUM,
741 .p_class = P_GLOBAL,
742 .offset = GLOBAL_VAR(client_signing),
743 .special = NULL,
744 .enum_list = enum_smb_signing_vals
747 .label = "rpc big endian",
748 .type = P_BOOL,
749 .p_class = P_GLOBAL,
750 .offset = GLOBAL_VAR(bRpcBigEndian),
751 .special = NULL,
752 .enum_list = NULL
756 .label = "max connections",
757 .type = P_INTEGER,
758 .p_class = P_LOCAL,
759 .offset = LOCAL_VAR(iMaxConnections),
760 .special = NULL,
761 .enum_list = NULL,
762 .flags = FLAG_ADVANCED | FLAG_SHARE,
765 .label = "paranoid server security",
766 .type = P_BOOL,
767 .p_class = P_GLOBAL,
768 .offset = GLOBAL_VAR(paranoid_server_security),
769 .special = NULL,
770 .enum_list = NULL
773 .label = "socket options",
774 .type = P_STRING,
775 .p_class = P_GLOBAL,
776 .offset = GLOBAL_VAR(socket_options),
777 .special = NULL,
778 .enum_list = NULL
782 .label = "strict sync",
783 .type = P_BOOL,
784 .p_class = P_LOCAL,
785 .offset = LOCAL_VAR(bStrictSync),
786 .special = NULL,
787 .enum_list = NULL
790 .label = "use mmap",
791 .type = P_BOOL,
792 .p_class = P_GLOBAL,
793 .offset = GLOBAL_VAR(bUseMmap),
794 .special = NULL,
795 .enum_list = NULL,
796 .flags = FLAG_ADVANCED,
800 .label = "max print jobs",
801 .type = P_INTEGER,
802 .p_class = P_LOCAL,
803 .offset = LOCAL_VAR(iMaxPrintJobs),
804 .special = NULL,
805 .enum_list = NULL
808 .label = "printable",
809 .type = P_BOOL,
810 .p_class = P_LOCAL,
811 .offset = LOCAL_VAR(bPrint_ok),
812 .special = NULL,
813 .enum_list = NULL
816 .label = "print ok",
817 .type = P_BOOL,
818 .p_class = P_LOCAL,
819 .offset = LOCAL_VAR(bPrint_ok),
820 .special = NULL,
821 .enum_list = NULL
825 .label = "printer name",
826 .type = P_STRING,
827 .p_class = P_LOCAL,
828 .offset = LOCAL_VAR(szPrintername),
829 .special = NULL,
830 .enum_list = NULL,
831 .flags = FLAG_ADVANCED | FLAG_PRINT,
834 .label = "printer",
835 .type = P_STRING,
836 .p_class = P_LOCAL,
837 .offset = LOCAL_VAR(szPrintername),
838 .special = NULL,
839 .enum_list = NULL,
840 .flags = FLAG_HIDE,
844 .label = "map system",
845 .type = P_BOOL,
846 .p_class = P_LOCAL,
847 .offset = LOCAL_VAR(bMap_system),
848 .special = NULL,
849 .enum_list = NULL
852 .label = "map hidden",
853 .type = P_BOOL,
854 .p_class = P_LOCAL,
855 .offset = LOCAL_VAR(bMap_hidden),
856 .special = NULL,
857 .enum_list = NULL
860 .label = "map archive",
861 .type = P_BOOL,
862 .p_class = P_LOCAL,
863 .offset = LOCAL_VAR(bMap_archive),
864 .special = NULL,
865 .enum_list = NULL
869 .label = "preferred master",
870 .type = P_ENUM,
871 .p_class = P_GLOBAL,
872 .offset = GLOBAL_VAR(bPreferredMaster),
873 .special = NULL,
874 .enum_list = enum_bool_auto,
875 .flags = FLAG_BASIC | FLAG_ADVANCED,
878 .label = "prefered master",
879 .type = P_ENUM,
880 .p_class = P_GLOBAL,
881 .offset = GLOBAL_VAR(bPreferredMaster),
882 .special = NULL,
883 .enum_list = enum_bool_auto,
884 .flags = FLAG_HIDE,
887 .label = "local master",
888 .type = P_BOOL,
889 .p_class = P_GLOBAL,
890 .offset = GLOBAL_VAR(bLocalMaster),
891 .special = NULL,
892 .enum_list = NULL
895 .label = "browseable",
896 .type = P_BOOL,
897 .p_class = P_LOCAL,
898 .offset = LOCAL_VAR(bBrowseable),
899 .special = NULL,
900 .enum_list = NULL,
901 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
904 .label = "browsable",
905 .type = P_BOOL,
906 .p_class = P_LOCAL,
907 .offset = LOCAL_VAR(bBrowseable),
908 .special = NULL,
909 .enum_list = NULL
913 .label = "dns proxy",
914 .type = P_BOOL,
915 .p_class = P_GLOBAL,
916 .offset = GLOBAL_VAR(bWINSdnsProxy),
917 .special = NULL,
918 .enum_list = NULL
921 .label = "wins server",
922 .type = P_LIST,
923 .p_class = P_GLOBAL,
924 .offset = GLOBAL_VAR(szWINSservers),
925 .special = NULL,
926 .enum_list = NULL,
927 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
930 .label = "wins support",
931 .type = P_BOOL,
932 .p_class = P_GLOBAL,
933 .offset = GLOBAL_VAR(bWINSsupport),
934 .special = NULL,
935 .enum_list = NULL,
936 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_WIZARD,
939 .label = "wins hook",
940 .type = P_STRING,
941 .p_class = P_GLOBAL,
942 .offset = GLOBAL_VAR(szWINSHook),
943 .special = NULL,
944 .enum_list = NULL,
945 .flags = FLAG_ADVANCED,
949 .label = "csc policy",
950 .type = P_ENUM,
951 .p_class = P_LOCAL,
952 .offset = LOCAL_VAR(iCSCPolicy),
953 .special = NULL,
954 .enum_list = enum_csc_policy,
955 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
959 .label = "strict locking",
960 .type = P_BOOL,
961 .p_class = P_LOCAL,
962 .offset = LOCAL_VAR(iStrictLocking),
963 .special = NULL,
964 .enum_list = NULL
967 .label = "oplocks",
968 .type = P_BOOL,
969 .p_class = P_LOCAL,
970 .offset = LOCAL_VAR(bOpLocks),
971 .special = NULL,
972 .enum_list = NULL
975 {N_("Ldap Options"), P_SEP, P_SEPARATOR},
978 .label = "ldap admin dn",
979 .type = P_STRING,
980 .p_class = P_GLOBAL,
981 .offset = GLOBAL_VAR(szLdapAdminDn),
982 .special = NULL,
983 .enum_list = NULL,
984 .flags = FLAG_ADVANCED,
987 .label = "ldap delete dn",
988 .type = P_BOOL,
989 .p_class = P_GLOBAL,
990 .offset = GLOBAL_VAR(ldap_delete_dn),
991 .special = NULL,
992 .enum_list = NULL,
993 .flags = FLAG_ADVANCED,
996 .label = "ldap group suffix",
997 .type = P_STRING,
998 .p_class = P_GLOBAL,
999 .offset = GLOBAL_VAR(szLdapGroupSuffix),
1000 .special = NULL,
1001 .enum_list = NULL,
1002 .flags = FLAG_ADVANCED,
1005 .label = "ldap idmap suffix",
1006 .type = P_STRING,
1007 .p_class = P_GLOBAL,
1008 .offset = GLOBAL_VAR(szLdapIdmapSuffix),
1009 .special = NULL,
1010 .enum_list = NULL,
1011 .flags = FLAG_ADVANCED,
1014 .label = "ldap machine suffix",
1015 .type = P_STRING,
1016 .p_class = P_GLOBAL,
1017 .offset = GLOBAL_VAR(szLdapMachineSuffix),
1018 .special = NULL,
1019 .enum_list = NULL,
1020 .flags = FLAG_ADVANCED,
1023 .label = "ldap passwd sync",
1024 .type = P_ENUM,
1025 .p_class = P_GLOBAL,
1026 .offset = GLOBAL_VAR(ldap_passwd_sync),
1027 .special = NULL,
1028 .enum_list = enum_ldap_passwd_sync,
1029 .flags = FLAG_ADVANCED,
1032 .label = "ldap password sync",
1033 .type = P_ENUM,
1034 .p_class = P_GLOBAL,
1035 .offset = GLOBAL_VAR(ldap_passwd_sync),
1036 .special = NULL,
1037 .enum_list = enum_ldap_passwd_sync,
1038 .flags = FLAG_HIDE,
1041 .label = "ldap replication sleep",
1042 .type = P_INTEGER,
1043 .p_class = P_GLOBAL,
1044 .offset = GLOBAL_VAR(ldap_replication_sleep),
1045 .special = NULL,
1046 .enum_list = NULL,
1047 .flags = FLAG_ADVANCED,
1050 .label = "ldap suffix",
1051 .type = P_STRING,
1052 .p_class = P_GLOBAL,
1053 .offset = GLOBAL_VAR(szLdapSuffix),
1054 .special = NULL,
1055 .enum_list = NULL,
1056 .flags = FLAG_ADVANCED,
1059 .label = "ldap ssl",
1060 .type = P_ENUM,
1061 .p_class = P_GLOBAL,
1062 .offset = GLOBAL_VAR(ldap_ssl),
1063 .special = NULL,
1064 .enum_list = enum_ldap_ssl,
1065 .flags = FLAG_ADVANCED,
1068 .label = "ldap ssl ads",
1069 .type = P_BOOL,
1070 .p_class = P_GLOBAL,
1071 .offset = GLOBAL_VAR(ldap_ssl_ads),
1072 .special = NULL,
1073 .enum_list = NULL,
1074 .flags = FLAG_ADVANCED,
1077 .label = "ldap deref",
1078 .type = P_ENUM,
1079 .p_class = P_GLOBAL,
1080 .offset = GLOBAL_VAR(ldap_deref),
1081 .special = NULL,
1082 .enum_list = enum_ldap_deref,
1083 .flags = FLAG_ADVANCED,
1086 .label = "ldap follow referral",
1087 .type = P_ENUM,
1088 .p_class = P_GLOBAL,
1089 .offset = GLOBAL_VAR(ldap_follow_referral),
1090 .special = NULL,
1091 .enum_list = enum_bool_auto,
1092 .flags = FLAG_ADVANCED,
1095 .label = "ldap timeout",
1096 .type = P_INTEGER,
1097 .p_class = P_GLOBAL,
1098 .offset = GLOBAL_VAR(ldap_timeout),
1099 .special = NULL,
1100 .enum_list = NULL,
1101 .flags = FLAG_ADVANCED,
1104 .label = "ldap connection timeout",
1105 .type = P_INTEGER,
1106 .p_class = P_GLOBAL,
1107 .offset = GLOBAL_VAR(ldap_connection_timeout),
1108 .special = NULL,
1109 .enum_list = NULL,
1110 .flags = FLAG_ADVANCED,
1113 .label = "ldap page size",
1114 .type = P_INTEGER,
1115 .p_class = P_GLOBAL,
1116 .offset = GLOBAL_VAR(ldap_page_size),
1117 .special = NULL,
1118 .enum_list = NULL,
1119 .flags = FLAG_ADVANCED,
1122 .label = "ldap user suffix",
1123 .type = P_STRING,
1124 .p_class = P_GLOBAL,
1125 .offset = GLOBAL_VAR(szLdapUserSuffix),
1126 .special = NULL,
1127 .enum_list = NULL,
1128 .flags = FLAG_ADVANCED,
1131 .label = "ldap debug level",
1132 .type = P_INTEGER,
1133 .p_class = P_GLOBAL,
1134 .offset = GLOBAL_VAR(ldap_debug_level),
1135 .special = handle_ldap_debug_level,
1136 .enum_list = NULL,
1137 .flags = FLAG_ADVANCED,
1140 .label = "ldap debug threshold",
1141 .type = P_INTEGER,
1142 .p_class = P_GLOBAL,
1143 .offset = GLOBAL_VAR(ldap_debug_threshold),
1144 .special = NULL,
1145 .enum_list = NULL,
1146 .flags = FLAG_ADVANCED,
1149 {N_("EventLog Options"), P_SEP, P_SEPARATOR},
1152 .label = "eventlog list",
1153 .type = P_LIST,
1154 .p_class = P_GLOBAL,
1155 .offset = GLOBAL_VAR(szEventLogs),
1156 .special = NULL,
1157 .enum_list = NULL,
1158 .flags = FLAG_ADVANCED | FLAG_GLOBAL | FLAG_SHARE,
1161 {N_("Miscellaneous Options"), P_SEP, P_SEPARATOR},
1164 .label = "add share command",
1165 .type = P_STRING,
1166 .p_class = P_GLOBAL,
1167 .offset = GLOBAL_VAR(szAddShareCommand),
1168 .special = NULL,
1169 .enum_list = NULL,
1170 .flags = FLAG_ADVANCED,
1173 .label = "change share command",
1174 .type = P_STRING,
1175 .p_class = P_GLOBAL,
1176 .offset = GLOBAL_VAR(szChangeShareCommand),
1177 .special = NULL,
1178 .enum_list = NULL,
1179 .flags = FLAG_ADVANCED,
1182 .label = "delete share command",
1183 .type = P_STRING,
1184 .p_class = P_GLOBAL,
1185 .offset = GLOBAL_VAR(szDeleteShareCommand),
1186 .special = NULL,
1187 .enum_list = NULL,
1188 .flags = FLAG_ADVANCED,
1191 .label = "config file",
1192 .type = P_STRING,
1193 .p_class = P_GLOBAL,
1194 .offset = GLOBAL_VAR(szConfigFile),
1195 .special = NULL,
1196 .enum_list = NULL,
1197 .flags = FLAG_HIDE|FLAG_META,
1200 .label = "preload",
1201 .type = P_STRING,
1202 .p_class = P_GLOBAL,
1203 .offset = GLOBAL_VAR(szAutoServices),
1204 .special = NULL,
1205 .enum_list = NULL,
1206 .flags = FLAG_ADVANCED,
1209 .label = "auto services",
1210 .type = P_STRING,
1211 .p_class = P_GLOBAL,
1212 .offset = GLOBAL_VAR(szAutoServices),
1213 .special = NULL,
1214 .enum_list = NULL,
1215 .flags = FLAG_ADVANCED,
1218 .label = "lock directory",
1219 .type = P_STRING,
1220 .p_class = P_GLOBAL,
1221 .offset = GLOBAL_VAR(szLockDir),
1222 .special = NULL,
1223 .enum_list = NULL,
1224 .flags = FLAG_ADVANCED,
1227 .label = "lock dir",
1228 .type = P_STRING,
1229 .p_class = P_GLOBAL,
1230 .offset = GLOBAL_VAR(szLockDir),
1231 .special = NULL,
1232 .enum_list = NULL,
1233 .flags = FLAG_HIDE,
1236 .label = "state directory",
1237 .type = P_STRING,
1238 .p_class = P_GLOBAL,
1239 .offset = GLOBAL_VAR(szStateDir),
1240 .special = NULL,
1241 .enum_list = NULL,
1242 .flags = FLAG_ADVANCED,
1245 .label = "cache directory",
1246 .type = P_STRING,
1247 .p_class = P_GLOBAL,
1248 .offset = GLOBAL_VAR(szCacheDir),
1249 .special = NULL,
1250 .enum_list = NULL,
1251 .flags = FLAG_ADVANCED,
1254 .label = "pid directory",
1255 .type = P_STRING,
1256 .p_class = P_GLOBAL,
1257 .offset = GLOBAL_VAR(szPidDir),
1258 .special = NULL,
1259 .enum_list = NULL,
1260 .flags = FLAG_ADVANCED,
1263 .label = "ntp signd socket directory",
1264 .type = P_STRING,
1265 .p_class = P_GLOBAL,
1266 .offset = GLOBAL_VAR(szNTPSignDSocketDirectory),
1267 .special = NULL,
1268 .enum_list = NULL,
1269 .flags = FLAG_ADVANCED,
1272 #ifdef WITH_UTMP
1274 .label = "utmp directory",
1275 .type = P_STRING,
1276 .p_class = P_GLOBAL,
1277 .offset = GLOBAL_VAR(szUtmpDir),
1278 .special = NULL,
1279 .enum_list = NULL,
1280 .flags = FLAG_ADVANCED,
1283 .label = "wtmp directory",
1284 .type = P_STRING,
1285 .p_class = P_GLOBAL,
1286 .offset = GLOBAL_VAR(szWtmpDir),
1287 .special = NULL,
1288 .enum_list = NULL,
1289 .flags = FLAG_ADVANCED,
1292 .label = "utmp",
1293 .type = P_BOOL,
1294 .p_class = P_GLOBAL,
1295 .offset = GLOBAL_VAR(bUtmp),
1296 .special = NULL,
1297 .enum_list = NULL,
1298 .flags = FLAG_ADVANCED,
1300 #endif
1302 .label = "default service",
1303 .type = P_STRING,
1304 .p_class = P_GLOBAL,
1305 .offset = GLOBAL_VAR(szDefaultService),
1306 .special = NULL,
1307 .enum_list = NULL,
1308 .flags = FLAG_ADVANCED,
1311 .label = "default",
1312 .type = P_STRING,
1313 .p_class = P_GLOBAL,
1314 .offset = GLOBAL_VAR(szDefaultService),
1315 .special = NULL,
1316 .enum_list = NULL,
1317 .flags = FLAG_ADVANCED,
1320 .label = "message command",
1321 .type = P_STRING,
1322 .p_class = P_GLOBAL,
1323 .offset = GLOBAL_VAR(szMsgCommand),
1324 .special = NULL,
1325 .enum_list = NULL,
1326 .flags = FLAG_ADVANCED,
1329 .label = "dfree cache time",
1330 .type = P_INTEGER,
1331 .p_class = P_LOCAL,
1332 .offset = LOCAL_VAR(iDfreeCacheTime),
1333 .special = NULL,
1334 .enum_list = NULL,
1335 .flags = FLAG_ADVANCED,
1338 .label = "dfree command",
1339 .type = P_STRING,
1340 .p_class = P_LOCAL,
1341 .offset = LOCAL_VAR(szDfree),
1342 .special = NULL,
1343 .enum_list = NULL,
1344 .flags = FLAG_ADVANCED,
1347 .label = "get quota command",
1348 .type = P_STRING,
1349 .p_class = P_GLOBAL,
1350 .offset = GLOBAL_VAR(szGetQuota),
1351 .special = NULL,
1352 .enum_list = NULL,
1353 .flags = FLAG_ADVANCED,
1356 .label = "set quota command",
1357 .type = P_STRING,
1358 .p_class = P_GLOBAL,
1359 .offset = GLOBAL_VAR(szSetQuota),
1360 .special = NULL,
1361 .enum_list = NULL,
1362 .flags = FLAG_ADVANCED,
1365 .label = "remote announce",
1366 .type = P_STRING,
1367 .p_class = P_GLOBAL,
1368 .offset = GLOBAL_VAR(szRemoteAnnounce),
1369 .special = NULL,
1370 .enum_list = NULL,
1371 .flags = FLAG_ADVANCED,
1374 .label = "remote browse sync",
1375 .type = P_STRING,
1376 .p_class = P_GLOBAL,
1377 .offset = GLOBAL_VAR(szRemoteBrowseSync),
1378 .special = NULL,
1379 .enum_list = NULL,
1380 .flags = FLAG_ADVANCED,
1383 .label = "socket address",
1384 .type = P_STRING,
1385 .p_class = P_GLOBAL,
1386 .offset = GLOBAL_VAR(szSocketAddress),
1387 .special = NULL,
1388 .enum_list = NULL,
1389 .flags = FLAG_ADVANCED,
1392 .label = "nmbd bind explicit broadcast",
1393 .type = P_BOOL,
1394 .p_class = P_GLOBAL,
1395 .offset = GLOBAL_VAR(bNmbdBindExplicitBroadcast),
1396 .special = NULL,
1397 .enum_list = NULL,
1398 .flags = FLAG_ADVANCED,
1401 .label = "homedir map",
1402 .type = P_STRING,
1403 .p_class = P_GLOBAL,
1404 .offset = GLOBAL_VAR(szNISHomeMapName),
1405 .special = NULL,
1406 .enum_list = NULL,
1407 .flags = FLAG_ADVANCED,
1410 .label = "afs username map",
1411 .type = P_STRING,
1412 .p_class = P_GLOBAL,
1413 .offset = GLOBAL_VAR(szAfsUsernameMap),
1414 .special = NULL,
1415 .enum_list = NULL,
1416 .flags = FLAG_ADVANCED,
1419 .label = "afs token lifetime",
1420 .type = P_INTEGER,
1421 .p_class = P_GLOBAL,
1422 .offset = GLOBAL_VAR(iAfsTokenLifetime),
1423 .special = NULL,
1424 .enum_list = NULL,
1425 .flags = FLAG_ADVANCED,
1428 .label = "log nt token command",
1429 .type = P_STRING,
1430 .p_class = P_GLOBAL,
1431 .offset = GLOBAL_VAR(szLogNtTokenCommand),
1432 .special = NULL,
1433 .enum_list = NULL,
1434 .flags = FLAG_ADVANCED,
1437 .label = "NIS homedir",
1438 .type = P_BOOL,
1439 .p_class = P_GLOBAL,
1440 .offset = GLOBAL_VAR(bNISHomeMap),
1441 .special = NULL,
1442 .enum_list = NULL,
1443 .flags = FLAG_ADVANCED,
1446 .label = "-valid",
1447 .type = P_BOOL,
1448 .p_class = P_LOCAL,
1449 .offset = LOCAL_VAR(valid),
1450 .special = NULL,
1451 .enum_list = NULL,
1452 .flags = FLAG_HIDE,
1455 .label = "copy",
1456 .type = P_STRING,
1457 .p_class = P_LOCAL,
1458 .offset = LOCAL_VAR(szCopy),
1459 .special = handle_copy,
1460 .enum_list = NULL,
1461 .flags = FLAG_HIDE,
1464 .label = "include",
1465 .type = P_STRING,
1466 .p_class = P_LOCAL,
1467 .offset = LOCAL_VAR(szInclude),
1468 .special = handle_include,
1469 .enum_list = NULL,
1470 .flags = FLAG_HIDE|FLAG_META,
1473 .label = "preexec",
1474 .type = P_STRING,
1475 .p_class = P_LOCAL,
1476 .offset = LOCAL_VAR(szPreExec),
1477 .special = NULL,
1478 .enum_list = NULL,
1479 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1482 .label = "exec",
1483 .type = P_STRING,
1484 .p_class = P_LOCAL,
1485 .offset = LOCAL_VAR(szPreExec),
1486 .special = NULL,
1487 .enum_list = NULL,
1488 .flags = FLAG_ADVANCED,
1491 .label = "preexec close",
1492 .type = P_BOOL,
1493 .p_class = P_LOCAL,
1494 .offset = LOCAL_VAR(bPreexecClose),
1495 .special = NULL,
1496 .enum_list = NULL,
1497 .flags = FLAG_ADVANCED | FLAG_SHARE,
1500 .label = "postexec",
1501 .type = P_STRING,
1502 .p_class = P_LOCAL,
1503 .offset = LOCAL_VAR(szPostExec),
1504 .special = NULL,
1505 .enum_list = NULL,
1506 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1509 .label = "root preexec",
1510 .type = P_STRING,
1511 .p_class = P_LOCAL,
1512 .offset = LOCAL_VAR(szRootPreExec),
1513 .special = NULL,
1514 .enum_list = NULL,
1515 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1518 .label = "root preexec close",
1519 .type = P_BOOL,
1520 .p_class = P_LOCAL,
1521 .offset = LOCAL_VAR(bRootpreexecClose),
1522 .special = NULL,
1523 .enum_list = NULL,
1524 .flags = FLAG_ADVANCED | FLAG_SHARE,
1527 .label = "root postexec",
1528 .type = P_STRING,
1529 .p_class = P_LOCAL,
1530 .offset = LOCAL_VAR(szRootPostExec),
1531 .special = NULL,
1532 .enum_list = NULL,
1533 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1536 .label = "available",
1537 .type = P_BOOL,
1538 .p_class = P_LOCAL,
1539 .offset = LOCAL_VAR(bAvailable),
1540 .special = NULL,
1541 .enum_list = NULL,
1542 .flags = FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT,
1545 .label = "registry shares",
1546 .type = P_BOOL,
1547 .p_class = P_GLOBAL,
1548 .offset = GLOBAL_VAR(bRegistryShares),
1549 .special = NULL,
1550 .enum_list = NULL,
1551 .flags = FLAG_ADVANCED,
1554 .label = "usershare allow guests",
1555 .type = P_BOOL,
1556 .p_class = P_GLOBAL,
1557 .offset = GLOBAL_VAR(bUsershareAllowGuests),
1558 .special = NULL,
1559 .enum_list = NULL,
1560 .flags = FLAG_ADVANCED,
1563 .label = "usershare max shares",
1564 .type = P_INTEGER,
1565 .p_class = P_GLOBAL,
1566 .offset = GLOBAL_VAR(iUsershareMaxShares),
1567 .special = NULL,
1568 .enum_list = NULL,
1569 .flags = FLAG_ADVANCED,
1572 .label = "usershare owner only",
1573 .type = P_BOOL,
1574 .p_class = P_GLOBAL,
1575 .offset = GLOBAL_VAR(bUsershareOwnerOnly),
1576 .special = NULL,
1577 .enum_list = NULL,
1578 .flags = FLAG_ADVANCED,
1581 .label = "usershare path",
1582 .type = P_STRING,
1583 .p_class = P_GLOBAL,
1584 .offset = GLOBAL_VAR(szUsersharePath),
1585 .special = NULL,
1586 .enum_list = NULL,
1587 .flags = FLAG_ADVANCED,
1590 .label = "usershare prefix allow list",
1591 .type = P_LIST,
1592 .p_class = P_GLOBAL,
1593 .offset = GLOBAL_VAR(szUsersharePrefixAllowList),
1594 .special = NULL,
1595 .enum_list = NULL,
1596 .flags = FLAG_ADVANCED,
1599 .label = "usershare prefix deny list",
1600 .type = P_LIST,
1601 .p_class = P_GLOBAL,
1602 .offset = GLOBAL_VAR(szUsersharePrefixDenyList),
1603 .special = NULL,
1604 .enum_list = NULL,
1605 .flags = FLAG_ADVANCED,
1608 .label = "usershare template share",
1609 .type = P_STRING,
1610 .p_class = P_GLOBAL,
1611 .offset = GLOBAL_VAR(szUsershareTemplateShare),
1612 .special = NULL,
1613 .enum_list = NULL,
1614 .flags = FLAG_ADVANCED,
1617 .label = "volume",
1618 .type = P_STRING,
1619 .p_class = P_LOCAL,
1620 .offset = LOCAL_VAR(volume),
1621 .special = NULL,
1622 .enum_list = NULL,
1623 .flags = FLAG_ADVANCED | FLAG_SHARE,
1626 .label = "fstype",
1627 .type = P_STRING,
1628 .p_class = P_LOCAL,
1629 .offset = LOCAL_VAR(fstype),
1630 .special = NULL,
1631 .enum_list = NULL,
1632 .flags = FLAG_ADVANCED | FLAG_SHARE,
1635 .label = "set directory",
1636 .type = P_BOOLREV,
1637 .p_class = P_LOCAL,
1638 .offset = LOCAL_VAR(bNo_set_dir),
1639 .special = NULL,
1640 .enum_list = NULL,
1641 .flags = FLAG_ADVANCED | FLAG_SHARE,
1644 .label = "allow insecure wide links",
1645 .type = P_BOOL,
1646 .p_class = P_GLOBAL,
1647 .offset = GLOBAL_VAR(bAllowInsecureWidelinks),
1648 .special = NULL,
1649 .enum_list = NULL,
1650 .flags = FLAG_ADVANCED,
1653 .label = "wide links",
1654 .type = P_BOOL,
1655 .p_class = P_LOCAL,
1656 .offset = LOCAL_VAR(bWidelinks),
1657 .special = NULL,
1658 .enum_list = NULL,
1659 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1662 .label = "follow symlinks",
1663 .type = P_BOOL,
1664 .p_class = P_LOCAL,
1665 .offset = LOCAL_VAR(bSymlinks),
1666 .special = NULL,
1667 .enum_list = NULL,
1668 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1671 .label = "dont descend",
1672 .type = P_STRING,
1673 .p_class = P_LOCAL,
1674 .offset = LOCAL_VAR(szDontdescend),
1675 .special = NULL,
1676 .enum_list = NULL,
1677 .flags = FLAG_ADVANCED | FLAG_SHARE,
1680 .label = "magic script",
1681 .type = P_STRING,
1682 .p_class = P_LOCAL,
1683 .offset = LOCAL_VAR(szMagicScript),
1684 .special = NULL,
1685 .enum_list = NULL,
1686 .flags = FLAG_ADVANCED | FLAG_SHARE,
1689 .label = "magic output",
1690 .type = P_STRING,
1691 .p_class = P_LOCAL,
1692 .offset = LOCAL_VAR(szMagicOutput),
1693 .special = NULL,
1694 .enum_list = NULL,
1695 .flags = FLAG_ADVANCED | FLAG_SHARE,
1698 .label = "delete readonly",
1699 .type = P_BOOL,
1700 .p_class = P_LOCAL,
1701 .offset = LOCAL_VAR(bDeleteReadonly),
1702 .special = NULL,
1703 .enum_list = NULL,
1704 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1707 .label = "dos filemode",
1708 .type = P_BOOL,
1709 .p_class = P_LOCAL,
1710 .offset = LOCAL_VAR(bDosFilemode),
1711 .special = NULL,
1712 .enum_list = NULL,
1713 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1716 .label = "dos filetimes",
1717 .type = P_BOOL,
1718 .p_class = P_LOCAL,
1719 .offset = LOCAL_VAR(bDosFiletimes),
1720 .special = NULL,
1721 .enum_list = NULL,
1722 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1725 .label = "dos filetime resolution",
1726 .type = P_BOOL,
1727 .p_class = P_LOCAL,
1728 .offset = LOCAL_VAR(bDosFiletimeResolution),
1729 .special = NULL,
1730 .enum_list = NULL,
1731 .flags = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
1734 .label = "fake directory create times",
1735 .type = P_BOOL,
1736 .p_class = P_LOCAL,
1737 .offset = LOCAL_VAR(bFakeDirCreateTimes),
1738 .special = NULL,
1739 .enum_list = NULL,
1740 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1743 .label = "async smb echo handler",
1744 .type = P_BOOL,
1745 .p_class = P_GLOBAL,
1746 .offset = GLOBAL_VAR(bAsyncSMBEchoHandler),
1747 .special = NULL,
1748 .enum_list = NULL,
1749 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
1752 .label = "panic action",
1753 .type = P_STRING,
1754 .p_class = P_GLOBAL,
1755 .offset = GLOBAL_VAR(szPanicAction),
1756 .special = NULL,
1757 .enum_list = NULL,
1758 .flags = FLAG_ADVANCED,
1761 .label = "perfcount module",
1762 .type = P_STRING,
1763 .p_class = P_GLOBAL,
1764 .offset = GLOBAL_VAR(szSMBPerfcountModule),
1765 .special = NULL,
1766 .enum_list = NULL,
1767 .flags = FLAG_ADVANCED,
1770 {N_("VFS module options"), P_SEP, P_SEPARATOR},
1773 .label = "vfs objects",
1774 .type = P_LIST,
1775 .p_class = P_LOCAL,
1776 .offset = LOCAL_VAR(szVfsObjects),
1777 .special = NULL,
1778 .enum_list = NULL,
1779 .flags = FLAG_ADVANCED | FLAG_SHARE,
1782 .label = "vfs object",
1783 .type = P_LIST,
1784 .p_class = P_LOCAL,
1785 .offset = LOCAL_VAR(szVfsObjects),
1786 .special = NULL,
1787 .enum_list = NULL,
1788 .flags = FLAG_HIDE,
1792 {N_("MSDFS options"), P_SEP, P_SEPARATOR},
1795 .label = "msdfs root",
1796 .type = P_BOOL,
1797 .p_class = P_LOCAL,
1798 .offset = LOCAL_VAR(bMSDfsRoot),
1799 .special = NULL,
1800 .enum_list = NULL,
1801 .flags = FLAG_ADVANCED | FLAG_SHARE,
1804 .label = "msdfs proxy",
1805 .type = P_STRING,
1806 .p_class = P_LOCAL,
1807 .offset = LOCAL_VAR(szMSDfsProxy),
1808 .special = NULL,
1809 .enum_list = NULL,
1810 .flags = FLAG_ADVANCED | FLAG_SHARE,
1813 .label = "host msdfs",
1814 .type = P_BOOL,
1815 .p_class = P_GLOBAL,
1816 .offset = GLOBAL_VAR(bHostMSDfs),
1817 .special = NULL,
1818 .enum_list = NULL,
1819 .flags = FLAG_ADVANCED,
1822 {N_("Winbind options"), P_SEP, P_SEPARATOR},
1825 .label = "passdb expand explicit",
1826 .type = P_BOOL,
1827 .p_class = P_GLOBAL,
1828 .offset = GLOBAL_VAR(bPassdbExpandExplicit),
1829 .special = NULL,
1830 .enum_list = NULL,
1831 .flags = FLAG_ADVANCED,
1834 .label = "idmap backend",
1835 .type = P_STRING,
1836 .p_class = P_GLOBAL,
1837 .offset = GLOBAL_VAR(szIdmapBackend),
1838 .special = handle_idmap_backend,
1839 .enum_list = NULL,
1840 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
1843 .label = "idmap cache time",
1844 .type = P_INTEGER,
1845 .p_class = P_GLOBAL,
1846 .offset = GLOBAL_VAR(iIdmapCacheTime),
1847 .special = NULL,
1848 .enum_list = NULL,
1849 .flags = FLAG_ADVANCED,
1852 .label = "idmap negative cache time",
1853 .type = P_INTEGER,
1854 .p_class = P_GLOBAL,
1855 .offset = GLOBAL_VAR(iIdmapNegativeCacheTime),
1856 .special = NULL,
1857 .enum_list = NULL,
1858 .flags = FLAG_ADVANCED,
1861 .label = "idmap uid",
1862 .type = P_STRING,
1863 .p_class = P_GLOBAL,
1864 .offset = GLOBAL_VAR(szIdmapUID),
1865 .special = handle_idmap_uid,
1866 .enum_list = NULL,
1867 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
1870 .label = "winbind uid",
1871 .type = P_STRING,
1872 .p_class = P_GLOBAL,
1873 .offset = GLOBAL_VAR(szIdmapUID),
1874 .special = handle_idmap_uid,
1875 .enum_list = NULL,
1876 .flags = FLAG_HIDE,
1879 .label = "idmap gid",
1880 .type = P_STRING,
1881 .p_class = P_GLOBAL,
1882 .offset = GLOBAL_VAR(szIdmapGID),
1883 .special = handle_idmap_gid,
1884 .enum_list = NULL,
1885 .flags = FLAG_ADVANCED | FLAG_DEPRECATED,
1888 .label = "winbind gid",
1889 .type = P_STRING,
1890 .p_class = P_GLOBAL,
1891 .offset = GLOBAL_VAR(szIdmapGID),
1892 .special = handle_idmap_gid,
1893 .enum_list = NULL,
1894 .flags = FLAG_HIDE,
1897 .label = "template homedir",
1898 .type = P_STRING,
1899 .p_class = P_GLOBAL,
1900 .offset = GLOBAL_VAR(szTemplateHomedir),
1901 .special = NULL,
1902 .enum_list = NULL,
1903 .flags = FLAG_ADVANCED,
1906 .label = "template shell",
1907 .type = P_STRING,
1908 .p_class = P_GLOBAL,
1909 .offset = GLOBAL_VAR(szTemplateShell),
1910 .special = NULL,
1911 .enum_list = NULL,
1912 .flags = FLAG_ADVANCED,
1915 .label = "winbind separator",
1916 .type = P_STRING,
1917 .p_class = P_GLOBAL,
1918 .offset = GLOBAL_VAR(szWinbindSeparator),
1919 .special = NULL,
1920 .enum_list = NULL,
1921 .flags = FLAG_ADVANCED,
1924 .label = "winbind cache time",
1925 .type = P_INTEGER,
1926 .p_class = P_GLOBAL,
1927 .offset = GLOBAL_VAR(winbind_cache_time),
1928 .special = NULL,
1929 .enum_list = NULL,
1930 .flags = FLAG_ADVANCED,
1933 .label = "winbind reconnect delay",
1934 .type = P_INTEGER,
1935 .p_class = P_GLOBAL,
1936 .offset = GLOBAL_VAR(winbind_reconnect_delay),
1937 .special = NULL,
1938 .enum_list = NULL,
1939 .flags = FLAG_ADVANCED,
1942 .label = "winbind max clients",
1943 .type = P_INTEGER,
1944 .p_class = P_GLOBAL,
1945 .offset = GLOBAL_VAR(winbind_max_clients),
1946 .special = NULL,
1947 .enum_list = NULL,
1948 .flags = FLAG_ADVANCED,
1951 .label = "winbind enum users",
1952 .type = P_BOOL,
1953 .p_class = P_GLOBAL,
1954 .offset = GLOBAL_VAR(bWinbindEnumUsers),
1955 .special = NULL,
1956 .enum_list = NULL,
1957 .flags = FLAG_ADVANCED,
1960 .label = "winbind enum groups",
1961 .type = P_BOOL,
1962 .p_class = P_GLOBAL,
1963 .offset = GLOBAL_VAR(bWinbindEnumGroups),
1964 .special = NULL,
1965 .enum_list = NULL,
1966 .flags = FLAG_ADVANCED,
1969 .label = "winbind use default domain",
1970 .type = P_BOOL,
1971 .p_class = P_GLOBAL,
1972 .offset = GLOBAL_VAR(bWinbindUseDefaultDomain),
1973 .special = NULL,
1974 .enum_list = NULL,
1975 .flags = FLAG_ADVANCED,
1978 .label = "winbind trusted domains only",
1979 .type = P_BOOL,
1980 .p_class = P_GLOBAL,
1981 .offset = GLOBAL_VAR(bWinbindTrustedDomainsOnly),
1982 .special = NULL,
1983 .enum_list = NULL,
1984 .flags = FLAG_ADVANCED,
1987 .label = "winbind nested groups",
1988 .type = P_BOOL,
1989 .p_class = P_GLOBAL,
1990 .offset = GLOBAL_VAR(bWinbindNestedGroups),
1991 .special = NULL,
1992 .enum_list = NULL,
1993 .flags = FLAG_ADVANCED,
1996 .label = "winbind expand groups",
1997 .type = P_INTEGER,
1998 .p_class = P_GLOBAL,
1999 .offset = GLOBAL_VAR(winbind_expand_groups),
2000 .special = NULL,
2001 .enum_list = NULL,
2002 .flags = FLAG_ADVANCED,
2005 .label = "winbind nss info",
2006 .type = P_LIST,
2007 .p_class = P_GLOBAL,
2008 .offset = GLOBAL_VAR(szWinbindNssInfo),
2009 .special = NULL,
2010 .enum_list = NULL,
2011 .flags = FLAG_ADVANCED,
2014 .label = "winbind refresh tickets",
2015 .type = P_BOOL,
2016 .p_class = P_GLOBAL,
2017 .offset = GLOBAL_VAR(bWinbindRefreshTickets),
2018 .special = NULL,
2019 .enum_list = NULL,
2020 .flags = FLAG_ADVANCED,
2023 .label = "winbind offline logon",
2024 .type = P_BOOL,
2025 .p_class = P_GLOBAL,
2026 .offset = GLOBAL_VAR(bWinbindOfflineLogon),
2027 .special = NULL,
2028 .enum_list = NULL,
2029 .flags = FLAG_ADVANCED,
2032 .label = "winbind normalize names",
2033 .type = P_BOOL,
2034 .p_class = P_GLOBAL,
2035 .offset = GLOBAL_VAR(bWinbindNormalizeNames),
2036 .special = NULL,
2037 .enum_list = NULL,
2038 .flags = FLAG_ADVANCED,
2041 .label = "winbind rpc only",
2042 .type = P_BOOL,
2043 .p_class = P_GLOBAL,
2044 .offset = GLOBAL_VAR(bWinbindRpcOnly),
2045 .special = NULL,
2046 .enum_list = NULL,
2047 .flags = FLAG_ADVANCED,
2050 .label = "create krb5 conf",
2051 .type = P_BOOL,
2052 .p_class = P_GLOBAL,
2053 .offset = GLOBAL_VAR(bCreateKrb5Conf),
2054 .special = NULL,
2055 .enum_list = NULL,
2056 .flags = FLAG_ADVANCED,
2059 .label = "ncalrpc dir",
2060 .type = P_STRING,
2061 .p_class = P_GLOBAL,
2062 .offset = GLOBAL_VAR(ncalrpc_dir),
2063 .special = NULL,
2064 .enum_list = NULL,
2065 .flags = FLAG_ADVANCED,
2068 .label = "winbind max domain connections",
2069 .type = P_INTEGER,
2070 .p_class = P_GLOBAL,
2071 .offset = GLOBAL_VAR(winbindMaxDomainConnections),
2072 .special = NULL,
2073 .enum_list = NULL,
2074 .flags = FLAG_ADVANCED,
2077 .label = "winbindd socket directory",
2078 .type = P_STRING,
2079 .p_class = P_GLOBAL,
2080 .offset = GLOBAL_VAR(szWinbinddSocketDirectory),
2081 .special = NULL,
2082 .enum_list = NULL,
2083 .flags = FLAG_ADVANCED,
2086 .label = "winbindd privileged socket directory",
2087 .type = P_STRING,
2088 .p_class = P_GLOBAL,
2089 .offset = GLOBAL_VAR(szWinbinddPrivilegedSocketDirectory),
2090 .special = NULL,
2091 .enum_list = NULL,
2092 .flags = FLAG_ADVANCED,
2095 .label = "winbind sealed pipes",
2096 .type = P_BOOL,
2097 .p_class = P_GLOBAL,
2098 .offset = GLOBAL_VAR(bWinbindSealedPipes),
2099 .special = NULL,
2100 .enum_list = NULL,
2101 .flags = FLAG_ADVANCED,
2104 {N_("DNS options"), P_SEP, P_SEPARATOR},
2106 .label = "allow dns updates",
2107 .type = P_ENUM,
2108 .p_class = P_GLOBAL,
2109 .offset = GLOBAL_VAR(allow_dns_updates),
2110 .special = NULL,
2111 .enum_list = enum_dns_update_settings,
2112 .flags = FLAG_ADVANCED,
2115 .label = "dns forwarder",
2116 .type = P_STRING,
2117 .p_class = P_GLOBAL,
2118 .offset = GLOBAL_VAR(dns_forwarder),
2119 .special = NULL,
2120 .enum_list = NULL,
2121 .flags = FLAG_ADVANCED,
2124 .label = "dns recursive queries",
2125 .type = P_BOOL,
2126 .p_class = P_GLOBAL,
2127 .offset = GLOBAL_VAR(dns_recursive_queries),
2128 .special = NULL,
2129 .enum_list = NULL
2132 .label = "dns update command",
2133 .type = P_CMDLIST,
2134 .p_class = P_GLOBAL,
2135 .offset = GLOBAL_VAR(szDNSUpdateCommand),
2136 .special = NULL,
2137 .enum_list = NULL,
2138 .flags = FLAG_ADVANCED,
2141 .label = "nsupdate command",
2142 .type = P_CMDLIST,
2143 .p_class = P_GLOBAL,
2144 .offset = GLOBAL_VAR(szNSUpdateCommand),
2145 .special = NULL,
2146 .enum_list = NULL,
2147 .flags = FLAG_ADVANCED,
2150 .label = "rndc command",
2151 .type = P_CMDLIST,
2152 .p_class = P_GLOBAL,
2153 .offset = GLOBAL_VAR(szRNDCCommand),
2154 .special = NULL,
2155 .enum_list = NULL,
2156 .flags = FLAG_ADVANCED,
2159 .label = "multicast dns register",
2160 .type = P_BOOL,
2161 .p_class = P_GLOBAL,
2162 .offset = GLOBAL_VAR(bMulticastDnsRegister),
2163 .special = NULL,
2164 .enum_list = NULL,
2165 .flags = FLAG_ADVANCED | FLAG_GLOBAL,
2168 {N_("AD DC options"), P_SEP, P_SEPARATOR},
2171 .label = "samba kcc command",
2172 .type = P_CMDLIST,
2173 .p_class = P_GLOBAL,
2174 .offset = GLOBAL_VAR(szSambaKCCCommand),
2175 .special = NULL,
2176 .enum_list = NULL,
2177 .flags = FLAG_ADVANCED,
2180 .label = "server services",
2181 .type = P_LIST,
2182 .p_class = P_GLOBAL,
2183 .offset = GLOBAL_VAR(server_services),
2184 .special = NULL,
2185 .enum_list = NULL
2188 .label = "dcerpc endpoint servers",
2189 .type = P_LIST,
2190 .p_class = P_GLOBAL,
2191 .offset = GLOBAL_VAR(dcerpc_ep_servers),
2192 .special = NULL,
2193 .enum_list = NULL
2196 .label = "spn update command",
2197 .type = P_CMDLIST,
2198 .p_class = P_GLOBAL,
2199 .offset = GLOBAL_VAR(szSPNUpdateCommand),
2200 .special = NULL,
2201 .enum_list = NULL,
2202 .flags = FLAG_ADVANCED,
2205 .label = "share backend",
2206 .type = P_STRING,
2207 .p_class = P_GLOBAL,
2208 .offset = GLOBAL_VAR(szShareBackend),
2209 .special = NULL,
2210 .enum_list = NULL
2213 .label = "ntvfs handler",
2214 .type = P_LIST,
2215 .p_class = P_LOCAL,
2216 .offset = LOCAL_VAR(ntvfs_handler),
2217 .special = NULL,
2218 .enum_list = NULL
2221 {N_("TLS options"), P_SEP, P_SEPARATOR},
2224 .label = "tls enabled",
2225 .type = P_BOOL,
2226 .p_class = P_GLOBAL,
2227 .offset = GLOBAL_VAR(tls_enabled),
2228 .special = NULL,
2229 .enum_list = NULL
2232 .label = "tls keyfile",
2233 .type = P_STRING,
2234 .p_class = P_GLOBAL,
2235 .offset = GLOBAL_VAR(tls_keyfile),
2236 .special = NULL,
2237 .enum_list = NULL
2240 .label = "tls certfile",
2241 .type = P_STRING,
2242 .p_class = P_GLOBAL,
2243 .offset = GLOBAL_VAR(tls_certfile),
2244 .special = NULL,
2245 .enum_list = NULL
2248 .label = "tls cafile",
2249 .type = P_STRING,
2250 .p_class = P_GLOBAL,
2251 .offset = GLOBAL_VAR(tls_cafile),
2252 .special = NULL,
2253 .enum_list = NULL
2256 .label = "tls crlfile",
2257 .type = P_STRING,
2258 .p_class = P_GLOBAL,
2259 .offset = GLOBAL_VAR(tls_crlfile),
2260 .special = NULL,
2261 .enum_list = NULL
2264 .label = "tls dh params file",
2265 .type = P_STRING,
2266 .p_class = P_GLOBAL,
2267 .offset = GLOBAL_VAR(tls_dhpfile),
2268 .special = NULL,
2269 .enum_list = NULL
2272 {NULL, P_BOOL, P_NONE, 0, NULL, NULL, 0}
2276 /* local variables */
2277 struct loadparm_context {
2278 const char *szConfigFile;
2279 struct loadparm_global *globals;
2280 struct loadparm_service **services;
2281 struct loadparm_service *sDefault;
2282 struct smb_iconv_handle *iconv_handle;
2283 int iNumServices;
2284 struct loadparm_service *currentService;
2285 bool bInGlobalSection;
2286 struct file_lists {
2287 struct file_lists *next;
2288 char *name;
2289 char *subfname;
2290 time_t modtime;
2291 } *file_lists;
2292 unsigned int flags[NUMPARAMETERS];
2293 bool loaded;
2294 bool refuse_free;
2295 bool global; /* Is this the global context, which may set
2296 * global variables such as debug level etc? */
2297 const struct loadparm_s3_helpers *s3_fns;
2301 struct loadparm_service *lpcfg_default_service(struct loadparm_context *lp_ctx)
2303 if (lp_ctx->s3_fns) {
2304 return lp_ctx->s3_fns->get_default_loadparm_service();
2306 return lp_ctx->sDefault;
2310 * Convenience routine to grab string parameters into temporary memory
2311 * and run standard_sub_basic on them.
2313 * The buffers can be written to by
2314 * callers without affecting the source string.
2317 static const char *lp_string(const char *s)
2319 #if 0 /* until REWRITE done to make thread-safe */
2320 size_t len = s ? strlen(s) : 0;
2321 char *ret;
2322 #endif
2324 /* The follow debug is useful for tracking down memory problems
2325 especially if you have an inner loop that is calling a lp_*()
2326 function that returns a string. Perhaps this debug should be
2327 present all the time? */
2329 #if 0
2330 DEBUG(10, ("lp_string(%s)\n", s));
2331 #endif
2333 #if 0 /* until REWRITE done to make thread-safe */
2334 if (!lp_talloc)
2335 lp_talloc = talloc_init("lp_talloc");
2337 ret = talloc_array(lp_talloc, char, len + 100); /* leave room for substitution */
2339 if (!ret)
2340 return NULL;
2342 if (!s)
2343 *ret = 0;
2344 else
2345 strlcpy(ret, s, len);
2347 if (trim_string(ret, "\"", "\"")) {
2348 if (strchr(ret,'"') != NULL)
2349 strlcpy(ret, s, len);
2352 standard_sub_basic(ret,len+100);
2353 return (ret);
2354 #endif
2355 return s;
2359 In this section all the functions that are used to access the
2360 parameters from the rest of the program are defined
2364 * the creation of separate lpcfg_*() and lp_*() functions is to allow
2365 * for code compatibility between existing Samba4 and Samba3 code.
2368 /* this global context supports the lp_*() function varients */
2369 static struct loadparm_context *global_loadparm_context;
2371 #define lpcfg_default_service global_loadparm_context->sDefault
2372 #define lpcfg_global_service(i) global_loadparm_context->services[i]
2374 #define FN_GLOBAL_STRING(fn_name,var_name) \
2375 _PUBLIC_ const char *lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) { \
2376 if (lp_ctx == NULL) return NULL; \
2377 if (lp_ctx->s3_fns) { \
2378 SMB_ASSERT(lp_ctx->s3_fns->fn_name); \
2379 return lp_ctx->s3_fns->fn_name(); \
2381 return lp_ctx->globals->var_name ? lp_string(lp_ctx->globals->var_name) : ""; \
2384 #define FN_GLOBAL_CONST_STRING(fn_name,var_name) \
2385 _PUBLIC_ const char *lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) {\
2386 if (lp_ctx == NULL) return NULL; \
2387 if (lp_ctx->s3_fns) { \
2388 SMB_ASSERT(lp_ctx->s3_fns->fn_name); \
2389 return lp_ctx->s3_fns->fn_name(); \
2391 return lp_ctx->globals->var_name ? lp_string(lp_ctx->globals->var_name) : ""; \
2394 #define FN_GLOBAL_LIST(fn_name,var_name) \
2395 _PUBLIC_ const char **lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) { \
2396 if (lp_ctx == NULL) return NULL; \
2397 if (lp_ctx->s3_fns) { \
2398 SMB_ASSERT(lp_ctx->s3_fns->fn_name); \
2399 return lp_ctx->s3_fns->fn_name(); \
2401 return lp_ctx->globals->var_name; \
2404 #define FN_GLOBAL_BOOL(fn_name,var_name) \
2405 _PUBLIC_ bool lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) {\
2406 if (lp_ctx == NULL) return false; \
2407 if (lp_ctx->s3_fns) { \
2408 SMB_ASSERT(lp_ctx->s3_fns->fn_name); \
2409 return lp_ctx->s3_fns->fn_name(); \
2411 return lp_ctx->globals->var_name; \
2414 #define FN_GLOBAL_INTEGER(fn_name,var_name) \
2415 _PUBLIC_ int lpcfg_ ## fn_name(struct loadparm_context *lp_ctx) { \
2416 if (lp_ctx->s3_fns) { \
2417 SMB_ASSERT(lp_ctx->s3_fns->fn_name); \
2418 return lp_ctx->s3_fns->fn_name(); \
2420 return lp_ctx->globals->var_name; \
2423 /* Local parameters don't need the ->s3_fns because the struct
2424 * loadparm_service is shared and lpcfg_service() checks the ->s3_fns
2425 * hook */
2426 #define FN_LOCAL_STRING(fn_name,val) \
2427 _PUBLIC_ const char *lpcfg_ ## fn_name(struct loadparm_service *service, \
2428 struct loadparm_service *sDefault) { \
2429 return(lp_string((const char *)((service != NULL && service->val != NULL) ? service->val : sDefault->val))); \
2432 #define FN_LOCAL_CONST_STRING(fn_name,val) FN_LOCAL_STRING(fn_name, val)
2434 #define FN_LOCAL_LIST(fn_name,val) \
2435 _PUBLIC_ const char **lpcfg_ ## fn_name(struct loadparm_service *service, \
2436 struct loadparm_service *sDefault) {\
2437 return(const char **)(service != NULL && service->val != NULL? service->val : sDefault->val); \
2440 #define FN_LOCAL_PARM_BOOL(fn_name, val) FN_LOCAL_BOOL(fn_name, val)
2442 #define FN_LOCAL_BOOL(fn_name,val) \
2443 _PUBLIC_ bool lpcfg_ ## fn_name(struct loadparm_service *service, \
2444 struct loadparm_service *sDefault) { \
2445 return((service != NULL)? service->val : sDefault->val); \
2448 #define FN_LOCAL_INTEGER(fn_name,val) \
2449 _PUBLIC_ int lpcfg_ ## fn_name(struct loadparm_service *service, \
2450 struct loadparm_service *sDefault) { \
2451 return((service != NULL)? service->val : sDefault->val); \
2454 #define FN_LOCAL_PARM_INTEGER(fn_name, val) FN_LOCAL_INTEGER(fn_name, val)
2456 #define FN_LOCAL_PARM_CHAR(fn_name, val) FN_LOCAL_CHAR(fn_name, val)
2458 #define FN_LOCAL_CHAR(fn_name,val) \
2459 _PUBLIC_ char lpcfg_ ## fn_name(struct loadparm_service *service, \
2460 struct loadparm_service *sDefault) { \
2461 return((service != NULL)? service->val : sDefault->val); \
2464 #include "lib/param/param_functions.c"
2466 /* These functions remain only in lib/param for now */
2467 FN_GLOBAL_BOOL(readraw, bReadRaw)
2468 FN_GLOBAL_BOOL(writeraw, bWriteRaw)
2469 FN_GLOBAL_STRING(cachedir, szCacheDir)
2470 FN_GLOBAL_STRING(socket_address, szSocketAddress)
2471 FN_GLOBAL_STRING(statedir, szStateDir)
2473 /* local prototypes */
2474 static int map_parameter(const char *pszParmName);
2475 static struct loadparm_service *getservicebyname(struct loadparm_context *lp_ctx,
2476 const char *pszServiceName);
2477 static void copy_service(struct loadparm_service *pserviceDest,
2478 struct loadparm_service *pserviceSource,
2479 struct bitmap *pcopymapDest);
2480 static bool lpcfg_service_ok(struct loadparm_service *service);
2481 static bool do_section(const char *pszSectionName, void *);
2482 static void init_copymap(struct loadparm_service *pservice);
2484 /* This is a helper function for parametrical options support. */
2485 /* It returns a pointer to parametrical option value if it exists or NULL otherwise */
2486 /* Actual parametrical functions are quite simple */
2487 const char *lpcfg_get_parametric(struct loadparm_context *lp_ctx,
2488 struct loadparm_service *service,
2489 const char *type, const char *option)
2491 char *vfskey_tmp = NULL;
2492 char *vfskey = NULL;
2493 struct parmlist_entry *data;
2495 if (lp_ctx == NULL)
2496 return NULL;
2498 if (lp_ctx->s3_fns) {
2499 return lp_ctx->s3_fns->get_parametric(service, type, option);
2502 data = (service == NULL ? lp_ctx->globals->param_opt : service->param_opt);
2504 vfskey_tmp = talloc_asprintf(NULL, "%s:%s", type, option);
2505 if (vfskey_tmp == NULL) return NULL;
2506 vfskey = strlower_talloc(NULL, vfskey_tmp);
2507 talloc_free(vfskey_tmp);
2509 while (data) {
2510 if (strcmp(data->key, vfskey) == 0) {
2511 talloc_free(vfskey);
2512 return data->value;
2514 data = data->next;
2517 if (service != NULL) {
2518 /* Try to fetch the same option but from globals */
2519 /* but only if we are not already working with globals */
2520 for (data = lp_ctx->globals->param_opt; data;
2521 data = data->next) {
2522 if (strcmp(data->key, vfskey) == 0) {
2523 talloc_free(vfskey);
2524 return data->value;
2529 talloc_free(vfskey);
2531 return NULL;
2536 * convenience routine to return int parameters.
2538 static int lp_int(const char *s)
2541 if (!s) {
2542 DEBUG(0,("lp_int(%s): is called with NULL!\n",s));
2543 return -1;
2546 return strtol(s, NULL, 0);
2550 * convenience routine to return unsigned long parameters.
2552 static unsigned long lp_ulong(const char *s)
2555 if (!s) {
2556 DEBUG(0,("lp_ulong(%s): is called with NULL!\n",s));
2557 return -1;
2560 return strtoul(s, NULL, 0);
2564 * convenience routine to return unsigned long parameters.
2566 static long lp_long(const char *s)
2569 if (!s) {
2570 DEBUG(0,("lp_long(%s): is called with NULL!\n",s));
2571 return -1;
2574 return strtol(s, NULL, 0);
2578 * convenience routine to return unsigned long parameters.
2580 static double lp_double(const char *s)
2583 if (!s) {
2584 DEBUG(0,("lp_double(%s): is called with NULL!\n",s));
2585 return -1;
2588 return strtod(s, NULL);
2592 * convenience routine to return boolean parameters.
2594 static bool lp_bool(const char *s)
2596 bool ret = false;
2598 if (!s) {
2599 DEBUG(0,("lp_bool(%s): is called with NULL!\n",s));
2600 return false;
2603 if (!set_boolean(s, &ret)) {
2604 DEBUG(0,("lp_bool(%s): value is not boolean!\n",s));
2605 return false;
2608 return ret;
2613 * Return parametric option from a given service. Type is a part of option before ':'
2614 * Parametric option has following syntax: 'Type: option = value'
2615 * Returned value is allocated in 'lp_talloc' context
2618 const char *lpcfg_parm_string(struct loadparm_context *lp_ctx,
2619 struct loadparm_service *service, const char *type,
2620 const char *option)
2622 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
2624 if (value)
2625 return lp_string(value);
2627 return NULL;
2631 * Return parametric option from a given service. Type is a part of option before ':'
2632 * Parametric option has following syntax: 'Type: option = value'
2633 * Returned value is allocated in 'lp_talloc' context
2636 const char **lpcfg_parm_string_list(TALLOC_CTX *mem_ctx,
2637 struct loadparm_context *lp_ctx,
2638 struct loadparm_service *service,
2639 const char *type,
2640 const char *option, const char *separator)
2642 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
2644 if (value != NULL)
2645 return (const char **)str_list_make(mem_ctx, value, separator);
2647 return NULL;
2651 * Return parametric option from a given service. Type is a part of option before ':'
2652 * Parametric option has following syntax: 'Type: option = value'
2655 int lpcfg_parm_int(struct loadparm_context *lp_ctx,
2656 struct loadparm_service *service, const char *type,
2657 const char *option, int default_v)
2659 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
2661 if (value)
2662 return lp_int(value);
2664 return default_v;
2668 * Return parametric option from a given service. Type is a part of
2669 * option before ':'.
2670 * Parametric option has following syntax: 'Type: option = value'.
2673 int lpcfg_parm_bytes(struct loadparm_context *lp_ctx,
2674 struct loadparm_service *service, const char *type,
2675 const char *option, int default_v)
2677 uint64_t bval;
2679 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
2681 if (value && conv_str_size_error(value, &bval)) {
2682 if (bval <= INT_MAX) {
2683 return (int)bval;
2687 return default_v;
2691 * Return parametric option from a given service.
2692 * Type is a part of option before ':'
2693 * Parametric option has following syntax: 'Type: option = value'
2695 unsigned long lpcfg_parm_ulong(struct loadparm_context *lp_ctx,
2696 struct loadparm_service *service, const char *type,
2697 const char *option, unsigned long default_v)
2699 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
2701 if (value)
2702 return lp_ulong(value);
2704 return default_v;
2707 long lpcfg_parm_long(struct loadparm_context *lp_ctx,
2708 struct loadparm_service *service, const char *type,
2709 const char *option, long default_v)
2711 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
2713 if (value)
2714 return lp_long(value);
2716 return default_v;
2719 double lpcfg_parm_double(struct loadparm_context *lp_ctx,
2720 struct loadparm_service *service, const char *type,
2721 const char *option, double default_v)
2723 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
2725 if (value != NULL)
2726 return lp_double(value);
2728 return default_v;
2732 * Return parametric option from a given service. Type is a part of option before ':'
2733 * Parametric option has following syntax: 'Type: option = value'
2736 bool lpcfg_parm_bool(struct loadparm_context *lp_ctx,
2737 struct loadparm_service *service, const char *type,
2738 const char *option, bool default_v)
2740 const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
2742 if (value != NULL)
2743 return lp_bool(value);
2745 return default_v;
2750 * Initialise a service to the defaults.
2753 static struct loadparm_service *init_service(TALLOC_CTX *mem_ctx, struct loadparm_service *sDefault)
2755 struct loadparm_service *pservice =
2756 talloc_zero(mem_ctx, struct loadparm_service);
2757 copy_service(pservice, sDefault, NULL);
2758 return pservice;
2762 * Set a string value, deallocating any existing space, and allocing the space
2763 * for the string
2765 static bool lpcfg_string_set(TALLOC_CTX *mem_ctx, char **dest, const char *src)
2767 talloc_free(*dest);
2769 if (src == NULL)
2770 src = "";
2772 *dest = talloc_strdup(mem_ctx, src);
2773 if ((*dest) == NULL) {
2774 DEBUG(0,("Out of memory in string_set\n"));
2775 return false;
2778 return true;
2782 * Set a string value, deallocating any existing space, and allocing the space
2783 * for the string
2785 static bool lpcfg_string_set_upper(TALLOC_CTX *mem_ctx, char **dest, const char *src)
2787 talloc_free(*dest);
2789 if (src == NULL)
2790 src = "";
2792 *dest = strupper_talloc(mem_ctx, src);
2793 if ((*dest) == NULL) {
2794 DEBUG(0,("Out of memory in string_set_upper\n"));
2795 return false;
2798 return true;
2804 * Add a new service to the services array initialising it with the given
2805 * service.
2808 struct loadparm_service *lpcfg_add_service(struct loadparm_context *lp_ctx,
2809 const struct loadparm_service *pservice,
2810 const char *name)
2812 int i;
2813 struct loadparm_service tservice;
2814 int num_to_alloc = lp_ctx->iNumServices + 1;
2815 struct parmlist_entry *data, *pdata;
2817 if (pservice == NULL) {
2818 pservice = lp_ctx->sDefault;
2821 tservice = *pservice;
2823 /* it might already exist */
2824 if (name) {
2825 struct loadparm_service *service = getservicebyname(lp_ctx,
2826 name);
2827 if (service != NULL) {
2828 /* Clean all parametric options for service */
2829 /* They will be added during parsing again */
2830 data = service->param_opt;
2831 while (data) {
2832 pdata = data->next;
2833 talloc_free(data);
2834 data = pdata;
2836 service->param_opt = NULL;
2837 return service;
2841 /* find an invalid one */
2842 for (i = 0; i < lp_ctx->iNumServices; i++)
2843 if (lp_ctx->services[i] == NULL)
2844 break;
2846 /* if not, then create one */
2847 if (i == lp_ctx->iNumServices) {
2848 struct loadparm_service **tsp;
2850 tsp = talloc_realloc(lp_ctx, lp_ctx->services, struct loadparm_service *, num_to_alloc);
2852 if (!tsp) {
2853 DEBUG(0,("lpcfg_add_service: failed to enlarge services!\n"));
2854 return NULL;
2855 } else {
2856 lp_ctx->services = tsp;
2857 lp_ctx->services[lp_ctx->iNumServices] = NULL;
2860 lp_ctx->iNumServices++;
2863 lp_ctx->services[i] = init_service(lp_ctx->services, lp_ctx->sDefault);
2864 if (lp_ctx->services[i] == NULL) {
2865 DEBUG(0,("lpcfg_add_service: out of memory!\n"));
2866 return NULL;
2868 copy_service(lp_ctx->services[i], &tservice, NULL);
2869 if (name != NULL)
2870 lpcfg_string_set(lp_ctx->services[i], &lp_ctx->services[i]->szService, name);
2871 return lp_ctx->services[i];
2875 * Add a new home service, with the specified home directory, defaults coming
2876 * from service ifrom.
2879 bool lpcfg_add_home(struct loadparm_context *lp_ctx,
2880 const char *pszHomename,
2881 struct loadparm_service *default_service,
2882 const char *user, const char *pszHomedir)
2884 struct loadparm_service *service;
2886 service = lpcfg_add_service(lp_ctx, default_service, pszHomename);
2888 if (service == NULL)
2889 return false;
2891 if (!(*(default_service->szPath))
2892 || strequal(default_service->szPath, lp_ctx->sDefault->szPath)) {
2893 service->szPath = talloc_strdup(service, pszHomedir);
2894 } else {
2895 service->szPath = string_sub_talloc(service, lpcfg_pathname(default_service, lp_ctx->sDefault), "%H", pszHomedir);
2898 if (!(*(service->comment))) {
2899 service->comment = talloc_asprintf(service, "Home directory of %s", user);
2901 service->bAvailable = default_service->bAvailable;
2902 service->bBrowseable = default_service->bBrowseable;
2904 DEBUG(3, ("adding home's share [%s] for user '%s' at '%s'\n",
2905 pszHomename, user, service->szPath));
2907 return true;
2911 * Add a new printer service, with defaults coming from service iFrom.
2914 bool lpcfg_add_printer(struct loadparm_context *lp_ctx,
2915 const char *pszPrintername,
2916 struct loadparm_service *default_service)
2918 const char *comment = "From Printcap";
2919 struct loadparm_service *service;
2920 service = lpcfg_add_service(lp_ctx, default_service, pszPrintername);
2922 if (service == NULL)
2923 return false;
2925 /* note that we do NOT default the availability flag to True - */
2926 /* we take it from the default service passed. This allows all */
2927 /* dynamic printers to be disabled by disabling the [printers] */
2928 /* entry (if/when the 'available' keyword is implemented!). */
2930 /* the printer name is set to the service name. */
2931 lpcfg_string_set(service, &service->szPrintername, pszPrintername);
2932 lpcfg_string_set(service, &service->comment, comment);
2933 service->bBrowseable = default_service->bBrowseable;
2934 /* Printers cannot be read_only. */
2935 service->bRead_only = false;
2936 /* Printer services must be printable. */
2937 service->bPrint_ok = true;
2939 DEBUG(3, ("adding printer service %s\n", pszPrintername));
2941 return true;
2945 * Map a parameter's string representation to something we can use.
2946 * Returns False if the parameter string is not recognised, else TRUE.
2949 static int map_parameter(const char *pszParmName)
2951 int iIndex;
2953 if (*pszParmName == '-')
2954 return -1;
2956 for (iIndex = 0; parm_table[iIndex].label; iIndex++)
2957 if (strwicmp(parm_table[iIndex].label, pszParmName) == 0)
2958 return iIndex;
2960 /* Warn only if it isn't parametric option */
2961 if (strchr(pszParmName, ':') == NULL)
2962 DEBUG(0, ("Unknown parameter encountered: \"%s\"\n", pszParmName));
2963 /* We do return 'fail' for parametric options as well because they are
2964 stored in different storage
2966 return -1;
2971 return the parameter structure for a parameter
2973 struct parm_struct *lpcfg_parm_struct(struct loadparm_context *lp_ctx, const char *name)
2975 int parmnum;
2977 if (lp_ctx->s3_fns) {
2978 return lp_ctx->s3_fns->get_parm_struct(name);
2981 parmnum = map_parameter(name);
2982 if (parmnum == -1) return NULL;
2983 return &parm_table[parmnum];
2987 return the parameter pointer for a parameter
2989 void *lpcfg_parm_ptr(struct loadparm_context *lp_ctx,
2990 struct loadparm_service *service, struct parm_struct *parm)
2992 if (lp_ctx->s3_fns) {
2993 return lp_ctx->s3_fns->get_parm_ptr(service, parm);
2996 if (service == NULL) {
2997 if (parm->p_class == P_LOCAL)
2998 return ((char *)lp_ctx->sDefault)+parm->offset;
2999 else if (parm->p_class == P_GLOBAL)
3000 return ((char *)lp_ctx->globals)+parm->offset;
3001 else return NULL;
3002 } else {
3003 return ((char *)service) + parm->offset;
3008 return the parameter pointer for a parameter
3010 bool lpcfg_parm_is_cmdline(struct loadparm_context *lp_ctx, const char *name)
3012 int parmnum;
3014 if (lp_ctx->s3_fns) {
3015 struct parm_struct *parm = lp_ctx->s3_fns->get_parm_struct(name);
3016 if (parm) {
3017 return parm->flags & FLAG_CMDLINE;
3019 return false;
3022 parmnum = map_parameter(name);
3023 if (parmnum == -1) return false;
3025 return lp_ctx->flags[parmnum] & FLAG_CMDLINE;
3029 * Find a service by name. Otherwise works like get_service.
3032 static struct loadparm_service *getservicebyname(struct loadparm_context *lp_ctx,
3033 const char *pszServiceName)
3035 int iService;
3037 if (lp_ctx->s3_fns) {
3038 return lp_ctx->s3_fns->get_service(pszServiceName);
3041 for (iService = lp_ctx->iNumServices - 1; iService >= 0; iService--)
3042 if (lp_ctx->services[iService] != NULL &&
3043 strwicmp(lp_ctx->services[iService]->szService, pszServiceName) == 0) {
3044 return lp_ctx->services[iService];
3047 return NULL;
3051 * Copy a service structure to another.
3052 * If pcopymapDest is NULL then copy all fields
3055 static void copy_service(struct loadparm_service *pserviceDest,
3056 struct loadparm_service *pserviceSource,
3057 struct bitmap *pcopymapDest)
3059 int i;
3060 bool bcopyall = (pcopymapDest == NULL);
3061 struct parmlist_entry *data, *pdata, *paramo;
3062 bool not_added;
3064 for (i = 0; parm_table[i].label; i++)
3065 if (parm_table[i].p_class == P_LOCAL &&
3066 (bcopyall || bitmap_query(pcopymapDest, i))) {
3067 void *src_ptr =
3068 ((char *)pserviceSource) + parm_table[i].offset;
3069 void *dest_ptr =
3070 ((char *)pserviceDest) + parm_table[i].offset;
3072 switch (parm_table[i].type) {
3073 case P_BOOL:
3074 *(bool *)dest_ptr = *(bool *)src_ptr;
3075 break;
3077 case P_INTEGER:
3078 case P_BYTES:
3079 case P_OCTAL:
3080 case P_ENUM:
3081 *(int *)dest_ptr = *(int *)src_ptr;
3082 break;
3084 case P_STRING:
3085 lpcfg_string_set(pserviceDest,
3086 (char **)dest_ptr,
3087 *(char **)src_ptr);
3088 break;
3090 case P_USTRING:
3091 lpcfg_string_set_upper(pserviceDest,
3092 (char **)dest_ptr,
3093 *(char **)src_ptr);
3094 break;
3095 case P_LIST:
3096 *(const char ***)dest_ptr = (const char **)str_list_copy(pserviceDest,
3097 *(const char ***)src_ptr);
3098 break;
3099 default:
3100 break;
3104 if (bcopyall) {
3105 init_copymap(pserviceDest);
3106 if (pserviceSource->copymap)
3107 bitmap_copy(pserviceDest->copymap,
3108 pserviceSource->copymap);
3111 data = pserviceSource->param_opt;
3112 while (data) {
3113 not_added = true;
3114 pdata = pserviceDest->param_opt;
3115 /* Traverse destination */
3116 while (pdata) {
3117 /* If we already have same option, override it */
3118 if (strcmp(pdata->key, data->key) == 0) {
3119 talloc_free(pdata->value);
3120 pdata->value = talloc_strdup(pdata,
3121 data->value);
3122 not_added = false;
3123 break;
3125 pdata = pdata->next;
3127 if (not_added) {
3128 paramo = talloc_zero(pserviceDest, struct parmlist_entry);
3129 if (paramo == NULL)
3130 smb_panic("OOM");
3131 paramo->key = talloc_strdup(paramo, data->key);
3132 paramo->value = talloc_strdup(paramo, data->value);
3133 DLIST_ADD(pserviceDest->param_opt, paramo);
3135 data = data->next;
3140 * Check a service for consistency. Return False if the service is in any way
3141 * incomplete or faulty, else True.
3143 static bool lpcfg_service_ok(struct loadparm_service *service)
3145 bool bRetval;
3147 bRetval = true;
3148 if (service->szService[0] == '\0') {
3149 DEBUG(0, ("The following message indicates an internal error:\n"));
3150 DEBUG(0, ("No service name in service entry.\n"));
3151 bRetval = false;
3154 /* The [printers] entry MUST be printable. I'm all for flexibility, but */
3155 /* I can't see why you'd want a non-printable printer service... */
3156 if (strwicmp(service->szService, PRINTERS_NAME) == 0) {
3157 if (!service->bPrint_ok) {
3158 DEBUG(0, ("WARNING: [%s] service MUST be printable!\n",
3159 service->szService));
3160 service->bPrint_ok = true;
3162 /* [printers] service must also be non-browsable. */
3163 if (service->bBrowseable)
3164 service->bBrowseable = false;
3167 /* If a service is flagged unavailable, log the fact at level 0. */
3168 if (!service->bAvailable)
3169 DEBUG(1, ("NOTE: Service %s is flagged unavailable.\n",
3170 service->szService));
3172 return bRetval;
3176 /*******************************************************************
3177 Keep a linked list of all config files so we know when one has changed
3178 it's date and needs to be reloaded.
3179 ********************************************************************/
3181 static void add_to_file_list(struct loadparm_context *lp_ctx,
3182 const char *fname, const char *subfname)
3184 struct file_lists *f = lp_ctx->file_lists;
3186 while (f) {
3187 if (f->name && !strcmp(f->name, fname))
3188 break;
3189 f = f->next;
3192 if (!f) {
3193 f = talloc(lp_ctx, struct file_lists);
3194 if (!f)
3195 return;
3196 f->next = lp_ctx->file_lists;
3197 f->name = talloc_strdup(f, fname);
3198 if (!f->name) {
3199 talloc_free(f);
3200 return;
3202 f->subfname = talloc_strdup(f, subfname);
3203 if (!f->subfname) {
3204 talloc_free(f);
3205 return;
3207 lp_ctx->file_lists = f;
3208 f->modtime = file_modtime(subfname);
3209 } else {
3210 time_t t = file_modtime(subfname);
3211 if (t)
3212 f->modtime = t;
3216 /*******************************************************************
3217 Check if a config file has changed date.
3218 ********************************************************************/
3219 bool lpcfg_file_list_changed(struct loadparm_context *lp_ctx)
3221 struct file_lists *f;
3222 DEBUG(6, ("lp_file_list_changed()\n"));
3224 for (f = lp_ctx->file_lists; f != NULL; f = f->next) {
3225 char *n2;
3226 time_t mod_time;
3228 n2 = standard_sub_basic(lp_ctx, f->name);
3230 DEBUGADD(6, ("file %s -> %s last mod_time: %s\n",
3231 f->name, n2, ctime(&f->modtime)));
3233 mod_time = file_modtime(n2);
3235 if (mod_time && ((f->modtime != mod_time) || (f->subfname == NULL) || (strcmp(n2, f->subfname) != 0))) {
3236 DEBUGADD(6, ("file %s modified: %s\n", n2,
3237 ctime(&mod_time)));
3238 f->modtime = mod_time;
3239 talloc_free(f->subfname);
3240 f->subfname = talloc_strdup(f, n2);
3241 return true;
3244 return false;
3247 /***************************************************************************
3248 Handle the "realm" parameter
3249 ***************************************************************************/
3251 static bool handle_realm(struct loadparm_context *lp_ctx, int unused,
3252 const char *pszParmValue, char **ptr)
3254 lpcfg_string_set(lp_ctx, ptr, pszParmValue);
3256 talloc_free(lp_ctx->globals->szRealm_upper);
3257 talloc_free(lp_ctx->globals->szRealm_lower);
3259 lp_ctx->globals->szRealm_upper = strupper_talloc(lp_ctx, pszParmValue);
3260 lp_ctx->globals->szRealm_lower = strlower_talloc(lp_ctx, pszParmValue);
3262 return true;
3265 /***************************************************************************
3266 Handle the include operation.
3267 ***************************************************************************/
3269 static bool handle_include(struct loadparm_context *lp_ctx, int unused,
3270 const char *pszParmValue, char **ptr)
3272 char *fname = standard_sub_basic(lp_ctx, pszParmValue);
3274 add_to_file_list(lp_ctx, pszParmValue, fname);
3276 lpcfg_string_set(lp_ctx, ptr, fname);
3278 if (file_exist(fname))
3279 return pm_process(fname, do_section, do_parameter, lp_ctx);
3281 DEBUG(2, ("Can't find include file %s\n", fname));
3283 return false;
3286 /***************************************************************************
3287 Handle the interpretation of the copy parameter.
3288 ***************************************************************************/
3290 static bool handle_copy(struct loadparm_context *lp_ctx, int unused,
3291 const char *pszParmValue, char **ptr)
3293 bool bRetval;
3294 struct loadparm_service *serviceTemp;
3296 lpcfg_string_set(lp_ctx, ptr, pszParmValue);
3298 bRetval = false;
3300 DEBUG(3, ("Copying service from service %s\n", pszParmValue));
3302 if ((serviceTemp = getservicebyname(lp_ctx, pszParmValue)) != NULL) {
3303 if (serviceTemp == lp_ctx->currentService) {
3304 DEBUG(0, ("Can't copy service %s - unable to copy self!\n", pszParmValue));
3305 } else {
3306 copy_service(lp_ctx->currentService,
3307 serviceTemp,
3308 lp_ctx->currentService->copymap);
3309 bRetval = true;
3311 } else {
3312 DEBUG(0, ("Unable to copy service - source not found: %s\n",
3313 pszParmValue));
3314 bRetval = false;
3317 return bRetval;
3320 static bool handle_debuglevel(struct loadparm_context *lp_ctx, int unused,
3321 const char *pszParmValue, char **ptr)
3324 lpcfg_string_set(lp_ctx, ptr, pszParmValue);
3325 if (lp_ctx->global) {
3326 return debug_parse_levels(pszParmValue);
3328 return true;
3331 static bool handle_logfile(struct loadparm_context *lp_ctx, int unused,
3332 const char *pszParmValue, char **ptr)
3334 debug_set_logfile(pszParmValue);
3335 if (lp_ctx->global) {
3336 lpcfg_string_set(lp_ctx, ptr, pszParmValue);
3338 return true;
3341 /***************************************************************************
3342 Initialise a copymap.
3343 ***************************************************************************/
3345 static void init_copymap(struct loadparm_service *pservice)
3347 int i;
3349 TALLOC_FREE(pservice->copymap);
3351 pservice->copymap = bitmap_talloc(NULL, NUMPARAMETERS);
3352 if (!pservice->copymap)
3353 DEBUG(0,
3354 ("Couldn't allocate copymap!! (size %d)\n",
3355 (int)NUMPARAMETERS));
3356 else
3357 for (i = 0; i < NUMPARAMETERS; i++)
3358 bitmap_set(pservice->copymap, i);
3362 * Process a parametric option
3364 static bool lp_do_parameter_parametric(struct loadparm_context *lp_ctx,
3365 struct loadparm_service *service,
3366 const char *pszParmName,
3367 const char *pszParmValue, int flags)
3369 struct parmlist_entry *paramo, *data;
3370 char *name;
3371 TALLOC_CTX *mem_ctx;
3373 while (isspace((unsigned char)*pszParmName)) {
3374 pszParmName++;
3377 name = strlower_talloc(lp_ctx, pszParmName);
3378 if (!name) return false;
3380 if (service == NULL) {
3381 data = lp_ctx->globals->param_opt;
3382 mem_ctx = lp_ctx->globals;
3383 } else {
3384 data = service->param_opt;
3385 mem_ctx = service;
3388 /* Traverse destination */
3389 for (paramo=data; paramo; paramo=paramo->next) {
3390 /* If we already have the option set, override it unless
3391 it was a command line option and the new one isn't */
3392 if (strcmp(paramo->key, name) == 0) {
3393 if ((paramo->priority & FLAG_CMDLINE) &&
3394 !(flags & FLAG_CMDLINE)) {
3395 talloc_free(name);
3396 return true;
3399 talloc_free(paramo->value);
3400 paramo->value = talloc_strdup(paramo, pszParmValue);
3401 paramo->priority = flags;
3402 talloc_free(name);
3403 return true;
3407 paramo = talloc_zero(mem_ctx, struct parmlist_entry);
3408 if (!paramo)
3409 smb_panic("OOM");
3410 paramo->key = talloc_strdup(paramo, name);
3411 paramo->value = talloc_strdup(paramo, pszParmValue);
3412 paramo->priority = flags;
3413 if (service == NULL) {
3414 DLIST_ADD(lp_ctx->globals->param_opt, paramo);
3415 } else {
3416 DLIST_ADD(service->param_opt, paramo);
3419 talloc_free(name);
3421 return true;
3424 static bool set_variable(TALLOC_CTX *mem_ctx, int parmnum, void *parm_ptr,
3425 const char *pszParmName, const char *pszParmValue,
3426 struct loadparm_context *lp_ctx, bool on_globals)
3428 int i;
3429 /* if it is a special case then go ahead */
3430 if (parm_table[parmnum].special) {
3431 bool ret;
3432 ret = parm_table[parmnum].special(lp_ctx, -1, pszParmValue,
3433 (char **)parm_ptr);
3434 if (!ret) {
3435 return false;
3437 goto mark_non_default;
3440 /* now switch on the type of variable it is */
3441 switch (parm_table[parmnum].type)
3443 case P_BOOL: {
3444 bool b;
3445 if (!set_boolean(pszParmValue, &b)) {
3446 DEBUG(0,("lp_do_parameter(%s): value is not boolean!\n", pszParmValue));
3447 return false;
3449 *(bool *)parm_ptr = b;
3451 break;
3453 case P_BOOLREV: {
3454 bool b;
3455 if (!set_boolean(pszParmValue, &b)) {
3456 DEBUG(0,("lp_do_parameter(%s): value is not boolean!\n", pszParmValue));
3457 return false;
3459 *(bool *)parm_ptr = !b;
3461 break;
3463 case P_INTEGER:
3464 *(int *)parm_ptr = atoi(pszParmValue);
3465 break;
3467 case P_CHAR:
3468 *(char *)parm_ptr = *pszParmValue;
3469 break;
3471 case P_OCTAL:
3472 *(int *)parm_ptr = strtol(pszParmValue, NULL, 8);
3473 break;
3475 case P_BYTES:
3477 uint64_t val;
3478 if (conv_str_size_error(pszParmValue, &val)) {
3479 if (val <= INT_MAX) {
3480 *(int *)parm_ptr = (int)val;
3481 break;
3485 DEBUG(0,("lp_do_parameter(%s): value is not "
3486 "a valid size specifier!\n", pszParmValue));
3487 return false;
3490 case P_CMDLIST:
3491 *(const char ***)parm_ptr = (const char **)str_list_make(mem_ctx,
3492 pszParmValue, NULL);
3493 break;
3494 case P_LIST:
3496 char **new_list = str_list_make(mem_ctx,
3497 pszParmValue, NULL);
3498 for (i=0; new_list[i]; i++) {
3499 if (new_list[i][0] == '+' && new_list[i][1]) {
3500 if (!str_list_check(*(const char ***)parm_ptr,
3501 &new_list[i][1])) {
3502 *(const char ***)parm_ptr = str_list_add(*(const char ***)parm_ptr,
3503 &new_list[i][1]);
3505 } else if (new_list[i][0] == '-' && new_list[i][1]) {
3506 str_list_remove(*(const char ***)parm_ptr,
3507 &new_list[i][1]);
3508 } else {
3509 if (i != 0) {
3510 DEBUG(0, ("Unsupported list syntax for: %s = %s\n",
3511 pszParmName, pszParmValue));
3512 return false;
3514 *(const char ***)parm_ptr = (const char **) new_list;
3515 break;
3518 break;
3520 case P_STRING:
3521 lpcfg_string_set(mem_ctx, (char **)parm_ptr, pszParmValue);
3522 break;
3524 case P_USTRING:
3525 lpcfg_string_set_upper(mem_ctx, (char **)parm_ptr, pszParmValue);
3526 break;
3528 case P_ENUM:
3529 for (i = 0; parm_table[parmnum].enum_list[i].name; i++) {
3530 if (strequal
3531 (pszParmValue,
3532 parm_table[parmnum].enum_list[i].name)) {
3533 *(int *)parm_ptr =
3534 parm_table[parmnum].
3535 enum_list[i].value;
3536 break;
3539 if (!parm_table[parmnum].enum_list[i].name) {
3540 DEBUG(0,("Unknown enumerated value '%s' for '%s'\n",
3541 pszParmValue, pszParmName));
3542 return false;
3544 break;
3546 case P_SEP:
3547 break;
3550 mark_non_default:
3551 if (on_globals && (lp_ctx->flags[parmnum] & FLAG_DEFAULT)) {
3552 lp_ctx->flags[parmnum] &= ~FLAG_DEFAULT;
3553 /* we have to also unset FLAG_DEFAULT on aliases */
3554 for (i=parmnum-1;i>=0 && parm_table[i].offset == parm_table[parmnum].offset;i--) {
3555 lp_ctx->flags[i] &= ~FLAG_DEFAULT;
3557 for (i=parmnum+1;i<NUMPARAMETERS && parm_table[i].offset == parm_table[parmnum].offset;i++) {
3558 lp_ctx->flags[i] &= ~FLAG_DEFAULT;
3561 return true;
3565 bool lpcfg_do_global_parameter(struct loadparm_context *lp_ctx,
3566 const char *pszParmName, const char *pszParmValue)
3568 int parmnum = map_parameter(pszParmName);
3569 void *parm_ptr;
3571 if (parmnum < 0) {
3572 if (strchr(pszParmName, ':')) {
3573 return lp_do_parameter_parametric(lp_ctx, NULL, pszParmName, pszParmValue, 0);
3575 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName));
3576 return true;
3579 /* if the flag has been set on the command line, then don't allow override,
3580 but don't report an error */
3581 if (lp_ctx->flags[parmnum] & FLAG_CMDLINE) {
3582 return true;
3585 parm_ptr = lpcfg_parm_ptr(lp_ctx, NULL, &parm_table[parmnum]);
3587 return set_variable(lp_ctx->globals, parmnum, parm_ptr,
3588 pszParmName, pszParmValue, lp_ctx, true);
3591 bool lpcfg_do_service_parameter(struct loadparm_context *lp_ctx,
3592 struct loadparm_service *service,
3593 const char *pszParmName, const char *pszParmValue)
3595 void *parm_ptr;
3596 int i;
3597 int parmnum = map_parameter(pszParmName);
3599 if (parmnum < 0) {
3600 if (strchr(pszParmName, ':')) {
3601 return lp_do_parameter_parametric(lp_ctx, service, pszParmName, pszParmValue, 0);
3603 DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName));
3604 return true;
3607 /* if the flag has been set on the command line, then don't allow override,
3608 but don't report an error */
3609 if (lp_ctx->flags[parmnum] & FLAG_CMDLINE) {
3610 return true;
3613 if (parm_table[parmnum].p_class == P_GLOBAL) {
3614 DEBUG(0,
3615 ("Global parameter %s found in service section!\n",
3616 pszParmName));
3617 return true;
3619 parm_ptr = ((char *)service) + parm_table[parmnum].offset;
3621 if (!service->copymap)
3622 init_copymap(service);
3624 /* this handles the aliases - set the copymap for other
3625 * entries with the same data pointer */
3626 for (i = 0; parm_table[i].label; i++)
3627 if (parm_table[i].offset == parm_table[parmnum].offset &&
3628 parm_table[i].p_class == parm_table[parmnum].p_class)
3629 bitmap_clear(service->copymap, i);
3631 return set_variable(service, parmnum, parm_ptr, pszParmName,
3632 pszParmValue, lp_ctx, false);
3636 * Process a parameter.
3639 static bool do_parameter(const char *pszParmName, const char *pszParmValue,
3640 void *userdata)
3642 struct loadparm_context *lp_ctx = (struct loadparm_context *)userdata;
3644 if (lp_ctx->bInGlobalSection)
3645 return lpcfg_do_global_parameter(lp_ctx, pszParmName,
3646 pszParmValue);
3647 else
3648 return lpcfg_do_service_parameter(lp_ctx, lp_ctx->currentService,
3649 pszParmName, pszParmValue);
3653 variable argument do parameter
3655 bool lpcfg_do_global_parameter_var(struct loadparm_context *lp_ctx, const char *pszParmName, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4);
3656 bool lpcfg_do_global_parameter_var(struct loadparm_context *lp_ctx,
3657 const char *pszParmName, const char *fmt, ...)
3659 char *s;
3660 bool ret;
3661 va_list ap;
3663 va_start(ap, fmt);
3664 s = talloc_vasprintf(NULL, fmt, ap);
3665 va_end(ap);
3666 ret = lpcfg_do_global_parameter(lp_ctx, pszParmName, s);
3667 talloc_free(s);
3668 return ret;
3673 set a parameter from the commandline - this is called from command line parameter
3674 parsing code. It sets the parameter then marks the parameter as unable to be modified
3675 by smb.conf processing
3677 bool lpcfg_set_cmdline(struct loadparm_context *lp_ctx, const char *pszParmName,
3678 const char *pszParmValue)
3680 int parmnum;
3681 int i;
3683 if (lp_ctx->s3_fns) {
3684 return lp_ctx->s3_fns->set_cmdline(pszParmName, pszParmValue);
3687 parmnum = map_parameter(pszParmName);
3689 while (isspace((unsigned char)*pszParmValue)) pszParmValue++;
3692 if (parmnum < 0 && strchr(pszParmName, ':')) {
3693 /* set a parametric option */
3694 return lp_do_parameter_parametric(lp_ctx, NULL, pszParmName,
3695 pszParmValue, FLAG_CMDLINE);
3698 if (parmnum < 0) {
3699 DEBUG(0,("Unknown option '%s'\n", pszParmName));
3700 return false;
3703 /* reset the CMDLINE flag in case this has been called before */
3704 lp_ctx->flags[parmnum] &= ~FLAG_CMDLINE;
3706 if (!lpcfg_do_global_parameter(lp_ctx, pszParmName, pszParmValue)) {
3707 return false;
3710 lp_ctx->flags[parmnum] |= FLAG_CMDLINE;
3712 /* we have to also set FLAG_CMDLINE on aliases */
3713 for (i=parmnum-1;i>=0 && parm_table[i].offset == parm_table[parmnum].offset;i--) {
3714 lp_ctx->flags[i] |= FLAG_CMDLINE;
3716 for (i=parmnum+1;i<NUMPARAMETERS && parm_table[i].offset == parm_table[parmnum].offset;i++) {
3717 lp_ctx->flags[i] |= FLAG_CMDLINE;
3720 return true;
3724 set a option from the commandline in 'a=b' format. Use to support --option
3726 bool lpcfg_set_option(struct loadparm_context *lp_ctx, const char *option)
3728 char *p, *s;
3729 bool ret;
3731 s = talloc_strdup(NULL, option);
3732 if (!s) {
3733 return false;
3736 p = strchr(s, '=');
3737 if (!p) {
3738 talloc_free(s);
3739 return false;
3742 *p = 0;
3744 ret = lpcfg_set_cmdline(lp_ctx, s, p+1);
3745 talloc_free(s);
3746 return ret;
3750 #define BOOLSTR(b) ((b) ? "Yes" : "No")
3753 * Print a parameter of the specified type.
3756 static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
3758 /* For the seperation of lists values that we print below */
3759 const char *list_sep = ", ";
3760 int i;
3761 switch (p->type)
3763 case P_ENUM:
3764 for (i = 0; p->enum_list[i].name; i++) {
3765 if (*(int *)ptr == p->enum_list[i].value) {
3766 fprintf(f, "%s",
3767 p->enum_list[i].name);
3768 break;
3771 break;
3773 case P_BOOL:
3774 fprintf(f, "%s", BOOLSTR(*(bool *)ptr));
3775 break;
3777 case P_BOOLREV:
3778 fprintf(f, "%s", BOOLSTR(!*(bool *)ptr));
3779 break;
3781 case P_INTEGER:
3782 case P_BYTES:
3783 fprintf(f, "%d", *(int *)ptr);
3784 break;
3786 case P_CHAR:
3787 fprintf(f, "%c", *(char *)ptr);
3788 break;
3790 case P_OCTAL: {
3791 int val = *(int *)ptr;
3792 if (val == -1) {
3793 fprintf(f, "-1");
3794 } else {
3795 fprintf(f, "0%o", val);
3797 break;
3800 case P_CMDLIST:
3801 list_sep = " ";
3802 /* fall through */
3803 case P_LIST:
3804 if ((char ***)ptr && *(char ***)ptr) {
3805 char **list = *(char ***)ptr;
3806 for (; *list; list++) {
3807 /* surround strings with whitespace in double quotes */
3808 if (*(list+1) == NULL) {
3809 /* last item, no extra separator */
3810 list_sep = "";
3812 if ( strchr_m( *list, ' ' ) ) {
3813 fprintf(f, "\"%s\"%s", *list, list_sep);
3814 } else {
3815 fprintf(f, "%s%s", *list, list_sep);
3819 break;
3821 case P_STRING:
3822 case P_USTRING:
3823 if (*(char **)ptr) {
3824 fprintf(f, "%s", *(char **)ptr);
3826 break;
3827 case P_SEP:
3828 break;
3833 * Check if two parameters are equal.
3836 static bool equal_parameter(parm_type type, void *ptr1, void *ptr2)
3838 switch (type) {
3839 case P_BOOL:
3840 case P_BOOLREV:
3841 return (*((bool *)ptr1) == *((bool *)ptr2));
3843 case P_INTEGER:
3844 case P_ENUM:
3845 case P_OCTAL:
3846 case P_BYTES:
3847 return (*((int *)ptr1) == *((int *)ptr2));
3849 case P_CHAR:
3850 return (*((char *)ptr1) == *((char *)ptr2));
3852 case P_LIST:
3853 case P_CMDLIST:
3854 return str_list_equal(*(const char ***)ptr1, *(const char ***)ptr2);
3856 case P_STRING:
3857 case P_USTRING:
3859 char *p1 = *(char **)ptr1, *p2 = *(char **)ptr2;
3860 if (p1 && !*p1)
3861 p1 = NULL;
3862 if (p2 && !*p2)
3863 p2 = NULL;
3864 return (p1 == p2 || strequal(p1, p2));
3866 case P_SEP:
3867 break;
3869 return false;
3873 * Process a new section (service).
3875 * At this stage all sections are services.
3876 * Later we'll have special sections that permit server parameters to be set.
3877 * Returns True on success, False on failure.
3880 static bool do_section(const char *pszSectionName, void *userdata)
3882 struct loadparm_context *lp_ctx = (struct loadparm_context *)userdata;
3883 bool bRetval;
3884 bool isglobal = ((strwicmp(pszSectionName, GLOBAL_NAME) == 0) ||
3885 (strwicmp(pszSectionName, GLOBAL_NAME2) == 0));
3886 bRetval = false;
3888 /* if we've just struck a global section, note the fact. */
3889 lp_ctx->bInGlobalSection = isglobal;
3891 /* check for multiple global sections */
3892 if (lp_ctx->bInGlobalSection) {
3893 DEBUG(4, ("Processing section \"[%s]\"\n", pszSectionName));
3894 return true;
3897 /* if we have a current service, tidy it up before moving on */
3898 bRetval = true;
3900 if (lp_ctx->currentService != NULL)
3901 bRetval = lpcfg_service_ok(lp_ctx->currentService);
3903 /* if all is still well, move to the next record in the services array */
3904 if (bRetval) {
3905 /* We put this here to avoid an odd message order if messages are */
3906 /* issued by the post-processing of a previous section. */
3907 DEBUG(4, ("Processing section \"[%s]\"\n", pszSectionName));
3909 if ((lp_ctx->currentService = lpcfg_add_service(lp_ctx, lp_ctx->sDefault,
3910 pszSectionName))
3911 == NULL) {
3912 DEBUG(0, ("Failed to add a new service\n"));
3913 return false;
3917 return bRetval;
3922 * Determine if a particular base parameter is currently set to the default value.
3925 static bool is_default(struct loadparm_service *sDefault, int i)
3927 void *def_ptr = ((char *)sDefault) + parm_table[i].offset;
3928 if (!defaults_saved)
3929 return false;
3930 switch (parm_table[i].type) {
3931 case P_CMDLIST:
3932 case P_LIST:
3933 return str_list_equal((const char **)parm_table[i].def.lvalue,
3934 (const char **)def_ptr);
3935 case P_STRING:
3936 case P_USTRING:
3937 return strequal(parm_table[i].def.svalue,
3938 *(char **)def_ptr);
3939 case P_BOOL:
3940 case P_BOOLREV:
3941 return parm_table[i].def.bvalue ==
3942 *(bool *)def_ptr;
3943 case P_INTEGER:
3944 case P_CHAR:
3945 case P_OCTAL:
3946 case P_BYTES:
3947 case P_ENUM:
3948 return parm_table[i].def.ivalue ==
3949 *(int *)def_ptr;
3950 case P_SEP:
3951 break;
3953 return false;
3957 *Display the contents of the global structure.
3960 static void dump_globals(struct loadparm_context *lp_ctx, FILE *f,
3961 bool show_defaults)
3963 int i;
3964 struct parmlist_entry *data;
3966 fprintf(f, "# Global parameters\n[global]\n");
3968 for (i = 0; parm_table[i].label; i++)
3969 if (parm_table[i].p_class == P_GLOBAL &&
3970 (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset))) {
3971 if (!show_defaults && (lp_ctx->flags[i] & FLAG_DEFAULT))
3972 continue;
3973 fprintf(f, "\t%s = ", parm_table[i].label);
3974 print_parameter(&parm_table[i], lpcfg_parm_ptr(lp_ctx, NULL, &parm_table[i]), f);
3975 fprintf(f, "\n");
3977 if (lp_ctx->globals->param_opt != NULL) {
3978 for (data = lp_ctx->globals->param_opt; data;
3979 data = data->next) {
3980 if (!show_defaults && (data->priority & FLAG_DEFAULT)) {
3981 continue;
3983 fprintf(f, "\t%s = %s\n", data->key, data->value);
3990 * Display the contents of a single services record.
3993 static void dump_a_service(struct loadparm_service * pService, struct loadparm_service *sDefault, FILE * f,
3994 unsigned int *flags)
3996 int i;
3997 struct parmlist_entry *data;
3999 if (pService != sDefault)
4000 fprintf(f, "\n[%s]\n", pService->szService);
4002 for (i = 0; parm_table[i].label; i++) {
4003 if (parm_table[i].p_class == P_LOCAL &&
4004 (*parm_table[i].label != '-') &&
4005 (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset)))
4007 if (pService == sDefault) {
4008 if (flags && (flags[i] & FLAG_DEFAULT)) {
4009 continue;
4011 if (defaults_saved) {
4012 if (is_default(sDefault, i)) {
4013 continue;
4016 } else {
4017 if (equal_parameter(parm_table[i].type,
4018 ((char *)pService) +
4019 parm_table[i].offset,
4020 ((char *)sDefault) +
4021 parm_table[i].offset))
4022 continue;
4025 fprintf(f, "\t%s = ", parm_table[i].label);
4026 print_parameter(&parm_table[i],
4027 ((char *)pService) + parm_table[i].offset, f);
4028 fprintf(f, "\n");
4031 if (pService->param_opt != NULL) {
4032 for (data = pService->param_opt; data; data = data->next) {
4033 fprintf(f, "\t%s = %s\n", data->key, data->value);
4038 bool lpcfg_dump_a_parameter(struct loadparm_context *lp_ctx,
4039 struct loadparm_service *service,
4040 const char *parm_name, FILE * f)
4042 struct parm_struct *parm;
4043 void *ptr;
4045 parm = lpcfg_parm_struct(lp_ctx, parm_name);
4046 if (!parm) {
4047 return false;
4050 ptr = lpcfg_parm_ptr(lp_ctx, service,parm);
4052 print_parameter(parm, ptr, f);
4053 fprintf(f, "\n");
4054 return true;
4058 * Return info about the next parameter in a service.
4059 * snum==-1 gives the globals.
4060 * Return NULL when out of parameters.
4064 struct parm_struct *lpcfg_next_parameter(struct loadparm_context *lp_ctx, int snum, int *i,
4065 int allparameters)
4067 if (snum == -1) {
4068 /* do the globals */
4069 for (; parm_table[*i].label; (*i)++) {
4070 if ((*parm_table[*i].label == '-'))
4071 continue;
4073 if ((*i) > 0
4074 && (parm_table[*i].offset ==
4075 parm_table[(*i) - 1].offset)
4076 && (parm_table[*i].p_class ==
4077 parm_table[(*i) - 1].p_class))
4078 continue;
4080 return &parm_table[(*i)++];
4082 } else {
4083 struct loadparm_service *pService = lp_ctx->services[snum];
4085 for (; parm_table[*i].label; (*i)++) {
4086 if (parm_table[*i].p_class == P_LOCAL &&
4087 (*parm_table[*i].label != '-') &&
4088 ((*i) == 0 ||
4089 (parm_table[*i].offset !=
4090 parm_table[(*i) - 1].offset)))
4092 if (allparameters ||
4093 !equal_parameter(parm_table[*i].type,
4094 ((char *)pService) +
4095 parm_table[*i].offset,
4096 ((char *)lp_ctx->sDefault) +
4097 parm_table[*i].offset))
4099 return &parm_table[(*i)++];
4105 return NULL;
4110 * Auto-load some home services.
4112 static void lpcfg_add_auto_services(struct loadparm_context *lp_ctx,
4113 const char *str)
4115 return;
4120 * Unload unused services.
4123 void lpcfg_killunused(struct loadparm_context *lp_ctx,
4124 struct smbsrv_connection *smb,
4125 bool (*snumused) (struct smbsrv_connection *, int))
4127 int i;
4128 for (i = 0; i < lp_ctx->iNumServices; i++) {
4129 if (lp_ctx->services[i] == NULL)
4130 continue;
4132 if (!snumused || !snumused(smb, i)) {
4133 talloc_free(lp_ctx->services[i]);
4134 lp_ctx->services[i] = NULL;
4140 static int lpcfg_destructor(struct loadparm_context *lp_ctx)
4142 struct parmlist_entry *data;
4144 if (lp_ctx->refuse_free) {
4145 /* someone is trying to free the
4146 global_loadparm_context.
4147 We can't allow that. */
4148 return -1;
4151 if (lp_ctx->globals->param_opt != NULL) {
4152 struct parmlist_entry *next;
4153 for (data = lp_ctx->globals->param_opt; data; data=next) {
4154 next = data->next;
4155 if (data->priority & FLAG_CMDLINE) continue;
4156 DLIST_REMOVE(lp_ctx->globals->param_opt, data);
4157 talloc_free(data);
4161 return 0;
4165 * Initialise the global parameter structure.
4167 * Note that most callers should use loadparm_init_global() instead
4169 struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
4171 int i;
4172 char *myname;
4173 struct loadparm_context *lp_ctx;
4174 struct parmlist_entry *parm;
4175 char *logfile;
4177 lp_ctx = talloc_zero(mem_ctx, struct loadparm_context);
4178 if (lp_ctx == NULL)
4179 return NULL;
4181 talloc_set_destructor(lp_ctx, lpcfg_destructor);
4182 lp_ctx->bInGlobalSection = true;
4183 lp_ctx->globals = talloc_zero(lp_ctx, struct loadparm_global);
4184 lp_ctx->sDefault = talloc_zero(lp_ctx, struct loadparm_service);
4186 lp_ctx->sDefault->iMaxPrintJobs = 1000;
4187 lp_ctx->sDefault->bAvailable = true;
4188 lp_ctx->sDefault->bBrowseable = true;
4189 lp_ctx->sDefault->bRead_only = true;
4190 lp_ctx->sDefault->bMap_archive = true;
4191 lp_ctx->sDefault->iStrictLocking = true;
4192 lp_ctx->sDefault->bOpLocks = true;
4193 lp_ctx->sDefault->iCreate_mask = 0744;
4194 lp_ctx->sDefault->iCreate_force_mode = 0000;
4195 lp_ctx->sDefault->iDir_mask = 0755;
4196 lp_ctx->sDefault->iDir_force_mode = 0000;
4198 DEBUG(3, ("Initialising global parameters\n"));
4200 for (i = 0; parm_table[i].label; i++) {
4201 if ((parm_table[i].type == P_STRING ||
4202 parm_table[i].type == P_USTRING) &&
4203 !(lp_ctx->flags[i] & FLAG_CMDLINE)) {
4204 char **r;
4205 if (parm_table[i].p_class == P_LOCAL) {
4206 r = (char **)(((char *)lp_ctx->sDefault) + parm_table[i].offset);
4207 } else {
4208 r = (char **)(((char *)lp_ctx->globals) + parm_table[i].offset);
4210 *r = talloc_strdup(lp_ctx, "");
4214 logfile = talloc_asprintf(lp_ctx, "%s/log.samba", dyn_LOGFILEBASE);
4215 lpcfg_do_global_parameter(lp_ctx, "log file", logfile);
4216 talloc_free(logfile);
4218 lpcfg_do_global_parameter(lp_ctx, "log level", "0");
4220 lpcfg_do_global_parameter(lp_ctx, "share backend", "classic");
4222 lpcfg_do_global_parameter(lp_ctx, "server role", "auto");
4223 lpcfg_do_global_parameter(lp_ctx, "domain logons", "No");
4224 lpcfg_do_global_parameter(lp_ctx, "domain master", "Auto");
4226 /* options that can be set on the command line must be initialised via
4227 the slower lpcfg_do_global_parameter() to ensure that FLAG_CMDLINE is obeyed */
4228 #ifdef TCP_NODELAY
4229 lpcfg_do_global_parameter(lp_ctx, "socket options", "TCP_NODELAY");
4230 #endif
4231 lpcfg_do_global_parameter(lp_ctx, "workgroup", DEFAULT_WORKGROUP);
4232 myname = get_myname(lp_ctx);
4233 lpcfg_do_global_parameter(lp_ctx, "netbios name", myname);
4234 talloc_free(myname);
4235 lpcfg_do_global_parameter(lp_ctx, "name resolve order", "wins host bcast");
4237 lpcfg_do_global_parameter(lp_ctx, "fstype", "NTFS");
4239 lpcfg_do_global_parameter(lp_ctx, "ntvfs handler", "unixuid default");
4240 lpcfg_do_global_parameter(lp_ctx, "max connections", "-1");
4242 lpcfg_do_global_parameter(lp_ctx, "dcerpc endpoint servers", "epmapper wkssvc rpcecho samr netlogon lsarpc spoolss drsuapi dssetup unixinfo browser eventlog6 backupkey dnsserver");
4243 lpcfg_do_global_parameter(lp_ctx, "server services", "s3fs rpc nbt wrepl ldap cldap kdc drepl winbind ntp_signd kcc dnsupdate");
4244 /* the winbind method for domain controllers is for both RODC
4245 auth forwarding and for trusted domains */
4246 lpcfg_do_global_parameter(lp_ctx, "private dir", dyn_PRIVATE_DIR);
4247 lpcfg_do_global_parameter(lp_ctx, "registry:HKEY_LOCAL_MACHINE", "hklm.ldb");
4249 /* This hive should be dynamically generated by Samba using
4250 data from the sam, but for the moment leave it in a tdb to
4251 keep regedt32 from popping up an annoying dialog. */
4252 lpcfg_do_global_parameter(lp_ctx, "registry:HKEY_USERS", "hku.ldb");
4254 /* using UTF8 by default allows us to support all chars */
4255 lpcfg_do_global_parameter(lp_ctx, "unix charset", "UTF8");
4257 /* Use codepage 850 as a default for the dos character set */
4258 lpcfg_do_global_parameter(lp_ctx, "dos charset", "CP850");
4261 * Allow the default PASSWD_CHAT to be overridden in local.h.
4263 lpcfg_do_global_parameter(lp_ctx, "passwd chat", DEFAULT_PASSWD_CHAT);
4265 lpcfg_do_global_parameter(lp_ctx, "pid directory", dyn_PIDDIR);
4266 lpcfg_do_global_parameter(lp_ctx, "lock dir", dyn_LOCKDIR);
4267 lpcfg_do_global_parameter(lp_ctx, "state directory", dyn_STATEDIR);
4268 lpcfg_do_global_parameter(lp_ctx, "cache directory", dyn_CACHEDIR);
4269 lpcfg_do_global_parameter(lp_ctx, "ncalrpc dir", dyn_NCALRPCDIR);
4271 lpcfg_do_global_parameter(lp_ctx, "socket address", "");
4272 lpcfg_do_global_parameter_var(lp_ctx, "server string",
4273 "Samba %s", SAMBA_VERSION_STRING);
4275 lpcfg_do_global_parameter(lp_ctx, "password server", "*");
4277 lpcfg_do_global_parameter(lp_ctx, "max mux", "50");
4278 lpcfg_do_global_parameter(lp_ctx, "max xmit", "12288");
4279 lpcfg_do_global_parameter(lp_ctx, "host msdfs", "true");
4281 lpcfg_do_global_parameter(lp_ctx, "password level", "0");
4282 lpcfg_do_global_parameter(lp_ctx, "LargeReadwrite", "True");
4283 lpcfg_do_global_parameter(lp_ctx, "server min protocol", "CORE");
4284 lpcfg_do_global_parameter(lp_ctx, "server max protocol", "NT1");
4285 lpcfg_do_global_parameter(lp_ctx, "client min protocol", "CORE");
4286 lpcfg_do_global_parameter(lp_ctx, "client max protocol", "NT1");
4287 lpcfg_do_global_parameter(lp_ctx, "security", "AUTO");
4288 lpcfg_do_global_parameter(lp_ctx, "paranoid server security", "True");
4289 lpcfg_do_global_parameter(lp_ctx, "EncryptPasswords", "True");
4290 lpcfg_do_global_parameter(lp_ctx, "ReadRaw", "True");
4291 lpcfg_do_global_parameter(lp_ctx, "WriteRaw", "True");
4292 lpcfg_do_global_parameter(lp_ctx, "NullPasswords", "False");
4293 lpcfg_do_global_parameter(lp_ctx, "ObeyPamRestrictions", "False");
4295 lpcfg_do_global_parameter(lp_ctx, "TimeServer", "False");
4296 lpcfg_do_global_parameter(lp_ctx, "BindInterfacesOnly", "False");
4297 lpcfg_do_global_parameter(lp_ctx, "Unicode", "True");
4298 lpcfg_do_global_parameter(lp_ctx, "ClientLanManAuth", "False");
4299 lpcfg_do_global_parameter(lp_ctx, "ClientNTLMv2Auth", "True");
4300 lpcfg_do_global_parameter(lp_ctx, "LanmanAuth", "False");
4301 lpcfg_do_global_parameter(lp_ctx, "NTLMAuth", "True");
4302 lpcfg_do_global_parameter(lp_ctx, "client use spnego principal", "False");
4304 lpcfg_do_global_parameter(lp_ctx, "UnixExtensions", "False");
4306 lpcfg_do_global_parameter(lp_ctx, "PreferredMaster", "Auto");
4307 lpcfg_do_global_parameter(lp_ctx, "LocalMaster", "True");
4309 lpcfg_do_global_parameter(lp_ctx, "wins support", "False");
4310 lpcfg_do_global_parameter(lp_ctx, "dns proxy", "True");
4312 lpcfg_do_global_parameter(lp_ctx, "winbind separator", "\\");
4313 lpcfg_do_global_parameter(lp_ctx, "winbind sealed pipes", "True");
4314 lpcfg_do_global_parameter(lp_ctx, "winbindd socket directory", dyn_WINBINDD_SOCKET_DIR);
4315 #if _SAMBA_BUILD_ >= 4
4316 lpcfg_do_global_parameter(lp_ctx, "winbindd privileged socket directory", dyn_WINBINDD_PRIVILEGED_SOCKET_DIR);
4317 lpcfg_do_global_parameter(lp_ctx, "ntp signd socket directory", dyn_NTP_SIGND_SOCKET_DIR);
4318 lpcfg_do_global_parameter_var(lp_ctx, "dns update command", "%s/samba_dnsupdate", dyn_SCRIPTSBINDIR);
4319 lpcfg_do_global_parameter_var(lp_ctx, "spn update command", "%s/samba_spnupdate", dyn_SCRIPTSBINDIR);
4320 lpcfg_do_global_parameter_var(lp_ctx, "samba kcc command",
4321 "%s/samba_kcc", dyn_SCRIPTSBINDIR);
4322 #endif
4323 lpcfg_do_global_parameter(lp_ctx, "template shell", "/bin/false");
4324 lpcfg_do_global_parameter(lp_ctx, "template homedir", "/home/%WORKGROUP%/%ACCOUNTNAME%");
4326 lpcfg_do_global_parameter(lp_ctx, "client signing", "default");
4327 lpcfg_do_global_parameter(lp_ctx, "server signing", "default");
4329 lpcfg_do_global_parameter(lp_ctx, "use spnego", "True");
4331 lpcfg_do_global_parameter(lp_ctx, "use mmap", "True");
4333 lpcfg_do_global_parameter(lp_ctx, "smb ports", "445 139");
4334 lpcfg_do_global_parameter(lp_ctx, "nbt port", "137");
4335 lpcfg_do_global_parameter(lp_ctx, "dgram port", "138");
4336 lpcfg_do_global_parameter(lp_ctx, "cldap port", "389");
4337 lpcfg_do_global_parameter(lp_ctx, "krb5 port", "88");
4338 lpcfg_do_global_parameter(lp_ctx, "kpasswd port", "464");
4339 lpcfg_do_global_parameter(lp_ctx, "web port", "901");
4341 lpcfg_do_global_parameter(lp_ctx, "nt status support", "True");
4343 lpcfg_do_global_parameter(lp_ctx, "max wins ttl", "518400"); /* 6 days */
4344 lpcfg_do_global_parameter(lp_ctx, "min wins ttl", "10");
4346 lpcfg_do_global_parameter(lp_ctx, "tls enabled", "True");
4347 lpcfg_do_global_parameter(lp_ctx, "tls keyfile", "tls/key.pem");
4348 lpcfg_do_global_parameter(lp_ctx, "tls certfile", "tls/cert.pem");
4349 lpcfg_do_global_parameter(lp_ctx, "tls cafile", "tls/ca.pem");
4350 lpcfg_do_global_parameter(lp_ctx, "prefork children:smb", "4");
4352 lpcfg_do_global_parameter(lp_ctx, "rndc command", "/usr/sbin/rndc");
4353 lpcfg_do_global_parameter(lp_ctx, "nsupdate command", "/usr/bin/nsupdate -g");
4355 lpcfg_do_global_parameter(lp_ctx, "allow dns updates", "False");
4356 lpcfg_do_global_parameter(lp_ctx, "dns recursive queries", "False");
4357 lpcfg_do_global_parameter(lp_ctx, "dns forwarder", "");
4359 for (i = 0; parm_table[i].label; i++) {
4360 if (!(lp_ctx->flags[i] & FLAG_CMDLINE)) {
4361 lp_ctx->flags[i] |= FLAG_DEFAULT;
4365 for (parm=lp_ctx->globals->param_opt; parm; parm=parm->next) {
4366 if (!(parm->priority & FLAG_CMDLINE)) {
4367 parm->priority |= FLAG_DEFAULT;
4371 return lp_ctx;
4375 * Initialise the global parameter structure.
4377 struct loadparm_context *loadparm_init_global(bool load_default)
4379 if (global_loadparm_context == NULL) {
4380 global_loadparm_context = loadparm_init(NULL);
4382 if (global_loadparm_context == NULL) {
4383 return NULL;
4385 global_loadparm_context->global = true;
4386 if (load_default && !global_loadparm_context->loaded) {
4387 lpcfg_load_default(global_loadparm_context);
4389 global_loadparm_context->refuse_free = true;
4390 return global_loadparm_context;
4394 * Initialise the global parameter structure.
4396 struct loadparm_context *loadparm_init_s3(TALLOC_CTX *mem_ctx,
4397 const struct loadparm_s3_helpers *s3_fns)
4399 struct loadparm_context *loadparm_context = talloc_zero(mem_ctx, struct loadparm_context);
4400 if (!loadparm_context) {
4401 return NULL;
4403 loadparm_context->s3_fns = s3_fns;
4404 return loadparm_context;
4407 const char *lpcfg_configfile(struct loadparm_context *lp_ctx)
4409 return lp_ctx->szConfigFile;
4412 const char *lp_default_path(void)
4414 if (getenv("SMB_CONF_PATH"))
4415 return getenv("SMB_CONF_PATH");
4416 else
4417 return dyn_CONFIGFILE;
4421 * Update the internal state of a loadparm context after settings
4422 * have changed.
4424 static bool lpcfg_update(struct loadparm_context *lp_ctx)
4426 struct debug_settings settings;
4427 lpcfg_add_auto_services(lp_ctx, lpcfg_auto_services(lp_ctx));
4429 if (!lp_ctx->globals->szWINSservers && lp_ctx->globals->bWINSsupport) {
4430 lpcfg_do_global_parameter(lp_ctx, "wins server", "127.0.0.1");
4433 if (!lp_ctx->global) {
4434 return true;
4437 panic_action = lp_ctx->globals->panic_action;
4439 reload_charcnv(lp_ctx);
4441 ZERO_STRUCT(settings);
4442 /* Add any more debug-related smb.conf parameters created in
4443 * future here */
4444 settings.timestamp_logs = true;
4445 debug_set_settings(&settings);
4447 /* FIXME: This is a bit of a hack, but we can't use a global, since
4448 * not everything that uses lp also uses the socket library */
4449 if (lpcfg_parm_bool(lp_ctx, NULL, "socket", "testnonblock", false)) {
4450 setenv("SOCKET_TESTNONBLOCK", "1", 1);
4451 } else {
4452 unsetenv("SOCKET_TESTNONBLOCK");
4455 return true;
4458 bool lpcfg_load_default(struct loadparm_context *lp_ctx)
4460 const char *path;
4462 path = lp_default_path();
4464 if (!file_exist(path)) {
4465 /* We allow the default smb.conf file to not exist,
4466 * basically the equivalent of an empty file. */
4467 return lpcfg_update(lp_ctx);
4470 return lpcfg_load(lp_ctx, path);
4474 * Load the services array from the services file.
4476 * Return True on success, False on failure.
4478 bool lpcfg_load(struct loadparm_context *lp_ctx, const char *filename)
4480 char *n2;
4481 bool bRetval;
4483 filename = talloc_strdup(lp_ctx, filename);
4485 lp_ctx->szConfigFile = filename;
4487 if (lp_ctx->s3_fns) {
4488 return lp_ctx->s3_fns->load(filename);
4491 lp_ctx->bInGlobalSection = true;
4492 n2 = standard_sub_basic(lp_ctx, lp_ctx->szConfigFile);
4493 DEBUG(2, ("lpcfg_load: refreshing parameters from %s\n", n2));
4495 add_to_file_list(lp_ctx, lp_ctx->szConfigFile, n2);
4497 /* We get sections first, so have to start 'behind' to make up */
4498 lp_ctx->currentService = NULL;
4499 bRetval = pm_process(n2, do_section, do_parameter, lp_ctx);
4501 /* finish up the last section */
4502 DEBUG(4, ("pm_process() returned %s\n", BOOLSTR(bRetval)));
4503 if (bRetval)
4504 if (lp_ctx->currentService != NULL)
4505 bRetval = lpcfg_service_ok(lp_ctx->currentService);
4507 bRetval = bRetval && lpcfg_update(lp_ctx);
4509 /* we do this unconditionally, so that it happens even
4510 for a missing smb.conf */
4511 reload_charcnv(lp_ctx);
4513 if (bRetval == true) {
4514 /* set this up so that any child python tasks will
4515 find the right smb.conf */
4516 setenv("SMB_CONF_PATH", filename, 1);
4518 /* set the context used by the lp_*() function
4519 varients */
4520 global_loadparm_context = lp_ctx;
4521 lp_ctx->loaded = true;
4524 return bRetval;
4528 * Return the max number of services.
4531 int lpcfg_numservices(struct loadparm_context *lp_ctx)
4533 if (lp_ctx->s3_fns) {
4534 return lp_ctx->s3_fns->get_numservices();
4537 return lp_ctx->iNumServices;
4541 * Display the contents of the services array in human-readable form.
4544 void lpcfg_dump(struct loadparm_context *lp_ctx, FILE *f, bool show_defaults,
4545 int maxtoprint)
4547 int iService;
4549 if (lp_ctx->s3_fns) {
4550 lp_ctx->s3_fns->dump(f, show_defaults, maxtoprint);
4551 return;
4554 defaults_saved = !show_defaults;
4556 dump_globals(lp_ctx, f, show_defaults);
4558 dump_a_service(lp_ctx->sDefault, lp_ctx->sDefault, f, lp_ctx->flags);
4560 for (iService = 0; iService < maxtoprint; iService++)
4561 lpcfg_dump_one(f, show_defaults, lp_ctx->services[iService], lp_ctx->sDefault);
4565 * Display the contents of one service in human-readable form.
4567 void lpcfg_dump_one(FILE *f, bool show_defaults, struct loadparm_service *service, struct loadparm_service *sDefault)
4569 if (service != NULL) {
4570 if (service->szService[0] == '\0')
4571 return;
4572 dump_a_service(service, sDefault, f, NULL);
4576 struct loadparm_service *lpcfg_servicebynum(struct loadparm_context *lp_ctx,
4577 int snum)
4579 if (lp_ctx->s3_fns) {
4580 return lp_ctx->s3_fns->get_servicebynum(snum);
4583 return lp_ctx->services[snum];
4586 struct loadparm_service *lpcfg_service(struct loadparm_context *lp_ctx,
4587 const char *service_name)
4589 int iService;
4590 char *serviceName;
4592 if (lp_ctx->s3_fns) {
4593 return lp_ctx->s3_fns->get_service(service_name);
4596 for (iService = lp_ctx->iNumServices - 1; iService >= 0; iService--) {
4597 if (lp_ctx->services[iService] &&
4598 lp_ctx->services[iService]->szService) {
4600 * The substitution here is used to support %U is
4601 * service names
4603 serviceName = standard_sub_basic(
4604 lp_ctx->services[iService],
4605 lp_ctx->services[iService]->szService);
4606 if (strequal(serviceName, service_name)) {
4607 talloc_free(serviceName);
4608 return lp_ctx->services[iService];
4610 talloc_free(serviceName);
4614 DEBUG(7,("lpcfg_servicenumber: couldn't find %s\n", service_name));
4615 return NULL;
4618 const char *lpcfg_servicename(const struct loadparm_service *service)
4620 return lp_string((const char *)service->szService);
4624 * A useful volume label function.
4626 const char *lpcfg_volume_label(struct loadparm_service *service, struct loadparm_service *sDefault)
4628 const char *ret;
4629 ret = lp_string((const char *)((service != NULL && service->volume != NULL) ?
4630 service->volume : sDefault->volume));
4631 if (!*ret)
4632 return lpcfg_servicename(service);
4633 return ret;
4637 * If we are PDC then prefer us as DMB
4639 const char *lpcfg_printername(struct loadparm_service *service, struct loadparm_service *sDefault)
4641 const char *ret;
4642 ret = lp_string((const char *)((service != NULL && service->szPrintername != NULL) ?
4643 service->szPrintername : sDefault->szPrintername));
4644 if (ret == NULL || (ret != NULL && *ret == '\0'))
4645 ret = lpcfg_servicename(service);
4647 return ret;
4652 * Return the max print jobs per queue.
4654 int lpcfg_maxprintjobs(struct loadparm_service *service, struct loadparm_service *sDefault)
4656 int maxjobs = (service != NULL) ? service->iMaxPrintJobs : sDefault->iMaxPrintJobs;
4657 if (maxjobs <= 0 || maxjobs >= PRINT_MAX_JOBID)
4658 maxjobs = PRINT_MAX_JOBID - 1;
4660 return maxjobs;
4663 struct smb_iconv_handle *lpcfg_iconv_handle(struct loadparm_context *lp_ctx)
4665 if (lp_ctx == NULL) {
4666 return get_iconv_handle();
4668 return lp_ctx->iconv_handle;
4671 _PUBLIC_ void reload_charcnv(struct loadparm_context *lp_ctx)
4673 struct smb_iconv_handle *old_ic = lp_ctx->iconv_handle;
4674 if (!lp_ctx->global) {
4675 return;
4678 if (old_ic == NULL) {
4679 old_ic = global_iconv_handle;
4681 lp_ctx->iconv_handle = smb_iconv_handle_reinit_lp(lp_ctx, lp_ctx, old_ic);
4682 global_iconv_handle = lp_ctx->iconv_handle;
4685 _PUBLIC_ char *lpcfg_tls_keyfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
4687 return lpcfg_private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_keyfile);
4690 _PUBLIC_ char *lpcfg_tls_certfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
4692 return lpcfg_private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_certfile);
4695 _PUBLIC_ char *lpcfg_tls_cafile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
4697 return lpcfg_private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_cafile);
4700 _PUBLIC_ char *lpcfg_tls_crlfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
4702 return lpcfg_private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_crlfile);
4705 _PUBLIC_ char *lpcfg_tls_dhpfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
4707 return lpcfg_private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_dhpfile);
4710 struct gensec_settings *lpcfg_gensec_settings(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
4712 struct gensec_settings *settings = talloc_zero(mem_ctx, struct gensec_settings);
4713 if (settings == NULL)
4714 return NULL;
4715 SMB_ASSERT(lp_ctx != NULL);
4716 settings->lp_ctx = talloc_reference(settings, lp_ctx);
4717 settings->target_hostname = lpcfg_parm_string(lp_ctx, NULL, "gensec", "target_hostname");
4718 return settings;
4721 int lpcfg_server_role(struct loadparm_context *lp_ctx)
4723 int domain_master = lpcfg__domain_master(lp_ctx);
4725 return lp_find_server_role(lpcfg__server_role(lp_ctx),
4726 lpcfg__security(lp_ctx),
4727 lpcfg__domain_logons(lp_ctx),
4728 (domain_master == true) ||
4729 (domain_master == Auto));
4732 int lpcfg_security(struct loadparm_context *lp_ctx)
4734 return lp_find_security(lpcfg__server_role(lp_ctx),
4735 lpcfg__security(lp_ctx));