Proper fix for #6898 - Samba duplicates file content on appending. Pointed out by...
[Samba/gebeck_regimport.git] / source3 / include / smb.h
blob09689840280c791d9fe410fb16f47bc73ecdb2ec
1 /*
2 Unix SMB/CIFS implementation.
3 SMB parameters and setup, plus a whole lot more.
5 Copyright (C) Andrew Tridgell 1992-2000
6 Copyright (C) John H Terpstra 1996-2002
7 Copyright (C) Luke Kenneth Casson Leighton 1996-2000
8 Copyright (C) Paul Ashton 1998-2000
9 Copyright (C) Simo Sorce 2001-2002
10 Copyright (C) Martin Pool 2002
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 3 of the License, or
15 (at your option) any later version.
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program. If not, see <http://www.gnu.org/licenses/>.
26 #ifndef _SMB_H
27 #define _SMB_H
29 /* logged when starting the various Samba daemons */
30 #define COPYRIGHT_STARTUP_MESSAGE "Copyright Andrew Tridgell and the Samba Team 1992-2009"
33 #if defined(LARGE_SMB_OFF_T)
34 #define BUFFER_SIZE (128*1024)
35 #else /* no large readwrite possible */
36 #define BUFFER_SIZE (0xFFFF)
37 #endif
39 #define SAFETY_MARGIN 1024
40 #define LARGE_WRITEX_HDR_SIZE 65
42 #define NMB_PORT 137
43 #define DGRAM_PORT 138
44 #define SMB_PORT1 445
45 #define SMB_PORT2 139
46 #define SMB_PORTS "445 139"
48 #define Undefined (-1)
49 #define False false
50 #define True true
51 #define Auto (2)
52 #define Required (3)
54 #define SIZEOFWORD 2
56 #ifndef DEF_CREATE_MASK
57 #define DEF_CREATE_MASK (0755)
58 #endif
60 /* string manipulation flags - see clistr.c and srvstr.c */
61 #define STR_TERMINATE 1
62 #define STR_UPPER 2
63 #define STR_ASCII 4
64 #define STR_UNICODE 8
65 #define STR_NOALIGN 16
66 #define STR_TERMINATE_ASCII 128
68 /* how long to wait for secondary SMB packets (milli-seconds) */
69 #define SMB_SECONDARY_WAIT (60*1000)
71 /* Debugging stuff */
72 #include "debug.h"
74 /* this defines the error codes that receive_smb can put in smb_read_error */
75 enum smb_read_errors {
76 SMB_READ_OK = 0,
77 SMB_READ_TIMEOUT,
78 SMB_READ_EOF,
79 SMB_READ_ERROR,
80 SMB_WRITE_ERROR, /* This error code can go into the client smb_rw_error. */
81 SMB_READ_BAD_SIG,
82 SMB_NO_MEMORY,
83 SMB_DO_NOT_DO_TDIS, /* cli_close_connection() check for this when smbfs wants to keep tree connected */
84 SMB_READ_BAD_DECRYPT
87 #define DIR_STRUCT_SIZE 43
89 /* these define the attribute byte as seen by DOS */
90 #define aRONLY (1L<<0) /* 0x01 */
91 #define aHIDDEN (1L<<1) /* 0x02 */
92 #define aSYSTEM (1L<<2) /* 0x04 */
93 #define aVOLID (1L<<3) /* 0x08 */
94 #define aDIR (1L<<4) /* 0x10 */
95 #define aARCH (1L<<5) /* 0x20 */
97 /* deny modes */
98 #define DENY_DOS 0
99 #define DENY_ALL 1
100 #define DENY_WRITE 2
101 #define DENY_READ 3
102 #define DENY_NONE 4
103 #define DENY_FCB 7
105 /* open modes */
106 #define DOS_OPEN_RDONLY 0
107 #define DOS_OPEN_WRONLY 1
108 #define DOS_OPEN_RDWR 2
109 #define DOS_OPEN_EXEC 3
110 #define DOS_OPEN_FCB 0xF
112 /* define shifts and masks for share and open modes. */
113 #define OPENX_MODE_MASK 0xF
114 #define DENY_MODE_SHIFT 4
115 #define DENY_MODE_MASK 0x7
116 #define GET_OPENX_MODE(x) ((x) & OPENX_MODE_MASK)
117 #define SET_OPENX_MODE(x) ((x) & OPENX_MODE_MASK)
118 #define GET_DENY_MODE(x) (((x)>>DENY_MODE_SHIFT) & DENY_MODE_MASK)
119 #define SET_DENY_MODE(x) (((x) & DENY_MODE_MASK) <<DENY_MODE_SHIFT)
121 /* Sync on open file (not sure if used anymore... ?) */
122 #define FILE_SYNC_OPENMODE (1<<14)
123 #define GET_FILE_SYNC_OPENMODE(x) (((x) & FILE_SYNC_OPENMODE) ? True : False)
125 /* open disposition values */
126 #define OPENX_FILE_EXISTS_FAIL 0
127 #define OPENX_FILE_EXISTS_OPEN 1
128 #define OPENX_FILE_EXISTS_TRUNCATE 2
130 /* mask for open disposition. */
131 #define OPENX_FILE_OPEN_MASK 0x3
133 #define GET_FILE_OPENX_DISPOSITION(x) ((x) & FILE_OPEN_MASK)
134 #define SET_FILE_OPENX_DISPOSITION(x) ((x) & FILE_OPEN_MASK)
136 /* The above can be OR'ed with... */
137 #define OPENX_FILE_CREATE_IF_NOT_EXIST 0x10
138 #define OPENX_FILE_FAIL_IF_NOT_EXIST 0
140 #include "../libcli/util/doserr.h"
142 typedef union unid_t {
143 uid_t uid;
144 gid_t gid;
145 } unid_t;
148 * SMB UCS2 (16-bit unicode) internal type.
149 * smb_ucs2_t is *always* in little endian format.
152 #ifdef WORDS_BIGENDIAN
153 #define UCS2_SHIFT 8
154 #else
155 #define UCS2_SHIFT 0
156 #endif
158 /* turn a 7 bit character into a ucs2 character */
159 #define UCS2_CHAR(c) ((c) << UCS2_SHIFT)
161 /* return an ascii version of a ucs2 character */
162 #define UCS2_TO_CHAR(c) (((c) >> UCS2_SHIFT) & 0xff)
164 /* Copy into a smb_ucs2_t from a possibly unaligned buffer. Return the copied smb_ucs2_t */
165 #define COPY_UCS2_CHAR(dest,src) (((unsigned char *)(dest))[0] = ((unsigned char *)(src))[0],\
166 ((unsigned char *)(dest))[1] = ((unsigned char *)(src))[1], (dest))
168 /* pipe string names */
169 #define PIPE_LANMAN "\\PIPE\\LANMAN"
171 #define MAX_HOURS_LEN 32
173 #ifndef MAXSUBAUTHS
174 #define MAXSUBAUTHS 15 /* max sub authorities in a SID */
175 #endif
177 #define SID_MAX_SIZE ((size_t)(8+(MAXSUBAUTHS*4)))
179 #define LOOKUP_NAME_NONE 0x00000000
180 #define LOOKUP_NAME_ISOLATED 0x00000001 /* Look up unqualified names */
181 #define LOOKUP_NAME_REMOTE 0x00000002 /* Ask others */
182 #define LOOKUP_NAME_GROUP 0x00000004 /* (unused) This is a NASTY hack for
183 valid users = @foo where foo also
184 exists in as user. */
185 #define LOOKUP_NAME_NO_NSS 0x00000008 /* no NSS calls to avoid
186 winbind recursions */
187 #define LOOKUP_NAME_BUILTIN 0x00000010 /* builtin names */
188 #define LOOKUP_NAME_WKN 0x00000020 /* well known names */
189 #define LOOKUP_NAME_DOMAIN 0x00000040 /* only lookup own domain */
190 #define LOOKUP_NAME_LOCAL (LOOKUP_NAME_ISOLATED\
191 |LOOKUP_NAME_BUILTIN\
192 |LOOKUP_NAME_WKN\
193 |LOOKUP_NAME_DOMAIN)
194 #define LOOKUP_NAME_ALL (LOOKUP_NAME_ISOLATED\
195 |LOOKUP_NAME_REMOTE\
196 |LOOKUP_NAME_BUILTIN\
197 |LOOKUP_NAME_WKN\
198 |LOOKUP_NAME_DOMAIN)
201 * @brief Security Identifier
203 * @sa http://msdn.microsoft.com/library/default.asp?url=/library/en-us/security/accctrl_38yn.asp
205 typedef struct dom_sid DOM_SID;
207 enum id_mapping {
208 ID_UNKNOWN = 0,
209 ID_MAPPED,
210 ID_UNMAPPED,
211 ID_EXPIRED
214 enum id_type {
215 ID_TYPE_NOT_SPECIFIED = 0,
216 ID_TYPE_UID,
217 ID_TYPE_GID
220 struct unixid {
221 uint32_t id;
222 enum id_type type;
225 struct id_map {
226 DOM_SID *sid;
227 struct unixid xid;
228 enum id_mapping status;
231 #include "librpc/gen_ndr/misc.h"
232 #include "librpc/gen_ndr/security.h"
233 #include "librpc/ndr/libndr.h"
234 #include "librpc/gen_ndr/lsa.h"
235 #include "librpc/gen_ndr/dfs.h"
236 #include "librpc/gen_ndr/winreg.h"
237 #include "librpc/gen_ndr/initshutdown.h"
238 #include "librpc/gen_ndr/eventlog.h"
239 #include "librpc/gen_ndr/srvsvc.h"
240 #include "librpc/gen_ndr/wkssvc.h"
241 #include "librpc/gen_ndr/echo.h"
242 #include "librpc/gen_ndr/svcctl.h"
243 #include "librpc/gen_ndr/netlogon.h"
244 #include "librpc/gen_ndr/samr.h"
245 #include "librpc/gen_ndr/dssetup.h"
246 #include "librpc/gen_ndr/epmapper.h"
247 #include "librpc/gen_ndr/libnet_join.h"
248 #include "librpc/gen_ndr/krb5pac.h"
249 #include "librpc/gen_ndr/ntsvcs.h"
250 #include "librpc/gen_ndr/nbt.h"
251 #include "librpc/gen_ndr/drsuapi.h"
252 #include "librpc/gen_ndr/drsblobs.h"
253 #include "librpc/gen_ndr/spoolss.h"
254 #include "librpc/gen_ndr/dcerpc.h"
255 #include "librpc/gen_ndr/ndr_dcerpc.h"
256 #include "librpc/gen_ndr/ntlmssp.h"
258 struct lsa_dom_info {
259 bool valid;
260 DOM_SID sid;
261 const char *name;
262 int num_idxs;
263 int *idxs;
266 struct lsa_name_info {
267 uint32 rid;
268 enum lsa_SidType type;
269 const char *name;
270 int dom_idx;
273 /* Some well-known SIDs */
274 extern const DOM_SID global_sid_World_Domain;
275 extern const DOM_SID global_sid_World;
276 extern const DOM_SID global_sid_Creator_Owner_Domain;
277 extern const DOM_SID global_sid_NT_Authority;
278 extern const DOM_SID global_sid_System;
279 extern const DOM_SID global_sid_NULL;
280 extern const DOM_SID global_sid_Authenticated_Users;
281 extern const DOM_SID global_sid_Network;
282 extern const DOM_SID global_sid_Creator_Owner;
283 extern const DOM_SID global_sid_Creator_Group;
284 extern const DOM_SID global_sid_Anonymous;
285 extern const DOM_SID global_sid_Builtin;
286 extern const DOM_SID global_sid_Builtin_Administrators;
287 extern const DOM_SID global_sid_Builtin_Users;
288 extern const DOM_SID global_sid_Builtin_Guests;
289 extern const DOM_SID global_sid_Builtin_Power_Users;
290 extern const DOM_SID global_sid_Builtin_Account_Operators;
291 extern const DOM_SID global_sid_Builtin_Server_Operators;
292 extern const DOM_SID global_sid_Builtin_Print_Operators;
293 extern const DOM_SID global_sid_Builtin_Backup_Operators;
294 extern const DOM_SID global_sid_Builtin_Replicator;
295 extern const DOM_SID global_sid_Builtin_PreWin2kAccess;
296 extern const DOM_SID global_sid_Unix_Users;
297 extern const DOM_SID global_sid_Unix_Groups;
300 * The complete list of SIDS belonging to this user.
301 * Created when a vuid is registered.
302 * The definition of the user_sids array is as follows :
304 * token->user_sids[0] = primary user SID.
305 * token->user_sids[1] = primary group SID.
306 * token->user_sids[2..num_sids] = supplementary group SIDS.
309 #define PRIMARY_USER_SID_INDEX 0
310 #define PRIMARY_GROUP_SID_INDEX 1
312 typedef struct nt_user_token {
313 size_t num_sids;
314 DOM_SID *user_sids;
315 SE_PRIV privileges;
316 } NT_USER_TOKEN;
318 typedef struct unix_user_token {
319 uid_t uid;
320 gid_t gid;
321 size_t ngroups;
322 gid_t *groups;
323 } UNIX_USER_TOKEN;
325 /* 32 bit time (sec) since 01jan1970 - cifs6.txt, section 3.5, page 30 */
326 typedef struct time_info {
327 uint32 time;
328 } UTIME;
330 typedef struct write_cache {
331 SMB_OFF_T file_size;
332 SMB_OFF_T offset;
333 size_t alloc_size;
334 size_t data_size;
335 char *data;
336 } write_cache;
338 #include "fake_file.h"
340 struct fd_handle {
341 size_t ref_count;
342 int fd;
343 uint64_t position_information;
344 SMB_OFF_T pos;
345 uint32 private_options; /* NT Create options, but we only look at
346 * NTCREATEX_OPTIONS_PRIVATE_DENY_DOS and
347 * NTCREATEX_OPTIONS_PRIVATE_DENY_FCB (Except
348 * for print files *only*, where
349 * DELETE_ON_CLOSE is not stored in the share
350 * mode database.
352 unsigned long gen_id;
355 struct idle_event;
356 struct share_mode_entry;
357 struct uuid;
358 struct named_mutex;
359 struct pcap_cache;
360 struct wb_context;
361 struct rpc_cli_smbd_conn;
362 struct fncall_context;
364 struct vfs_fsp_data {
365 struct vfs_fsp_data *next;
366 struct vfs_handle_struct *owner;
367 void (*destroy)(void *p_data);
368 void *_dummy_;
369 /* NOTE: This structure contains four pointers so that we can guarantee
370 * that the end of the structure is always both 4-byte and 8-byte aligned.
374 /* the basic packet size, assuming no words or bytes */
375 #define smb_size 39
377 struct notify_change {
378 uint32_t action;
379 const char *name;
382 struct notify_mid_map;
383 struct notify_entry;
384 struct notify_event;
385 struct notify_change_request;
386 struct sys_notify_backend;
387 struct sys_notify_context {
388 struct event_context *ev;
389 struct connection_struct *conn;
390 void *private_data; /* For use by the system backend */
393 struct notify_change_buf {
395 * If no requests are pending, changes are queued here. Simple array,
396 * we only append.
400 * num_changes == -1 means that we have got a catch-all change, when
401 * asked we just return NT_STATUS_OK without specific changes.
403 int num_changes;
404 struct notify_change *changes;
407 * If no changes are around requests are queued here. Using a linked
408 * list, because we have to append at the end and delete from the top.
410 struct notify_change_request *requests;
413 typedef struct files_struct {
414 struct files_struct *next, *prev;
415 int fnum;
416 struct connection_struct *conn;
417 struct fd_handle *fh;
418 unsigned int num_smb_operations;
419 uint16 rap_print_jobid;
420 struct file_id file_id;
421 uint64_t initial_allocation_size; /* Faked up initial allocation on disk. */
422 mode_t mode;
423 uint16 file_pid;
424 uint16 vuid;
425 write_cache *wcp;
426 struct timeval open_time;
427 uint32 access_mask; /* NTCreateX access bits (FILE_READ_DATA etc.) */
428 uint32 share_access; /* NTCreateX share constants (FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE). */
430 bool update_write_time_triggered;
431 struct timed_event *update_write_time_event;
432 bool update_write_time_on_close;
433 struct timespec close_write_time;
434 bool write_time_forced;
436 int oplock_type;
437 int sent_oplock_break;
438 struct timed_event *oplock_timeout;
439 struct lock_struct last_lock_failure;
440 int current_lock_count; /* Count the number of outstanding locks and pending locks. */
442 struct share_mode_entry *pending_break_messages;
443 int num_pending_break_messages;
445 bool can_lock;
446 bool can_read;
447 bool can_write;
448 bool print_file;
449 bool modified;
450 bool is_directory;
451 bool aio_write_behind;
452 bool lockdb_clean;
453 bool initial_delete_on_close; /* Only set at NTCreateX if file was created. */
454 bool posix_open;
455 struct smb_filename *fsp_name;
457 struct vfs_fsp_data *vfs_extension;
458 struct fake_file_handle *fake_file_handle;
460 struct notify_change_buf *notify;
462 struct files_struct *base_fsp; /* placeholder for delete on close */
465 * Read-only cached brlock record, thrown away when the
466 * brlock.tdb seqnum changes. This avoids fetching data from
467 * the brlock.tdb on every read/write call.
469 int brlock_seqnum;
470 struct byte_range_lock *brlock_rec;
472 struct dptr_struct *dptr;
473 } files_struct;
475 #include "ntquotas.h"
476 #include "sysquotas.h"
478 struct vuid_cache_entry {
479 struct auth_serversupplied_info *server_info;
480 uint16_t vuid;
481 bool read_only;
482 bool admin_user;
485 struct vuid_cache {
486 unsigned int next_entry;
487 struct vuid_cache_entry array[VUID_CACHE_SIZE];
490 typedef struct {
491 char *name;
492 bool is_wild;
493 } name_compare_entry;
495 struct trans_state {
496 struct trans_state *next, *prev;
497 uint16 vuid;
498 uint16 mid;
500 uint32 max_param_return;
501 uint32 max_data_return;
502 uint32 max_setup_return;
504 uint8 cmd; /* SMBtrans or SMBtrans2 */
506 char *name; /* for trans requests */
507 uint16 call; /* for trans2 and nttrans requests */
509 bool close_on_completion;
510 bool one_way;
512 unsigned int setup_count;
513 uint16 *setup;
515 size_t received_data;
516 size_t received_param;
518 size_t total_param;
519 char *param;
521 size_t total_data;
522 char *data;
526 * Info about an alternate data stream
529 struct stream_struct {
530 SMB_OFF_T size;
531 SMB_OFF_T alloc_size;
532 char *name;
535 /* Include VFS stuff */
537 #include "smb_acls.h"
538 #include "vfs.h"
540 struct dfree_cached_info {
541 time_t last_dfree_time;
542 uint64_t dfree_ret;
543 uint64_t bsize;
544 uint64_t dfree;
545 uint64_t dsize;
548 struct dptr_struct;
550 struct share_params {
551 int service;
554 struct share_iterator {
555 int next_id;
558 typedef struct connection_struct {
559 struct connection_struct *next, *prev;
560 struct smbd_server_connection *sconn; /* can be NULL */
561 unsigned cnum; /* an index passed over the wire */
562 struct share_params *params;
563 bool force_user;
564 struct vuid_cache vuid_cache;
565 bool printer;
566 bool ipc;
567 bool read_only; /* Attributes for the current user of the share. */
568 bool admin_user; /* Attributes for the current user of the share. */
569 /* Does this filesystem honor
570 sub second timestamps on files
571 and directories when setting time ? */
572 enum timestamp_set_resolution ts_res;
573 char *connectpath;
574 char *origpath;
576 struct vfs_handle_struct *vfs_handles; /* for the new plugins */
579 * This represents the user information on this connection. Depending
580 * on the vuid using this tid, this might change per SMB request.
582 struct auth_serversupplied_info *server_info;
585 * If the "force group" parameter is set, this is the primary gid that
586 * may be used in the users token, depending on the vuid using this tid.
588 gid_t force_group_gid;
590 char client_address[INET6_ADDRSTRLEN]; /* String version of client IP address. */
592 uint16 vuid; /* vuid of user who *opened* this connection, or UID_FIELD_INVALID */
594 time_t lastused;
595 time_t lastused_count;
596 bool used;
597 int num_files_open;
598 unsigned int num_smb_operations; /* Count of smb operations on this tree. */
599 int encrypt_level;
600 bool encrypted_tid;
602 /* Semantics requested by the client or forced by the server config. */
603 bool case_sensitive;
604 bool case_preserve;
605 bool short_case_preserve;
607 /* Semantics provided by the underlying filesystem. */
608 int fs_capabilities;
610 name_compare_entry *hide_list; /* Per-share list of files to return as hidden. */
611 name_compare_entry *veto_list; /* Per-share list of files to veto (never show). */
612 name_compare_entry *veto_oplock_list; /* Per-share list of files to refuse oplocks on. */
613 name_compare_entry *aio_write_behind_list; /* Per-share list of files to use aio write behind on. */
614 struct dfree_cached_info *dfree_info;
615 struct trans_state *pending_trans;
616 struct notify_context *notify_ctx;
617 } connection_struct;
619 struct current_user {
620 connection_struct *conn;
621 uint16 vuid;
622 UNIX_USER_TOKEN ut;
623 NT_USER_TOKEN *nt_user_token;
627 struct smb_request {
628 uint8_t cmd;
629 uint16 flags2;
630 uint16 smbpid;
631 uint16 mid;
632 uint32_t seqnum;
633 uint16 vuid;
634 uint16 tid;
635 uint8 wct;
636 uint16_t *vwv;
637 uint16_t buflen;
638 const uint8_t *buf;
639 const uint8 *inbuf;
642 * Async handling in the main smb processing loop is directed by
643 * outbuf: reply_xxx routines indicate sync behaviour by putting their
644 * reply into "outbuf". If they leave it as NULL, they take of it
645 * themselves, possibly later.
647 * If async handling is wanted, the reply_xxx routine must make sure
648 * that it talloc_move()s the smb_req somewhere else.
650 uint8 *outbuf;
652 size_t unread_bytes;
653 bool encrypted;
654 connection_struct *conn;
655 struct smb_perfcount_data pcd;
658 * Chained request handling
660 struct files_struct *chain_fsp;
663 * Here we collect the outbufs from the chain handlers
665 uint8_t *chain_outbuf;
668 * state information for async smb handling
670 void *async_priv;
672 bool done;
675 /* Defines for the sent_oplock_break field above. */
676 #define NO_BREAK_SENT 0
677 #define BREAK_TO_NONE_SENT 1
678 #define LEVEL_II_BREAK_SENT 2
680 typedef struct {
681 fstring smb_name; /* user name from the client */
682 fstring unix_name; /* unix user name of a validated user */
683 fstring domain; /* domain that the client specified */
684 } userdom_struct;
686 /* Extra fields above "LPQ_PRINTING" are used to map extra NT status codes. */
688 enum {LPQ_QUEUED=0,LPQ_PAUSED,LPQ_SPOOLING,LPQ_PRINTING,LPQ_ERROR,LPQ_DELETING,
689 LPQ_OFFLINE,LPQ_PAPEROUT,LPQ_PRINTED,LPQ_DELETED,LPQ_BLOCKED,LPQ_USER_INTERVENTION};
691 typedef struct _print_queue_struct {
692 int job; /* normally the UNIX jobid -- see note in
693 printing.c:traverse_fn_delete() */
694 int size;
695 int page_count;
696 int status;
697 int priority;
698 time_t time;
699 fstring fs_user;
700 fstring fs_file;
701 } print_queue_struct;
703 enum {LPSTAT_OK, LPSTAT_STOPPED, LPSTAT_ERROR};
705 typedef struct {
706 fstring message;
707 int qcount;
708 int status;
709 } print_status_struct;
711 /* used for server information: client, nameserv and ipc */
712 struct server_info_struct {
713 fstring name;
714 uint32 type;
715 fstring comment;
716 fstring domain; /* used ONLY in ipc.c NOT namework.c */
717 bool server_added; /* used ONLY in ipc.c NOT namework.c */
720 /* used for network interfaces */
721 struct interface {
722 struct interface *next, *prev;
723 char *name;
724 int flags;
725 struct sockaddr_storage ip;
726 struct sockaddr_storage netmask;
727 struct sockaddr_storage bcast;
730 /* Internal message queue for deferred opens. */
731 struct pending_message_list {
732 struct pending_message_list *next, *prev;
733 struct timeval request_time; /* When was this first issued? */
734 struct timed_event *te;
735 struct smb_perfcount_data pcd;
736 uint32_t seqnum;
737 bool encrypted;
738 bool processed;
739 DATA_BLOB buf;
740 DATA_BLOB private_data;
743 #define SHARE_MODE_FLAG_POSIX_OPEN 0x1
745 /* struct returned by get_share_modes */
746 struct share_mode_entry {
747 struct server_id pid;
748 uint16 op_mid;
749 uint16 op_type;
750 uint32 access_mask; /* NTCreateX access bits (FILE_READ_DATA etc.) */
751 uint32 share_access; /* NTCreateX share constants (FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE). */
752 uint32 private_options; /* NT Create options, but we only look at
753 * NTCREATEX_OPTIONS_PRIVATE_DENY_DOS and
754 * NTCREATEX_OPTIONS_PRIVATE_DENY_FCB for
755 * smbstatus and swat */
756 struct timeval time;
757 struct file_id id;
758 unsigned long share_file_id;
759 uint32 uid; /* uid of file opener. */
760 uint16 flags; /* See SHARE_MODE_XX above. */
763 /* oplock break message definition - linearization of share_mode_entry.
765 Offset Data length.
766 0 struct server_id pid 4
767 4 uint16 op_mid 2
768 6 uint16 op_type 2
769 8 uint32 access_mask 4
770 12 uint32 share_access 4
771 16 uint32 private_options 4
772 20 uint32 time sec 4
773 24 uint32 time usec 4
774 28 uint64 dev 8 bytes
775 36 uint64 inode 8 bytes
776 44 uint64 extid 8 bytes
777 52 unsigned long file_id 4 bytes
778 56 uint32 uid 4 bytes
779 60 uint16 flags 2 bytes
783 #ifdef CLUSTER_SUPPORT
784 #define MSG_SMB_SHARE_MODE_ENTRY_SIZE 66
785 #else
786 #define MSG_SMB_SHARE_MODE_ENTRY_SIZE 62
787 #endif
789 struct share_mode_lock {
790 const char *servicepath; /* canonicalized. */
791 const char *base_name;
792 const char *stream_name;
793 struct file_id id;
794 int num_share_modes;
795 struct share_mode_entry *share_modes;
796 UNIX_USER_TOKEN *delete_token;
797 bool delete_on_close;
798 struct timespec old_write_time;
799 struct timespec changed_write_time;
800 bool fresh;
801 bool modified;
802 struct db_record *record;
806 * Internal structure of locking.tdb share mode db.
807 * Used by locking.c and libsmbsharemodes.c
810 struct locking_data {
811 union {
812 struct {
813 int num_share_mode_entries;
814 bool delete_on_close;
815 struct timespec old_write_time;
816 struct timespec changed_write_time;
817 uint32 delete_token_size; /* Only valid if either of
818 the two previous fields
819 are True. */
820 } s;
821 struct share_mode_entry dummy; /* Needed for alignment. */
822 } u;
823 /* The following four entries are implicit
824 struct share_mode_entry modes[num_share_mode_entries];
825 char unix_token[delete_token_size] (divisible by 4).
826 char share_name[];
827 char file_name[];
831 /* Used to store pipe open records for NetFileEnum() */
833 struct pipe_open_rec {
834 struct server_id pid;
835 uid_t uid;
836 int pnum;
837 fstring name;
841 #define NT_HASH_LEN 16
842 #define LM_HASH_LEN 16
844 /* Password history contants. */
845 #define PW_HISTORY_SALT_LEN 16
846 #define SALTED_MD5_HASH_LEN 16
847 #define PW_HISTORY_ENTRY_LEN (PW_HISTORY_SALT_LEN+SALTED_MD5_HASH_LEN)
848 #define MAX_PW_HISTORY_LEN 24
851 * Flags for local user manipulation.
854 #define LOCAL_ADD_USER 0x1
855 #define LOCAL_DELETE_USER 0x2
856 #define LOCAL_DISABLE_USER 0x4
857 #define LOCAL_ENABLE_USER 0x8
858 #define LOCAL_TRUST_ACCOUNT 0x10
859 #define LOCAL_SET_NO_PASSWORD 0x20
860 #define LOCAL_SET_PASSWORD 0x40
861 #define LOCAL_SET_LDAP_ADMIN_PW 0x80
862 #define LOCAL_INTERDOM_ACCOUNT 0x100
863 #define LOCAL_AM_ROOT 0x200 /* Act as root */
865 /* key and data in the connections database - used in smbstatus and smbd */
866 struct connections_key {
867 struct server_id pid;
868 int cnum;
869 fstring name;
872 struct connections_data {
873 int magic;
874 struct server_id pid;
875 int cnum;
876 uid_t uid;
877 gid_t gid;
878 char servicename[FSTRING_LEN];
879 char addr[24];
880 char machine[FSTRING_LEN];
881 time_t start;
882 uint32 bcast_msg_flags;
886 /* the following are used by loadparm for option lists */
887 typedef enum {
888 P_BOOL,P_BOOLREV,P_CHAR,P_INTEGER,P_OCTAL,P_LIST,
889 P_STRING,P_USTRING,P_ENUM,P_SEP
890 } parm_type;
892 typedef enum {
893 P_LOCAL,P_GLOBAL,P_SEPARATOR,P_NONE
894 } parm_class;
896 struct enum_list {
897 int value;
898 const char *name;
901 struct parm_struct {
902 const char *label;
903 parm_type type;
904 parm_class p_class;
905 void *ptr;
906 bool (*special)(int snum, const char *, char **);
907 const struct enum_list *enum_list;
908 unsigned flags;
909 union {
910 bool bvalue;
911 int ivalue;
912 char *svalue;
913 char cvalue;
914 char **lvalue;
915 } def;
918 /* The following flags are used in SWAT */
919 #define FLAG_BASIC 0x0001 /* Display only in BASIC view */
920 #define FLAG_SHARE 0x0002 /* file sharing options */
921 #define FLAG_PRINT 0x0004 /* printing options */
922 #define FLAG_GLOBAL 0x0008 /* local options that should be globally settable in SWAT */
923 #define FLAG_WIZARD 0x0010 /* Parameters that the wizard will operate on */
924 #define FLAG_ADVANCED 0x0020 /* Parameters that will be visible in advanced view */
925 #define FLAG_DEVELOPER 0x0040 /* No longer used */
926 #define FLAG_DEPRECATED 0x1000 /* options that should no longer be used */
927 #define FLAG_HIDE 0x2000 /* options that should be hidden in SWAT */
928 #define FLAG_DOS_STRING 0x4000 /* convert from UNIX to DOS codepage when reading this string. */
929 #define FLAG_META 0x8000 /* A meta directive - not a real parameter */
931 struct bitmap {
932 uint32 *b;
933 unsigned int n;
936 /* offsets into message for common items */
937 #define smb_com 8
938 #define smb_rcls 9
939 #define smb_reh 10
940 #define smb_err 11
941 #define smb_flg 13
942 #define smb_flg2 14
943 #define smb_pidhigh 16
944 #define smb_ss_field 18
945 #define smb_tid 28
946 #define smb_pid 30
947 #define smb_uid 32
948 #define smb_mid 34
949 #define smb_wct 36
950 #define smb_vwv 37
951 #define smb_vwv0 37
952 #define smb_vwv1 39
953 #define smb_vwv2 41
954 #define smb_vwv3 43
955 #define smb_vwv4 45
956 #define smb_vwv5 47
957 #define smb_vwv6 49
958 #define smb_vwv7 51
959 #define smb_vwv8 53
960 #define smb_vwv9 55
961 #define smb_vwv10 57
962 #define smb_vwv11 59
963 #define smb_vwv12 61
964 #define smb_vwv13 63
965 #define smb_vwv14 65
966 #define smb_vwv15 67
967 #define smb_vwv16 69
968 #define smb_vwv17 71
970 /* flag defines. CIFS spec 3.1.1 */
971 #define FLAG_SUPPORT_LOCKREAD 0x01
972 #define FLAG_CLIENT_BUF_AVAIL 0x02
973 #define FLAG_RESERVED 0x04
974 #define FLAG_CASELESS_PATHNAMES 0x08
975 #define FLAG_CANONICAL_PATHNAMES 0x10
976 #define FLAG_REQUEST_OPLOCK 0x20
977 #define FLAG_REQUEST_BATCH_OPLOCK 0x40
978 #define FLAG_REPLY 0x80
980 /* the complete */
981 #define SMBmkdir 0x00 /* create directory */
982 #define SMBrmdir 0x01 /* delete directory */
983 #define SMBopen 0x02 /* open file */
984 #define SMBcreate 0x03 /* create file */
985 #define SMBclose 0x04 /* close file */
986 #define SMBflush 0x05 /* flush file */
987 #define SMBunlink 0x06 /* delete file */
988 #define SMBmv 0x07 /* rename file */
989 #define SMBgetatr 0x08 /* get file attributes */
990 #define SMBsetatr 0x09 /* set file attributes */
991 #define SMBread 0x0A /* read from file */
992 #define SMBwrite 0x0B /* write to file */
993 #define SMBlock 0x0C /* lock byte range */
994 #define SMBunlock 0x0D /* unlock byte range */
995 #define SMBctemp 0x0E /* create temporary file */
996 #define SMBmknew 0x0F /* make new file */
997 #define SMBcheckpath 0x10 /* check directory path */
998 #define SMBexit 0x11 /* process exit */
999 #define SMBlseek 0x12 /* seek */
1000 #define SMBtcon 0x70 /* tree connect */
1001 #define SMBtconX 0x75 /* tree connect and X*/
1002 #define SMBtdis 0x71 /* tree disconnect */
1003 #define SMBnegprot 0x72 /* negotiate protocol */
1004 #define SMBdskattr 0x80 /* get disk attributes */
1005 #define SMBsearch 0x81 /* search directory */
1006 #define SMBsplopen 0xC0 /* open print spool file */
1007 #define SMBsplwr 0xC1 /* write to print spool file */
1008 #define SMBsplclose 0xC2 /* close print spool file */
1009 #define SMBsplretq 0xC3 /* return print queue */
1010 #define SMBsends 0xD0 /* send single block message */
1011 #define SMBsendb 0xD1 /* send broadcast message */
1012 #define SMBfwdname 0xD2 /* forward user name */
1013 #define SMBcancelf 0xD3 /* cancel forward */
1014 #define SMBgetmac 0xD4 /* get machine name */
1015 #define SMBsendstrt 0xD5 /* send start of multi-block message */
1016 #define SMBsendend 0xD6 /* send end of multi-block message */
1017 #define SMBsendtxt 0xD7 /* send text of multi-block message */
1019 /* Core+ protocol */
1020 #define SMBlockread 0x13 /* Lock a range and read */
1021 #define SMBwriteunlock 0x14 /* Unlock a range then write */
1022 #define SMBreadbraw 0x1a /* read a block of data with no smb header */
1023 #define SMBwritebraw 0x1d /* write a block of data with no smb header */
1024 #define SMBwritec 0x20 /* secondary write request */
1025 #define SMBwriteclose 0x2c /* write a file then close it */
1027 /* dos extended protocol */
1028 #define SMBreadBraw 0x1A /* read block raw */
1029 #define SMBreadBmpx 0x1B /* read block multiplexed */
1030 #define SMBreadBs 0x1C /* read block (secondary response) */
1031 #define SMBwriteBraw 0x1D /* write block raw */
1032 #define SMBwriteBmpx 0x1E /* write block multiplexed */
1033 #define SMBwriteBs 0x1F /* write block (secondary request) */
1034 #define SMBwriteC 0x20 /* write complete response */
1035 #define SMBsetattrE 0x22 /* set file attributes expanded */
1036 #define SMBgetattrE 0x23 /* get file attributes expanded */
1037 #define SMBlockingX 0x24 /* lock/unlock byte ranges and X */
1038 #define SMBtrans 0x25 /* transaction - name, bytes in/out */
1039 #define SMBtranss 0x26 /* transaction (secondary request/response) */
1040 #define SMBioctl 0x27 /* IOCTL */
1041 #define SMBioctls 0x28 /* IOCTL (secondary request/response) */
1042 #define SMBcopy 0x29 /* copy */
1043 #define SMBmove 0x2A /* move */
1044 #define SMBecho 0x2B /* echo */
1045 #define SMBopenX 0x2D /* open and X */
1046 #define SMBreadX 0x2E /* read and X */
1047 #define SMBwriteX 0x2F /* write and X */
1048 #define SMBsesssetupX 0x73 /* Session Set Up & X (including User Logon) */
1049 #define SMBffirst 0x82 /* find first */
1050 #define SMBfunique 0x83 /* find unique */
1051 #define SMBfclose 0x84 /* find close */
1052 #define SMBkeepalive 0x85 /* keepalive */
1053 #define SMBinvalid 0xFE /* invalid command */
1055 /* Extended 2.0 protocol */
1056 #define SMBtrans2 0x32 /* TRANS2 protocol set */
1057 #define SMBtranss2 0x33 /* TRANS2 protocol set, secondary command */
1058 #define SMBfindclose 0x34 /* Terminate a TRANSACT2_FINDFIRST */
1059 #define SMBfindnclose 0x35 /* Terminate a TRANSACT2_FINDNOTIFYFIRST */
1060 #define SMBulogoffX 0x74 /* user logoff */
1062 /* NT SMB extensions. */
1063 #define SMBnttrans 0xA0 /* NT transact */
1064 #define SMBnttranss 0xA1 /* NT transact secondary */
1065 #define SMBntcreateX 0xA2 /* NT create and X */
1066 #define SMBntcancel 0xA4 /* NT cancel */
1067 #define SMBntrename 0xA5 /* NT rename */
1069 /* These are the trans subcommands */
1070 #define TRANSACT_SETNAMEDPIPEHANDLESTATE 0x01
1071 #define TRANSACT_DCERPCCMD 0x26
1072 #define TRANSACT_WAITNAMEDPIPEHANDLESTATE 0x53
1074 /* These are the TRANS2 sub commands */
1075 #define TRANSACT2_OPEN 0x00
1076 #define TRANSACT2_FINDFIRST 0x01
1077 #define TRANSACT2_FINDNEXT 0x02
1078 #define TRANSACT2_QFSINFO 0x03
1079 #define TRANSACT2_SETFSINFO 0x04
1080 #define TRANSACT2_QPATHINFO 0x05
1081 #define TRANSACT2_SETPATHINFO 0x06
1082 #define TRANSACT2_QFILEINFO 0x07
1083 #define TRANSACT2_SETFILEINFO 0x08
1084 #define TRANSACT2_FSCTL 0x09
1085 #define TRANSACT2_IOCTL 0x0A
1086 #define TRANSACT2_FINDNOTIFYFIRST 0x0B
1087 #define TRANSACT2_FINDNOTIFYNEXT 0x0C
1088 #define TRANSACT2_MKDIR 0x0D
1089 #define TRANSACT2_SESSION_SETUP 0x0E
1090 #define TRANSACT2_GET_DFS_REFERRAL 0x10
1091 #define TRANSACT2_REPORT_DFS_INCONSISTANCY 0x11
1093 /* These are the NT transact sub commands. */
1094 #define NT_TRANSACT_CREATE 1
1095 #define NT_TRANSACT_IOCTL 2
1096 #define NT_TRANSACT_SET_SECURITY_DESC 3
1097 #define NT_TRANSACT_NOTIFY_CHANGE 4
1098 #define NT_TRANSACT_RENAME 5
1099 #define NT_TRANSACT_QUERY_SECURITY_DESC 6
1100 #define NT_TRANSACT_GET_USER_QUOTA 7
1101 #define NT_TRANSACT_SET_USER_QUOTA 8
1103 /* These are the NT transact_get_user_quota sub commands */
1104 #define TRANSACT_GET_USER_QUOTA_LIST_CONTINUE 0x0000
1105 #define TRANSACT_GET_USER_QUOTA_LIST_START 0x0100
1106 #define TRANSACT_GET_USER_QUOTA_FOR_SID 0x0101
1108 /* Relevant IOCTL codes */
1109 #define IOCTL_QUERY_JOB_INFO 0x530060
1111 /* these are the trans2 sub fields for primary requests */
1112 #define smb_tpscnt smb_vwv0
1113 #define smb_tdscnt smb_vwv1
1114 #define smb_mprcnt smb_vwv2
1115 #define smb_mdrcnt smb_vwv3
1116 #define smb_msrcnt smb_vwv4
1117 #define smb_flags smb_vwv5
1118 #define smb_timeout smb_vwv6
1119 #define smb_pscnt smb_vwv9
1120 #define smb_psoff smb_vwv10
1121 #define smb_dscnt smb_vwv11
1122 #define smb_dsoff smb_vwv12
1123 #define smb_suwcnt smb_vwv13
1124 #define smb_setup smb_vwv14
1125 #define smb_setup0 smb_setup
1126 #define smb_setup1 (smb_setup+2)
1127 #define smb_setup2 (smb_setup+4)
1129 /* these are for the secondary requests */
1130 #define smb_spscnt smb_vwv2
1131 #define smb_spsoff smb_vwv3
1132 #define smb_spsdisp smb_vwv4
1133 #define smb_sdscnt smb_vwv5
1134 #define smb_sdsoff smb_vwv6
1135 #define smb_sdsdisp smb_vwv7
1136 #define smb_sfid smb_vwv8
1138 /* and these for responses */
1139 #define smb_tprcnt smb_vwv0
1140 #define smb_tdrcnt smb_vwv1
1141 #define smb_prcnt smb_vwv3
1142 #define smb_proff smb_vwv4
1143 #define smb_prdisp smb_vwv5
1144 #define smb_drcnt smb_vwv6
1145 #define smb_droff smb_vwv7
1146 #define smb_drdisp smb_vwv8
1148 /* these are for the NT trans primary request. */
1149 #define smb_nt_MaxSetupCount smb_vwv0
1150 #define smb_nt_Flags (smb_vwv0 + 1)
1151 #define smb_nt_TotalParameterCount (smb_vwv0 + 3)
1152 #define smb_nt_TotalDataCount (smb_vwv0 + 7)
1153 #define smb_nt_MaxParameterCount (smb_vwv0 + 11)
1154 #define smb_nt_MaxDataCount (smb_vwv0 + 15)
1155 #define smb_nt_ParameterCount (smb_vwv0 + 19)
1156 #define smb_nt_ParameterOffset (smb_vwv0 + 23)
1157 #define smb_nt_DataCount (smb_vwv0 + 27)
1158 #define smb_nt_DataOffset (smb_vwv0 + 31)
1159 #define smb_nt_SetupCount (smb_vwv0 + 35)
1160 #define smb_nt_Function (smb_vwv0 + 36)
1161 #define smb_nt_SetupStart (smb_vwv0 + 38)
1163 /* these are for the NT trans secondary request. */
1164 #define smb_nts_TotalParameterCount (smb_vwv0 + 3)
1165 #define smb_nts_TotalDataCount (smb_vwv0 + 7)
1166 #define smb_nts_ParameterCount (smb_vwv0 + 11)
1167 #define smb_nts_ParameterOffset (smb_vwv0 + 15)
1168 #define smb_nts_ParameterDisplacement (smb_vwv0 + 19)
1169 #define smb_nts_DataCount (smb_vwv0 + 23)
1170 #define smb_nts_DataOffset (smb_vwv0 + 27)
1171 #define smb_nts_DataDisplacement (smb_vwv0 + 31)
1173 /* these are for the NT trans reply. */
1174 #define smb_ntr_TotalParameterCount (smb_vwv0 + 3)
1175 #define smb_ntr_TotalDataCount (smb_vwv0 + 7)
1176 #define smb_ntr_ParameterCount (smb_vwv0 + 11)
1177 #define smb_ntr_ParameterOffset (smb_vwv0 + 15)
1178 #define smb_ntr_ParameterDisplacement (smb_vwv0 + 19)
1179 #define smb_ntr_DataCount (smb_vwv0 + 23)
1180 #define smb_ntr_DataOffset (smb_vwv0 + 27)
1181 #define smb_ntr_DataDisplacement (smb_vwv0 + 31)
1183 /* these are for the NT create_and_X */
1184 #define smb_ntcreate_NameLength (smb_vwv0 + 5)
1185 #define smb_ntcreate_Flags (smb_vwv0 + 7)
1186 #define smb_ntcreate_RootDirectoryFid (smb_vwv0 + 11)
1187 #define smb_ntcreate_DesiredAccess (smb_vwv0 + 15)
1188 #define smb_ntcreate_AllocationSize (smb_vwv0 + 19)
1189 #define smb_ntcreate_FileAttributes (smb_vwv0 + 27)
1190 #define smb_ntcreate_ShareAccess (smb_vwv0 + 31)
1191 #define smb_ntcreate_CreateDisposition (smb_vwv0 + 35)
1192 #define smb_ntcreate_CreateOptions (smb_vwv0 + 39)
1193 #define smb_ntcreate_ImpersonationLevel (smb_vwv0 + 43)
1194 #define smb_ntcreate_SecurityFlags (smb_vwv0 + 47)
1196 /* this is used on a TConX. I'm not sure the name is very helpful though */
1197 #define SMB_SUPPORT_SEARCH_BITS 0x0001
1198 #define SMB_SHARE_IN_DFS 0x0002
1200 /* Named pipe write mode flags. Used in writeX calls. */
1201 #define PIPE_RAW_MODE 0x4
1202 #define PIPE_START_MESSAGE 0x8
1204 /* File Specific access rights */
1205 #define FILE_READ_DATA 0x00000001
1206 #define FILE_WRITE_DATA 0x00000002
1207 #define FILE_APPEND_DATA 0x00000004
1208 #define FILE_READ_EA 0x00000008 /* File and directory */
1209 #define FILE_WRITE_EA 0x00000010 /* File and directory */
1210 #define FILE_EXECUTE 0x00000020
1211 #define FILE_DELETE_CHILD 0x00000040
1212 #define FILE_READ_ATTRIBUTES 0x00000080
1213 #define FILE_WRITE_ATTRIBUTES 0x00000100
1215 #define FILE_ALL_ACCESS 0x000001FF
1217 /* Directory specific access rights */
1218 #define FILE_LIST_DIRECTORY 0x00000001
1219 #define FILE_ADD_FILE 0x00000002
1220 #define FILE_ADD_SUBDIRECTORY 0x00000004
1221 #define FILE_TRAVERSE 0x00000020
1222 #define FILE_DELETE_CHILD 0x00000040
1224 /* the desired access to use when opening a pipe */
1225 #define DESIRED_ACCESS_PIPE 0x2019f
1227 /* Generic access masks & rights. */
1228 #define DELETE_ACCESS 0x00010000 /* (1L<<16) */
1229 #define READ_CONTROL_ACCESS 0x00020000 /* (1L<<17) */
1230 #define WRITE_DAC_ACCESS 0x00040000 /* (1L<<18) */
1231 #define WRITE_OWNER_ACCESS 0x00080000 /* (1L<<19) */
1232 #define SYNCHRONIZE_ACCESS 0x00100000 /* (1L<<20) */
1234 #define SYSTEM_SECURITY_ACCESS 0x01000000 /* (1L<<24) */
1235 #define MAXIMUM_ALLOWED_ACCESS 0x02000000 /* (1L<<25) */
1236 #define GENERIC_ALL_ACCESS 0x10000000 /* (1<<28) */
1237 #define GENERIC_EXECUTE_ACCESS 0x20000000 /* (1<<29) */
1238 #define GENERIC_WRITE_ACCESS 0x40000000 /* (1<<30) */
1239 #define GENERIC_READ_ACCESS ((unsigned)0x80000000) /* (((unsigned)1)<<31) */
1241 /* Mapping of generic access rights for files to specific rights. */
1243 /* This maps to 0x1F01FF */
1244 #define FILE_GENERIC_ALL (STANDARD_RIGHTS_REQUIRED_ACCESS|\
1245 SYNCHRONIZE_ACCESS|\
1246 FILE_ALL_ACCESS)
1248 /* This maps to 0x120089 */
1249 #define FILE_GENERIC_READ (STANDARD_RIGHTS_READ_ACCESS|\
1250 FILE_READ_DATA|\
1251 FILE_READ_ATTRIBUTES|\
1252 FILE_READ_EA|\
1253 SYNCHRONIZE_ACCESS)
1255 /* This maps to 0x120116 */
1256 #define FILE_GENERIC_WRITE (STD_RIGHT_READ_CONTROL_ACCESS|\
1257 FILE_WRITE_DATA|\
1258 FILE_WRITE_ATTRIBUTES|\
1259 FILE_WRITE_EA|\
1260 FILE_APPEND_DATA|\
1261 SYNCHRONIZE_ACCESS)
1263 #define FILE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE_ACCESS|\
1264 FILE_READ_ATTRIBUTES|\
1265 FILE_EXECUTE|\
1266 SYNCHRONIZE_ACCESS)
1268 /* Share specific rights. */
1269 #define SHARE_ALL_ACCESS FILE_GENERIC_ALL
1270 #define SHARE_READ_ONLY (FILE_GENERIC_READ|FILE_EXECUTE)
1272 /* Mapping of access rights to UNIX perms. */
1273 #define UNIX_ACCESS_RWX FILE_GENERIC_ALL
1274 #define UNIX_ACCESS_R FILE_GENERIC_READ
1275 #define UNIX_ACCESS_W FILE_GENERIC_WRITE
1276 #define UNIX_ACCESS_X FILE_GENERIC_EXECUTE
1278 /* Mapping of access rights to UNIX perms. for a UNIX directory. */
1279 #define UNIX_DIRECTORY_ACCESS_RWX FILE_GENERIC_ALL
1280 #define UNIX_DIRECTORY_ACCESS_R FILE_GENERIC_READ
1281 #define UNIX_DIRECTORY_ACCESS_W (FILE_GENERIC_WRITE|FILE_DELETE_CHILD)
1282 #define UNIX_DIRECTORY_ACCESS_X FILE_GENERIC_EXECUTE
1284 #if 0
1286 * This is the old mapping we used to use. To get W2KSP2 profiles
1287 * working we need to map to the canonical file perms.
1289 #define UNIX_ACCESS_RWX (UNIX_ACCESS_R|UNIX_ACCESS_W|UNIX_ACCESS_X)
1290 #define UNIX_ACCESS_R (READ_CONTROL_ACCESS|SYNCHRONIZE_ACCESS|\
1291 FILE_READ_ATTRIBUTES|FILE_READ_EA|FILE_READ_DATA)
1292 #define UNIX_ACCESS_W (READ_CONTROL_ACCESS|SYNCHRONIZE_ACCESS|\
1293 FILE_WRITE_ATTRIBUTES|FILE_WRITE_EA|\
1294 FILE_APPEND_DATA|FILE_WRITE_DATA)
1295 #define UNIX_ACCESS_X (READ_CONTROL_ACCESS|SYNCHRONIZE_ACCESS|\
1296 FILE_EXECUTE|FILE_READ_ATTRIBUTES)
1297 #endif
1299 #define UNIX_ACCESS_NONE (WRITE_OWNER_ACCESS)
1301 /* Flags field. */
1302 #define REQUEST_OPLOCK 2
1303 #define REQUEST_BATCH_OPLOCK 4
1304 #define OPEN_DIRECTORY 8
1305 #define EXTENDED_RESPONSE_REQUIRED 0x10
1307 /* ShareAccess field. */
1308 #define FILE_SHARE_NONE 0 /* Cannot be used in bitmask. */
1309 #define FILE_SHARE_READ 1
1310 #define FILE_SHARE_WRITE 2
1311 #define FILE_SHARE_DELETE 4
1313 /* FileAttributesField */
1314 #define FILE_ATTRIBUTE_READONLY 0x001L
1315 #define FILE_ATTRIBUTE_HIDDEN 0x002L
1316 #define FILE_ATTRIBUTE_SYSTEM 0x004L
1317 #define FILE_ATTRIBUTE_DIRECTORY 0x010L
1318 #define FILE_ATTRIBUTE_ARCHIVE 0x020L
1319 #define FILE_ATTRIBUTE_NORMAL 0x080L
1320 #define FILE_ATTRIBUTE_TEMPORARY 0x100L
1321 #define FILE_ATTRIBUTE_SPARSE 0x200L
1322 #define FILE_ATTRIBUTE_REPARSE_POINT 0x400L
1323 #define FILE_ATTRIBUTE_COMPRESSED 0x800L
1324 #define FILE_ATTRIBUTE_OFFLINE 0x1000L
1325 #define FILE_ATTRIBUTE_NONINDEXED 0x2000L
1326 #define FILE_ATTRIBUTE_ENCRYPTED 0x4000L
1327 #define SAMBA_ATTRIBUTES_MASK 0x7F
1329 /* Flags - combined with attributes. */
1330 #define FILE_FLAG_WRITE_THROUGH 0x80000000L
1331 #define FILE_FLAG_NO_BUFFERING 0x20000000L
1332 #define FILE_FLAG_RANDOM_ACCESS 0x10000000L
1333 #define FILE_FLAG_SEQUENTIAL_SCAN 0x08000000L
1334 #define FILE_FLAG_DELETE_ON_CLOSE 0x04000000L
1335 #define FILE_FLAG_BACKUP_SEMANTICS 0x02000000L
1336 #define FILE_FLAG_POSIX_SEMANTICS 0x01000000L
1338 /* CreateDisposition field. */
1339 #define FILE_SUPERSEDE 0 /* File exists overwrite/supersede. File not exist create. */
1340 #define FILE_OPEN 1 /* File exists open. File not exist fail. */
1341 #define FILE_CREATE 2 /* File exists fail. File not exist create. */
1342 #define FILE_OPEN_IF 3 /* File exists open. File not exist create. */
1343 #define FILE_OVERWRITE 4 /* File exists overwrite. File not exist fail. */
1344 #define FILE_OVERWRITE_IF 5 /* File exists overwrite. File not exist create. */
1346 /* CreateOptions field. */
1347 #define FILE_DIRECTORY_FILE 0x0001
1348 #define FILE_WRITE_THROUGH 0x0002
1349 #define FILE_SEQUENTIAL_ONLY 0x0004
1350 #define FILE_NO_INTERMEDIATE_BUFFERING 0x0008
1351 #define FILE_SYNCHRONOUS_IO_ALERT 0x0010 /* may be ignored */
1352 #define FILE_SYNCHRONOUS_IO_NONALERT 0x0020 /* may be ignored */
1353 #define FILE_NON_DIRECTORY_FILE 0x0040
1354 #define FILE_CREATE_TREE_CONNECTION 0x0080 /* ignore, should be zero */
1355 #define FILE_COMPLETE_IF_OPLOCKED 0x0100 /* ignore, should be zero */
1356 #define FILE_NO_EA_KNOWLEDGE 0x0200
1357 #define FILE_EIGHT_DOT_THREE_ONLY 0x0400 /* aka OPEN_FOR_RECOVERY: ignore, should be zero */
1358 #define FILE_RANDOM_ACCESS 0x0800
1359 #define FILE_DELETE_ON_CLOSE 0x1000
1360 #define FILE_OPEN_BY_FILE_ID 0x2000
1361 #define FILE_OPEN_FOR_BACKUP_INTENT 0x4000
1362 #define FILE_NO_COMPRESSION 0x8000
1363 #define FILE_RESERVER_OPFILTER 0x00100000 /* ignore, should be zero */
1364 #define FILE_OPEN_REPARSE_POINT 0x00200000
1365 #define FILE_OPEN_NO_RECALL 0x00400000
1366 #define FILE_OPEN_FOR_FREE_SPACE_QUERY 0x00800000 /* ignore should be zero */
1368 #define NTCREATEX_OPTIONS_MUST_IGNORE_MASK (0x008F0480)
1370 #define NTCREATEX_OPTIONS_INVALID_PARAM_MASK (0xFF100030)
1373 * Private create options used by the ntcreatex processing code. From Samba4.
1374 * We reuse some ignored flags for private use.
1376 #define NTCREATEX_OPTIONS_PRIVATE_DENY_DOS 0x00010000
1377 #define NTCREATEX_OPTIONS_PRIVATE_DENY_FCB 0x00020000
1379 /* Private options for streams support */
1380 #define NTCREATEX_OPTIONS_PRIVATE_STREAM_DELETE 0x00040000
1382 /* Responses when opening a file. */
1383 #define FILE_WAS_SUPERSEDED 0
1384 #define FILE_WAS_OPENED 1
1385 #define FILE_WAS_CREATED 2
1386 #define FILE_WAS_OVERWRITTEN 3
1388 /* File type flags */
1389 #define FILE_TYPE_DISK 0
1390 #define FILE_TYPE_BYTE_MODE_PIPE 1
1391 #define FILE_TYPE_MESSAGE_MODE_PIPE 2
1392 #define FILE_TYPE_PRINTER 3
1393 #define FILE_TYPE_COMM_DEVICE 4
1394 #define FILE_TYPE_UNKNOWN 0xFFFF
1396 /* Flag for NT transact rename call. */
1397 #define RENAME_REPLACE_IF_EXISTS 1
1399 /* flags for SMBntrename call (from Samba4) */
1400 #define RENAME_FLAG_MOVE_CLUSTER_INFORMATION 0x102 /* ???? */
1401 #define RENAME_FLAG_HARD_LINK 0x103
1402 #define RENAME_FLAG_RENAME 0x104
1403 #define RENAME_FLAG_COPY 0x105
1405 /* Filesystem Attributes. */
1406 #define FILE_CASE_SENSITIVE_SEARCH 0x00000001
1407 #define FILE_CASE_PRESERVED_NAMES 0x00000002
1408 #define FILE_UNICODE_ON_DISK 0x00000004
1409 /* According to cifs9f, this is 4, not 8 */
1410 /* Acconding to testing, this actually sets the security attribute! */
1411 #define FILE_PERSISTENT_ACLS 0x00000008
1412 #define FILE_FILE_COMPRESSION 0x00000010
1413 #define FILE_VOLUME_QUOTAS 0x00000020
1414 #define FILE_SUPPORTS_SPARSE_FILES 0x00000040
1415 #define FILE_SUPPORTS_REPARSE_POINTS 0x00000080
1416 #define FILE_SUPPORTS_REMOTE_STORAGE 0x00000100
1417 #define FS_LFN_APIS 0x00004000
1418 #define FILE_VOLUME_IS_COMPRESSED 0x00008000
1419 #define FILE_SUPPORTS_OBJECT_IDS 0x00010000
1420 #define FILE_SUPPORTS_ENCRYPTION 0x00020000
1421 #define FILE_NAMED_STREAMS 0x00040000
1422 #define FILE_READ_ONLY_VOLUME 0x00080000
1424 /* ChangeNotify flags. */
1425 #define FILE_NOTIFY_CHANGE_FILE_NAME 0x001
1426 #define FILE_NOTIFY_CHANGE_DIR_NAME 0x002
1427 #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x004
1428 #define FILE_NOTIFY_CHANGE_SIZE 0x008
1429 #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x010
1430 #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x020
1431 #define FILE_NOTIFY_CHANGE_CREATION 0x040
1432 #define FILE_NOTIFY_CHANGE_EA 0x080
1433 #define FILE_NOTIFY_CHANGE_SECURITY 0x100
1434 #define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200
1435 #define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400
1436 #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
1438 #define FILE_NOTIFY_CHANGE_NAME \
1439 (FILE_NOTIFY_CHANGE_FILE_NAME|FILE_NOTIFY_CHANGE_DIR_NAME)
1441 /* change notify action results */
1442 #define NOTIFY_ACTION_ADDED 1
1443 #define NOTIFY_ACTION_REMOVED 2
1444 #define NOTIFY_ACTION_MODIFIED 3
1445 #define NOTIFY_ACTION_OLD_NAME 4
1446 #define NOTIFY_ACTION_NEW_NAME 5
1447 #define NOTIFY_ACTION_ADDED_STREAM 6
1448 #define NOTIFY_ACTION_REMOVED_STREAM 7
1449 #define NOTIFY_ACTION_MODIFIED_STREAM 8
1452 /* where to find the base of the SMB packet proper */
1453 #define smb_base(buf) (((char *)(buf))+4)
1455 /* we don't allow server strings to be longer than 48 characters as
1456 otherwise NT will not honour the announce packets */
1457 #define MAX_SERVER_STRING_LENGTH 48
1460 #define SMB_SUCCESS 0 /* The request was successful. */
1462 #ifdef WITH_DFS
1463 void dfs_unlogin(void);
1464 extern int dcelogin_atmost_once;
1465 #endif
1467 #ifdef NOSTRDUP
1468 char *strdup(char *s);
1469 #endif
1471 #ifndef SIGNAL_CAST
1472 #define SIGNAL_CAST (RETSIGTYPE (*)(int))
1473 #endif
1475 #ifndef SELECT_CAST
1476 #define SELECT_CAST
1477 #endif
1479 /* This was set by JHT in liaison with Jeremy Allison early 1997
1480 * History:
1481 * Version 4.0 - never made public
1482 * Version 4.10 - New to 1.9.16p2, lost in space 1.9.16p3 to 1.9.16p9
1483 * - Reappeared in 1.9.16p11 with fixed smbd services
1484 * Version 4.20 - To indicate that nmbd and browsing now works better
1485 * Version 4.50 - Set at release of samba-2.2.0 by JHT
1487 * Note: In the presence of NT4.X do not set above 4.9
1488 * Setting this above 4.9 can have undesired side-effects.
1489 * This may change again in Samba-3.0 after further testing. JHT
1492 #define DEFAULT_MAJOR_VERSION 0x04
1493 #define DEFAULT_MINOR_VERSION 0x09
1495 /* Browser Election Values */
1496 #define BROWSER_ELECTION_VERSION 0x010f
1497 #define BROWSER_CONSTANT 0xaa55
1499 /* Sercurity mode bits. */
1500 #define NEGOTIATE_SECURITY_USER_LEVEL 0x01
1501 #define NEGOTIATE_SECURITY_CHALLENGE_RESPONSE 0x02
1502 #define NEGOTIATE_SECURITY_SIGNATURES_ENABLED 0x04
1503 #define NEGOTIATE_SECURITY_SIGNATURES_REQUIRED 0x08
1505 /* NT Flags2 bits - cifs6.txt section 3.1.2 */
1507 #define FLAGS2_LONG_PATH_COMPONENTS 0x0001
1508 #define FLAGS2_EXTENDED_ATTRIBUTES 0x0002
1509 #define FLAGS2_SMB_SECURITY_SIGNATURES 0x0004
1510 #define FLAGS2_UNKNOWN_BIT4 0x0010
1511 #define FLAGS2_IS_LONG_NAME 0x0040
1512 #define FLAGS2_EXTENDED_SECURITY 0x0800
1513 #define FLAGS2_DFS_PATHNAMES 0x1000
1514 #define FLAGS2_READ_PERMIT_EXECUTE 0x2000
1515 #define FLAGS2_32_BIT_ERROR_CODES 0x4000
1516 #define FLAGS2_UNICODE_STRINGS 0x8000
1518 #define FLAGS2_WIN2K_SIGNATURE 0xC852 /* Hack alert ! For now... JRA. */
1520 /* TCONX Flag (smb_vwv2). */
1521 #define TCONX_FLAG_EXTENDED_RESPONSE 0x8
1523 /* File Status Flags. See:
1525 http://msdn.microsoft.com/en-us/library/cc246334(PROT.13).aspx
1528 #define NO_EAS 0x1
1529 #define NO_SUBSTREAMS 0x2
1530 #define NO_REPARSETAG 0x4
1532 /* Capabilities. see ftp.microsoft.com/developr/drg/cifs/cifs/cifs4.txt */
1534 #define CAP_RAW_MODE 0x0001
1535 #define CAP_MPX_MODE 0x0002
1536 #define CAP_UNICODE 0x0004
1537 #define CAP_LARGE_FILES 0x0008
1538 #define CAP_NT_SMBS 0x0010
1539 #define CAP_RPC_REMOTE_APIS 0x0020
1540 #define CAP_STATUS32 0x0040
1541 #define CAP_LEVEL_II_OPLOCKS 0x0080
1542 #define CAP_LOCK_AND_READ 0x0100
1543 #define CAP_NT_FIND 0x0200
1544 #define CAP_DFS 0x1000
1545 #define CAP_W2K_SMBS 0x2000
1546 #define CAP_LARGE_READX 0x4000
1547 #define CAP_LARGE_WRITEX 0x8000
1548 #define CAP_UNIX 0x800000 /* Capabilities for UNIX extensions. Created by HP. */
1549 #define CAP_EXTENDED_SECURITY 0x80000000
1551 /* protocol types. It assumes that higher protocols include lower protocols
1552 as subsets */
1553 enum protocol_types {
1554 PROTOCOL_NONE,
1555 PROTOCOL_CORE,
1556 PROTOCOL_COREPLUS,
1557 PROTOCOL_LANMAN1,
1558 PROTOCOL_LANMAN2,
1559 PROTOCOL_NT1,
1560 PROTOCOL_SMB2
1563 /* security levels */
1564 enum security_types {SEC_SHARE,SEC_USER,SEC_SERVER,SEC_DOMAIN,SEC_ADS};
1566 /* server roles */
1567 enum server_types {
1568 ROLE_STANDALONE,
1569 ROLE_DOMAIN_MEMBER,
1570 ROLE_DOMAIN_BDC,
1571 ROLE_DOMAIN_PDC
1574 /* printing types */
1575 enum printing_types {PRINT_BSD,PRINT_SYSV,PRINT_AIX,PRINT_HPUX,
1576 PRINT_QNX,PRINT_PLP,PRINT_LPRNG,PRINT_SOFTQ,
1577 PRINT_CUPS,PRINT_LPRNT,PRINT_LPROS2,PRINT_IPRINT
1578 #if defined(DEVELOPER) || defined(ENABLE_BUILD_FARM_HACKS)
1579 ,PRINT_TEST,PRINT_VLP
1580 #endif /* DEVELOPER */
1583 /* LDAP schema types */
1584 enum schema_types {SCHEMA_COMPAT, SCHEMA_AD, SCHEMA_SAMBA};
1586 /* LDAP SSL options */
1587 enum ldap_ssl_types {LDAP_SSL_OFF, LDAP_SSL_START_TLS};
1589 /* LDAP PASSWD SYNC methods */
1590 enum ldap_passwd_sync_types {LDAP_PASSWD_SYNC_ON, LDAP_PASSWD_SYNC_OFF, LDAP_PASSWD_SYNC_ONLY};
1592 /* Remote architectures we know about. */
1593 enum remote_arch_types {RA_UNKNOWN, RA_WFWG, RA_OS2, RA_WIN95, RA_WINNT,
1594 RA_WIN2K, RA_WINXP, RA_WIN2K3, RA_VISTA,
1595 RA_SAMBA, RA_CIFSFS, RA_WINXP64};
1597 /* case handling */
1598 enum case_handling {CASE_LOWER,CASE_UPPER};
1600 /* ACL compatibility */
1601 enum acl_compatibility {ACL_COMPAT_AUTO, ACL_COMPAT_WINNT, ACL_COMPAT_WIN2K};
1603 * Global value meaing that the smb_uid field should be
1604 * ingored (in share level security and protocol level == CORE)
1607 #define UID_FIELD_INVALID 0
1608 #define VUID_OFFSET 100 /* Amount to bias returned vuid numbers */
1611 * Size of buffer to use when moving files across filesystems.
1613 #define COPYBUF_SIZE (8*1024)
1616 * Map the Core and Extended Oplock requesst bits down
1617 * to common bits (EXCLUSIVE_OPLOCK & BATCH_OPLOCK).
1621 * Core protocol.
1623 #define CORE_OPLOCK_REQUEST(inbuf) \
1624 ((CVAL(inbuf,smb_flg)&(FLAG_REQUEST_OPLOCK|FLAG_REQUEST_BATCH_OPLOCK))>>5)
1627 * Extended protocol.
1629 #define EXTENDED_OPLOCK_REQUEST(inbuf) ((SVAL(inbuf,smb_vwv2)&((1<<1)|(1<<2)))>>1)
1631 /* Lock types. */
1632 #define LOCKING_ANDX_SHARED_LOCK 0x1
1633 #define LOCKING_ANDX_OPLOCK_RELEASE 0x2
1634 #define LOCKING_ANDX_CHANGE_LOCKTYPE 0x4
1635 #define LOCKING_ANDX_CANCEL_LOCK 0x8
1636 #define LOCKING_ANDX_LARGE_FILES 0x10
1639 * Bits we test with.
1640 * Note these must fit into 16-bits.
1643 #define NO_OPLOCK 0x0
1644 #define EXCLUSIVE_OPLOCK 0x1
1645 #define BATCH_OPLOCK 0x2
1646 #define LEVEL_II_OPLOCK 0x4
1648 /* The following are Samba-private. */
1649 #define INTERNAL_OPEN_ONLY 0x8
1650 #define FAKE_LEVEL_II_OPLOCK 0x10 /* Client requested no_oplock, but we have to
1651 * inform potential level2 holders on
1652 * write. */
1653 #define DEFERRED_OPEN_ENTRY 0x20
1654 #define UNUSED_SHARE_MODE_ENTRY 0x40
1655 #define FORCE_OPLOCK_BREAK_TO_NONE 0x80
1657 /* None of the following should ever appear in fsp->oplock_request. */
1658 #define SAMBA_PRIVATE_OPLOCK_MASK (INTERNAL_OPEN_ONLY|DEFERRED_OPEN_ENTRY|UNUSED_SHARE_MODE_ENTRY|FORCE_OPLOCK_BREAK_TO_NONE)
1660 #define EXCLUSIVE_OPLOCK_TYPE(lck) ((lck) & ((unsigned int)EXCLUSIVE_OPLOCK|(unsigned int)BATCH_OPLOCK))
1661 #define BATCH_OPLOCK_TYPE(lck) ((lck) & (unsigned int)BATCH_OPLOCK)
1662 #define LEVEL_II_OPLOCK_TYPE(lck) ((lck) & ((unsigned int)LEVEL_II_OPLOCK|(unsigned int)FAKE_LEVEL_II_OPLOCK))
1664 /* kernel_oplock_message definition.
1666 struct kernel_oplock_message {
1667 uint64_t dev;
1668 uint64_t inode;
1669 unit64_t extid;
1670 unsigned long file_id;
1673 Offset Data length.
1674 0 uint64_t dev 8 bytes
1675 8 uint64_t inode 8 bytes
1676 16 uint64_t extid 8 bytes
1677 24 unsigned long file_id 4 bytes
1681 #define MSG_SMB_KERNEL_BREAK_SIZE 28
1683 /* file_renamed_message definition.
1685 struct file_renamed_message {
1686 uint64_t dev;
1687 uint64_t inode;
1688 char names[1]; A variable area containing sharepath and filename.
1691 Offset Data length.
1692 0 uint64_t dev 8 bytes
1693 8 uint64_t inode 8 bytes
1694 16 unit64_t extid 8 bytes
1695 24 char [] name zero terminated namelen bytes
1696 minimum length == 24.
1700 #define MSG_FILE_RENAMED_MIN_SIZE 24
1703 * On the wire return values for oplock types.
1706 #define CORE_OPLOCK_GRANTED (1<<5)
1707 #define EXTENDED_OPLOCK_GRANTED (1<<15)
1709 #define NO_OPLOCK_RETURN 0
1710 #define EXCLUSIVE_OPLOCK_RETURN 1
1711 #define BATCH_OPLOCK_RETURN 2
1712 #define LEVEL_II_OPLOCK_RETURN 3
1714 /* Oplock levels */
1715 #define OPLOCKLEVEL_NONE 0
1716 #define OPLOCKLEVEL_II 1
1719 * Capabilities abstracted for different systems.
1722 enum smbd_capability {
1723 KERNEL_OPLOCK_CAPABILITY,
1724 DMAPI_ACCESS_CAPABILITY,
1725 LEASE_CAPABILITY
1729 * Kernel oplocks capability flags.
1732 /* Level 2 oplocks are supported natively by kernel oplocks. */
1733 #define KOPLOCKS_LEVEL2_SUPPORTED 0x1
1735 /* The kernel notifies deferred openers when they can retry the open. */
1736 #define KOPLOCKS_DEFERRED_OPEN_NOTIFICATION 0x2
1738 /* The kernel notifies smbds when an oplock break times out. */
1739 #define KOPLOCKS_TIMEOUT_NOTIFICATION 0x4
1741 /* The kernel notifies smbds when an oplock is broken. */
1742 #define KOPLOCKS_OPLOCK_BROKEN_NOTIFICATION 0x8
1744 struct kernel_oplocks_ops;
1745 struct kernel_oplocks {
1746 const struct kernel_oplocks_ops *ops;
1747 uint32_t flags;
1748 void *private_data;
1751 enum level2_contention_type {
1752 LEVEL2_CONTEND_ALLOC_SHRINK,
1753 LEVEL2_CONTEND_ALLOC_GROW,
1754 LEVEL2_CONTEND_SET_FILE_LEN,
1755 LEVEL2_CONTEND_FILL_SPARSE,
1756 LEVEL2_CONTEND_WRITE,
1757 LEVEL2_CONTEND_WINDOWS_BRL,
1758 LEVEL2_CONTEND_POSIX_BRL
1761 /* if a kernel does support oplocks then a structure of the following
1762 typee is used to describe how to interact with the kernel */
1763 struct kernel_oplocks_ops {
1764 bool (*set_oplock)(struct kernel_oplocks *ctx,
1765 files_struct *fsp, int oplock_type);
1766 void (*release_oplock)(struct kernel_oplocks *ctx,
1767 files_struct *fsp, int oplock_type);
1768 void (*contend_level2_oplocks_begin)(files_struct *fsp,
1769 enum level2_contention_type type);
1770 void (*contend_level2_oplocks_end)(files_struct *fsp,
1771 enum level2_contention_type type);
1774 #include "smb_macros.h"
1776 #define MAX_NETBIOSNAME_LEN 16
1777 /* DOS character, NetBIOS namestring. Type used on the wire. */
1778 typedef char nstring[MAX_NETBIOSNAME_LEN];
1779 /* Unix character, NetBIOS namestring. Type used to manipulate name in nmbd. */
1780 typedef char unstring[MAX_NETBIOSNAME_LEN*4];
1782 /* A netbios name structure. */
1783 struct nmb_name {
1784 nstring name;
1785 char scope[64];
1786 unsigned int name_type;
1789 /* A netbios node status array element. */
1790 typedef struct node_status_ {
1791 nstring name;
1792 unsigned char type;
1793 unsigned char flags;
1794 } NODE_STATUS_STRUCT;
1796 /* The extra info from a NetBIOS node status query */
1797 struct node_status_extra {
1798 unsigned char mac_addr[6];
1799 /* There really is more here ... */
1802 typedef struct user_struct {
1803 struct user_struct *next, *prev;
1804 uint16 vuid; /* Tag for this entry. */
1806 char *session_keystr; /* used by utmp and pam session code.
1807 TDB key string */
1808 int homes_snum;
1810 struct auth_serversupplied_info *server_info;
1812 struct auth_ntlmssp_state *auth_ntlmssp_state;
1813 } user_struct;
1815 struct unix_error_map {
1816 int unix_error;
1817 int dos_class;
1818 int dos_code;
1819 NTSTATUS nt_error;
1823 * Size of new password account encoding string. This is enough space to
1824 * hold 11 ACB characters, plus the surrounding [] and a terminating null.
1825 * Do not change unless you are adding new ACB bits!
1828 #define NEW_PW_FORMAT_SPACE_PADDED_LEN 14
1831 Do you want session setups at user level security with a invalid
1832 password to be rejected or allowed in as guest? WinNT rejects them
1833 but it can be a pain as it means "net view" needs to use a password
1835 You have 3 choices in the setting of map_to_guest:
1837 "NEVER_MAP_TO_GUEST" means session setups with an invalid password
1838 are rejected. This is the default.
1840 "MAP_TO_GUEST_ON_BAD_USER" means session setups with an invalid password
1841 are rejected, unless the username does not exist, in which case it
1842 is treated as a guest login
1844 "MAP_TO_GUEST_ON_BAD_PASSWORD" means session setups with an invalid password
1845 are treated as a guest login
1847 Note that map_to_guest only has an effect in user or server
1848 level security.
1851 #define NEVER_MAP_TO_GUEST 0
1852 #define MAP_TO_GUEST_ON_BAD_USER 1
1853 #define MAP_TO_GUEST_ON_BAD_PASSWORD 2
1854 #define MAP_TO_GUEST_ON_BAD_UID 3
1856 #define SAFE_NETBIOS_CHARS ". -_"
1858 /* The maximum length of a trust account password.
1859 Used when we randomly create it, 15 char passwords
1860 exceed NT4's max password length */
1862 #define DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH 14
1864 #include "popt_common.h"
1866 #define PORT_NONE 0
1867 #ifndef LDAP_PORT
1868 #define LDAP_PORT 389
1869 #endif
1870 #define LDAP_GC_PORT 3268
1872 /* used by the IP comparison function */
1873 struct ip_service {
1874 struct sockaddr_storage ss;
1875 unsigned port;
1878 /* Special name type used to cause a _kerberos DNS lookup. */
1879 #define KDC_NAME_TYPE 0xDCDC
1881 struct ea_struct {
1882 uint8 flags;
1883 char *name;
1884 DATA_BLOB value;
1887 struct ea_list {
1888 struct ea_list *next, *prev;
1889 struct ea_struct ea;
1892 /* EA names used internally in Samba. KEEP UP TO DATE with prohibited_ea_names in trans2.c !. */
1893 #define SAMBA_POSIX_INHERITANCE_EA_NAME "user.SAMBA_PAI"
1894 /* EA to use for DOS attributes */
1895 #define SAMBA_XATTR_DOS_ATTRIB "user.DOSATTRIB"
1896 /* Prefix for DosStreams in the vfs_streams_xattr module */
1897 #define SAMBA_XATTR_DOSSTREAM_PREFIX "user.DosStream."
1898 /* Prefix for DOS timestamps. */
1899 #define SAMBA_XATTR_DOSTIMESTAMPS "user.DosTimestamps"
1900 /* Prefix for xattrs storing streams. */
1901 #define SAMBA_XATTR_MARKER "user.SAMBA_STREAMS"
1903 #define UUID_SIZE 16
1905 #define UUID_FLAT_SIZE 16
1906 typedef struct uuid_flat {
1907 uint8 info[UUID_FLAT_SIZE];
1908 } UUID_FLAT;
1910 /* map readonly options */
1911 enum mapreadonly_options {MAP_READONLY_NO, MAP_READONLY_YES, MAP_READONLY_PERMISSIONS};
1913 /* usershare error codes. */
1914 enum usershare_err {
1915 USERSHARE_OK=0,
1916 USERSHARE_MALFORMED_FILE,
1917 USERSHARE_BAD_VERSION,
1918 USERSHARE_MALFORMED_PATH,
1919 USERSHARE_MALFORMED_COMMENT_DEF,
1920 USERSHARE_MALFORMED_ACL_DEF,
1921 USERSHARE_ACL_ERR,
1922 USERSHARE_PATH_NOT_ABSOLUTE,
1923 USERSHARE_PATH_IS_DENIED,
1924 USERSHARE_PATH_NOT_ALLOWED,
1925 USERSHARE_PATH_NOT_DIRECTORY,
1926 USERSHARE_POSIX_ERR
1929 /* Different reasons for closing a file. */
1930 enum file_close_type {NORMAL_CLOSE=0,SHUTDOWN_CLOSE,ERROR_CLOSE};
1932 /* Used in SMB_FS_OBJECTID_INFORMATION requests. Must be exactly 48 bytes. */
1933 #define SAMBA_EXTENDED_INFO_MAGIC 0x536d4261 /* "SmBa" */
1934 #define SAMBA_EXTENDED_INFO_VERSION_STRING_LENGTH 28
1935 struct smb_extended_info {
1936 uint32 samba_magic; /* Always SAMBA_EXTRA_INFO_MAGIC */
1937 uint32 samba_version; /* Major/Minor/Release/Revision */
1938 uint32 samba_subversion; /* Prerelease/RC/Vendor patch */
1939 NTTIME samba_gitcommitdate;
1940 char samba_version_string[SAMBA_EXTENDED_INFO_VERSION_STRING_LENGTH];
1943 /* time info */
1944 struct smb_file_time {
1945 struct timespec mtime;
1946 struct timespec atime;
1947 struct timespec ctime;
1948 struct timespec create_time;
1952 * unix_convert_flags
1954 #define UCF_SAVE_LCOMP 0x00000001
1955 #define UCF_ALWAYS_ALLOW_WCARD_LCOMP 0x00000002
1956 #define UCF_COND_ALLOW_WCARD_LCOMP 0x00000004
1957 #define UCF_POSIX_PATHNAMES 0x00000008
1960 * smb_filename
1962 struct smb_filename {
1963 char *base_name;
1964 char *stream_name;
1965 char *original_lcomp;
1966 SMB_STRUCT_STAT st;
1969 /* struct for maintaining the child processes that get spawned from smbd */
1970 struct child_pid {
1971 struct child_pid *prev, *next;
1972 pid_t pid;
1975 #endif /* _SMB_H */