2 Unix SMB/CIFS implementation.
3 Parameter loading functions
4 Copyright (C) Karl Auer 1993-1998
6 Largely re-written by Andrew Tridgell, September 1994
8 Copyright (C) Simo Sorce 2001
9 Copyright (C) Alexander Bokovoy 2002
10 Copyright (C) Stefan (metze) Metzmacher 2002
11 Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2003.
12 Copyright (C) James Myers 2003 <myersjj@samba.org>
13 Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
14 Copyright (C) Andrew Bartlett 2011-2012
16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 3 of the License, or
19 (at your option) any later version.
21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 GNU General Public License for more details.
26 You should have received a copy of the GNU General Public License
27 along with this program. If not, see <http://www.gnu.org/licenses/>.
33 * This module provides suitable callback functions for the params
34 * module. It builds the internal table of service details which is
35 * then used by the rest of the server.
39 * 1) add it to the global or service structure definition
40 * 2) add it to the parm_table
41 * 3) add it to the list of available functions (eg: using FN_GLOBAL_STRING())
42 * 4) If it's a global then initialise it in init_globals. If a local
43 * (ie. service) parameter then initialise it in the sDefault structure
47 * The configuration file is processed sequentially for speed. It is NOT
48 * accessed randomly as happens in 'real' Windows. For this reason, there
49 * is a fair bit of sequence-dependent code here - ie., code which assumes
50 * that certain things happen before others. In particular, the code which
51 * happens at the boundary between sections is delicately poised, so be
58 #include "dynconfig/dynconfig.h"
59 #include "system/time.h"
60 #include "system/locale.h"
61 #include "system/network.h" /* needed for TCP_NODELAY */
62 #include "../lib/util/dlinklist.h"
63 #include "lib/param/param.h"
64 #include "lib/param/loadparm.h"
65 #include "auth/gensec/gensec.h"
66 #include "lib/param/s3_param.h"
67 #include "lib/util/bitmap.h"
68 #include "libcli/smb/smb_constants.h"
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; \
80 char *szLdapMachineSuffix; \
81 char *szLdapUserSuffix; \
82 char *szLdapIdmapSuffix; \
83 char *szLdapGroupSuffix; \
84 char *szUsershareTemplateShare; \
87 int winbindMaxDomainConnections; \
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
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
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",
142 .offset
= GLOBAL_VAR(server_role
),
144 .enum_list
= enum_server_role
147 .label
= "domain logons",
150 .offset
= GLOBAL_VAR(bDomainLogons
),
152 .enum_list
= enum_bool_auto
155 .label
= "domain master",
158 .offset
= GLOBAL_VAR(domain_master
),
160 .enum_list
= enum_bool_auto
163 .label
= "dos charset",
166 .offset
= GLOBAL_VAR(dos_charset
),
171 .label
= "unix charset",
174 .offset
= GLOBAL_VAR(unix_charset
),
182 .offset
= LOCAL_VAR(comment
),
185 .flags
= FLAG_BASIC
| FLAG_ADVANCED
| FLAG_SHARE
| FLAG_PRINT
191 .offset
= LOCAL_VAR(szPath
),
194 .flags
= FLAG_BASIC
| FLAG_ADVANCED
| FLAG_SHARE
| FLAG_PRINT
,
197 .label
= "directory",
200 .offset
= LOCAL_VAR(szPath
),
206 .label
= "workgroup",
209 .offset
= GLOBAL_VAR(szWorkgroup
),
212 .flags
= FLAG_BASIC
| FLAG_ADVANCED
| FLAG_WIZARD
,
218 .offset
= GLOBAL_VAR(szRealm
),
219 .special
= handle_realm
,
221 .flags
= FLAG_BASIC
| FLAG_ADVANCED
| FLAG_WIZARD
,
224 .label
= "netbios name",
227 .offset
= GLOBAL_VAR(szNetbiosName
),
230 .flags
= FLAG_BASIC
| FLAG_ADVANCED
| FLAG_WIZARD
,
233 .label
= "netbios aliases",
236 .offset
= GLOBAL_VAR(szNetbiosAliases
),
241 .label
= "netbios scope",
244 .offset
= GLOBAL_VAR(szNetbiosScope
),
247 .flags
= FLAG_ADVANCED
,
250 .label
= "server string",
253 .offset
= GLOBAL_VAR(szServerString
),
256 .flags
= FLAG_BASIC
| FLAG_ADVANCED
,
259 .label
= "interfaces",
262 .offset
= GLOBAL_VAR(szInterfaces
),
265 .flags
= FLAG_BASIC
| FLAG_ADVANCED
| FLAG_WIZARD
,
268 .label
= "bind interfaces only",
271 .offset
= GLOBAL_VAR(bBindInterfacesOnly
),
274 .flags
= FLAG_ADVANCED
| FLAG_WIZARD
,
277 .label
= "passdb backend",
280 .offset
= GLOBAL_VAR(passdb_backend
),
289 .offset
= GLOBAL_VAR(security
),
291 .enum_list
= enum_security
294 .label
= "encrypt passwords",
297 .offset
= GLOBAL_VAR(bEncryptPasswords
),
302 .label
= "null passwords",
305 .offset
= GLOBAL_VAR(bNullPasswords
),
308 .flags
= FLAG_ADVANCED
| FLAG_DEPRECATED
,
311 .label
= "obey pam restrictions",
314 .offset
= GLOBAL_VAR(bObeyPamRestrictions
),
317 .flags
= FLAG_ADVANCED
,
320 .label
= "password server",
323 .offset
= GLOBAL_VAR(szPasswordServer
),
328 .label
= "private dir",
331 .offset
= GLOBAL_VAR(szPrivateDir
),
336 .label
= "passwd chat",
339 .offset
= GLOBAL_VAR(szPasswdChat
),
344 .label
= "password level",
347 .offset
= GLOBAL_VAR(pwordlevel
),
352 .label
= "lanman auth",
355 .offset
= GLOBAL_VAR(bLanmanAuth
),
358 .flags
= FLAG_ADVANCED
,
361 .label
= "ntlm auth",
364 .offset
= GLOBAL_VAR(bNTLMAuth
),
367 .flags
= FLAG_ADVANCED
,
370 .label
= "client NTLMv2 auth",
373 .offset
= GLOBAL_VAR(bClientNTLMv2Auth
),
376 .flags
= FLAG_ADVANCED
,
379 .label
= "client lanman auth",
382 .offset
= GLOBAL_VAR(bClientLanManAuth
),
385 .flags
= FLAG_ADVANCED
,
388 .label
= "client plaintext auth",
391 .offset
= GLOBAL_VAR(bClientPlaintextAuth
),
394 .flags
= FLAG_ADVANCED
,
397 .label
= "client use spnego principal",
400 .offset
= GLOBAL_VAR(client_use_spnego_principal
),
406 .label
= "read only",
409 .offset
= LOCAL_VAR(bRead_only
),
415 .label
= "create mask",
418 .offset
= LOCAL_VAR(iCreate_mask
),
423 .label
= "force create mode",
426 .offset
= LOCAL_VAR(iCreate_force_mode
),
431 .label
= "directory mask",
434 .offset
= LOCAL_VAR(iDir_mask
),
439 .label
= "force directory mode",
442 .offset
= LOCAL_VAR(iDir_force_mode
),
448 .label
= "hosts allow",
451 .offset
= LOCAL_VAR(szHostsallow
),
456 .label
= "hosts deny",
459 .offset
= LOCAL_VAR(szHostsdeny
),
465 .label
= "log level",
468 .offset
= GLOBAL_VAR(loglevel
),
469 .special
= handle_debuglevel
,
473 .label
= "debuglevel",
476 .offset
= GLOBAL_VAR(loglevel
),
477 .special
= handle_debuglevel
,
484 .offset
= GLOBAL_VAR(logfile
),
485 .special
= handle_logfile
,
487 .flags
= FLAG_ADVANCED
,
491 .label
= "smb ports",
494 .offset
= GLOBAL_VAR(smb_ports
),
502 .offset
= GLOBAL_VAR(nbt_port
),
507 .label
= "dgram port",
510 .offset
= GLOBAL_VAR(dgram_port
),
515 .label
= "cldap port",
518 .offset
= GLOBAL_VAR(cldap_port
),
523 .label
= "krb5 port",
526 .offset
= GLOBAL_VAR(krb5_port
),
531 .label
= "kpasswd port",
534 .offset
= GLOBAL_VAR(kpasswd_port
),
542 .offset
= GLOBAL_VAR(web_port
),
547 .label
= "large readwrite",
550 .offset
= GLOBAL_VAR(bLargeReadwrite
),
553 .flags
= FLAG_ADVANCED
,
556 .label
= "server max protocol",
559 .offset
= GLOBAL_VAR(srv_maxprotocol
),
561 .enum_list
= enum_protocol
,
562 .flags
= FLAG_ADVANCED
,
565 .label
= "max protocol",
568 .offset
= GLOBAL_VAR(srv_maxprotocol
),
570 .enum_list
= enum_protocol
,
571 .flags
= FLAG_ADVANCED
,
577 .offset
= GLOBAL_VAR(srv_maxprotocol
),
579 .enum_list
= enum_protocol
,
580 .flags
= FLAG_ADVANCED
,
583 .label
= "server min protocol",
586 .offset
= GLOBAL_VAR(srv_minprotocol
),
588 .enum_list
= enum_protocol
,
589 .flags
= FLAG_ADVANCED
,
592 .label
= "min protocol",
595 .offset
= GLOBAL_VAR(srv_minprotocol
),
597 .enum_list
= enum_protocol
,
598 .flags
= FLAG_ADVANCED
,
601 .label
= "client max protocol",
604 .offset
= GLOBAL_VAR(cli_maxprotocol
),
606 .enum_list
= enum_protocol
609 .label
= "client min protocol",
612 .offset
= GLOBAL_VAR(cli_minprotocol
),
614 .enum_list
= enum_protocol
620 .offset
= GLOBAL_VAR(bUnicode
),
628 .offset
= GLOBAL_VAR(bReadRaw
),
633 .label
= "write raw",
636 .offset
= GLOBAL_VAR(bWriteRaw
),
641 .label
= "disable netbios",
644 .offset
= GLOBAL_VAR(bDisableNetbios
),
650 .label
= "nt status support",
653 .offset
= GLOBAL_VAR(bNTStatusSupport
),
662 .offset
= GLOBAL_VAR(max_mux
),
665 .flags
= FLAG_ADVANCED
,
671 .offset
= GLOBAL_VAR(max_xmit
),
674 .flags
= FLAG_ADVANCED
,
678 .label
= "name resolve order",
681 .offset
= GLOBAL_VAR(szNameResolveOrder
),
686 .label
= "max wins ttl",
689 .offset
= GLOBAL_VAR(max_wins_ttl
),
692 .flags
= FLAG_ADVANCED
,
695 .label
= "min wins ttl",
698 .offset
= GLOBAL_VAR(min_wins_ttl
),
701 .flags
= FLAG_ADVANCED
,
704 .label
= "time server",
707 .offset
= GLOBAL_VAR(bTimeServer
),
710 .flags
= FLAG_ADVANCED
,
713 .label
= "unix extensions",
716 .offset
= GLOBAL_VAR(bUnixExtensions
),
719 .flags
= FLAG_ADVANCED
,
722 .label
= "use spnego",
725 .offset
= GLOBAL_VAR(bUseSpnego
),
730 .label
= "server signing",
733 .offset
= GLOBAL_VAR(server_signing
),
735 .enum_list
= enum_smb_signing_vals
,
736 .flags
= FLAG_ADVANCED
,
739 .label
= "client signing",
742 .offset
= GLOBAL_VAR(client_signing
),
744 .enum_list
= enum_smb_signing_vals
747 .label
= "rpc big endian",
750 .offset
= GLOBAL_VAR(bRpcBigEndian
),
756 .label
= "max connections",
759 .offset
= LOCAL_VAR(iMaxConnections
),
762 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
765 .label
= "paranoid server security",
768 .offset
= GLOBAL_VAR(paranoid_server_security
),
773 .label
= "socket options",
776 .offset
= GLOBAL_VAR(socket_options
),
782 .label
= "strict sync",
785 .offset
= LOCAL_VAR(bStrictSync
),
793 .offset
= GLOBAL_VAR(bUseMmap
),
796 .flags
= FLAG_ADVANCED
,
800 .label
= "max print jobs",
803 .offset
= LOCAL_VAR(iMaxPrintJobs
),
808 .label
= "printable",
811 .offset
= LOCAL_VAR(bPrint_ok
),
819 .offset
= LOCAL_VAR(bPrint_ok
),
825 .label
= "printer name",
828 .offset
= LOCAL_VAR(szPrintername
),
831 .flags
= FLAG_ADVANCED
| FLAG_PRINT
,
837 .offset
= LOCAL_VAR(szPrintername
),
844 .label
= "map system",
847 .offset
= LOCAL_VAR(bMap_system
),
852 .label
= "map hidden",
855 .offset
= LOCAL_VAR(bMap_hidden
),
860 .label
= "map archive",
863 .offset
= LOCAL_VAR(bMap_archive
),
869 .label
= "preferred master",
872 .offset
= GLOBAL_VAR(bPreferredMaster
),
874 .enum_list
= enum_bool_auto
,
875 .flags
= FLAG_BASIC
| FLAG_ADVANCED
,
878 .label
= "prefered master",
881 .offset
= GLOBAL_VAR(bPreferredMaster
),
883 .enum_list
= enum_bool_auto
,
887 .label
= "local master",
890 .offset
= GLOBAL_VAR(bLocalMaster
),
895 .label
= "browseable",
898 .offset
= LOCAL_VAR(bBrowseable
),
901 .flags
= FLAG_BASIC
| FLAG_ADVANCED
| FLAG_SHARE
| FLAG_PRINT
,
904 .label
= "browsable",
907 .offset
= LOCAL_VAR(bBrowseable
),
913 .label
= "dns proxy",
916 .offset
= GLOBAL_VAR(bWINSdnsProxy
),
921 .label
= "wins server",
924 .offset
= GLOBAL_VAR(szWINSservers
),
927 .flags
= FLAG_BASIC
| FLAG_ADVANCED
| FLAG_WIZARD
,
930 .label
= "wins support",
933 .offset
= GLOBAL_VAR(bWINSsupport
),
936 .flags
= FLAG_BASIC
| FLAG_ADVANCED
| FLAG_WIZARD
,
939 .label
= "wins hook",
942 .offset
= GLOBAL_VAR(szWINSHook
),
945 .flags
= FLAG_ADVANCED
,
949 .label
= "csc policy",
952 .offset
= LOCAL_VAR(iCSCPolicy
),
954 .enum_list
= enum_csc_policy
,
955 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
959 .label
= "strict locking",
962 .offset
= LOCAL_VAR(iStrictLocking
),
970 .offset
= LOCAL_VAR(bOpLocks
),
975 {N_("Ldap Options"), P_SEP
, P_SEPARATOR
},
978 .label
= "ldap admin dn",
981 .offset
= GLOBAL_VAR(szLdapAdminDn
),
984 .flags
= FLAG_ADVANCED
,
987 .label
= "ldap delete dn",
990 .offset
= GLOBAL_VAR(ldap_delete_dn
),
993 .flags
= FLAG_ADVANCED
,
996 .label
= "ldap group suffix",
999 .offset
= GLOBAL_VAR(szLdapGroupSuffix
),
1002 .flags
= FLAG_ADVANCED
,
1005 .label
= "ldap idmap suffix",
1007 .p_class
= P_GLOBAL
,
1008 .offset
= GLOBAL_VAR(szLdapIdmapSuffix
),
1011 .flags
= FLAG_ADVANCED
,
1014 .label
= "ldap machine suffix",
1016 .p_class
= P_GLOBAL
,
1017 .offset
= GLOBAL_VAR(szLdapMachineSuffix
),
1020 .flags
= FLAG_ADVANCED
,
1023 .label
= "ldap passwd sync",
1025 .p_class
= P_GLOBAL
,
1026 .offset
= GLOBAL_VAR(ldap_passwd_sync
),
1028 .enum_list
= enum_ldap_passwd_sync
,
1029 .flags
= FLAG_ADVANCED
,
1032 .label
= "ldap password sync",
1034 .p_class
= P_GLOBAL
,
1035 .offset
= GLOBAL_VAR(ldap_passwd_sync
),
1037 .enum_list
= enum_ldap_passwd_sync
,
1041 .label
= "ldap replication sleep",
1043 .p_class
= P_GLOBAL
,
1044 .offset
= GLOBAL_VAR(ldap_replication_sleep
),
1047 .flags
= FLAG_ADVANCED
,
1050 .label
= "ldap suffix",
1052 .p_class
= P_GLOBAL
,
1053 .offset
= GLOBAL_VAR(szLdapSuffix
),
1056 .flags
= FLAG_ADVANCED
,
1059 .label
= "ldap ssl",
1061 .p_class
= P_GLOBAL
,
1062 .offset
= GLOBAL_VAR(ldap_ssl
),
1064 .enum_list
= enum_ldap_ssl
,
1065 .flags
= FLAG_ADVANCED
,
1068 .label
= "ldap ssl ads",
1070 .p_class
= P_GLOBAL
,
1071 .offset
= GLOBAL_VAR(ldap_ssl_ads
),
1074 .flags
= FLAG_ADVANCED
,
1077 .label
= "ldap deref",
1079 .p_class
= P_GLOBAL
,
1080 .offset
= GLOBAL_VAR(ldap_deref
),
1082 .enum_list
= enum_ldap_deref
,
1083 .flags
= FLAG_ADVANCED
,
1086 .label
= "ldap follow referral",
1088 .p_class
= P_GLOBAL
,
1089 .offset
= GLOBAL_VAR(ldap_follow_referral
),
1091 .enum_list
= enum_bool_auto
,
1092 .flags
= FLAG_ADVANCED
,
1095 .label
= "ldap timeout",
1097 .p_class
= P_GLOBAL
,
1098 .offset
= GLOBAL_VAR(ldap_timeout
),
1101 .flags
= FLAG_ADVANCED
,
1104 .label
= "ldap connection timeout",
1106 .p_class
= P_GLOBAL
,
1107 .offset
= GLOBAL_VAR(ldap_connection_timeout
),
1110 .flags
= FLAG_ADVANCED
,
1113 .label
= "ldap page size",
1115 .p_class
= P_GLOBAL
,
1116 .offset
= GLOBAL_VAR(ldap_page_size
),
1119 .flags
= FLAG_ADVANCED
,
1122 .label
= "ldap user suffix",
1124 .p_class
= P_GLOBAL
,
1125 .offset
= GLOBAL_VAR(szLdapUserSuffix
),
1128 .flags
= FLAG_ADVANCED
,
1131 .label
= "ldap debug level",
1133 .p_class
= P_GLOBAL
,
1134 .offset
= GLOBAL_VAR(ldap_debug_level
),
1135 .special
= handle_ldap_debug_level
,
1137 .flags
= FLAG_ADVANCED
,
1140 .label
= "ldap debug threshold",
1142 .p_class
= P_GLOBAL
,
1143 .offset
= GLOBAL_VAR(ldap_debug_threshold
),
1146 .flags
= FLAG_ADVANCED
,
1149 {N_("EventLog Options"), P_SEP
, P_SEPARATOR
},
1152 .label
= "eventlog list",
1154 .p_class
= P_GLOBAL
,
1155 .offset
= GLOBAL_VAR(szEventLogs
),
1158 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
| FLAG_SHARE
,
1161 {N_("Miscellaneous Options"), P_SEP
, P_SEPARATOR
},
1164 .label
= "add share command",
1166 .p_class
= P_GLOBAL
,
1167 .offset
= GLOBAL_VAR(szAddShareCommand
),
1170 .flags
= FLAG_ADVANCED
,
1173 .label
= "change share command",
1175 .p_class
= P_GLOBAL
,
1176 .offset
= GLOBAL_VAR(szChangeShareCommand
),
1179 .flags
= FLAG_ADVANCED
,
1182 .label
= "delete share command",
1184 .p_class
= P_GLOBAL
,
1185 .offset
= GLOBAL_VAR(szDeleteShareCommand
),
1188 .flags
= FLAG_ADVANCED
,
1191 .label
= "config file",
1193 .p_class
= P_GLOBAL
,
1194 .offset
= GLOBAL_VAR(szConfigFile
),
1197 .flags
= FLAG_HIDE
|FLAG_META
,
1202 .p_class
= P_GLOBAL
,
1203 .offset
= GLOBAL_VAR(szAutoServices
),
1206 .flags
= FLAG_ADVANCED
,
1209 .label
= "auto services",
1211 .p_class
= P_GLOBAL
,
1212 .offset
= GLOBAL_VAR(szAutoServices
),
1215 .flags
= FLAG_ADVANCED
,
1218 .label
= "lock directory",
1220 .p_class
= P_GLOBAL
,
1221 .offset
= GLOBAL_VAR(szLockDir
),
1224 .flags
= FLAG_ADVANCED
,
1227 .label
= "lock dir",
1229 .p_class
= P_GLOBAL
,
1230 .offset
= GLOBAL_VAR(szLockDir
),
1236 .label
= "state directory",
1238 .p_class
= P_GLOBAL
,
1239 .offset
= GLOBAL_VAR(szStateDir
),
1242 .flags
= FLAG_ADVANCED
,
1245 .label
= "cache directory",
1247 .p_class
= P_GLOBAL
,
1248 .offset
= GLOBAL_VAR(szCacheDir
),
1251 .flags
= FLAG_ADVANCED
,
1254 .label
= "pid directory",
1256 .p_class
= P_GLOBAL
,
1257 .offset
= GLOBAL_VAR(szPidDir
),
1260 .flags
= FLAG_ADVANCED
,
1263 .label
= "ntp signd socket directory",
1265 .p_class
= P_GLOBAL
,
1266 .offset
= GLOBAL_VAR(szNTPSignDSocketDirectory
),
1269 .flags
= FLAG_ADVANCED
,
1274 .label
= "utmp directory",
1276 .p_class
= P_GLOBAL
,
1277 .offset
= GLOBAL_VAR(szUtmpDir
),
1280 .flags
= FLAG_ADVANCED
,
1283 .label
= "wtmp directory",
1285 .p_class
= P_GLOBAL
,
1286 .offset
= GLOBAL_VAR(szWtmpDir
),
1289 .flags
= FLAG_ADVANCED
,
1294 .p_class
= P_GLOBAL
,
1295 .offset
= GLOBAL_VAR(bUtmp
),
1298 .flags
= FLAG_ADVANCED
,
1302 .label
= "default service",
1304 .p_class
= P_GLOBAL
,
1305 .offset
= GLOBAL_VAR(szDefaultService
),
1308 .flags
= FLAG_ADVANCED
,
1313 .p_class
= P_GLOBAL
,
1314 .offset
= GLOBAL_VAR(szDefaultService
),
1317 .flags
= FLAG_ADVANCED
,
1320 .label
= "message command",
1322 .p_class
= P_GLOBAL
,
1323 .offset
= GLOBAL_VAR(szMsgCommand
),
1326 .flags
= FLAG_ADVANCED
,
1329 .label
= "dfree cache time",
1332 .offset
= LOCAL_VAR(iDfreeCacheTime
),
1335 .flags
= FLAG_ADVANCED
,
1338 .label
= "dfree command",
1341 .offset
= LOCAL_VAR(szDfree
),
1344 .flags
= FLAG_ADVANCED
,
1347 .label
= "get quota command",
1349 .p_class
= P_GLOBAL
,
1350 .offset
= GLOBAL_VAR(szGetQuota
),
1353 .flags
= FLAG_ADVANCED
,
1356 .label
= "set quota command",
1358 .p_class
= P_GLOBAL
,
1359 .offset
= GLOBAL_VAR(szSetQuota
),
1362 .flags
= FLAG_ADVANCED
,
1365 .label
= "remote announce",
1367 .p_class
= P_GLOBAL
,
1368 .offset
= GLOBAL_VAR(szRemoteAnnounce
),
1371 .flags
= FLAG_ADVANCED
,
1374 .label
= "remote browse sync",
1376 .p_class
= P_GLOBAL
,
1377 .offset
= GLOBAL_VAR(szRemoteBrowseSync
),
1380 .flags
= FLAG_ADVANCED
,
1383 .label
= "socket address",
1385 .p_class
= P_GLOBAL
,
1386 .offset
= GLOBAL_VAR(szSocketAddress
),
1389 .flags
= FLAG_ADVANCED
,
1392 .label
= "nmbd bind explicit broadcast",
1394 .p_class
= P_GLOBAL
,
1395 .offset
= GLOBAL_VAR(bNmbdBindExplicitBroadcast
),
1398 .flags
= FLAG_ADVANCED
,
1401 .label
= "homedir map",
1403 .p_class
= P_GLOBAL
,
1404 .offset
= GLOBAL_VAR(szNISHomeMapName
),
1407 .flags
= FLAG_ADVANCED
,
1410 .label
= "afs username map",
1412 .p_class
= P_GLOBAL
,
1413 .offset
= GLOBAL_VAR(szAfsUsernameMap
),
1416 .flags
= FLAG_ADVANCED
,
1419 .label
= "afs token lifetime",
1421 .p_class
= P_GLOBAL
,
1422 .offset
= GLOBAL_VAR(iAfsTokenLifetime
),
1425 .flags
= FLAG_ADVANCED
,
1428 .label
= "log nt token command",
1430 .p_class
= P_GLOBAL
,
1431 .offset
= GLOBAL_VAR(szLogNtTokenCommand
),
1434 .flags
= FLAG_ADVANCED
,
1437 .label
= "NIS homedir",
1439 .p_class
= P_GLOBAL
,
1440 .offset
= GLOBAL_VAR(bNISHomeMap
),
1443 .flags
= FLAG_ADVANCED
,
1449 .offset
= LOCAL_VAR(valid
),
1458 .offset
= LOCAL_VAR(szCopy
),
1459 .special
= handle_copy
,
1467 .offset
= LOCAL_VAR(szInclude
),
1468 .special
= handle_include
,
1470 .flags
= FLAG_HIDE
|FLAG_META
,
1476 .offset
= LOCAL_VAR(szPreExec
),
1479 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_PRINT
,
1485 .offset
= LOCAL_VAR(szPreExec
),
1488 .flags
= FLAG_ADVANCED
,
1491 .label
= "preexec close",
1494 .offset
= LOCAL_VAR(bPreexecClose
),
1497 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
1500 .label
= "postexec",
1503 .offset
= LOCAL_VAR(szPostExec
),
1506 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_PRINT
,
1509 .label
= "root preexec",
1512 .offset
= LOCAL_VAR(szRootPreExec
),
1515 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_PRINT
,
1518 .label
= "root preexec close",
1521 .offset
= LOCAL_VAR(bRootpreexecClose
),
1524 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
1527 .label
= "root postexec",
1530 .offset
= LOCAL_VAR(szRootPostExec
),
1533 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_PRINT
,
1536 .label
= "available",
1539 .offset
= LOCAL_VAR(bAvailable
),
1542 .flags
= FLAG_BASIC
| FLAG_ADVANCED
| FLAG_SHARE
| FLAG_PRINT
,
1545 .label
= "registry shares",
1547 .p_class
= P_GLOBAL
,
1548 .offset
= GLOBAL_VAR(bRegistryShares
),
1551 .flags
= FLAG_ADVANCED
,
1554 .label
= "usershare allow guests",
1556 .p_class
= P_GLOBAL
,
1557 .offset
= GLOBAL_VAR(bUsershareAllowGuests
),
1560 .flags
= FLAG_ADVANCED
,
1563 .label
= "usershare max shares",
1565 .p_class
= P_GLOBAL
,
1566 .offset
= GLOBAL_VAR(iUsershareMaxShares
),
1569 .flags
= FLAG_ADVANCED
,
1572 .label
= "usershare owner only",
1574 .p_class
= P_GLOBAL
,
1575 .offset
= GLOBAL_VAR(bUsershareOwnerOnly
),
1578 .flags
= FLAG_ADVANCED
,
1581 .label
= "usershare path",
1583 .p_class
= P_GLOBAL
,
1584 .offset
= GLOBAL_VAR(szUsersharePath
),
1587 .flags
= FLAG_ADVANCED
,
1590 .label
= "usershare prefix allow list",
1592 .p_class
= P_GLOBAL
,
1593 .offset
= GLOBAL_VAR(szUsersharePrefixAllowList
),
1596 .flags
= FLAG_ADVANCED
,
1599 .label
= "usershare prefix deny list",
1601 .p_class
= P_GLOBAL
,
1602 .offset
= GLOBAL_VAR(szUsersharePrefixDenyList
),
1605 .flags
= FLAG_ADVANCED
,
1608 .label
= "usershare template share",
1610 .p_class
= P_GLOBAL
,
1611 .offset
= GLOBAL_VAR(szUsershareTemplateShare
),
1614 .flags
= FLAG_ADVANCED
,
1620 .offset
= LOCAL_VAR(volume
),
1623 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
1629 .offset
= LOCAL_VAR(fstype
),
1632 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
1635 .label
= "set directory",
1638 .offset
= LOCAL_VAR(bNo_set_dir
),
1641 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
1644 .label
= "allow insecure wide links",
1646 .p_class
= P_GLOBAL
,
1647 .offset
= GLOBAL_VAR(bAllowInsecureWidelinks
),
1650 .flags
= FLAG_ADVANCED
,
1653 .label
= "wide links",
1656 .offset
= LOCAL_VAR(bWidelinks
),
1659 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
1662 .label
= "follow symlinks",
1665 .offset
= LOCAL_VAR(bSymlinks
),
1668 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
1671 .label
= "dont descend",
1674 .offset
= LOCAL_VAR(szDontdescend
),
1677 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
1680 .label
= "magic script",
1683 .offset
= LOCAL_VAR(szMagicScript
),
1686 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
1689 .label
= "magic output",
1692 .offset
= LOCAL_VAR(szMagicOutput
),
1695 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
1698 .label
= "delete readonly",
1701 .offset
= LOCAL_VAR(bDeleteReadonly
),
1704 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
1707 .label
= "dos filemode",
1710 .offset
= LOCAL_VAR(bDosFilemode
),
1713 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
1716 .label
= "dos filetimes",
1719 .offset
= LOCAL_VAR(bDosFiletimes
),
1722 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
1725 .label
= "dos filetime resolution",
1728 .offset
= LOCAL_VAR(bDosFiletimeResolution
),
1731 .flags
= FLAG_ADVANCED
| FLAG_SHARE
| FLAG_GLOBAL
,
1734 .label
= "fake directory create times",
1737 .offset
= LOCAL_VAR(bFakeDirCreateTimes
),
1740 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
,
1743 .label
= "async smb echo handler",
1745 .p_class
= P_GLOBAL
,
1746 .offset
= GLOBAL_VAR(bAsyncSMBEchoHandler
),
1749 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
,
1752 .label
= "panic action",
1754 .p_class
= P_GLOBAL
,
1755 .offset
= GLOBAL_VAR(szPanicAction
),
1758 .flags
= FLAG_ADVANCED
,
1761 .label
= "perfcount module",
1763 .p_class
= P_GLOBAL
,
1764 .offset
= GLOBAL_VAR(szSMBPerfcountModule
),
1767 .flags
= FLAG_ADVANCED
,
1770 {N_("VFS module options"), P_SEP
, P_SEPARATOR
},
1773 .label
= "vfs objects",
1776 .offset
= LOCAL_VAR(szVfsObjects
),
1779 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
1782 .label
= "vfs object",
1785 .offset
= LOCAL_VAR(szVfsObjects
),
1792 {N_("MSDFS options"), P_SEP
, P_SEPARATOR
},
1795 .label
= "msdfs root",
1798 .offset
= LOCAL_VAR(bMSDfsRoot
),
1801 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
1804 .label
= "msdfs proxy",
1807 .offset
= LOCAL_VAR(szMSDfsProxy
),
1810 .flags
= FLAG_ADVANCED
| FLAG_SHARE
,
1813 .label
= "host msdfs",
1815 .p_class
= P_GLOBAL
,
1816 .offset
= GLOBAL_VAR(bHostMSDfs
),
1819 .flags
= FLAG_ADVANCED
,
1822 {N_("Winbind options"), P_SEP
, P_SEPARATOR
},
1825 .label
= "passdb expand explicit",
1827 .p_class
= P_GLOBAL
,
1828 .offset
= GLOBAL_VAR(bPassdbExpandExplicit
),
1831 .flags
= FLAG_ADVANCED
,
1834 .label
= "idmap backend",
1836 .p_class
= P_GLOBAL
,
1837 .offset
= GLOBAL_VAR(szIdmapBackend
),
1838 .special
= handle_idmap_backend
,
1840 .flags
= FLAG_ADVANCED
| FLAG_DEPRECATED
,
1843 .label
= "idmap cache time",
1845 .p_class
= P_GLOBAL
,
1846 .offset
= GLOBAL_VAR(iIdmapCacheTime
),
1849 .flags
= FLAG_ADVANCED
,
1852 .label
= "idmap negative cache time",
1854 .p_class
= P_GLOBAL
,
1855 .offset
= GLOBAL_VAR(iIdmapNegativeCacheTime
),
1858 .flags
= FLAG_ADVANCED
,
1861 .label
= "idmap uid",
1863 .p_class
= P_GLOBAL
,
1864 .offset
= GLOBAL_VAR(szIdmapUID
),
1865 .special
= handle_idmap_uid
,
1867 .flags
= FLAG_ADVANCED
| FLAG_DEPRECATED
,
1870 .label
= "winbind uid",
1872 .p_class
= P_GLOBAL
,
1873 .offset
= GLOBAL_VAR(szIdmapUID
),
1874 .special
= handle_idmap_uid
,
1879 .label
= "idmap gid",
1881 .p_class
= P_GLOBAL
,
1882 .offset
= GLOBAL_VAR(szIdmapGID
),
1883 .special
= handle_idmap_gid
,
1885 .flags
= FLAG_ADVANCED
| FLAG_DEPRECATED
,
1888 .label
= "winbind gid",
1890 .p_class
= P_GLOBAL
,
1891 .offset
= GLOBAL_VAR(szIdmapGID
),
1892 .special
= handle_idmap_gid
,
1897 .label
= "template homedir",
1899 .p_class
= P_GLOBAL
,
1900 .offset
= GLOBAL_VAR(szTemplateHomedir
),
1903 .flags
= FLAG_ADVANCED
,
1906 .label
= "template shell",
1908 .p_class
= P_GLOBAL
,
1909 .offset
= GLOBAL_VAR(szTemplateShell
),
1912 .flags
= FLAG_ADVANCED
,
1915 .label
= "winbind separator",
1917 .p_class
= P_GLOBAL
,
1918 .offset
= GLOBAL_VAR(szWinbindSeparator
),
1921 .flags
= FLAG_ADVANCED
,
1924 .label
= "winbind cache time",
1926 .p_class
= P_GLOBAL
,
1927 .offset
= GLOBAL_VAR(winbind_cache_time
),
1930 .flags
= FLAG_ADVANCED
,
1933 .label
= "winbind reconnect delay",
1935 .p_class
= P_GLOBAL
,
1936 .offset
= GLOBAL_VAR(winbind_reconnect_delay
),
1939 .flags
= FLAG_ADVANCED
,
1942 .label
= "winbind max clients",
1944 .p_class
= P_GLOBAL
,
1945 .offset
= GLOBAL_VAR(winbind_max_clients
),
1948 .flags
= FLAG_ADVANCED
,
1951 .label
= "winbind enum users",
1953 .p_class
= P_GLOBAL
,
1954 .offset
= GLOBAL_VAR(bWinbindEnumUsers
),
1957 .flags
= FLAG_ADVANCED
,
1960 .label
= "winbind enum groups",
1962 .p_class
= P_GLOBAL
,
1963 .offset
= GLOBAL_VAR(bWinbindEnumGroups
),
1966 .flags
= FLAG_ADVANCED
,
1969 .label
= "winbind use default domain",
1971 .p_class
= P_GLOBAL
,
1972 .offset
= GLOBAL_VAR(bWinbindUseDefaultDomain
),
1975 .flags
= FLAG_ADVANCED
,
1978 .label
= "winbind trusted domains only",
1980 .p_class
= P_GLOBAL
,
1981 .offset
= GLOBAL_VAR(bWinbindTrustedDomainsOnly
),
1984 .flags
= FLAG_ADVANCED
,
1987 .label
= "winbind nested groups",
1989 .p_class
= P_GLOBAL
,
1990 .offset
= GLOBAL_VAR(bWinbindNestedGroups
),
1993 .flags
= FLAG_ADVANCED
,
1996 .label
= "winbind expand groups",
1998 .p_class
= P_GLOBAL
,
1999 .offset
= GLOBAL_VAR(winbind_expand_groups
),
2002 .flags
= FLAG_ADVANCED
,
2005 .label
= "winbind nss info",
2007 .p_class
= P_GLOBAL
,
2008 .offset
= GLOBAL_VAR(szWinbindNssInfo
),
2011 .flags
= FLAG_ADVANCED
,
2014 .label
= "winbind refresh tickets",
2016 .p_class
= P_GLOBAL
,
2017 .offset
= GLOBAL_VAR(bWinbindRefreshTickets
),
2020 .flags
= FLAG_ADVANCED
,
2023 .label
= "winbind offline logon",
2025 .p_class
= P_GLOBAL
,
2026 .offset
= GLOBAL_VAR(bWinbindOfflineLogon
),
2029 .flags
= FLAG_ADVANCED
,
2032 .label
= "winbind normalize names",
2034 .p_class
= P_GLOBAL
,
2035 .offset
= GLOBAL_VAR(bWinbindNormalizeNames
),
2038 .flags
= FLAG_ADVANCED
,
2041 .label
= "winbind rpc only",
2043 .p_class
= P_GLOBAL
,
2044 .offset
= GLOBAL_VAR(bWinbindRpcOnly
),
2047 .flags
= FLAG_ADVANCED
,
2050 .label
= "create krb5 conf",
2052 .p_class
= P_GLOBAL
,
2053 .offset
= GLOBAL_VAR(bCreateKrb5Conf
),
2056 .flags
= FLAG_ADVANCED
,
2059 .label
= "ncalrpc dir",
2061 .p_class
= P_GLOBAL
,
2062 .offset
= GLOBAL_VAR(ncalrpc_dir
),
2065 .flags
= FLAG_ADVANCED
,
2068 .label
= "winbind max domain connections",
2070 .p_class
= P_GLOBAL
,
2071 .offset
= GLOBAL_VAR(winbindMaxDomainConnections
),
2074 .flags
= FLAG_ADVANCED
,
2077 .label
= "winbindd socket directory",
2079 .p_class
= P_GLOBAL
,
2080 .offset
= GLOBAL_VAR(szWinbinddSocketDirectory
),
2083 .flags
= FLAG_ADVANCED
,
2086 .label
= "winbindd privileged socket directory",
2088 .p_class
= P_GLOBAL
,
2089 .offset
= GLOBAL_VAR(szWinbinddPrivilegedSocketDirectory
),
2092 .flags
= FLAG_ADVANCED
,
2095 .label
= "winbind sealed pipes",
2097 .p_class
= P_GLOBAL
,
2098 .offset
= GLOBAL_VAR(bWinbindSealedPipes
),
2101 .flags
= FLAG_ADVANCED
,
2104 {N_("DNS options"), P_SEP
, P_SEPARATOR
},
2106 .label
= "allow dns updates",
2108 .p_class
= P_GLOBAL
,
2109 .offset
= GLOBAL_VAR(allow_dns_updates
),
2111 .enum_list
= enum_dns_update_settings
,
2112 .flags
= FLAG_ADVANCED
,
2115 .label
= "dns forwarder",
2117 .p_class
= P_GLOBAL
,
2118 .offset
= GLOBAL_VAR(dns_forwarder
),
2121 .flags
= FLAG_ADVANCED
,
2124 .label
= "dns recursive queries",
2126 .p_class
= P_GLOBAL
,
2127 .offset
= GLOBAL_VAR(dns_recursive_queries
),
2132 .label
= "dns update command",
2134 .p_class
= P_GLOBAL
,
2135 .offset
= GLOBAL_VAR(szDNSUpdateCommand
),
2138 .flags
= FLAG_ADVANCED
,
2141 .label
= "nsupdate command",
2143 .p_class
= P_GLOBAL
,
2144 .offset
= GLOBAL_VAR(szNSUpdateCommand
),
2147 .flags
= FLAG_ADVANCED
,
2150 .label
= "rndc command",
2152 .p_class
= P_GLOBAL
,
2153 .offset
= GLOBAL_VAR(szRNDCCommand
),
2156 .flags
= FLAG_ADVANCED
,
2159 .label
= "multicast dns register",
2161 .p_class
= P_GLOBAL
,
2162 .offset
= GLOBAL_VAR(bMulticastDnsRegister
),
2165 .flags
= FLAG_ADVANCED
| FLAG_GLOBAL
,
2168 {N_("AD DC options"), P_SEP
, P_SEPARATOR
},
2171 .label
= "samba kcc command",
2173 .p_class
= P_GLOBAL
,
2174 .offset
= GLOBAL_VAR(szSambaKCCCommand
),
2177 .flags
= FLAG_ADVANCED
,
2180 .label
= "server services",
2182 .p_class
= P_GLOBAL
,
2183 .offset
= GLOBAL_VAR(server_services
),
2188 .label
= "dcerpc endpoint servers",
2190 .p_class
= P_GLOBAL
,
2191 .offset
= GLOBAL_VAR(dcerpc_ep_servers
),
2196 .label
= "spn update command",
2198 .p_class
= P_GLOBAL
,
2199 .offset
= GLOBAL_VAR(szSPNUpdateCommand
),
2202 .flags
= FLAG_ADVANCED
,
2205 .label
= "share backend",
2207 .p_class
= P_GLOBAL
,
2208 .offset
= GLOBAL_VAR(szShareBackend
),
2213 .label
= "ntvfs handler",
2216 .offset
= LOCAL_VAR(ntvfs_handler
),
2221 {N_("TLS options"), P_SEP
, P_SEPARATOR
},
2224 .label
= "tls enabled",
2226 .p_class
= P_GLOBAL
,
2227 .offset
= GLOBAL_VAR(tls_enabled
),
2232 .label
= "tls keyfile",
2234 .p_class
= P_GLOBAL
,
2235 .offset
= GLOBAL_VAR(tls_keyfile
),
2240 .label
= "tls certfile",
2242 .p_class
= P_GLOBAL
,
2243 .offset
= GLOBAL_VAR(tls_certfile
),
2248 .label
= "tls cafile",
2250 .p_class
= P_GLOBAL
,
2251 .offset
= GLOBAL_VAR(tls_cafile
),
2256 .label
= "tls crlfile",
2258 .p_class
= P_GLOBAL
,
2259 .offset
= GLOBAL_VAR(tls_crlfile
),
2264 .label
= "tls dh params file",
2266 .p_class
= P_GLOBAL
,
2267 .offset
= GLOBAL_VAR(tls_dhpfile
),
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
;
2284 struct loadparm_service
*currentService
;
2285 bool bInGlobalSection
;
2287 struct file_lists
*next
;
2292 unsigned int flags
[NUMPARAMETERS
];
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;
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? */
2330 DEBUG(10, ("lp_string(%s)\n", s
));
2333 #if 0 /* until REWRITE done to make thread-safe */
2335 lp_talloc
= talloc_init("lp_talloc");
2337 ret
= talloc_array(lp_talloc
, char, len
+ 100); /* leave room for substitution */
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);
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
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
;
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
);
2510 if (strcmp(data
->key
, vfskey
) == 0) {
2511 talloc_free(vfskey
);
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
);
2529 talloc_free(vfskey
);
2536 * convenience routine to return int parameters.
2538 static int lp_int(const char *s
)
2542 DEBUG(0,("lp_int(%s): is called with NULL!\n",s
));
2546 return strtol(s
, NULL
, 0);
2550 * convenience routine to return unsigned long parameters.
2552 static unsigned long lp_ulong(const char *s
)
2556 DEBUG(0,("lp_ulong(%s): is called with NULL!\n",s
));
2560 return strtoul(s
, NULL
, 0);
2564 * convenience routine to return unsigned long parameters.
2566 static long lp_long(const char *s
)
2570 DEBUG(0,("lp_long(%s): is called with NULL!\n",s
));
2574 return strtol(s
, NULL
, 0);
2578 * convenience routine to return unsigned long parameters.
2580 static double lp_double(const char *s
)
2584 DEBUG(0,("lp_double(%s): is called with NULL!\n",s
));
2588 return strtod(s
, NULL
);
2592 * convenience routine to return boolean parameters.
2594 static bool lp_bool(const char *s
)
2599 DEBUG(0,("lp_bool(%s): is called with NULL!\n",s
));
2603 if (!set_boolean(s
, &ret
)) {
2604 DEBUG(0,("lp_bool(%s): value is not boolean!\n",s
));
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
,
2622 const char *value
= lpcfg_get_parametric(lp_ctx
, service
, type
, option
);
2625 return lp_string(value
);
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
,
2640 const char *option
, const char *separator
)
2642 const char *value
= lpcfg_get_parametric(lp_ctx
, service
, type
, option
);
2645 return (const char **)str_list_make(mem_ctx
, value
, separator
);
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
);
2662 return lp_int(value
);
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
)
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
) {
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
);
2702 return lp_ulong(value
);
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
);
2714 return lp_long(value
);
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
);
2726 return lp_double(value
);
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
);
2743 return lp_bool(value
);
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
);
2762 * Set a string value, deallocating any existing space, and allocing the space
2765 static bool lpcfg_string_set(TALLOC_CTX
*mem_ctx
, char **dest
, const char *src
)
2772 *dest
= talloc_strdup(mem_ctx
, src
);
2773 if ((*dest
) == NULL
) {
2774 DEBUG(0,("Out of memory in string_set\n"));
2782 * Set a string value, deallocating any existing space, and allocing the space
2785 static bool lpcfg_string_set_upper(TALLOC_CTX
*mem_ctx
, char **dest
, const char *src
)
2792 *dest
= strupper_talloc(mem_ctx
, src
);
2793 if ((*dest
) == NULL
) {
2794 DEBUG(0,("Out of memory in string_set_upper\n"));
2804 * Add a new service to the services array initialising it with the given
2808 struct loadparm_service
*lpcfg_add_service(struct loadparm_context
*lp_ctx
,
2809 const struct loadparm_service
*pservice
,
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 */
2825 struct loadparm_service
*service
= getservicebyname(lp_ctx
,
2827 if (service
!= NULL
) {
2828 /* Clean all parametric options for service */
2829 /* They will be added during parsing again */
2830 data
= service
->param_opt
;
2836 service
->param_opt
= NULL
;
2841 /* find an invalid one */
2842 for (i
= 0; i
< lp_ctx
->iNumServices
; i
++)
2843 if (lp_ctx
->services
[i
] == NULL
)
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
);
2853 DEBUG(0,("lpcfg_add_service: failed to enlarge services!\n"));
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"));
2868 copy_service(lp_ctx
->services
[i
], &tservice
, 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
)
2891 if (!(*(default_service
->szPath
))
2892 || strequal(default_service
->szPath
, lp_ctx
->sDefault
->szPath
)) {
2893 service
->szPath
= talloc_strdup(service
, pszHomedir
);
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
));
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
)
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
));
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
)
2953 if (*pszParmName
== '-')
2956 for (iIndex
= 0; parm_table
[iIndex
].label
; iIndex
++)
2957 if (strwicmp(parm_table
[iIndex
].label
, pszParmName
) == 0)
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
2971 return the parameter structure for a parameter
2973 struct parm_struct
*lpcfg_parm_struct(struct loadparm_context
*lp_ctx
, const char *name
)
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
;
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
)
3014 if (lp_ctx
->s3_fns
) {
3015 struct parm_struct
*parm
= lp_ctx
->s3_fns
->get_parm_struct(name
);
3017 return parm
->flags
& FLAG_CMDLINE
;
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
)
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
];
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
)
3060 bool bcopyall
= (pcopymapDest
== NULL
);
3061 struct parmlist_entry
*data
, *pdata
, *paramo
;
3064 for (i
= 0; parm_table
[i
].label
; i
++)
3065 if (parm_table
[i
].p_class
== P_LOCAL
&&
3066 (bcopyall
|| bitmap_query(pcopymapDest
, i
))) {
3068 ((char *)pserviceSource
) + parm_table
[i
].offset
;
3070 ((char *)pserviceDest
) + parm_table
[i
].offset
;
3072 switch (parm_table
[i
].type
) {
3074 *(bool *)dest_ptr
= *(bool *)src_ptr
;
3081 *(int *)dest_ptr
= *(int *)src_ptr
;
3085 lpcfg_string_set(pserviceDest
,
3091 lpcfg_string_set_upper(pserviceDest
,
3096 *(const char ***)dest_ptr
= (const char **)str_list_copy(pserviceDest
,
3097 *(const char ***)src_ptr
);
3105 init_copymap(pserviceDest
);
3106 if (pserviceSource
->copymap
)
3107 bitmap_copy(pserviceDest
->copymap
,
3108 pserviceSource
->copymap
);
3111 data
= pserviceSource
->param_opt
;
3114 pdata
= pserviceDest
->param_opt
;
3115 /* Traverse destination */
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
,
3125 pdata
= pdata
->next
;
3128 paramo
= talloc_zero(pserviceDest
, struct parmlist_entry
);
3131 paramo
->key
= talloc_strdup(paramo
, data
->key
);
3132 paramo
->value
= talloc_strdup(paramo
, data
->value
);
3133 DLIST_ADD(pserviceDest
->param_opt
, paramo
);
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
)
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"));
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
));
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
;
3187 if (f
->name
&& !strcmp(f
->name
, fname
))
3193 f
= talloc(lp_ctx
, struct file_lists
);
3196 f
->next
= lp_ctx
->file_lists
;
3197 f
->name
= talloc_strdup(f
, fname
);
3202 f
->subfname
= talloc_strdup(f
, subfname
);
3207 lp_ctx
->file_lists
= f
;
3208 f
->modtime
= file_modtime(subfname
);
3210 time_t t
= file_modtime(subfname
);
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
) {
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
,
3238 f
->modtime
= mod_time
;
3239 talloc_free(f
->subfname
);
3240 f
->subfname
= talloc_strdup(f
, n2
);
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
);
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
));
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
)
3294 struct loadparm_service
*serviceTemp
;
3296 lpcfg_string_set(lp_ctx
, ptr
, pszParmValue
);
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
));
3306 copy_service(lp_ctx
->currentService
,
3308 lp_ctx
->currentService
->copymap
);
3312 DEBUG(0, ("Unable to copy service - source not found: %s\n",
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
);
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
);
3341 /***************************************************************************
3342 Initialise a copymap.
3343 ***************************************************************************/
3345 static void init_copymap(struct loadparm_service
*pservice
)
3349 TALLOC_FREE(pservice
->copymap
);
3351 pservice
->copymap
= bitmap_talloc(NULL
, NUMPARAMETERS
);
3352 if (!pservice
->copymap
)
3354 ("Couldn't allocate copymap!! (size %d)\n",
3355 (int)NUMPARAMETERS
));
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
;
3371 TALLOC_CTX
*mem_ctx
;
3373 while (isspace((unsigned char)*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
;
3384 data
= service
->param_opt
;
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
)) {
3399 talloc_free(paramo
->value
);
3400 paramo
->value
= talloc_strdup(paramo
, pszParmValue
);
3401 paramo
->priority
= flags
;
3407 paramo
= talloc_zero(mem_ctx
, struct parmlist_entry
);
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
);
3416 DLIST_ADD(service
->param_opt
, paramo
);
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
)
3429 /* if it is a special case then go ahead */
3430 if (parm_table
[parmnum
].special
) {
3432 ret
= parm_table
[parmnum
].special(lp_ctx
, -1, pszParmValue
,
3437 goto mark_non_default
;
3440 /* now switch on the type of variable it is */
3441 switch (parm_table
[parmnum
].type
)
3445 if (!set_boolean(pszParmValue
, &b
)) {
3446 DEBUG(0,("lp_do_parameter(%s): value is not boolean!\n", pszParmValue
));
3449 *(bool *)parm_ptr
= b
;
3455 if (!set_boolean(pszParmValue
, &b
)) {
3456 DEBUG(0,("lp_do_parameter(%s): value is not boolean!\n", pszParmValue
));
3459 *(bool *)parm_ptr
= !b
;
3464 *(int *)parm_ptr
= atoi(pszParmValue
);
3468 *(char *)parm_ptr
= *pszParmValue
;
3472 *(int *)parm_ptr
= strtol(pszParmValue
, NULL
, 8);
3478 if (conv_str_size_error(pszParmValue
, &val
)) {
3479 if (val
<= INT_MAX
) {
3480 *(int *)parm_ptr
= (int)val
;
3485 DEBUG(0,("lp_do_parameter(%s): value is not "
3486 "a valid size specifier!\n", pszParmValue
));
3491 *(const char ***)parm_ptr
= (const char **)str_list_make(mem_ctx
,
3492 pszParmValue
, NULL
);
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
,
3502 *(const char ***)parm_ptr
= str_list_add(*(const char ***)parm_ptr
,
3505 } else if (new_list
[i
][0] == '-' && new_list
[i
][1]) {
3506 str_list_remove(*(const char ***)parm_ptr
,
3510 DEBUG(0, ("Unsupported list syntax for: %s = %s\n",
3511 pszParmName
, pszParmValue
));
3514 *(const char ***)parm_ptr
= (const char **) new_list
;
3521 lpcfg_string_set(mem_ctx
, (char **)parm_ptr
, pszParmValue
);
3525 lpcfg_string_set_upper(mem_ctx
, (char **)parm_ptr
, pszParmValue
);
3529 for (i
= 0; parm_table
[parmnum
].enum_list
[i
].name
; i
++) {
3532 parm_table
[parmnum
].enum_list
[i
].name
)) {
3534 parm_table
[parmnum
].
3539 if (!parm_table
[parmnum
].enum_list
[i
].name
) {
3540 DEBUG(0,("Unknown enumerated value '%s' for '%s'\n",
3541 pszParmValue
, pszParmName
));
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
;
3565 bool lpcfg_do_global_parameter(struct loadparm_context
*lp_ctx
,
3566 const char *pszParmName
, const char *pszParmValue
)
3568 int parmnum
= map_parameter(pszParmName
);
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
));
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
) {
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
)
3597 int parmnum
= map_parameter(pszParmName
);
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
));
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
) {
3613 if (parm_table
[parmnum
].p_class
== P_GLOBAL
) {
3615 ("Global parameter %s found in service section!\n",
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
,
3642 struct loadparm_context
*lp_ctx
= (struct loadparm_context
*)userdata
;
3644 if (lp_ctx
->bInGlobalSection
)
3645 return lpcfg_do_global_parameter(lp_ctx
, pszParmName
,
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
, ...)
3664 s
= talloc_vasprintf(NULL
, fmt
, ap
);
3666 ret
= lpcfg_do_global_parameter(lp_ctx
, pszParmName
, s
);
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
)
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
);
3699 DEBUG(0,("Unknown option '%s'\n", pszParmName
));
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
)) {
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
;
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
)
3731 s
= talloc_strdup(NULL
, option
);
3744 ret
= lpcfg_set_cmdline(lp_ctx
, s
, p
+1);
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
= ", ";
3764 for (i
= 0; p
->enum_list
[i
].name
; i
++) {
3765 if (*(int *)ptr
== p
->enum_list
[i
].value
) {
3767 p
->enum_list
[i
].name
);
3774 fprintf(f
, "%s", BOOLSTR(*(bool *)ptr
));
3778 fprintf(f
, "%s", BOOLSTR(!*(bool *)ptr
));
3783 fprintf(f
, "%d", *(int *)ptr
);
3787 fprintf(f
, "%c", *(char *)ptr
);
3791 int val
= *(int *)ptr
;
3795 fprintf(f
, "0%o", val
);
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 */
3812 if ( strchr_m( *list
, ' ' ) ) {
3813 fprintf(f
, "\"%s\"%s", *list
, list_sep
);
3815 fprintf(f
, "%s%s", *list
, list_sep
);
3823 if (*(char **)ptr
) {
3824 fprintf(f
, "%s", *(char **)ptr
);
3833 * Check if two parameters are equal.
3836 static bool equal_parameter(parm_type type
, void *ptr1
, void *ptr2
)
3841 return (*((bool *)ptr1
) == *((bool *)ptr2
));
3847 return (*((int *)ptr1
) == *((int *)ptr2
));
3850 return (*((char *)ptr1
) == *((char *)ptr2
));
3854 return str_list_equal(*(const char ***)ptr1
, *(const char ***)ptr2
);
3859 char *p1
= *(char **)ptr1
, *p2
= *(char **)ptr2
;
3864 return (p1
== p2
|| strequal(p1
, p2
));
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
;
3884 bool isglobal
= ((strwicmp(pszSectionName
, GLOBAL_NAME
) == 0) ||
3885 (strwicmp(pszSectionName
, GLOBAL_NAME2
) == 0));
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
));
3897 /* if we have a current service, tidy it up before moving on */
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 */
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
,
3912 DEBUG(0, ("Failed to add a new service\n"));
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
)
3930 switch (parm_table
[i
].type
) {
3933 return str_list_equal((const char **)parm_table
[i
].def
.lvalue
,
3934 (const char **)def_ptr
);
3937 return strequal(parm_table
[i
].def
.svalue
,
3941 return parm_table
[i
].def
.bvalue
==
3948 return parm_table
[i
].def
.ivalue
==
3957 *Display the contents of the global structure.
3960 static void dump_globals(struct loadparm_context
*lp_ctx
, FILE *f
,
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
))
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
);
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
)) {
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
)
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
)) {
4011 if (defaults_saved
) {
4012 if (is_default(sDefault
, i
)) {
4017 if (equal_parameter(parm_table
[i
].type
,
4018 ((char *)pService
) +
4019 parm_table
[i
].offset
,
4020 ((char *)sDefault
) +
4021 parm_table
[i
].offset
))
4025 fprintf(f
, "\t%s = ", parm_table
[i
].label
);
4026 print_parameter(&parm_table
[i
],
4027 ((char *)pService
) + parm_table
[i
].offset
, f
);
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
;
4045 parm
= lpcfg_parm_struct(lp_ctx
, parm_name
);
4050 ptr
= lpcfg_parm_ptr(lp_ctx
, service
,parm
);
4052 print_parameter(parm
, ptr
, f
);
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
,
4068 /* do the globals */
4069 for (; parm_table
[*i
].label
; (*i
)++) {
4070 if ((*parm_table
[*i
].label
== '-'))
4074 && (parm_table
[*i
].offset
==
4075 parm_table
[(*i
) - 1].offset
)
4076 && (parm_table
[*i
].p_class
==
4077 parm_table
[(*i
) - 1].p_class
))
4080 return &parm_table
[(*i
)++];
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
!= '-') &&
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
)++];
4110 * Auto-load some home services.
4112 static void lpcfg_add_auto_services(struct loadparm_context
*lp_ctx
,
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))
4128 for (i
= 0; i
< lp_ctx
->iNumServices
; i
++) {
4129 if (lp_ctx
->services
[i
] == NULL
)
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. */
4151 if (lp_ctx
->globals
->param_opt
!= NULL
) {
4152 struct parmlist_entry
*next
;
4153 for (data
= lp_ctx
->globals
->param_opt
; data
; data
=next
) {
4155 if (data
->priority
& FLAG_CMDLINE
) continue;
4156 DLIST_REMOVE(lp_ctx
->globals
->param_opt
, data
);
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
)
4173 struct loadparm_context
*lp_ctx
;
4174 struct parmlist_entry
*parm
;
4177 lp_ctx
= talloc_zero(mem_ctx
, struct loadparm_context
);
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
)) {
4205 if (parm_table
[i
].p_class
== P_LOCAL
) {
4206 r
= (char **)(((char *)lp_ctx
->sDefault
) + parm_table
[i
].offset
);
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 */
4229 lpcfg_do_global_parameter(lp_ctx
, "socket options", "TCP_NODELAY");
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
);
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
;
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
) {
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
) {
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");
4417 return dyn_CONFIGFILE
;
4421 * Update the internal state of a loadparm context after settings
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
) {
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
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);
4452 unsetenv("SOCKET_TESTNONBLOCK");
4458 bool lpcfg_load_default(struct loadparm_context
*lp_ctx
)
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
)
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
)));
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
4520 global_loadparm_context
= lp_ctx
;
4521 lp_ctx
->loaded
= true;
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
,
4549 if (lp_ctx
->s3_fns
) {
4550 lp_ctx
->s3_fns
->dump(f
, show_defaults
, maxtoprint
);
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')
4572 dump_a_service(service
, sDefault
, f
, NULL
);
4576 struct loadparm_service
*lpcfg_servicebynum(struct loadparm_context
*lp_ctx
,
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
)
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
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
));
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
)
4629 ret
= lp_string((const char *)((service
!= NULL
&& service
->volume
!= NULL
) ?
4630 service
->volume
: sDefault
->volume
));
4632 return lpcfg_servicename(service
);
4637 * If we are PDC then prefer us as DMB
4639 const char *lpcfg_printername(struct loadparm_service
*service
, struct loadparm_service
*sDefault
)
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
);
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;
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
) {
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
)
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");
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
));