d8f69753ad4f4d4879b3b578747845b52bcfb61b
[sfrench/samba-autobuild/.git] / lib / param / loadparm.h
1 /*
2    Unix SMB/CIFS implementation.
3
4    type definitions for loadparm
5
6    Copyright (C) Karl Auer 1993-1998
7
8    Largely re-written by Andrew Tridgell, September 1994
9
10    Copyright (C) Simo Sorce 2001
11    Copyright (C) Alexander Bokovoy 2002
12    Copyright (C) Stefan (metze) Metzmacher 2002
13    Copyright (C) Jim McDonough (jmcd@us.ibm.com)  2003.
14    Copyright (C) James Myers 2003 <myersjj@samba.org>
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 #ifndef _LOADPARM_H
31 #define _LOADPARM_H
32
33 #include <talloc.h>
34
35 struct parmlist_entry {
36         struct parmlist_entry *prev, *next;
37         char *key;
38         char *value;
39         char **list; /* For the source3 parametric options, to save the parsed list */
40         int priority;
41 };
42
43 struct parmlist {
44         struct parmlist_entry *entries;
45 };
46
47 /* the following are used by loadparm for option lists */
48 typedef enum {
49         P_BOOL,P_BOOLREV,P_CHAR,P_INTEGER,P_OCTAL,P_LIST,
50         P_STRING,P_USTRING,P_ENUM,P_BYTES,P_CMDLIST
51 } parm_type;
52
53 typedef enum {
54         P_LOCAL,P_GLOBAL,P_NONE
55 } parm_class;
56
57 struct enum_list {
58         int value;
59         const char *name;
60 };
61
62 struct loadparm_service;
63 struct loadparm_context {
64         const char *szConfigFile;
65         struct loadparm_global *globals;
66         struct loadparm_service **services;
67         struct loadparm_service *sDefault;
68         struct smb_iconv_handle *iconv_handle;
69         int iNumServices;
70         struct loadparm_service *currentService;
71         bool bInGlobalSection;
72         struct file_lists *file_lists;
73         unsigned int *flags;
74         bool loaded;
75         bool refuse_free;
76         bool global; /* Is this the global context, which may set
77                       * global variables such as debug level etc? */
78         const struct loadparm_s3_helpers *s3_fns;
79 };
80
81 struct parm_struct {
82         const char *label;
83         parm_type type;
84         parm_class p_class;
85         offset_t offset;
86         bool (*special)(struct loadparm_context *lpcfg_ctx,
87                         struct loadparm_service *, const char *, char **);
88         const struct enum_list *enum_list;
89         unsigned flags;
90         union {
91                 bool bvalue;
92                 int ivalue;
93                 char *svalue;
94                 char cvalue;
95                 char **lvalue;
96         } def;
97 };
98
99 extern struct parm_struct parm_table[];
100
101 struct file_lists {
102         struct file_lists *next;
103         char *name;
104         char *subfname;
105         time_t modtime;
106 };
107
108 #define FLAG_DEPRECATED 0x1000 /* options that should no longer be used */
109 #define FLAG_SYNONYM    0x2000 /* options that is a synonym of another option */
110 #define FLAG_CMDLINE    0x10000 /* option has been overridden */
111 #define FLAG_DEFAULT    0x20000 /* this option was a default */
112
113 /* This defines the section name in the configuration file that will
114    refer to the special "printers" service */
115 #ifndef PRINTERS_NAME
116 #define PRINTERS_NAME "printers"
117 #endif
118
119 /* This defines the section name in the configuration file that will
120    refer to the special "homes" service */
121 #ifndef HOMES_NAME
122 #define HOMES_NAME "homes"
123 #endif
124
125 /* This defines the section name in the configuration file that will contain */
126 /* global parameters - that is, parameters relating to the whole server, not */
127 /* just services. This name is then reserved, and may not be used as a       */
128 /* a service name. It will default to "global" if not defined here.          */
129 #ifndef GLOBAL_NAME
130 #define GLOBAL_NAME "global"
131 #define GLOBAL_NAME2 "globals"
132 #endif
133
134 /* The default workgroup - usually overridden in smb.conf */
135 #ifndef DEFAULT_WORKGROUP
136 #define DEFAULT_WORKGROUP "WORKGROUP"
137 #endif
138
139 /* types of configuration backends for loadparm */
140 #define CONFIG_BACKEND_FILE 0
141 #define CONFIG_BACKEND_REGISTRY 1
142
143 /*
144    Do you want session setups at user level security with a invalid
145    password to be rejected or allowed in as guest? WinNT rejects them
146    but it can be a pain as it means "net view" needs to use a password
147
148    You have 3 choices in the setting of map_to_guest:
149
150    "NEVER_MAP_TO_GUEST" means session setups with an invalid password
151    are rejected. This is the default.
152
153    "MAP_TO_GUEST_ON_BAD_USER" means session setups with an invalid password
154    are rejected, unless the username does not exist, in which case it
155    is treated as a guest login
156
157    "MAP_TO_GUEST_ON_BAD_PASSWORD" means session setups with an invalid password
158    are treated as a guest login
159
160    Note that map_to_guest only has an effect in user or server
161    level security.
162 */
163
164 #define NEVER_MAP_TO_GUEST              0
165 #define MAP_TO_GUEST_ON_BAD_USER        1
166 #define MAP_TO_GUEST_ON_BAD_PASSWORD    2
167 #define MAP_TO_GUEST_ON_BAD_UID         3
168
169 /*
170  * This should be under the HAVE_KRB5 flag but since they're used
171  * in lp_kerberos_method(), they ned to be always available
172  * If you add any entries to KERBEROS_VERIFY defines, please modify USE.*KEYTAB macros
173  * so they remain accurate.
174  */
175
176 #define KERBEROS_VERIFY_SECRETS 0
177 #define KERBEROS_VERIFY_SYSTEM_KEYTAB 1
178 #define KERBEROS_VERIFY_DEDICATED_KEYTAB 2
179 #define KERBEROS_VERIFY_SECRETS_AND_KEYTAB 3
180
181 #define KERBEROS_ETYPES_ALL 0
182 #define KERBEROS_ETYPES_STRONG 1
183 #define KERBEROS_ETYPES_LEGACY 2
184
185 /* ACL compatibility */
186 enum acl_compatibility {ACL_COMPAT_AUTO, ACL_COMPAT_WINNT, ACL_COMPAT_WIN2K};
187
188 /* printing types */
189 enum printing_types {PRINT_BSD,PRINT_SYSV,PRINT_AIX,PRINT_HPUX,
190                      PRINT_QNX,PRINT_PLP,PRINT_LPRNG,PRINT_SOFTQ,
191                      PRINT_CUPS,PRINT_LPRNT,PRINT_LPROS2,PRINT_IPRINT
192 #if defined(DEVELOPER) || defined(ENABLE_SELFTEST)
193 ,PRINT_TEST,PRINT_VLP
194 #endif /* DEVELOPER */
195 };
196
197
198
199
200 /* ads auth control flags */
201 #define ADS_AUTH_DISABLE_KERBEROS 0x0001
202 #define ADS_AUTH_NO_BIND          0x0002
203 #define ADS_AUTH_ANON_BIND        0x0004
204 #define ADS_AUTH_SIMPLE_BIND      0x0008
205 #define ADS_AUTH_ALLOW_NTLMSSP    0x0010
206 #define ADS_AUTH_SASL_SIGN        0x0020
207 #define ADS_AUTH_SASL_SEAL        0x0040
208 #define ADS_AUTH_SASL_FORCE       0x0080
209 #define ADS_AUTH_USER_CREDS       0x0100
210
211 enum ldap_server_require_strong_auth {
212         LDAP_SERVER_REQUIRE_STRONG_AUTH_NO,
213         LDAP_SERVER_REQUIRE_STRONG_AUTH_ALLOW_SASL_OVER_TLS,
214         LDAP_SERVER_REQUIRE_STRONG_AUTH_YES,
215 };
216
217 /* DNS update settings */
218 enum dns_update_settings {DNS_UPDATE_OFF, DNS_UPDATE_ON, DNS_UPDATE_SIGNED};
219
220 /* LDAP SSL options */
221 enum ldap_ssl_types {LDAP_SSL_OFF, LDAP_SSL_START_TLS};
222
223 /* LDAP PASSWD SYNC methods */
224 enum ldap_passwd_sync_types {LDAP_PASSWD_SYNC_ON, LDAP_PASSWD_SYNC_OFF, LDAP_PASSWD_SYNC_ONLY};
225
226 /* map readonly options */
227 enum mapreadonly_options {MAP_READONLY_NO, MAP_READONLY_YES, MAP_READONLY_PERMISSIONS};
228
229 /* case handling */
230 enum case_handling {CASE_LOWER,CASE_UPPER};
231
232 /*
233  * Default passwd chat script.
234  */
235 #ifndef DEFAULT_PASSWD_CHAT
236 #define DEFAULT_PASSWD_CHAT "*new*password* %n\\n *new*password* %n\\n *changed*"
237 #endif
238
239 /* Max number of jobs per print queue. */
240 #ifndef PRINT_MAX_JOBID
241 #define PRINT_MAX_JOBID 10000
242 #endif
243
244 /* the default guest account - allow override via CFLAGS */
245 #ifndef GUEST_ACCOUNT
246 #define GUEST_ACCOUNT "nobody"
247 #endif
248
249 /* SMB2 defaults */
250 #define DEFAULT_SMB2_MAX_READ (8*1024*1024)
251 #define DEFAULT_SMB2_MAX_WRITE (8*1024*1024)
252 #define DEFAULT_SMB2_MAX_TRANSACT (8*1024*1024)
253 #define DEFAULT_SMB2_MAX_CREDITS 8192
254
255 #define LOADPARM_EXTRA_LOCALS                                           \
256         int usershare;                                                  \
257         struct timespec usershare_last_mod;                             \
258         char *szService;                                                \
259         struct parmlist_entry *param_opt;                               \
260         struct bitmap *copymap;                                         \
261         char dummy[3];          /* for alignment */
262
263 #include "lib/param/param_local.h"
264
265 #define LOADPARM_EXTRA_GLOBALS \
266         struct parmlist_entry *param_opt;                               \
267         char *dnsdomain;                                                \
268         char *realm_original;
269
270 const char* server_role_str(uint32_t role);
271 int lp_find_server_role(int server_role, int security, int domain_logons, int domain_master);
272 int lp_find_security(int server_role, int security);
273 bool lp_is_security_and_server_role_valid(int server_role, int security);
274
275 struct loadparm_global * get_globals(void);
276 unsigned int * get_flags(void);
277 char * lp_string(TALLOC_CTX *, const char *);
278 int getservicebyname(const char *, struct loadparm_service *);
279 bool lp_include(struct loadparm_context *, struct loadparm_service *,
280                 const char *, char **);
281 bool lp_do_section(const char *pszSectionName, void *userdata);
282 bool store_lp_set_cmdline(const char *pszParmName, const char *pszParmValue);
283
284 int num_parameters(void);
285
286 #endif /* _LOADPARM_H */