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