get rid of annoying "change your password now" message
[Samba.git] / source / include / smb.h
blobed5230a8d690d1c77f5975a249f1f8f9957cbb74
1 /*
2 Unix SMB/Netbios implementation.
3 Version 1.9.
4 SMB parameters and setup
5 Copyright (C) Andrew Tridgell 1992-2000
6 Copyright (C) John H Terpstra 1996-2000
7 Copyright (C) Luke Kenneth Casson Leighton 1996-2000
8 Copyright (C) Paul Ashton 1998-2000
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #ifndef _SMB_H
26 #define _SMB_H
28 #if defined(LARGE_SMB_OFF_T)
29 #define BUFFER_SIZE (128*1024)
30 #else /* no large readwrite possible */
31 #define BUFFER_SIZE (0xFFFF)
32 #endif
34 #define SAFETY_MARGIN 1024
35 #define LARGE_WRITEX_HDR_SIZE 65
37 #define NMB_PORT 137
38 #define DGRAM_PORT 138
39 #define SMB_PORT 139
41 #define False (0)
42 #define True (1)
43 #define Auto (2)
45 #ifndef _BOOL
46 typedef int BOOL;
47 #define _BOOL /* So we don't typedef BOOL again in vfs.h */
48 #endif
50 /* limiting size of ipc replies */
51 #define REALLOC(ptr,size) Realloc(ptr,MAX((size),4*1024))
53 #define SIZEOFWORD 2
55 #ifndef DEF_CREATE_MASK
56 #define DEF_CREATE_MASK (0755)
57 #endif
59 /* string manipulation flags - see clistr.c and srvstr.c */
60 #define STR_TERMINATE 1
61 #define STR_CONVERT 2
62 #define STR_UPPER 4
63 #define STR_ASCII 8
64 #define STR_UNICODE 16
65 #define STR_NOALIGN 32
67 /* how long to wait for secondary SMB packets (milli-seconds) */
68 #define SMB_SECONDARY_WAIT (60*1000)
70 /* Debugging stuff */
71 #include "debug.h"
73 /* this defines the error codes that receive_smb can put in smb_read_error */
74 #define READ_TIMEOUT 1
75 #define READ_EOF 2
76 #define READ_ERROR 3
79 #define DIR_STRUCT_SIZE 43
81 /* these define all the command types recognised by the server - there
82 are lots of gaps so probably there are some rare commands that are not
83 implemented */
85 #define pSETDIR '\377'
87 /* these define the attribute byte as seen by DOS */
88 #define aRONLY (1L<<0) /* 0x01 */
89 #define aHIDDEN (1L<<1) /* 0x02 */
90 #define aSYSTEM (1L<<2) /* 0x04 */
91 #define aVOLID (1L<<3) /* 0x08 */
92 #define aDIR (1L<<4) /* 0x10 */
93 #define aARCH (1L<<5) /* 0x20 */
95 /* deny modes */
96 #define DENY_DOS 0
97 #define DENY_ALL 1
98 #define DENY_WRITE 2
99 #define DENY_READ 3
100 #define DENY_NONE 4
101 #define DENY_FCB 7
103 /* open modes */
104 #define DOS_OPEN_RDONLY 0
105 #define DOS_OPEN_WRONLY 1
106 #define DOS_OPEN_RDWR 2
107 #define DOS_OPEN_FCB 0xF
109 /* define shifts and masks for share and open modes. */
110 #define OPEN_MODE_MASK 0xF
111 #define SHARE_MODE_SHIFT 4
112 #define SHARE_MODE_MASK 0x7
113 #define GET_OPEN_MODE(x) ((x) & OPEN_MODE_MASK)
114 #define SET_OPEN_MODE(x) ((x) & OPEN_MODE_MASK)
115 #define GET_DENY_MODE(x) (((x)>>SHARE_MODE_SHIFT) & SHARE_MODE_MASK)
116 #define SET_DENY_MODE(x) (((x) & SHARE_MODE_MASK) <<SHARE_MODE_SHIFT)
118 /* Sync on open file (not sure if used anymore... ?) */
119 #define FILE_SYNC_OPENMODE (1<<14)
120 #define GET_FILE_SYNC_OPENMODE(x) (((x) & FILE_SYNC_OPENMODE) ? True : False)
122 /* allow delete on open file mode (used by NT SMB's). */
123 #define ALLOW_SHARE_DELETE (1<<15)
124 #define GET_ALLOW_SHARE_DELETE(x) (((x) & ALLOW_SHARE_DELETE) ? True : False)
125 #define SET_ALLOW_SHARE_DELETE(x) ((x) ? ALLOW_SHARE_DELETE : 0)
127 /* delete on close flag (used by NT SMB's). */
128 #define DELETE_ON_CLOSE_FLAG (1<<16)
129 #define GET_DELETE_ON_CLOSE_FLAG(x) (((x) & DELETE_ON_CLOSE_FLAG) ? True : False)
130 #define SET_DELETE_ON_CLOSE_FLAG(x) ((x) ? DELETE_ON_CLOSE_FLAG : 0)
132 /* open disposition values */
133 #define FILE_EXISTS_FAIL 0
134 #define FILE_EXISTS_OPEN 1
135 #define FILE_EXISTS_TRUNCATE 2
137 /* mask for open disposition. */
138 #define FILE_OPEN_MASK 0x3
140 #define GET_FILE_OPEN_DISPOSITION(x) ((x) & FILE_OPEN_MASK)
141 #define SET_FILE_OPEN_DISPOSITION(x) ((x) & FILE_OPEN_MASK)
143 /* The above can be OR'ed with... */
144 #define FILE_CREATE_IF_NOT_EXIST 0x10
145 #define FILE_FAIL_IF_NOT_EXIST 0
147 #define GET_FILE_CREATE_DISPOSITION(x) ((x) & (FILE_CREATE_IF_NOT_EXIST|FILE_FAIL_IF_NOT_EXIST))
149 /* share types */
150 #define STYPE_DISKTREE 0 /* Disk drive */
151 #define STYPE_PRINTQ 1 /* Spooler queue */
152 #define STYPE_DEVICE 2 /* Serial device */
153 #define STYPE_IPC 3 /* Interprocess communication (IPC) */
154 #define STYPE_HIDDEN 0x80000000 /* share is a hidden one (ends with $) */
156 #include "doserr.h"
158 #ifndef _PSTRING
160 #define PSTRING_LEN 1024
161 #define FSTRING_LEN 256
163 typedef char pstring[PSTRING_LEN];
164 typedef char fstring[FSTRING_LEN];
166 #define _PSTRING
168 #endif
171 * SMB UCS2 (16-bit unicode) internal type.
174 typedef uint16 smb_ucs2_t;
176 /* ucs2 string types. */
177 typedef smb_ucs2_t wpstring[PSTRING_LEN];
178 typedef smb_ucs2_t wfstring[FSTRING_LEN];
180 /* pipe string names */
181 #define PIPE_LANMAN "\\PIPE\\LANMAN"
182 #define PIPE_SRVSVC "\\PIPE\\srvsvc"
183 #define PIPE_SAMR "\\PIPE\\samr"
184 #define PIPE_WINREG "\\PIPE\\winreg"
185 #define PIPE_WKSSVC "\\PIPE\\wkssvc"
186 #define PIPE_NETLOGON "\\PIPE\\NETLOGON"
187 #define PIPE_NTLSA "\\PIPE\\ntlsa"
188 #define PIPE_NTSVCS "\\PIPE\\ntsvcs"
189 #define PIPE_LSASS "\\PIPE\\lsass"
190 #define PIPE_LSARPC "\\PIPE\\lsarpc"
191 #define PIPE_SPOOLSS "\\PIPE\\spoolss"
192 #define PIPE_NETDFS "\\PIPE\\netdfs"
194 /* 64 bit time (100usec) since ????? - cifs6.txt, section 3.5, page 30 */
195 typedef struct nttime_info
197 uint32 low;
198 uint32 high;
200 } NTTIME;
202 #ifndef TIME_T_MIN
203 #define TIME_T_MIN ((time_t)0 < (time_t) -1 ? (time_t) 0 \
204 : ~ (time_t) 0 << (sizeof (time_t) * CHAR_BIT - 1))
205 #endif
206 #ifndef TIME_T_MAX
207 #define TIME_T_MAX (~ (time_t) 0 - TIME_T_MIN)
208 #endif
211 /* the following rather strange looking definitions of NTSTATUS and WERROR
212 and there in order to catch common coding errors where different error types
213 are mixed up. This is especially important as we slowly convert Samba
214 from using BOOL for internal functions
216 #if defined(HAVE_IMMEDIATE_STRUCTURES)
217 typedef struct {uint32 v;} NTSTATUS;
218 #define NT_STATUS(x) ((NTSTATUS) { x })
219 #define NT_STATUS_V(x) ((x).v)
220 #else
221 typedef uint32 NTSTATUS;
222 #define NT_STATUS(x) (x)
223 #define NT_STATUS_V(x) (x)
224 #endif
226 #if defined(HAVE_IMMEDIATE_STRUCTURES)
227 typedef struct {uint32 v;} WERROR;
228 #define W_ERROR(x) ((WERROR) { x })
229 #define W_ERROR_V(x) ((x).v)
230 #else
231 typedef uint32 WERROR;
232 #define W_ERROR(x) (x)
233 #define W_ERROR_V(x) (x)
234 #endif
236 #define NT_STATUS_IS_OK(x) (NT_STATUS_V(x) == 0)
237 #define NT_STATUS_IS_ERR(x) ((NT_STATUS_V(x) & 0xc0000000) == 0xc0000000)
238 #define NT_STATUS_EQUAL(x,y) (NT_STATUS_V(x) == NT_STATUS_V(y))
239 #define W_ERROR_IS_OK(x) (W_ERROR_V(x) == 0)
241 /* Allowable account control bits */
242 #define ACB_DISABLED 0x0001 /* 1 = User account disabled */
243 #define ACB_HOMDIRREQ 0x0002 /* 1 = Home directory required */
244 #define ACB_PWNOTREQ 0x0004 /* 1 = User password not required */
245 #define ACB_TEMPDUP 0x0008 /* 1 = Temporary duplicate account */
246 #define ACB_NORMAL 0x0010 /* 1 = Normal user account */
247 #define ACB_MNS 0x0020 /* 1 = MNS logon user account */
248 #define ACB_DOMTRUST 0x0040 /* 1 = Interdomain trust account */
249 #define ACB_WSTRUST 0x0080 /* 1 = Workstation trust account */
250 #define ACB_SVRTRUST 0x0100 /* 1 = Server trust account */
251 #define ACB_PWNOEXP 0x0200 /* 1 = User password does not expire */
252 #define ACB_AUTOLOCK 0x0400 /* 1 = Account auto locked */
254 #define MAX_HOURS_LEN 32
257 struct sam_disp_info
259 uint32 user_rid; /* Primary User ID */
260 char *smb_name; /* username string */
261 char *full_name; /* user's full name string */
264 typedef struct
266 uint32 pid;
267 uint16 vuid;
270 vuser_key;
273 struct use_info
275 BOOL connected;
276 char *srv_name;
277 vuser_key key;
278 char *user_name;
279 char *domain;
282 #ifndef MAXSUBAUTHS
283 #define MAXSUBAUTHS 15 /* max sub authorities in a SID */
284 #endif
286 #ifndef _DOM_SID
287 /* DOM_SID - security id */
288 typedef struct sid_info
290 uint8 sid_rev_num; /* SID revision number */
291 uint8 num_auths; /* number of sub-authorities */
292 uint8 id_auth[6]; /* Identifier Authority */
294 * Note that the values in these uint32's are in *native* byteorder,
295 * not neccessarily little-endian...... JRA.
297 uint32 sub_auths[MAXSUBAUTHS]; /* pointer to sub-authorities. */
299 } DOM_SID;
300 #define _DOM_SID
301 #endif
304 * The complete list of SIDS belonging to this user.
305 * Created when a vuid is registered.
306 * The definition of the user_sids array is as follows :
308 * token->user_sids[0] = primary user SID.
309 * token->user_sids[1] = primary group SID.
310 * token->user_sids[2-num_sids] = supplementary group SIDS.
313 #define PRIMARY_USER_SID_INDEX 0
314 #define PRIMARY_GROUP_SID_INDEX 1
316 #ifndef _NT_USER_TOKEN
317 typedef struct _nt_user_token {
318 size_t num_sids;
319 DOM_SID *user_sids;
320 } NT_USER_TOKEN;
321 #define _NT_USER_TOKEN
322 #endif
324 /*** query a local group, get a list of these: shows who is in that group ***/
326 /* local group member info */
327 typedef struct local_grp_member_info
329 DOM_SID sid ; /* matches with name */
330 uint8 sid_use; /* usr=1 grp=2 dom=3 alias=4 wkng=5 del=6 inv=7 unk=8 */
331 fstring name ; /* matches with sid: must be of the form "DOMAIN\account" */
333 } LOCAL_GRP_MEMBER;
335 /* enumerate these to get list of local groups */
337 /* local group info */
338 typedef struct local_grp_info
340 fstring name;
341 fstring comment;
343 } LOCAL_GRP;
345 /*** enumerate these to get list of domain groups ***/
347 /* domain group member info */
348 typedef struct domain_grp_info
350 fstring name;
351 fstring comment;
352 uint32 rid; /* group rid */
353 uint8 attr; /* attributes forced to be set to 0x7: SE_GROUP_xxx */
355 } DOMAIN_GRP;
357 /*** query a domain group, get a list of these: shows who is in that group ***/
359 /* domain group info */
360 typedef struct domain_grp_member_info
362 fstring name;
363 uint8 attr; /* attributes forced to be set to 0x7: SE_GROUP_xxx */
365 } DOMAIN_GRP_MEMBER;
367 /* 32 bit time (sec) since 01jan1970 - cifs6.txt, section 3.5, page 30 */
368 typedef struct time_info
370 uint32 time;
371 } UTIME;
373 /* Structure used when SMBwritebmpx is active */
374 typedef struct
376 size_t wr_total_written; /* So we know when to discard this */
377 int32 wr_timeout;
378 int32 wr_errclass;
379 int32 wr_error; /* Cached errors */
380 BOOL wr_mode; /* write through mode) */
381 BOOL wr_discard; /* discard all further data */
382 } write_bmpx_struct;
384 typedef struct write_cache
386 SMB_OFF_T file_size;
387 SMB_OFF_T offset;
388 size_t alloc_size;
389 size_t data_size;
390 char *data;
391 } write_cache;
393 typedef struct files_struct
395 struct files_struct *next, *prev;
396 int fnum;
397 struct connection_struct *conn;
398 int fd;
399 int print_jobid;
400 SMB_DEV_T dev;
401 SMB_INO_T inode;
402 BOOL delete_on_close;
403 SMB_OFF_T pos;
404 SMB_OFF_T size;
405 mode_t mode;
406 uint16 vuid;
407 write_bmpx_struct *wbmpx_ptr;
408 write_cache *wcp;
409 struct timeval open_time;
410 int share_mode;
411 uint32 desired_access;
412 time_t pending_modtime;
413 int oplock_type;
414 int sent_oplock_break;
415 unsigned long file_id;
416 BOOL can_lock;
417 BOOL can_read;
418 BOOL can_write;
419 BOOL print_file;
420 BOOL modified;
421 BOOL is_directory;
422 BOOL directory_delete_on_close;
423 char *fsp_name;
424 } files_struct;
426 /* used to hold an arbitrary blob of data */
427 typedef struct data_blob {
428 uint8 *data;
429 size_t length;
430 void (*free)(struct data_blob *data_blob);
431 } DATA_BLOB;
434 * Structure used to keep directory state information around.
435 * Used in NT change-notify code.
438 typedef struct
440 time_t modify_time;
441 time_t status_time;
442 } dir_status_struct;
444 struct uid_cache {
445 int entries;
446 uid_t list[UID_CACHE_SIZE];
449 typedef struct
451 char *name;
452 BOOL is_wild;
453 } name_compare_entry;
455 /* Include VFS stuff */
457 #include "smb_acls.h"
458 #include "vfs.h"
460 typedef struct connection_struct
462 struct connection_struct *next, *prev;
463 unsigned cnum; /* an index passed over the wire */
464 int service;
465 BOOL force_user;
466 struct uid_cache uid_cache;
467 void *dirptr;
468 BOOL printer;
469 BOOL ipc;
470 BOOL read_only;
471 BOOL admin_user;
472 char *dirpath;
473 char *connectpath;
474 char *origpath;
476 struct vfs_ops vfs_ops; /* Filesystem operations */
477 /* Handle on dlopen() call */
478 void *dl_handle;
479 void *vfs_private;
481 char *user; /* name of user who *opened* this connection */
482 uid_t uid; /* uid of user who *opened* this connection */
483 gid_t gid; /* gid of user who *opened* this connection */
484 char client_address[18]; /* String version of client IP address. */
486 uint16 vuid; /* vuid of user who *opened* this connection, or UID_FIELD_INVALID */
488 /* following groups stuff added by ih */
490 /* This groups info is valid for the user that *opened* the connection */
491 int ngroups;
492 gid_t *groups;
493 NT_USER_TOKEN *nt_user_token;
495 time_t lastused;
496 BOOL used;
497 int num_files_open;
498 name_compare_entry *hide_list; /* Per-share list of files to return as hidden. */
499 name_compare_entry *veto_list; /* Per-share list of files to veto (never show). */
500 name_compare_entry *veto_oplock_list; /* Per-share list of files to refuse oplocks on. */
502 } connection_struct;
504 struct current_user
506 connection_struct *conn;
507 uint16 vuid;
508 uid_t uid;
509 gid_t gid;
510 int ngroups;
511 gid_t *groups;
512 NT_USER_TOKEN *nt_user_token;
515 /* Defines for the sent_oplock_break field above. */
516 #define NO_BREAK_SENT 0
517 #define EXCLUSIVE_BREAK_SENT 1
518 #define LEVEL_II_BREAK_SENT 2
520 typedef struct {
521 fstring smb_name; /* user name from the client */
522 fstring unix_name; /* unix user name of a validated user */
523 fstring full_name; /* to store full name (such as "Joe Bloggs") from gecos field of password file */
524 fstring domain; /* domain that the client specified */
525 } userdom_struct;
527 /* Extra fields above "LPQ_PRINTING" are used to map extra NT status codes. */
529 enum {LPQ_QUEUED=0,LPQ_PAUSED,LPQ_SPOOLING,LPQ_PRINTING,LPQ_ERROR,LPQ_DELETING,
530 LPQ_OFFLINE,LPQ_PAPEROUT,LPQ_PRINTED,LPQ_DELETED,LPQ_BLOCKED,LPQ_USER_INTERVENTION};
532 typedef struct _print_queue_struct
534 int job;
535 int size;
536 int page_count;
537 int status;
538 int priority;
539 time_t time;
540 fstring fs_user;
541 fstring fs_file;
542 } print_queue_struct;
544 enum {LPSTAT_OK, LPSTAT_STOPPED, LPSTAT_ERROR};
546 typedef struct
548 fstring message;
549 int qcount;
550 int status;
551 } print_status_struct;
553 /* used for server information: client, nameserv and ipc */
554 struct server_info_struct
556 fstring name;
557 uint32 type;
558 fstring comment;
559 fstring domain; /* used ONLY in ipc.c NOT namework.c */
560 BOOL server_added; /* used ONLY in ipc.c NOT namework.c */
564 /* used for network interfaces */
565 struct interface
567 struct interface *next, *prev;
568 struct in_addr ip;
569 struct in_addr bcast;
570 struct in_addr nmask;
573 /* struct returned by get_share_modes */
574 typedef struct {
575 pid_t pid;
576 uint16 op_port;
577 uint16 op_type;
578 int share_mode;
579 uint32 desired_access;
580 struct timeval time;
581 SMB_DEV_T dev;
582 SMB_INO_T inode;
583 unsigned long share_file_id;
584 } share_mode_entry;
587 #define SHAREMODE_FN_CAST() \
588 void (*)(share_mode_entry *, char*)
590 #define SHAREMODE_FN(fn) \
591 void (*fn)(share_mode_entry *, char*)
594 * bit flags representing initialized fields in SAM_ACCOUNT
596 #define FLAG_SAM_UNINIT 0x00000000
597 #define FLAG_SAM_UID 0x00000001
598 #define FLAG_SAM_GID 0x00000002
599 #define FLAG_SAM_SMBHOME 0x00000004
600 #define FLAG_SAM_PROFILE 0x00000008
601 #define FLAG_SAM_LOGONSCRIPT 0x00000010
602 #define FLAG_SAM_DRIVE 0x00000020
604 #define IS_SAM_UNIX_USER(x) \
605 (((x)->init_flag & SAM_ACCT_UNIX_UID) \
606 && ((x)->init_flag & SAM_ACCT_UNIX_GID))
608 #define IS_SAM_SET(x, flag) ((x)->init_flag & (flag))
611 typedef struct sam_passwd
613 /* initiailization flags */
614 uint32 init_flag;
616 time_t logon_time; /* logon time */
617 time_t logoff_time; /* logoff time */
618 time_t kickoff_time; /* kickoff time */
619 time_t pass_last_set_time; /* password last set time */
620 time_t pass_can_change_time; /* password can change time */
621 time_t pass_must_change_time; /* password must change time */
623 pstring username; /* UNIX username string */
624 pstring domain; /* Windows Domain name */
625 pstring nt_username; /* Windows username string */
626 pstring full_name; /* user's full name string */
627 pstring home_dir; /* home directory string */
628 pstring dir_drive; /* home directory drive string */
629 pstring logon_script; /* logon script string */
630 pstring profile_path; /* profile path string */
631 pstring acct_desc ; /* user description string */
632 pstring workstations; /* login from workstations string */
633 pstring unknown_str ; /* don't know what this is, yet. */
634 pstring munged_dial ; /* munged path name and dial-back tel number */
636 uid_t uid; /* this is actually the unix uid_t */
637 gid_t gid; /* this is actually the unix gid_t */
638 uint32 user_rid; /* Primary User ID */
639 uint32 group_rid; /* Primary Group ID */
641 unsigned char *lm_pw; /* Null if no password */
642 unsigned char *nt_pw; /* Null if no password */
644 uint16 acct_ctrl; /* account info (ACB_xxxx bit-mask) */
645 uint32 unknown_3; /* 0x00ff ffff */
647 uint16 logon_divs; /* 168 - number of hours in a week */
648 uint32 hours_len; /* normally 21 bytes */
649 uint8 hours[MAX_HOURS_LEN];
651 uint32 unknown_5; /* 0x0002 0000 */
652 uint32 unknown_6; /* 0x0000 04ec */
654 } SAM_ACCOUNT;
658 * Flags for local user manipulation.
661 #define LOCAL_ADD_USER 0x01
662 #define LOCAL_DELETE_USER 0x02
663 #define LOCAL_DISABLE_USER 0x04
664 #define LOCAL_ENABLE_USER 0x08
665 #define LOCAL_TRUST_ACCOUNT 0x10
666 #define LOCAL_SET_NO_PASSWORD 0x20
667 #define LOCAL_SET_LDAP_ADMIN_PW 0x40
668 #define LOCAL_GET_DOM_SID 0x80
670 /* key and data in the connections database - used in smbstatus and smbd */
671 struct connections_key {
672 pid_t pid;
673 int cnum;
674 fstring name;
677 struct connections_data {
678 int magic;
679 pid_t pid;
680 int cnum;
681 uid_t uid;
682 gid_t gid;
683 char name[24];
684 char addr[24];
685 char machine[FSTRING_LEN];
686 time_t start;
690 /* key and data records in the tdb locking database */
691 struct locking_key {
692 SMB_DEV_T dev;
693 SMB_INO_T inode;
696 struct locking_data {
697 union {
698 int num_share_mode_entries;
699 share_mode_entry dummy; /* Needed for alignment. */
700 } u;
701 /* the following two entries are implicit
702 share_mode_entry modes[num_share_mode_entries];
703 char file_name[];
708 /* the following are used by loadparm for option lists */
709 typedef enum
711 P_BOOL,P_BOOLREV,P_CHAR,P_INTEGER,P_OCTAL,
712 P_STRING,P_USTRING,P_GSTRING,P_UGSTRING,P_ENUM,P_SEP
713 } parm_type;
715 typedef enum
717 P_LOCAL,P_GLOBAL,P_SEPARATOR,P_NONE
718 } parm_class;
720 /* passed to br lock code */
721 enum brl_type {READ_LOCK, WRITE_LOCK};
723 struct enum_list {
724 int value;
725 char *name;
728 #define BRLOCK_FN_CAST() \
729 void (*)(SMB_DEV_T dev, SMB_INO_T ino, int pid, \
730 enum brl_type lock_type, \
731 br_off start, br_off size)
732 #define BRLOCK_FN(fn) \
733 void (*fn)(SMB_DEV_T dev, SMB_INO_T ino, int pid, \
734 enum brl_type lock_type, \
735 br_off start, br_off size)
736 struct parm_struct
738 char *label;
739 parm_type type;
740 parm_class class;
741 void *ptr;
742 BOOL (*special)(char *, char **);
743 struct enum_list *enum_list;
744 unsigned flags;
745 union {
746 BOOL bvalue;
747 int ivalue;
748 char *svalue;
749 char cvalue;
750 } def;
753 struct bitmap {
754 uint32 *b;
755 int n;
758 #define FLAG_BASIC 0x01 /* fundamental options */
759 #define FLAG_SHARE 0x02 /* file sharing options */
760 #define FLAG_PRINT 0x04 /* printing options */
761 #define FLAG_GLOBAL 0x08 /* local options that should be globally settable in SWAT */
762 #define FLAG_DEPRECATED 0x10 /* options that should no longer be used */
763 #define FLAG_HIDE 0x20 /* options that should be hidden in SWAT */
764 #define FLAG_DOS_STRING 0x40 /* convert from UNIX to DOS codepage when reading this string. */
766 #ifndef LOCKING_VERSION
767 #define LOCKING_VERSION 4
768 #endif /* LOCKING_VERSION */
771 /* the basic packet size, assuming no words or bytes */
772 #define smb_size 39
774 /* offsets into message for common items */
775 #define smb_com 8
776 #define smb_rcls 9
777 #define smb_reh 10
778 #define smb_err 11
779 #define smb_flg 13
780 #define smb_flg2 14
781 #define smb_reb 13
782 #define smb_tid 28
783 #define smb_pid 30
784 #define smb_uid 32
785 #define smb_mid 34
786 #define smb_wct 36
787 #define smb_vwv 37
788 #define smb_vwv0 37
789 #define smb_vwv1 39
790 #define smb_vwv2 41
791 #define smb_vwv3 43
792 #define smb_vwv4 45
793 #define smb_vwv5 47
794 #define smb_vwv6 49
795 #define smb_vwv7 51
796 #define smb_vwv8 53
797 #define smb_vwv9 55
798 #define smb_vwv10 57
799 #define smb_vwv11 59
800 #define smb_vwv12 61
801 #define smb_vwv13 63
802 #define smb_vwv14 65
803 #define smb_vwv15 67
804 #define smb_vwv16 69
805 #define smb_vwv17 71
807 /* flag defines. CIFS spec 3.1.1 */
808 #define FLAG_SUPPORT_LOCKREAD 0x01
809 #define FLAG_CLIENT_BUF_AVAIL 0x02
810 #define FLAG_RESERVED 0x04
811 #define FLAG_CASELESS_PATHNAMES 0x08
812 #define FLAG_CANONICAL_PATHNAMES 0x10
813 #define FLAG_REQUEST_OPLOCK 0x20
814 #define FLAG_REQUEST_BATCH_OPLOCK 0x40
815 #define FLAG_REPLY 0x80
817 /* the complete */
818 #define SMBmkdir 0x00 /* create directory */
819 #define SMBrmdir 0x01 /* delete directory */
820 #define SMBopen 0x02 /* open file */
821 #define SMBcreate 0x03 /* create file */
822 #define SMBclose 0x04 /* close file */
823 #define SMBflush 0x05 /* flush file */
824 #define SMBunlink 0x06 /* delete file */
825 #define SMBmv 0x07 /* rename file */
826 #define SMBgetatr 0x08 /* get file attributes */
827 #define SMBsetatr 0x09 /* set file attributes */
828 #define SMBread 0x0A /* read from file */
829 #define SMBwrite 0x0B /* write to file */
830 #define SMBlock 0x0C /* lock byte range */
831 #define SMBunlock 0x0D /* unlock byte range */
832 #define SMBctemp 0x0E /* create temporary file */
833 #define SMBmknew 0x0F /* make new file */
834 #define SMBchkpth 0x10 /* check directory path */
835 #define SMBexit 0x11 /* process exit */
836 #define SMBlseek 0x12 /* seek */
837 #define SMBtcon 0x70 /* tree connect */
838 #define SMBtconX 0x75 /* tree connect and X*/
839 #define SMBtdis 0x71 /* tree disconnect */
840 #define SMBnegprot 0x72 /* negotiate protocol */
841 #define SMBdskattr 0x80 /* get disk attributes */
842 #define SMBsearch 0x81 /* search directory */
843 #define SMBsplopen 0xC0 /* open print spool file */
844 #define SMBsplwr 0xC1 /* write to print spool file */
845 #define SMBsplclose 0xC2 /* close print spool file */
846 #define SMBsplretq 0xC3 /* return print queue */
847 #define SMBsends 0xD0 /* send single block message */
848 #define SMBsendb 0xD1 /* send broadcast message */
849 #define SMBfwdname 0xD2 /* forward user name */
850 #define SMBcancelf 0xD3 /* cancel forward */
851 #define SMBgetmac 0xD4 /* get machine name */
852 #define SMBsendstrt 0xD5 /* send start of multi-block message */
853 #define SMBsendend 0xD6 /* send end of multi-block message */
854 #define SMBsendtxt 0xD7 /* send text of multi-block message */
856 /* Core+ protocol */
857 #define SMBlockread 0x13 /* Lock a range and read */
858 #define SMBwriteunlock 0x14 /* Unlock a range then write */
859 #define SMBreadbraw 0x1a /* read a block of data with no smb header */
860 #define SMBwritebraw 0x1d /* write a block of data with no smb header */
861 #define SMBwritec 0x20 /* secondary write request */
862 #define SMBwriteclose 0x2c /* write a file then close it */
864 /* dos extended protocol */
865 #define SMBreadBraw 0x1A /* read block raw */
866 #define SMBreadBmpx 0x1B /* read block multiplexed */
867 #define SMBreadBs 0x1C /* read block (secondary response) */
868 #define SMBwriteBraw 0x1D /* write block raw */
869 #define SMBwriteBmpx 0x1E /* write block multiplexed */
870 #define SMBwriteBs 0x1F /* write block (secondary request) */
871 #define SMBwriteC 0x20 /* write complete response */
872 #define SMBsetattrE 0x22 /* set file attributes expanded */
873 #define SMBgetattrE 0x23 /* get file attributes expanded */
874 #define SMBlockingX 0x24 /* lock/unlock byte ranges and X */
875 #define SMBtrans 0x25 /* transaction - name, bytes in/out */
876 #define SMBtranss 0x26 /* transaction (secondary request/response) */
877 #define SMBioctl 0x27 /* IOCTL */
878 #define SMBioctls 0x28 /* IOCTL (secondary request/response) */
879 #define SMBcopy 0x29 /* copy */
880 #define SMBmove 0x2A /* move */
881 #define SMBecho 0x2B /* echo */
882 #define SMBopenX 0x2D /* open and X */
883 #define SMBreadX 0x2E /* read and X */
884 #define SMBwriteX 0x2F /* write and X */
885 #define SMBsesssetupX 0x73 /* Session Set Up & X (including User Logon) */
886 #define SMBffirst 0x82 /* find first */
887 #define SMBfunique 0x83 /* find unique */
888 #define SMBfclose 0x84 /* find close */
889 #define SMBinvalid 0xFE /* invalid command */
891 /* Extended 2.0 protocol */
892 #define SMBtrans2 0x32 /* TRANS2 protocol set */
893 #define SMBtranss2 0x33 /* TRANS2 protocol set, secondary command */
894 #define SMBfindclose 0x34 /* Terminate a TRANSACT2_FINDFIRST */
895 #define SMBfindnclose 0x35 /* Terminate a TRANSACT2_FINDNOTIFYFIRST */
896 #define SMBulogoffX 0x74 /* user logoff */
898 /* NT SMB extensions. */
899 #define SMBnttrans 0xA0 /* NT transact */
900 #define SMBnttranss 0xA1 /* NT transact secondary */
901 #define SMBntcreateX 0xA2 /* NT create and X */
902 #define SMBntcancel 0xA4 /* NT cancel */
904 /* These are the TRANS2 sub commands */
905 #define TRANSACT2_OPEN 0
906 #define TRANSACT2_FINDFIRST 1
907 #define TRANSACT2_FINDNEXT 2
908 #define TRANSACT2_QFSINFO 3
909 #define TRANSACT2_SETFSINFO 4
910 #define TRANSACT2_QPATHINFO 5
911 #define TRANSACT2_SETPATHINFO 6
912 #define TRANSACT2_QFILEINFO 7
913 #define TRANSACT2_SETFILEINFO 8
914 #define TRANSACT2_FSCTL 9
915 #define TRANSACT2_IOCTL 0xA
916 #define TRANSACT2_FINDNOTIFYFIRST 0xB
917 #define TRANSACT2_FINDNOTIFYNEXT 0xC
918 #define TRANSACT2_MKDIR 0xD
919 #define TRANSACT2_SESSION_SETUP 0xE
920 #define TRANSACT2_GET_DFS_REFERRAL 0x10
921 #define TRANSACT2_REPORT_DFS_INCONSISTANCY 0x11
923 /* These are the NT transact sub commands. */
924 #define NT_TRANSACT_CREATE 1
925 #define NT_TRANSACT_IOCTL 2
926 #define NT_TRANSACT_SET_SECURITY_DESC 3
927 #define NT_TRANSACT_NOTIFY_CHANGE 4
928 #define NT_TRANSACT_RENAME 5
929 #define NT_TRANSACT_QUERY_SECURITY_DESC 6
931 /* Relevant IOCTL codes */
932 #define IOCTL_QUERY_JOB_INFO 0x530060
934 /* these are the trans2 sub fields for primary requests */
935 #define smb_tpscnt smb_vwv0
936 #define smb_tdscnt smb_vwv1
937 #define smb_mprcnt smb_vwv2
938 #define smb_mdrcnt smb_vwv3
939 #define smb_msrcnt smb_vwv4
940 #define smb_flags smb_vwv5
941 #define smb_timeout smb_vwv6
942 #define smb_pscnt smb_vwv9
943 #define smb_psoff smb_vwv10
944 #define smb_dscnt smb_vwv11
945 #define smb_dsoff smb_vwv12
946 #define smb_suwcnt smb_vwv13
947 #define smb_setup smb_vwv14
948 #define smb_setup0 smb_setup
949 #define smb_setup1 (smb_setup+2)
950 #define smb_setup2 (smb_setup+4)
952 /* these are for the secondary requests */
953 #define smb_spscnt smb_vwv2
954 #define smb_spsoff smb_vwv3
955 #define smb_spsdisp smb_vwv4
956 #define smb_sdscnt smb_vwv5
957 #define smb_sdsoff smb_vwv6
958 #define smb_sdsdisp smb_vwv7
959 #define smb_sfid smb_vwv8
961 /* and these for responses */
962 #define smb_tprcnt smb_vwv0
963 #define smb_tdrcnt smb_vwv1
964 #define smb_prcnt smb_vwv3
965 #define smb_proff smb_vwv4
966 #define smb_prdisp smb_vwv5
967 #define smb_drcnt smb_vwv6
968 #define smb_droff smb_vwv7
969 #define smb_drdisp smb_vwv8
971 /* these are for the NT trans primary request. */
972 #define smb_nt_MaxSetupCount smb_vwv0
973 #define smb_nt_Flags (smb_vwv0 + 1)
974 #define smb_nt_TotalParameterCount (smb_vwv0 + 3)
975 #define smb_nt_TotalDataCount (smb_vwv0 + 7)
976 #define smb_nt_MaxParameterCount (smb_vwv0 + 11)
977 #define smb_nt_MaxDataCount (smb_vwv0 + 15)
978 #define smb_nt_ParameterCount (smb_vwv0 + 19)
979 #define smb_nt_ParameterOffset (smb_vwv0 + 23)
980 #define smb_nt_DataCount (smb_vwv0 + 27)
981 #define smb_nt_DataOffset (smb_vwv0 + 31)
982 #define smb_nt_SetupCount (smb_vwv0 + 35)
983 #define smb_nt_Function (smb_vwv0 + 36)
984 #define smb_nt_SetupStart (smb_vwv0 + 38)
986 /* these are for the NT trans secondary request. */
987 #define smb_nts_TotalParameterCount (smb_vwv0 + 3)
988 #define smb_nts_TotalDataCount (smb_vwv0 + 7)
989 #define smb_nts_ParameterCount (smb_vwv0 + 11)
990 #define smb_nts_ParameterOffset (smb_vwv0 + 15)
991 #define smb_nts_ParameterDisplacement (smb_vwv0 + 19)
992 #define smb_nts_DataCount (smb_vwv0 + 23)
993 #define smb_nts_DataOffset (smb_vwv0 + 27)
994 #define smb_nts_DataDisplacement (smb_vwv0 + 31)
996 /* these are for the NT trans reply. */
997 #define smb_ntr_TotalParameterCount (smb_vwv0 + 3)
998 #define smb_ntr_TotalDataCount (smb_vwv0 + 7)
999 #define smb_ntr_ParameterCount (smb_vwv0 + 11)
1000 #define smb_ntr_ParameterOffset (smb_vwv0 + 15)
1001 #define smb_ntr_ParameterDisplacement (smb_vwv0 + 19)
1002 #define smb_ntr_DataCount (smb_vwv0 + 23)
1003 #define smb_ntr_DataOffset (smb_vwv0 + 27)
1004 #define smb_ntr_DataDisplacement (smb_vwv0 + 31)
1006 /* these are for the NT create_and_X */
1007 #define smb_ntcreate_NameLength (smb_vwv0 + 5)
1008 #define smb_ntcreate_Flags (smb_vwv0 + 7)
1009 #define smb_ntcreate_RootDirectoryFid (smb_vwv0 + 11)
1010 #define smb_ntcreate_DesiredAccess (smb_vwv0 + 15)
1011 #define smb_ntcreate_AllocationSize (smb_vwv0 + 19)
1012 #define smb_ntcreate_FileAttributes (smb_vwv0 + 27)
1013 #define smb_ntcreate_ShareAccess (smb_vwv0 + 31)
1014 #define smb_ntcreate_CreateDisposition (smb_vwv0 + 35)
1015 #define smb_ntcreate_CreateOptions (smb_vwv0 + 39)
1016 #define smb_ntcreate_ImpersonationLevel (smb_vwv0 + 43)
1017 #define smb_ntcreate_SecurityFlags (smb_vwv0 + 47)
1019 /* this is used on a TConX. I'm not sure the name is very helpful though */
1020 #define SMB_SUPPORT_SEARCH_BITS 0x0001
1021 #define SMB_SHARE_IN_DFS 0x0002
1023 /* Named pipe write mode flags. Used in writeX calls. */
1024 #define PIPE_RAW_MODE 0x4
1025 #define PIPE_START_MESSAGE 0x8
1027 /* these are the constants used in the above call. */
1028 /* DesiredAccess */
1029 /* File Specific access rights. */
1030 #define FILE_READ_DATA 0x001
1031 #define FILE_WRITE_DATA 0x002
1032 #define FILE_APPEND_DATA 0x004
1033 #define FILE_READ_EA 0x008
1034 #define FILE_WRITE_EA 0x010
1035 #define FILE_EXECUTE 0x020
1036 #define FILE_DELETE_CHILD 0x040
1037 #define FILE_READ_ATTRIBUTES 0x080
1038 #define FILE_WRITE_ATTRIBUTES 0x100
1040 #define FILE_ALL_ACCESS 0x1FF
1042 /* the desired access to use when opening a pipe */
1043 #define DESIRED_ACCESS_PIPE 0x2019f
1045 /* Generic access masks & rights. */
1046 #define SPECIFIC_RIGHTS_MASK 0x00FFFFL
1047 #define STANDARD_RIGHTS_MASK 0xFF0000L
1048 #define DELETE_ACCESS (1L<<16) /* 0x00010000 */
1049 #define READ_CONTROL_ACCESS (1L<<17) /* 0x00020000 */
1050 #define WRITE_DAC_ACCESS (1L<<18) /* 0x00040000 */
1051 #define WRITE_OWNER_ACCESS (1L<<19) /* 0x00080000 */
1052 #define SYNCHRONIZE_ACCESS (1L<<20) /* 0x00100000 */
1054 /* Combinations of standard masks. */
1055 #define STANDARD_RIGHTS_ALL_ACCESS (DELETE_ACCESS|READ_CONTROL_ACCESS|WRITE_DAC_ACCESS|WRITE_OWNER_ACCESS|SYNCHRONIZE_ACCESS) /* 0x001f0000 */
1056 #define STANDARD_RIGHTS_EXECUTE_ACCESS (READ_CONTROL_ACCESS) /* 0x00020000 */
1057 #define STANDARD_RIGHTS_READ_ACCESS (READ_CONTROL_ACCESS) /* 0x00200000 */
1058 #define STANDARD_RIGHTS_REQUIRED_ACCESS (DELETE_ACCESS|READ_CONTROL_ACCESS|WRITE_DAC_ACCESS|WRITE_OWNER_ACCESS) /* 0x000f0000 */
1059 #define STANDARD_RIGHTS_WRITE_ACCESS (READ_CONTROL_ACCESS) /* 0x00020000 */
1061 #define SYSTEM_SECURITY_ACCESS (1L<<24) /* 0x01000000 */
1062 #define MAXIMUM_ALLOWED_ACCESS (1L<<25) /* 0x02000000 */
1063 #define GENERIC_ALL_ACCESS (1<<28) /* 0x10000000 */
1064 #define GENERIC_EXECUTE_ACCESS (1<<29) /* 0x20000000 */
1065 #define GENERIC_WRITE_ACCESS (1<<30) /* 0x40000000 */
1066 #define GENERIC_READ_ACCESS (((unsigned)1)<<31) /* 0x80000000 */
1068 /* Mapping of generic access rights for files to specific rights. */
1070 #define FILE_GENERIC_ALL (STANDARD_RIGHTS_REQUIRED_ACCESS| SYNCHRONIZE_ACCESS|FILE_ALL_ACCESS)
1072 #define FILE_GENERIC_READ (STANDARD_RIGHTS_READ_ACCESS|FILE_READ_DATA|FILE_READ_ATTRIBUTES|\
1073 FILE_READ_EA|SYNCHRONIZE_ACCESS)
1075 #define FILE_GENERIC_WRITE (STANDARD_RIGHTS_WRITE_ACCESS|FILE_WRITE_DATA|FILE_WRITE_ATTRIBUTES|\
1076 FILE_WRITE_EA|FILE_APPEND_DATA|SYNCHRONIZE_ACCESS)
1078 #define FILE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE_ACCESS|FILE_READ_ATTRIBUTES|\
1079 FILE_EXECUTE|SYNCHRONIZE_ACCESS)
1081 /* Mapping of access rights to UNIX perms. */
1082 #define UNIX_ACCESS_RWX FILE_GENERIC_ALL
1083 #define UNIX_ACCESS_R FILE_GENERIC_READ
1084 #define UNIX_ACCESS_W FILE_GENERIC_WRITE
1085 #define UNIX_ACCESS_X FILE_GENERIC_EXECUTE
1087 #if 0
1089 * This is the old mapping we used to use. To get W2KSP2 profiles
1090 * working we need to map to the canonical file perms.
1092 #define UNIX_ACCESS_RWX (UNIX_ACCESS_R|UNIX_ACCESS_W|UNIX_ACCESS_X)
1093 #define UNIX_ACCESS_R (READ_CONTROL_ACCESS|SYNCHRONIZE_ACCESS|\
1094 FILE_READ_ATTRIBUTES|FILE_READ_EA|FILE_READ_DATA)
1095 #define UNIX_ACCESS_W (READ_CONTROL_ACCESS|SYNCHRONIZE_ACCESS|\
1096 FILE_WRITE_ATTRIBUTES|FILE_WRITE_EA|\
1097 FILE_APPEND_DATA|FILE_WRITE_DATA)
1098 #define UNIX_ACCESS_X (READ_CONTROL_ACCESS|SYNCHRONIZE_ACCESS|\
1099 FILE_EXECUTE|FILE_READ_ATTRIBUTES)
1100 #endif
1102 #define UNIX_ACCESS_NONE (WRITE_OWNER_ACCESS)
1104 /* Flags field. */
1105 #define REQUEST_OPLOCK 2
1106 #define REQUEST_BATCH_OPLOCK 4
1107 #define OPEN_DIRECTORY 8
1109 /* ShareAccess field. */
1110 #define FILE_SHARE_NONE 0 /* Cannot be used in bitmask. */
1111 #define FILE_SHARE_READ 1
1112 #define FILE_SHARE_WRITE 2
1113 #define FILE_SHARE_DELETE 4
1115 /* FileAttributesField */
1116 #define FILE_ATTRIBUTE_READONLY aRONLY
1117 #define FILE_ATTRIBUTE_HIDDEN aHIDDEN
1118 #define FILE_ATTRIBUTE_SYSTEM aSYSTEM
1119 #define FILE_ATTRIBUTE_DIRECTORY aDIR
1120 #define FILE_ATTRIBUTE_ARCHIVE aARCH
1121 #define FILE_ATTRIBUTE_NORMAL 0x80L
1122 #define FILE_ATTRIBUTE_TEMPORARY 0x100L
1123 #define FILE_ATTRIBUTE_SPARSE 0x200L
1124 #define FILE_ATTRIBUTE_COMPRESSED 0x800L
1125 #define FILE_ATTRIBUTE_NONINDEXED 0x2000L
1126 #define SAMBA_ATTRIBUTES_MASK 0x7F
1128 /* Flags - combined with attributes. */
1129 #define FILE_FLAG_WRITE_THROUGH 0x80000000L
1130 #define FILE_FLAG_NO_BUFFERING 0x20000000L
1131 #define FILE_FLAG_RANDOM_ACCESS 0x10000000L
1132 #define FILE_FLAG_SEQUENTIAL_SCAN 0x08000000L
1133 #define FILE_FLAG_DELETE_ON_CLOSE 0x04000000L
1134 #define FILE_FLAG_BACKUP_SEMANTICS 0x02000000L
1135 #define FILE_FLAG_POSIX_SEMANTICS 0x01000000L
1137 /* CreateDisposition field. */
1138 #define FILE_SUPERSEDE 0
1139 #define FILE_OPEN 1
1140 #define FILE_CREATE 2
1141 #define FILE_OPEN_IF 3
1142 #define FILE_OVERWRITE 4
1143 #define FILE_OVERWRITE_IF 5
1145 /* CreateOptions field. */
1146 #define FILE_DIRECTORY_FILE 0x0001
1147 #define FILE_WRITE_THROUGH 0x0002
1148 #define FILE_SEQUENTIAL_ONLY 0x0004
1149 #define FILE_NON_DIRECTORY_FILE 0x0040
1150 #define FILE_NO_EA_KNOWLEDGE 0x0200
1151 #define FILE_EIGHT_DOT_THREE_ONLY 0x0400
1152 #define FILE_RANDOM_ACCESS 0x0800
1153 #define FILE_DELETE_ON_CLOSE 0x1000
1155 /* Responses when opening a file. */
1156 #define FILE_WAS_OPENED 1
1157 #define FILE_WAS_CREATED 2
1158 #define FILE_WAS_OVERWRITTEN 3
1160 /* File type flags */
1161 #define FILE_TYPE_DISK 0
1162 #define FILE_TYPE_BYTE_MODE_PIPE 1
1163 #define FILE_TYPE_MESSAGE_MODE_PIPE 2
1164 #define FILE_TYPE_PRINTER 3
1165 #define FILE_TYPE_COMM_DEVICE 4
1166 #define FILE_TYPE_UNKNOWN 0xFFFF
1168 /* Flag for NT transact rename call. */
1169 #define RENAME_REPLACE_IF_EXISTS 1
1171 /* Filesystem Attributes. */
1172 #define FILE_CASE_SENSITIVE_SEARCH 0x01
1173 #define FILE_CASE_PRESERVED_NAMES 0x02
1174 #define FILE_UNICODE_ON_DISK 0x04
1175 /* According to cifs9f, this is 4, not 8 */
1176 /* Acconding to testing, this actually sets the security attribute! */
1177 #define FILE_PERSISTENT_ACLS 0x08
1178 /* These entries added from cifs9f --tsb */
1179 #define FILE_FILE_COMPRESSION 0x10
1180 #define FILE_VOLUME_QUOTAS 0x20
1181 /* I think this is wrong. JRA #define FILE_DEVICE_IS_MOUNTED 0x20 */
1182 #define FILE_VOLUME_SPARSE_FILE 0x40
1183 #define FILE_VOLUME_IS_COMPRESSED 0x8000
1185 /* ChangeNotify flags. */
1186 #define FILE_NOTIFY_CHANGE_FILE 0x001
1187 #define FILE_NOTIFY_CHANGE_DIR_NAME 0x002
1188 #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x004
1189 #define FILE_NOTIFY_CHANGE_SIZE 0x008
1190 #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x010
1191 #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x020
1192 #define FILE_NOTIFY_CHANGE_CREATION 0x040
1193 #define FILE_NOTIFY_CHANGE_EA 0x080
1194 #define FILE_NOTIFY_CHANGE_SECURITY 0x100
1195 #define FILE_NOTIFY_CHANGE_FILE_NAME 0x200
1197 /* where to find the base of the SMB packet proper */
1198 #define smb_base(buf) (((char *)(buf))+4)
1200 /* we don't allow server strings to be longer than 48 characters as
1201 otherwise NT will not honour the announce packets */
1202 #define MAX_SERVER_STRING_LENGTH 48
1205 #define SMB_SUCCESS 0 /* The request was successful. */
1207 #ifdef HAVE_STDARG_H
1208 int slprintf(char *str, int n, char *format, ...)
1209 #ifdef __GNUC__
1210 __attribute__ ((format (__printf__, 3, 4)))
1211 #endif
1213 #else
1214 int slprintf();
1215 #endif
1217 #ifdef HAVE_STDARG_H
1218 int fdprintf(int fd, char *format, ...)
1219 #ifdef __GNUC__
1220 __attribute__ ((format (__printf__, 2, 3)))
1221 #endif
1223 #else
1224 int fdprintf();
1225 #endif
1227 #ifdef WITH_DFS
1228 void dfs_unlogin(void);
1229 extern int dcelogin_atmost_once;
1230 #endif
1232 #ifdef NOSTRDUP
1233 char *strdup(char *s);
1234 #endif
1236 #ifndef SIGNAL_CAST
1237 #define SIGNAL_CAST (RETSIGTYPE (*)(int))
1238 #endif
1240 #ifndef SELECT_CAST
1241 #define SELECT_CAST
1242 #endif
1244 /* these are used in NetServerEnum to choose what to receive */
1245 #define SV_TYPE_WORKSTATION 0x00000001
1246 #define SV_TYPE_SERVER 0x00000002
1247 #define SV_TYPE_SQLSERVER 0x00000004
1248 #define SV_TYPE_DOMAIN_CTRL 0x00000008
1249 #define SV_TYPE_DOMAIN_BAKCTRL 0x00000010
1250 #define SV_TYPE_TIME_SOURCE 0x00000020
1251 #define SV_TYPE_AFP 0x00000040
1252 #define SV_TYPE_NOVELL 0x00000080
1253 #define SV_TYPE_DOMAIN_MEMBER 0x00000100
1254 #define SV_TYPE_PRINTQ_SERVER 0x00000200
1255 #define SV_TYPE_DIALIN_SERVER 0x00000400
1256 #define SV_TYPE_SERVER_UNIX 0x00000800
1257 #define SV_TYPE_NT 0x00001000
1258 #define SV_TYPE_WFW 0x00002000
1259 #define SV_TYPE_SERVER_MFPN 0x00004000
1260 #define SV_TYPE_SERVER_NT 0x00008000
1261 #define SV_TYPE_POTENTIAL_BROWSER 0x00010000
1262 #define SV_TYPE_BACKUP_BROWSER 0x00020000
1263 #define SV_TYPE_MASTER_BROWSER 0x00040000
1264 #define SV_TYPE_DOMAIN_MASTER 0x00080000
1265 #define SV_TYPE_SERVER_OSF 0x00100000
1266 #define SV_TYPE_SERVER_VMS 0x00200000
1267 #define SV_TYPE_WIN95_PLUS 0x00400000
1268 #define SV_TYPE_DFS_SERVER 0x00800000
1269 #define SV_TYPE_ALTERNATE_XPORT 0x20000000
1270 #define SV_TYPE_LOCAL_LIST_ONLY 0x40000000
1271 #define SV_TYPE_DOMAIN_ENUM 0x80000000
1272 #define SV_TYPE_ALL 0xFFFFFFFF
1274 /* This was set by JHT in liaison with Jeremy Allison early 1997
1275 * History:
1276 * Version 4.0 - never made public
1277 * Version 4.10 - New to 1.9.16p2, lost in space 1.9.16p3 to 1.9.16p9
1278 * - Reappeared in 1.9.16p11 with fixed smbd services
1279 * Version 4.20 - To indicate that nmbd and browsing now works better
1280 * Version 4.50 - Set at release of samba-2.2.0 by JHT
1282 * Note: In the presence of NT4.X do not set above 4.9
1283 * Setting this above 4.9 can have undesired side-effects.
1284 * This may change again in Samba-3.0 after further testing. JHT
1287 #define DEFAULT_MAJOR_VERSION 0x04
1288 #define DEFAULT_MINOR_VERSION 0x05
1290 /* Browser Election Values */
1291 #define BROWSER_ELECTION_VERSION 0x010f
1292 #define BROWSER_CONSTANT 0xaa55
1294 /* NT Flags2 bits - cifs6.txt section 3.1.2 */
1296 #define FLAGS2_LONG_PATH_COMPONENTS 0x0001
1297 #define FLAGS2_EXTENDED_ATTRIBUTES 0x0002
1298 #define FLAGS2_IS_LONG_NAME 0x0040
1299 #define FLAGS2_DFS_PATHNAMES 0x1000
1300 #define FLAGS2_READ_PERMIT_NO_EXECUTE 0x2000
1301 #define FLAGS2_32_BIT_ERROR_CODES 0x4000
1302 #define FLAGS2_UNICODE_STRINGS 0x8000
1304 #define FLAGS2_WIN2K_SIGNATURE 0xC852 /* Hack alert ! For now... JRA. */
1306 /* Capabilities. see ftp.microsoft.com/developr/drg/cifs/cifs/cifs4.txt */
1308 #define CAP_RAW_MODE 0x0001
1309 #define CAP_MPX_MODE 0x0002
1310 #define CAP_UNICODE 0x0004
1311 #define CAP_LARGE_FILES 0x0008
1312 #define CAP_NT_SMBS 0x0010
1313 #define CAP_RPC_REMOTE_APIS 0x0020
1314 #define CAP_STATUS32 0x0040
1315 #define CAP_LEVEL_II_OPLOCKS 0x0080
1316 #define CAP_LOCK_AND_READ 0x0100
1317 #define CAP_NT_FIND 0x0200
1318 #define CAP_DFS 0x1000
1319 #define CAP_W2K_SMBS 0x2000
1320 #define CAP_LARGE_READX 0x4000
1321 #define CAP_LARGE_WRITEX 0x8000
1322 #define CAP_UNIX 0x800000 /* Capabilities for UNIX extensions. Created by HP. */
1323 #define CAP_EXTENDED_SECURITY 0x80000000
1325 /* protocol types. It assumes that higher protocols include lower protocols
1326 as subsets */
1327 enum protocol_types {PROTOCOL_NONE,PROTOCOL_CORE,PROTOCOL_COREPLUS,PROTOCOL_LANMAN1,PROTOCOL_LANMAN2,PROTOCOL_NT1};
1329 /* security levels */
1330 enum security_types {SEC_SHARE,SEC_USER,SEC_SERVER,SEC_DOMAIN};
1332 /* server roles */
1333 enum server_types
1335 ROLE_STANDALONE,
1336 ROLE_DOMAIN_MEMBER,
1337 ROLE_DOMAIN_BDC,
1338 ROLE_DOMAIN_PDC
1341 /* printing types */
1342 enum printing_types {PRINT_BSD,PRINT_SYSV,PRINT_AIX,PRINT_HPUX,
1343 PRINT_QNX,PRINT_PLP,PRINT_LPRNG,PRINT_SOFTQ,
1344 PRINT_CUPS,PRINT_LPRNT,PRINT_LPROS2
1345 #ifdef DEVELOPER
1346 ,PRINT_TEST,PRINT_VLP
1347 #endif /* DEVELOPER */
1350 /* LDAP schema types */
1351 enum schema_types {SCHEMA_COMPAT, SCHEMA_AD, SCHEMA_SAMBA};
1353 /* LDAP SSL options */
1354 enum ldap_ssl_types {LDAP_SSL_ON, LDAP_SSL_OFF, LDAP_SSL_START_TLS};
1356 /* Remote architectures we know about. */
1357 enum remote_arch_types {RA_UNKNOWN, RA_WFWG, RA_OS2, RA_WIN95, RA_WINNT, RA_WIN2K, RA_SAMBA};
1359 /* case handling */
1360 enum case_handling {CASE_LOWER,CASE_UPPER};
1362 #ifdef WITH_SSL
1363 /* SSL version options */
1364 enum ssl_version_enum {SMB_SSL_V2,SMB_SSL_V3,SMB_SSL_V23,SMB_SSL_TLS1};
1365 #endif /* WITH_SSL */
1368 * Global value meaing that the smb_uid field should be
1369 * ingored (in share level security and protocol level == CORE)
1372 #define UID_FIELD_INVALID 0
1373 #define VUID_OFFSET 100 /* Amount to bias returned vuid numbers */
1375 /* Defines needed for multi-codepage support. */
1376 #define MSDOS_LATIN_1_CODEPAGE 850
1377 #define KANJI_CODEPAGE 932
1378 #define HANGUL_CODEPAGE 949
1379 #define BIG5_CODEPAGE 950
1380 #define SIMPLIFIED_CHINESE_CODEPAGE 936
1382 #ifdef KANJI
1384 * Default client code page - Japanese
1386 #define DEFAULT_CLIENT_CODE_PAGE KANJI_CODEPAGE
1387 #else /* KANJI */
1389 * Default client code page - 850 - Western European
1391 #define DEFAULT_CLIENT_CODE_PAGE MSDOS_LATIN_1_CODEPAGE
1392 #endif /* KANJI */
1394 /* Global val set if multibyte codepage. */
1395 extern int global_is_multibyte_codepage;
1397 #define get_character_len(x) (global_is_multibyte_codepage ? skip_multibyte_char((x)) : 0)
1400 * Size of buffer to use when moving files across filesystems.
1402 #define COPYBUF_SIZE (8*1024)
1405 * Values used to override error codes.
1407 extern int unix_ERR_class;
1408 extern int unix_ERR_code;
1411 * Used in chaining code.
1413 extern int chain_size;
1416 * Map the Core and Extended Oplock requesst bits down
1417 * to common bits (EXCLUSIVE_OPLOCK & BATCH_OPLOCK).
1421 * Core protocol.
1423 #define CORE_OPLOCK_REQUEST(inbuf) \
1424 ((CVAL(inbuf,smb_flg)&(FLAG_REQUEST_OPLOCK|FLAG_REQUEST_BATCH_OPLOCK))>>5)
1427 * Extended protocol.
1429 #define EXTENDED_OPLOCK_REQUEST(inbuf) ((SVAL(inbuf,smb_vwv2)&((1<<1)|(1<<2)))>>1)
1431 /* Lock types. */
1432 #define LOCKING_ANDX_SHARED_LOCK 0x1
1433 #define LOCKING_ANDX_OPLOCK_RELEASE 0x2
1434 #define LOCKING_ANDX_CHANGE_LOCKTYPE 0x4
1435 #define LOCKING_ANDX_CANCEL_LOCK 0x8
1436 #define LOCKING_ANDX_LARGE_FILES 0x10
1438 /* Oplock levels */
1439 #define OPLOCKLEVEL_NONE 0
1440 #define OPLOCKLEVEL_II 1
1443 * Bits we test with.
1446 #define NO_OPLOCK 0
1447 #define EXCLUSIVE_OPLOCK 1
1448 #define BATCH_OPLOCK 2
1449 #define LEVEL_II_OPLOCK 4
1451 #define EXCLUSIVE_OPLOCK_TYPE(lck) ((lck) & (EXCLUSIVE_OPLOCK|BATCH_OPLOCK))
1452 #define BATCH_OPLOCK_TYPE(lck) ((lck) & BATCH_OPLOCK)
1453 #define LEVEL_II_OPLOCK_TYPE(lck) ((lck) & LEVEL_II_OPLOCK)
1455 #define CORE_OPLOCK_GRANTED (1<<5)
1456 #define EXTENDED_OPLOCK_GRANTED (1<<15)
1459 * Return values for oplock types.
1462 #define NO_OPLOCK_RETURN 0
1463 #define EXCLUSIVE_OPLOCK_RETURN 1
1464 #define BATCH_OPLOCK_RETURN 2
1465 #define LEVEL_II_OPLOCK_RETURN 3
1468 * Loopback command offsets.
1471 #define OPBRK_CMD_LEN_OFFSET 0
1472 #define OPBRK_CMD_PORT_OFFSET 4
1473 #define OPBRK_CMD_HEADER_LEN 6
1475 #define OPBRK_MESSAGE_CMD_OFFSET 0
1478 * Oplock break command code to send over the udp socket.
1479 * The same message is sent for both exlusive and level II breaks.
1481 * The form of this is :
1483 * 0 2 2+pid 2+pid+dev 2+pid+dev+ino
1484 * +----+--------+-------+--------+---------+
1485 * | cmd| pid | dev | inode | fileid |
1486 * +----+--------+-------+--------+---------+
1489 #define OPLOCK_BREAK_CMD 0x1
1490 #define OPLOCK_BREAK_PID_OFFSET 2
1491 #define OPLOCK_BREAK_DEV_OFFSET (OPLOCK_BREAK_PID_OFFSET + sizeof(pid_t))
1492 #define OPLOCK_BREAK_INODE_OFFSET (OPLOCK_BREAK_DEV_OFFSET + sizeof(SMB_DEV_T))
1493 #define OPLOCK_BREAK_FILEID_OFFSET (OPLOCK_BREAK_INODE_OFFSET + sizeof(SMB_INO_T))
1494 #define OPLOCK_BREAK_MSG_LEN (OPLOCK_BREAK_FILEID_OFFSET + sizeof(unsigned long))
1496 #define KERNEL_OPLOCK_BREAK_CMD 0x2
1497 #define LEVEL_II_OPLOCK_BREAK_CMD 0x3
1500 * Capabilities abstracted for different systems.
1503 #define KERNEL_OPLOCK_CAPABILITY 0x1
1506 * Oplock break command code sent via the kernel interface (if it exists).
1508 * Form of this is :
1510 * 0 2 2+devsize 2+devsize+inodesize
1511 * +----+--------+--------+----------+
1512 * | cmd| dev | inode | fileid |
1513 * +----+--------+--------+----------+
1515 #define KERNEL_OPLOCK_BREAK_DEV_OFFSET 2
1516 #define KERNEL_OPLOCK_BREAK_INODE_OFFSET (KERNEL_OPLOCK_BREAK_DEV_OFFSET + sizeof(SMB_DEV_T))
1517 #define KERNEL_OPLOCK_BREAK_FILEID_OFFSET (KERNEL_OPLOCK_BREAK_INODE_OFFSET + sizeof(SMB_INO_T))
1518 #define KERNEL_OPLOCK_BREAK_MSG_LEN (KERNEL_OPLOCK_BREAK_FILEID_OFFSET + sizeof(unsigned long))
1521 /* if a kernel does support oplocks then a structure of the following
1522 typee is used to describe how to interact with the kernel */
1523 struct kernel_oplocks {
1524 BOOL (*receive_message)(fd_set *fds, char *buffer, int buffer_len);
1525 BOOL (*set_oplock)(files_struct *fsp, int oplock_type);
1526 void (*release_oplock)(files_struct *fsp);
1527 BOOL (*parse_message)(char *msg_start, int msg_len, SMB_INO_T *inode, SMB_DEV_T *dev, unsigned long *file_id);
1528 BOOL (*msg_waiting)(fd_set *fds);
1529 int notification_fd;
1533 #define CMD_REPLY 0x8000
1535 /* this structure defines the functions for doing change notify in
1536 various implementations */
1537 struct cnotify_fns {
1538 void * (*register_notify)(connection_struct *conn, char *path, uint32 flags);
1539 BOOL (*check_notify)(connection_struct *conn, uint16 vuid, char *path, uint32 flags, void *data, time_t t);
1540 void (*remove_notify)(void *data);
1541 int select_time;
1546 #include "smb_macros.h"
1548 /* A netbios name structure. */
1549 struct nmb_name {
1550 char name[17];
1551 char scope[64];
1552 unsigned int name_type;
1556 /* A netbios node status array element. */
1557 struct node_status {
1558 char name[16];
1559 unsigned char type;
1560 unsigned char flags;
1565 #define AGENT_CMD_CON 0
1566 #define AGENT_CMD_CON_ANON 2
1567 #define AGENT_CMD_CON_REUSE 1
1569 struct pwd_info
1571 BOOL null_pwd;
1572 BOOL cleartext;
1573 BOOL crypted;
1575 fstring password;
1577 uchar smb_lm_pwd[16];
1578 uchar smb_nt_pwd[16];
1580 uchar smb_lm_owf[24];
1581 uchar smb_nt_owf[128];
1582 uint32 nt_owf_len;
1584 uchar lm_cli_chal[8];
1585 uchar nt_cli_chal[128];
1586 uint32 nt_cli_chal_len;
1588 uchar sess_key[16];
1592 * Network Computing Architechture Context Name Named Pipe
1593 * See MSDN docs for more information
1595 struct ncacn_np
1597 fstring pipe_name;
1598 struct cli_state *smb;
1599 uint16 fnum;
1600 BOOL initialised;
1603 #include "rpc_creds.h"
1604 #include "rpc_misc.h"
1605 #include "rpc_secdes.h"
1606 #include "nt_printing.h"
1608 typedef struct user_struct
1610 struct user_struct *next, *prev;
1611 uint16 vuid; /* Tag for this entry. */
1612 uid_t uid; /* uid of a validated user */
1613 gid_t gid; /* gid of a validated user */
1615 userdom_struct user;
1616 BOOL guest;
1618 /* following groups stuff added by ih */
1619 /* This groups info is needed for when we become_user() for this uid */
1620 int n_groups;
1621 gid_t *groups;
1623 NT_USER_TOKEN *nt_user_token;
1625 int session_id; /* used by utmp and pam session code */
1626 } user_struct;
1628 struct unix_error_map {
1629 int unix_error;
1630 int dos_class;
1631 int dos_code;
1632 NTSTATUS nt_error;
1635 #include "ntdomain.h"
1637 #include "client.h"
1640 * Size of new password account encoding string. DO NOT CHANGE.
1643 #define NEW_PW_FORMAT_SPACE_PADDED_LEN 14
1646 Do you want session setups at user level security with a invalid
1647 password to be rejected or allowed in as guest? WinNT rejects them
1648 but it can be a pain as it means "net view" needs to use a password
1650 You have 3 choices in the setting of map_to_guest:
1652 "NEVER_MAP_TO_GUEST" means session setups with an invalid password
1653 are rejected. This is the default.
1655 "MAP_TO_GUEST_ON_BAD_USER" means session setups with an invalid password
1656 are rejected, unless the username does not exist, in which case it
1657 is treated as a guest login
1659 "MAP_TO_GUEST_ON_BAD_PASSWORD" means session setups with an invalid password
1660 are treated as a guest login
1662 Note that map_to_guest only has an effect in user or server
1663 level security.
1666 #define NEVER_MAP_TO_GUEST 0
1667 #define MAP_TO_GUEST_ON_BAD_USER 1
1668 #define MAP_TO_GUEST_ON_BAD_PASSWORD 2
1670 #define SAFE_NETBIOS_CHARS ". -_"
1672 #include "nsswitch/winbindd_nss.h"
1674 #endif /* _SMB_H */