ldb_tdb: Use mem_ctx and so avoid leak onto long-term memory on duplicated add.
[garming/samba-autobuild/.git] / lib / param / param_table.c
1 /*
2    Unix SMB/CIFS implementation.
3    Parameter loading functions
4    Copyright (C) Karl Auer 1993-1998
5
6    Largely re-written by Andrew Tridgell, September 1994
7
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) Michael Adam 2008
13    Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
14    Copyright (C) Andrew Bartlett 2011
15
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.
20
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.
25
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/>.
28 */
29
30 #include "includes.h"
31 #include "lib/param/param.h"
32 #include "lib/param/loadparm.h"
33 #include "lib/param/param_global.h"
34 #include "libcli/auth/ntlm_check.h"
35 #include "libcli/smb/smb_constants.h"
36 #include "libds/common/roles.h"
37 #include "source4/lib/tls/tls.h"
38
39 #ifndef N_
40 #define N_(x) x
41 #endif
42
43 static const struct enum_list enum_protocol[] = {
44         {PROTOCOL_DEFAULT, "default"}, /* the caller decides what this means */
45         {PROTOCOL_SMB2_10, "SMB2"}, /* for now keep PROTOCOL_SMB2_10 */
46         {PROTOCOL_SMB3_11, "SMB3"}, /* for now keep PROTOCOL_SMB3_11 */
47         {PROTOCOL_SMB3_11, "SMB3_11"},
48         {PROTOCOL_SMB3_10, "SMB3_10"},
49         {PROTOCOL_SMB3_02, "SMB3_02"},
50         {PROTOCOL_SMB3_00, "SMB3_00"},
51         {PROTOCOL_SMB2_24, "SMB2_24"},
52         {PROTOCOL_SMB2_22, "SMB2_22"},
53         {PROTOCOL_SMB2_10, "SMB2_10"},
54         {PROTOCOL_SMB2_02, "SMB2_02"},
55         {PROTOCOL_NT1, "NT1"},
56         {PROTOCOL_LANMAN2, "LANMAN2"},
57         {PROTOCOL_LANMAN1, "LANMAN1"},
58         {PROTOCOL_CORE, "CORE"},
59         {PROTOCOL_COREPLUS, "COREPLUS"},
60         {PROTOCOL_COREPLUS, "CORE+"},
61         {-1, NULL}
62 };
63
64 static const struct enum_list enum_security[] = {
65         {SEC_AUTO, "AUTO"},
66         {SEC_USER, "USER"},
67         {SEC_DOMAIN, "DOMAIN"},
68         {SEC_ADS, "ADS"},
69         {-1, NULL}
70 };
71
72 static const struct enum_list enum_bool_auto[] = {
73         {false, "No"},
74         {false, "False"},
75         {false, "0"},
76         {true, "Yes"},
77         {true, "True"},
78         {true, "1"},
79         {Auto, "Auto"},
80         {-1, NULL}
81 };
82
83 static const struct enum_list enum_csc_policy[] = {
84         {CSC_POLICY_MANUAL, "manual"},
85         {CSC_POLICY_DOCUMENTS, "documents"},
86         {CSC_POLICY_PROGRAMS, "programs"},
87         {CSC_POLICY_DISABLE, "disable"},
88         {-1, NULL}
89 };
90
91 /* Server role options */
92 static const struct enum_list enum_server_role[] = {
93         {ROLE_AUTO, "auto"},
94         {ROLE_STANDALONE, "standalone server"},
95         {ROLE_STANDALONE, "standalone"},
96         {ROLE_DOMAIN_MEMBER, "member server"},
97         {ROLE_DOMAIN_MEMBER, "member"},
98         {ROLE_DOMAIN_PDC, "classic primary domain controller"},
99         {ROLE_DOMAIN_BDC, "classic backup domain controller"},
100         {ROLE_ACTIVE_DIRECTORY_DC, "active directory domain controller"},
101         {ROLE_ACTIVE_DIRECTORY_DC, "domain controller"},
102         {ROLE_ACTIVE_DIRECTORY_DC, "dc"},
103         {-1, NULL}
104 };
105
106 /* SMB signing types. */
107 static const struct enum_list enum_smb_signing_vals[] = {
108         {SMB_SIGNING_DEFAULT, "default"},
109         {SMB_SIGNING_OFF, "No"},
110         {SMB_SIGNING_OFF, "False"},
111         {SMB_SIGNING_OFF, "0"},
112         {SMB_SIGNING_OFF, "Off"},
113         {SMB_SIGNING_OFF, "disabled"},
114         {SMB_SIGNING_IF_REQUIRED, "if_required"},
115         {SMB_SIGNING_IF_REQUIRED, "Yes"},
116         {SMB_SIGNING_IF_REQUIRED, "True"},
117         {SMB_SIGNING_IF_REQUIRED, "1"},
118         {SMB_SIGNING_IF_REQUIRED, "On"},
119         {SMB_SIGNING_IF_REQUIRED, "enabled"},
120         {SMB_SIGNING_IF_REQUIRED, "auto"},
121         {SMB_SIGNING_DESIRED, "desired"},
122         {SMB_SIGNING_REQUIRED, "required"},
123         {SMB_SIGNING_REQUIRED, "mandatory"},
124         {SMB_SIGNING_REQUIRED, "force"},
125         {SMB_SIGNING_REQUIRED, "forced"},
126         {SMB_SIGNING_REQUIRED, "enforced"},
127         {-1, NULL}
128 };
129
130 static const struct enum_list enum_mdns_name_values[] = {
131         {MDNS_NAME_NETBIOS, "netbios"},
132         {MDNS_NAME_MDNS, "mdns"},
133         {-1, NULL}
134 };
135
136 static const struct enum_list enum_tls_verify_peer_vals[] = {
137         {TLS_VERIFY_PEER_NO_CHECK,
138          TLS_VERIFY_PEER_NO_CHECK_STRING},
139         {TLS_VERIFY_PEER_CA_ONLY,
140          TLS_VERIFY_PEER_CA_ONLY_STRING},
141         {TLS_VERIFY_PEER_CA_AND_NAME_IF_AVAILABLE,
142          TLS_VERIFY_PEER_CA_AND_NAME_IF_AVAILABLE_STRING},
143         {TLS_VERIFY_PEER_CA_AND_NAME,
144          TLS_VERIFY_PEER_CA_AND_NAME_STRING},
145         {TLS_VERIFY_PEER_AS_STRICT_AS_POSSIBLE,
146          TLS_VERIFY_PEER_AS_STRICT_AS_POSSIBLE_STRING},
147         {-1, NULL}
148 };
149
150 /* DNS update options. */
151 static const struct enum_list enum_dns_update_settings[] = {
152         {DNS_UPDATE_OFF, "disabled"},
153         {DNS_UPDATE_OFF, "No"},
154         {DNS_UPDATE_OFF, "False"},
155         {DNS_UPDATE_OFF, "0"},
156         {DNS_UPDATE_OFF, "Off"},
157         {DNS_UPDATE_ON, "nonsecure and secure"},
158         {DNS_UPDATE_ON, "nonsecure"},
159         {DNS_UPDATE_SIGNED, "secure only"},
160         {DNS_UPDATE_SIGNED, "secure"},
161         {DNS_UPDATE_SIGNED, "signed"},
162         {-1, NULL}
163 };
164
165 /*
166    Do you want session setups at user level security with a invalid
167    password to be rejected or allowed in as guest? WinNT rejects them
168    but it can be a pain as it means "net view" needs to use a password
169
170    You have 3 choices in the setting of map_to_guest:
171
172    "Never" means session setups with an invalid password
173    are rejected. This is the default.
174
175    "Bad User" means session setups with an invalid password
176    are rejected, unless the username does not exist, in which case it
177    is treated as a guest login
178
179    "Bad Password" means session setups with an invalid password
180    are treated as a guest login
181
182    Note that map_to_guest only has an effect in user or server
183    level security.
184 */
185
186 static const struct enum_list enum_map_to_guest[] = {
187         {NEVER_MAP_TO_GUEST, "Never"},
188         {MAP_TO_GUEST_ON_BAD_USER, "Bad User"},
189         {MAP_TO_GUEST_ON_BAD_PASSWORD, "Bad Password"},
190         {MAP_TO_GUEST_ON_BAD_UID, "Bad Uid"},
191         {-1, NULL}
192 };
193
194 /* Config backend options */
195
196 static const struct enum_list enum_config_backend[] = {
197         {CONFIG_BACKEND_FILE, "file"},
198         {CONFIG_BACKEND_REGISTRY, "registry"},
199         {-1, NULL}
200 };
201
202 static const struct enum_list enum_smbd_profiling_level[] = {
203         {0, "off"}, {1, "count"}, {2, "on"}, {-1, NULL}
204 };
205
206
207 /* ADS kerberos ticket verification options */
208
209 static const struct enum_list enum_kerberos_method[] = {
210         {KERBEROS_VERIFY_SECRETS, "default"},
211         {KERBEROS_VERIFY_SECRETS, "secrets only"},
212         {KERBEROS_VERIFY_SECRETS, "secretsonly"},
213         {KERBEROS_VERIFY_SYSTEM_KEYTAB, "system keytab"},
214         {KERBEROS_VERIFY_SYSTEM_KEYTAB, "systemkeytab"},
215         {KERBEROS_VERIFY_DEDICATED_KEYTAB, "dedicated keytab"},
216         {KERBEROS_VERIFY_DEDICATED_KEYTAB, "dedicatedkeytab"},
217         {KERBEROS_VERIFY_SECRETS_AND_KEYTAB, "secrets and keytab"},
218         {KERBEROS_VERIFY_SECRETS_AND_KEYTAB, "secretsandkeytab"},
219         {-1, NULL}
220 };
221
222 /* Kerberos encryption types selection options */
223
224 static const struct enum_list enum_kerberos_encryption_types_vals[] = {
225         {KERBEROS_ETYPES_ALL, "all"},
226         {KERBEROS_ETYPES_STRONG, "strong"},
227         {KERBEROS_ETYPES_LEGACY, "legacy"},
228         {-1, NULL}
229 };
230
231 static const struct enum_list enum_printing[] = {
232         {PRINT_SYSV, "sysv"},
233         {PRINT_AIX, "aix"},
234         {PRINT_HPUX, "hpux"},
235         {PRINT_BSD, "bsd"},
236         {PRINT_QNX, "qnx"},
237         {PRINT_PLP, "plp"},
238         {PRINT_LPRNG, "lprng"},
239 #ifdef HAVE_CUPS
240         {PRINT_CUPS, "cups"},
241 #endif
242 #ifdef HAVE_IPRINT
243         {PRINT_IPRINT, "iprint"},
244 #endif
245         {PRINT_LPRNT, "nt"},
246         {PRINT_LPROS2, "os2"},
247 #if defined(DEVELOPER) || defined(ENABLE_SELFTEST)
248         {PRINT_TEST, "test"},
249         {PRINT_VLP, "vlp"},
250 #endif /* DEVELOPER */
251         {-1, NULL}
252 };
253
254 static const struct enum_list enum_ldap_sasl_wrapping[] = {
255         {0, "plain"},
256         {ADS_AUTH_SASL_SIGN, "sign"},
257         {ADS_AUTH_SASL_SEAL, "seal"},
258         {-1, NULL}
259 };
260
261 static const struct enum_list enum_ldap_server_require_strong_auth_vals[] = {
262         { LDAP_SERVER_REQUIRE_STRONG_AUTH_NO, "No" },
263         { LDAP_SERVER_REQUIRE_STRONG_AUTH_NO, "False" },
264         { LDAP_SERVER_REQUIRE_STRONG_AUTH_NO, "0" },
265         { LDAP_SERVER_REQUIRE_STRONG_AUTH_ALLOW_SASL_OVER_TLS,
266           "allow_sasl_over_tls" },
267         { LDAP_SERVER_REQUIRE_STRONG_AUTH_YES, "Yes" },
268         { LDAP_SERVER_REQUIRE_STRONG_AUTH_YES, "True" },
269         { LDAP_SERVER_REQUIRE_STRONG_AUTH_YES, "1" },
270         {-1, NULL}
271 };
272
273 static const struct enum_list enum_ldap_ssl[] = {
274         {LDAP_SSL_OFF, "no"},
275         {LDAP_SSL_OFF, "off"},
276         {LDAP_SSL_START_TLS, "start tls"},
277         {LDAP_SSL_START_TLS, "start_tls"},
278         {-1, NULL}
279 };
280
281 /* LDAP Dereferencing Alias types */
282 #define SAMBA_LDAP_DEREF_NEVER          0
283 #define SAMBA_LDAP_DEREF_SEARCHING      1
284 #define SAMBA_LDAP_DEREF_FINDING        2
285 #define SAMBA_LDAP_DEREF_ALWAYS         3
286
287 static const struct enum_list enum_ldap_deref[] = {
288         {SAMBA_LDAP_DEREF_NEVER, "never"},
289         {SAMBA_LDAP_DEREF_SEARCHING, "searching"},
290         {SAMBA_LDAP_DEREF_FINDING, "finding"},
291         {SAMBA_LDAP_DEREF_ALWAYS, "always"},
292         {-1, "auto"}
293 };
294
295 static const struct enum_list enum_ldap_passwd_sync[] = {
296         {LDAP_PASSWD_SYNC_OFF, "no"},
297         {LDAP_PASSWD_SYNC_OFF, "off"},
298         {LDAP_PASSWD_SYNC_ON, "yes"},
299         {LDAP_PASSWD_SYNC_ON, "on"},
300         {LDAP_PASSWD_SYNC_ONLY, "only"},
301         {-1, NULL}
302 };
303
304 static const struct enum_list enum_map_readonly[] = {
305         {MAP_READONLY_NO, "no"},
306         {MAP_READONLY_NO, "false"},
307         {MAP_READONLY_NO, "0"},
308         {MAP_READONLY_YES, "yes"},
309         {MAP_READONLY_YES, "true"},
310         {MAP_READONLY_YES, "1"},
311         {MAP_READONLY_PERMISSIONS, "permissions"},
312         {MAP_READONLY_PERMISSIONS, "perms"},
313         {-1, NULL}
314 };
315
316 static const struct enum_list enum_case[] = {
317         {CASE_LOWER, "lower"},
318         {CASE_UPPER, "upper"},
319         {-1, NULL}
320 };
321
322 static const struct enum_list enum_inherit_owner_vals[] = {
323     {INHERIT_OWNER_NO, "no"},
324     {INHERIT_OWNER_WINDOWS_AND_UNIX, "windows and unix"},
325     {INHERIT_OWNER_WINDOWS_AND_UNIX, "yes"},
326     {INHERIT_OWNER_UNIX_ONLY, "unix only"},
327     {-1, NULL}};
328
329 static const struct enum_list enum_mangled_names[] = {
330         {MANGLED_NAMES_NO, "no"},
331         {MANGLED_NAMES_NO, "false"},
332         {MANGLED_NAMES_NO, "0"},
333         {MANGLED_NAMES_ILLEGAL, "illegal"},
334         {MANGLED_NAMES_YES, "yes"},
335         {MANGLED_NAMES_YES, "true"},
336         {MANGLED_NAMES_YES, "1"},
337         {-1, NULL}
338 };
339
340 static const struct enum_list enum_ntlm_auth[] = {
341         {NTLM_AUTH_DISABLED, "disabled"},
342         {NTLM_AUTH_NTLMV2_ONLY, "ntlmv2-only"},
343         {NTLM_AUTH_NTLMV2_ONLY, "no"},
344         {NTLM_AUTH_NTLMV2_ONLY, "false"},
345         {NTLM_AUTH_NTLMV2_ONLY, "0"},
346         {NTLM_AUTH_ON, "ntlmv1-permitted"},
347         {NTLM_AUTH_ON, "yes"},
348         {NTLM_AUTH_ON, "true"},
349         {NTLM_AUTH_ON, "1"},
350         {NTLM_AUTH_MSCHAPv2_NTLMV2_ONLY, "mschapv2-and-ntlmv2-only"},
351         {-1, NULL}
352 };
353
354 /* Note: We do not initialise the defaults union - it is not allowed in ANSI C
355  *
356  * NOTE: Handling of duplicated (synonym) parameters:
357  *   Parameters that are synonymous are stored in the same variable.
358  *   All but the default spelling carry the flag FLAG_SYNONYM.
359  */
360
361 #define GLOBAL_VAR(name) offsetof(struct loadparm_global, name)
362 #define LOCAL_VAR(name) offsetof(struct loadparm_service, name)
363
364 #include "lib/param/param_table_gen.c"
365
366 int num_parameters(void)
367 {
368         return (sizeof(parm_table) / sizeof(struct parm_struct));
369 }