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 2 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, write to the Free Software
24 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31 #define DGRAM_PORT 138
34 #define SMB_PORTS "445 139"
40 enum smb_signing_state {SMB_SIGNING_OFF, SMB_SIGNING_SUPPORTED, SMB_SIGNING_REQUIRED};
44 #define _BOOL /* So we don't typedef BOOL again in vfs.h */
49 #ifndef DEF_CREATE_MASK
50 #define DEF_CREATE_MASK (0755)
53 /* string manipulation flags - see clistr.c and srvstr.c */
54 #define STR_TERMINATE 1
58 #define STR_NOALIGN 16
59 #define STR_NO_RANGE_CHECK 32
60 #define STR_LEN8BIT 64
61 #define STR_TERMINATE_ASCII 128 /* only terminate if ascii */
62 #define STR_LEN_NOTERM 256 /* the length field is the unterminated length */
67 /* types of socket errors */
68 enum socket_error {SOCKET_READ_TIMEOUT,
83 #define DOS_OPEN_RDONLY 0
84 #define DOS_OPEN_WRONLY 1
85 #define DOS_OPEN_RDWR 2
86 #define DOS_OPEN_FCB 0xF
89 /**********************************/
90 /* SMBopen field definitions */
91 #define OPEN_FLAGS_DENY_MASK 0x70
92 #define OPEN_FLAGS_DENY_DOS 0x00
93 #define OPEN_FLAGS_DENY_ALL 0x10
94 #define OPEN_FLAGS_DENY_WRITE 0x20
95 #define OPEN_FLAGS_DENY_READ 0x30
96 #define OPEN_FLAGS_DENY_NONE 0x40
98 #define OPEN_FLAGS_MODE_MASK 0x0F
99 #define OPEN_FLAGS_OPEN_READ 0
100 #define OPEN_FLAGS_OPEN_WRITE 1
101 #define OPEN_FLAGS_OPEN_RDWR 2
102 #define OPEN_FLAGS_FCB 0xFF
105 /**********************************/
106 /* SMBopenX field definitions */
108 /* OpenX Flags field. */
109 #define OPENX_FLAGS_ADDITIONAL_INFO 0x01
110 #define OPENX_FLAGS_REQUEST_OPLOCK 0x02
111 #define OPENX_FLAGS_REQUEST_BATCH_OPLOCK 0x04
112 #define OPENX_FLAGS_EA_LEN 0x08
113 #define OPENX_FLAGS_EXTENDED_RETURN 0x10
115 /* desired access (open_mode), split info 4 4-bit nibbles */
116 #define OPENX_MODE_ACCESS_MASK 0x000F
117 #define OPENX_MODE_ACCESS_READ 0x0000
118 #define OPENX_MODE_ACCESS_WRITE 0x0001
119 #define OPENX_MODE_ACCESS_RDWR 0x0002
120 #define OPENX_MODE_ACCESS_EXEC 0x0003
121 #define OPENX_MODE_ACCESS_FCB 0x000F
123 #define OPENX_MODE_DENY_SHIFT 4
124 #define OPENX_MODE_DENY_MASK (0xF << OPENX_MODE_DENY_SHIFT)
125 #define OPENX_MODE_DENY_DOS (DENY_DOS << OPENX_MODE_DENY_SHIFT)
126 #define OPENX_MODE_DENY_ALL (DENY_ALL << OPENX_MODE_DENY_SHIFT)
127 #define OPENX_MODE_DENY_WRITE (DENY_WRITE << OPENX_MODE_DENY_SHIFT)
128 #define OPENX_MODE_DENY_READ (DENY_READ << OPENX_MODE_DENY_SHIFT)
129 #define OPENX_MODE_DENY_NONE (DENY_NONE << OPENX_MODE_DENY_SHIFT)
130 #define OPENX_MODE_DENY_FCB (0xF << OPENX_MODE_DENY_SHIFT)
132 #define OPENX_MODE_LOCALITY_MASK 0x0F00 /* what does this do? */
134 #define OPENX_MODE_NO_CACHE 0x1000
135 #define OPENX_MODE_WRITE_THRU 0x4000
137 /* open function values */
138 #define OPENX_OPEN_FUNC_MASK 0x3
139 #define OPENX_OPEN_FUNC_FAIL 0x0
140 #define OPENX_OPEN_FUNC_OPEN 0x1
141 #define OPENX_OPEN_FUNC_TRUNC 0x2
143 /* The above can be OR'ed with... */
144 #define OPENX_OPEN_FUNC_CREATE 0x10
146 /* openx action in reply */
147 #define OPENX_ACTION_EXISTED 1
148 #define OPENX_ACTION_CREATED 2
149 #define OPENX_ACTION_TRUNCATED 3
152 /**********************************/
153 /* SMBntcreateX field definitions */
155 /* ntcreatex flags field. */
156 #define NTCREATEX_FLAGS_REQUEST_OPLOCK 0x02
157 #define NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK 0x04
158 #define NTCREATEX_FLAGS_OPEN_DIRECTORY 0x08
159 #define NTCREATEX_FLAGS_EXTENDED 0x10
161 /* the ntcreatex access_mask field
162 this is split into 4 pieces
163 AAAABBBBCCCCCCCCDDDDDDDDDDDDDDDD
169 which set of SA_RIGHT_* bits is applicable depends on the type
175 /* ntcreatex share_access field */
176 #define NTCREATEX_SHARE_ACCESS_NONE 0
177 #define NTCREATEX_SHARE_ACCESS_READ 1
178 #define NTCREATEX_SHARE_ACCESS_WRITE 2
179 #define NTCREATEX_SHARE_ACCESS_DELETE 4
181 /* ntcreatex open_disposition field */
182 #define NTCREATEX_DISP_SUPERSEDE 0 /* supersede existing file (if it exists) */
183 #define NTCREATEX_DISP_OPEN 1 /* if file exists open it, else fail */
184 #define NTCREATEX_DISP_CREATE 2 /* if file exists fail, else create it */
185 #define NTCREATEX_DISP_OPEN_IF 3 /* if file exists open it, else create it */
186 #define NTCREATEX_DISP_OVERWRITE 4 /* if exists overwrite, else fail */
187 #define NTCREATEX_DISP_OVERWRITE_IF 5 /* if exists overwrite, else create */
189 /* ntcreatex create_options field */
190 #define NTCREATEX_OPTIONS_DIRECTORY 0x0001
191 #define NTCREATEX_OPTIONS_WRITE_THROUGH 0x0002
192 #define NTCREATEX_OPTIONS_SEQUENTIAL_ONLY 0x0004
193 #define NTCREATEX_OPTIONS_SYNC_ALERT 0x0010
194 #define NTCREATEX_OPTIONS_ASYNC_ALERT 0x0020
195 #define NTCREATEX_OPTIONS_NON_DIRECTORY_FILE 0x0040
196 #define NTCREATEX_OPTIONS_NO_EA_KNOWLEDGE 0x0200
197 #define NTCREATEX_OPTIONS_EIGHT_DOT_THREE_ONLY 0x0400
198 #define NTCREATEX_OPTIONS_RANDOM_ACCESS 0x0800
199 #define NTCREATEX_OPTIONS_DELETE_ON_CLOSE 0x1000
200 #define NTCREATEX_OPTIONS_OPEN_BY_FILE_ID 0x2000
202 /* ntcreatex impersonation field */
203 #define NTCREATEX_IMPERSONATION_ANONYMOUS 0
204 #define NTCREATEX_IMPERSONATION_IDENTIFICATION 1
205 #define NTCREATEX_IMPERSONATION_IMPERSONATION 2
206 #define NTCREATEX_IMPERSONATION_DELEGATION 3
208 /* ntcreatex security flags bit field */
209 #define NTCREATEX_SECURITY_DYNAMIC 1
210 #define NTCREATEX_SECURITY_ALL 2
212 /* ntcreatex create_action in reply */
213 #define NTCREATEX_ACTION_EXISTED 1
214 #define NTCREATEX_ACTION_CREATED 2
215 #define NTCREATEX_ACTION_TRUNCATED 3
216 /* the value 5 can also be returned when you try to create a directory with
217 incorrect parameters - what does it mean? maybe created temporary file? */
218 #define NTCREATEX_ACTION_UNKNOWN 5
223 * SMB UCS2 (16-bit unicode) internal type.
226 typedef uint16_t smb_ucs2_t;
228 /* ucs2 string types. */
229 typedef smb_ucs2_t wpstring[PSTRING_LEN];
230 typedef smb_ucs2_t wfstring[FSTRING_LEN];
232 #ifdef WORDS_BIGENDIAN
238 /* turn a 7 bit character into a ucs2 character */
239 #define UCS2_CHAR(c) ((c) << UCS2_SHIFT)
241 #define MAX_HOURS_LEN 32
243 /* for compatibility */
244 #define SID_NAME_USE samr_SidType
247 * The complete list of SIDS belonging to this user.
248 * Created when a vuid is registered.
249 * The definition of the user_sids array is as follows :
251 * token->user_sids[0] = primary user SID.
252 * token->user_sids[1] = primary group SID.
253 * token->user_sids[2..num_sids] = supplementary group SIDS.
256 #define PRIMARY_USER_SID_INDEX 0
257 #define PRIMARY_GROUP_SID_INDEX 1
259 typedef struct nt_user_token {
261 struct dom_sid **user_sids;
264 /* 32 bit time (sec) since 01jan1970 - cifs6.txt, section 3.5, page 30 */
265 typedef struct time_info
270 /* used to hold an arbitrary blob of data */
271 typedef struct data_blob {
274 void (*free)(struct data_blob *data_blob);
279 #include "librpc/gen_ndr/ndr_misc.h"
280 #include "smb_interfaces.h"
281 #include "librpc/ndr/libndr.h"
283 typedef struct userdom_struct {
284 fstring smb_name; /* user name from the client */
285 fstring unix_name; /* unix user name of a validated user */
286 fstring full_name; /* to store full name (such as "Joe Bloggs") from gecos field of password file */
287 fstring domain; /* domain that the client specified */
291 /* used for server information: client, nameserv and ipc */
292 struct server_info_struct
297 fstring domain; /* used ONLY in ipc.c NOT namework.c */
298 BOOL server_added; /* used ONLY in ipc.c NOT namework.c */
302 /* used for network interfaces */
305 struct interface *next, *prev;
307 struct in_addr bcast;
308 struct in_addr nmask;
311 #define NT_HASH_LEN 16
312 #define LM_HASH_LEN 16
315 * Flags for account policy.
317 #define AP_MIN_PASSWORD_LEN 1
318 #define AP_PASSWORD_HISTORY 2
319 #define AP_USER_MUST_LOGON_TO_CHG_PASS 3
320 #define AP_MAX_PASSWORD_AGE 4
321 #define AP_MIN_PASSWORD_AGE 5
322 #define AP_LOCK_ACCOUNT_DURATION 6
323 #define AP_RESET_COUNT_TIME 7
324 #define AP_BAD_ATTEMPT_LOCKOUT 8
325 #define AP_TIME_TO_LOGOUT 9
329 * Flags for local user manipulation.
332 #define LOCAL_ADD_USER 0x1
333 #define LOCAL_DELETE_USER 0x2
334 #define LOCAL_DISABLE_USER 0x4
335 #define LOCAL_ENABLE_USER 0x8
336 #define LOCAL_TRUST_ACCOUNT 0x10
337 #define LOCAL_SET_NO_PASSWORD 0x20
338 #define LOCAL_SET_PASSWORD 0x40
339 #define LOCAL_SET_LDAP_ADMIN_PW 0x80
340 #define LOCAL_INTERDOM_ACCOUNT 0x100
341 #define LOCAL_AM_ROOT 0x200 /* Act as root */
343 /* key and data in the connections database - used in smbstatus and smbd */
344 struct connections_key {
350 struct connections_data {
358 char machine[FSTRING_LEN];
360 uint32_t bcast_msg_flags;
363 /* the following are used by loadparm for option lists */
366 P_BOOL,P_BOOLREV,P_CHAR,P_INTEGER,P_OCTAL,P_LIST,
367 P_STRING,P_USTRING,P_ENUM,P_SEP
372 P_LOCAL,P_GLOBAL,P_SEPARATOR,P_NONE
386 BOOL (*special)(const char *, char **);
387 const struct enum_list *enum_list;
403 #define FLAG_BASIC 0x0001 /* fundamental options */
404 #define FLAG_SHARE 0x0002 /* file sharing options */
405 #define FLAG_PRINT 0x0004 /* printing options */
406 #define FLAG_GLOBAL 0x0008 /* local options that should be globally settable in SWAT */
407 #define FLAG_WIZARD 0x0010 /* Parameters that the wizard will operate on */
408 #define FLAG_ADVANCED 0x0020 /* Parameters that the wizard will operate on */
409 #define FLAG_DEVELOPER 0x0040 /* Parameters that the wizard will operate on */
410 #define FLAG_DEPRECATED 0x1000 /* options that should no longer be used */
411 #define FLAG_HIDE 0x2000 /* options that should be hidden in SWAT */
412 #define FLAG_DOS_STRING 0x4000 /* convert from UNIX to DOS codepage when reading this string. */
413 #define FLAG_CMDLINE 0x8000 /* this option was set from the command line */
415 #ifndef LOCKING_VERSION
416 #define LOCKING_VERSION 4
417 #endif /* LOCKING_VERSION */
420 /* the basic packet size, assuming no words or bytes. Does not include the NBT header */
421 #define MIN_SMB_SIZE 35
423 /* when using NBT encapsulation every packet has a 4 byte header */
424 #define NBT_HDR_SIZE 4
426 /* offsets into message header for common items - NOTE: These have
427 changed from being offsets from the base of the NBT packet to the base of the SMB packet.
428 this has reduced all these values by 4
436 #define HDR_PIDHIGH 12
437 #define HDR_SS_FIELD 14
446 /* types of buffers in core SMB protocol */
447 #define SMB_DATA_BLOCK 0x1
448 #define SMB_ASCII4 0x4
451 /* flag defines. CIFS spec 3.1.1 */
452 #define FLAG_SUPPORT_LOCKREAD 0x01
453 #define FLAG_CLIENT_BUF_AVAIL 0x02
454 #define FLAG_RESERVED 0x04
455 #define FLAG_CASELESS_PATHNAMES 0x08
456 #define FLAG_CANONICAL_PATHNAMES 0x10
457 #define FLAG_REQUEST_OPLOCK 0x20
458 #define FLAG_REQUEST_BATCH_OPLOCK 0x40
459 #define FLAG_REPLY 0x80
462 #define SMBmkdir 0x00 /* create directory */
463 #define SMBrmdir 0x01 /* delete directory */
464 #define SMBopen 0x02 /* open file */
465 #define SMBcreate 0x03 /* create file */
466 #define SMBclose 0x04 /* close file */
467 #define SMBflush 0x05 /* flush file */
468 #define SMBunlink 0x06 /* delete file */
469 #define SMBmv 0x07 /* rename file */
470 #define SMBgetatr 0x08 /* get file attributes */
471 #define SMBsetatr 0x09 /* set file attributes */
472 #define SMBread 0x0A /* read from file */
473 #define SMBwrite 0x0B /* write to file */
474 #define SMBlock 0x0C /* lock byte range */
475 #define SMBunlock 0x0D /* unlock byte range */
476 #define SMBctemp 0x0E /* create temporary file */
477 #define SMBmknew 0x0F /* make new file */
478 #define SMBchkpth 0x10 /* check directory path */
479 #define SMBexit 0x11 /* process exit */
480 #define SMBlseek 0x12 /* seek */
481 #define SMBtcon 0x70 /* tree connect */
482 #define SMBtconX 0x75 /* tree connect and X*/
483 #define SMBtdis 0x71 /* tree disconnect */
484 #define SMBnegprot 0x72 /* negotiate protocol */
485 #define SMBdskattr 0x80 /* get disk attributes */
486 #define SMBsearch 0x81 /* search directory */
487 #define SMBsplopen 0xC0 /* open print spool file */
488 #define SMBsplwr 0xC1 /* write to print spool file */
489 #define SMBsplclose 0xC2 /* close print spool file */
490 #define SMBsplretq 0xC3 /* return print queue */
491 #define SMBsends 0xD0 /* send single block message */
492 #define SMBsendb 0xD1 /* send broadcast message */
493 #define SMBfwdname 0xD2 /* forward user name */
494 #define SMBcancelf 0xD3 /* cancel forward */
495 #define SMBgetmac 0xD4 /* get machine name */
496 #define SMBsendstrt 0xD5 /* send start of multi-block message */
497 #define SMBsendend 0xD6 /* send end of multi-block message */
498 #define SMBsendtxt 0xD7 /* send text of multi-block message */
501 #define SMBlockread 0x13 /* Lock a range and read */
502 #define SMBwriteunlock 0x14 /* write then range then unlock it */
503 #define SMBreadbraw 0x1a /* read a block of data with no smb header */
504 #define SMBwritebraw 0x1d /* write a block of data with no smb header */
505 #define SMBwritec 0x20 /* secondary write request */
506 #define SMBwriteclose 0x2c /* write a file then close it */
508 /* dos extended protocol */
509 #define SMBreadBraw 0x1A /* read block raw */
510 #define SMBreadBmpx 0x1B /* read block multiplexed */
511 #define SMBreadBs 0x1C /* read block (secondary response) */
512 #define SMBwriteBraw 0x1D /* write block raw */
513 #define SMBwriteBmpx 0x1E /* write block multiplexed */
514 #define SMBwriteBs 0x1F /* write block (secondary request) */
515 #define SMBwriteC 0x20 /* write complete response */
516 #define SMBsetattrE 0x22 /* set file attributes expanded */
517 #define SMBgetattrE 0x23 /* get file attributes expanded */
518 #define SMBlockingX 0x24 /* lock/unlock byte ranges and X */
519 #define SMBtrans 0x25 /* transaction - name, bytes in/out */
520 #define SMBtranss 0x26 /* transaction (secondary request/response) */
521 #define SMBioctl 0x27 /* IOCTL */
522 #define SMBioctls 0x28 /* IOCTL (secondary request/response) */
523 #define SMBcopy 0x29 /* copy */
524 #define SMBmove 0x2A /* move */
525 #define SMBecho 0x2B /* echo */
526 #define SMBopenX 0x2D /* open and X */
527 #define SMBreadX 0x2E /* read and X */
528 #define SMBwriteX 0x2F /* write and X */
529 #define SMBsesssetupX 0x73 /* Session Set Up & X (including User Logon) */
530 #define SMBffirst 0x82 /* find first */
531 #define SMBfunique 0x83 /* find unique */
532 #define SMBfclose 0x84 /* find close */
533 #define SMBkeepalive 0x85 /* keepalive */
534 #define SMBinvalid 0xFE /* invalid command */
536 /* Extended 2.0 protocol */
537 #define SMBtrans2 0x32 /* TRANS2 protocol set */
538 #define SMBtranss2 0x33 /* TRANS2 protocol set, secondary command */
539 #define SMBfindclose 0x34 /* Terminate a TRANSACT2_FINDFIRST */
540 #define SMBfindnclose 0x35 /* Terminate a TRANSACT2_FINDNOTIFYFIRST */
541 #define SMBulogoffX 0x74 /* user logoff */
543 /* NT SMB extensions. */
544 #define SMBnttrans 0xA0 /* NT transact */
545 #define SMBnttranss 0xA1 /* NT transact secondary */
546 #define SMBntcreateX 0xA2 /* NT create and X */
547 #define SMBntcancel 0xA4 /* NT cancel */
548 #define SMBntrename 0xA5 /* NT rename */
550 /* used to indicate end of chain */
551 #define SMB_CHAIN_NONE 0xFF
553 /* These are the trans subcommands */
554 #define TRANSACT_SETNAMEDPIPEHANDLESTATE 0x01
555 #define TRANSACT_DCERPCCMD 0x26
556 #define TRANSACT_WAITNAMEDPIPEHANDLESTATE 0x53
558 /* These are the NT transact sub commands. */
559 #define NT_TRANSACT_CREATE 1
560 #define NT_TRANSACT_IOCTL 2
561 #define NT_TRANSACT_SET_SECURITY_DESC 3
562 #define NT_TRANSACT_NOTIFY_CHANGE 4
563 #define NT_TRANSACT_RENAME 5
564 #define NT_TRANSACT_QUERY_SECURITY_DESC 6
566 /* this is used on a TConX. I'm not sure the name is very helpful though */
567 #define SMB_SUPPORT_SEARCH_BITS 0x0001
568 #define SMB_SHARE_IN_DFS 0x0002
570 /* Named pipe write mode flags. Used in writeX calls. */
571 #define PIPE_RAW_MODE 0x4
572 #define PIPE_START_MESSAGE 0x8
574 /* the desired access to use when opening a pipe */
575 #define DESIRED_ACCESS_PIPE 0x2019f
578 /* Mapping of generic access rights for files to specific rights. */
579 #define FILE_GENERIC_ALL (STANDARD_RIGHTS_REQUIRED_ACCESS| NT_ACCESS_SYNCHRONIZE_ACCESS|FILE_ALL_ACCESS)
581 #define FILE_GENERIC_READ (STANDARD_RIGHTS_READ_ACCESS|FILE_READ_DATA|FILE_READ_ATTRIBUTES|\
582 FILE_READ_EA|NT_ACCESS_SYNCHRONIZE_ACCESS)
584 #define FILE_GENERIC_WRITE (STANDARD_RIGHTS_WRITE_ACCESS|FILE_WRITE_DATA|FILE_WRITE_ATTRIBUTES|\
585 FILE_WRITE_EA|FILE_APPEND_DATA|NT_ACCESS_SYNCHRONIZE_ACCESS)
587 #define FILE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE_ACCESS|FILE_READ_ATTRIBUTES|\
588 FILE_EXECUTE|NT_ACCESS_SYNCHRONIZE_ACCESS)
591 /* FileAttributes (search attributes) field */
592 #define FILE_ATTRIBUTE_READONLY 0x0001
593 #define FILE_ATTRIBUTE_HIDDEN 0x0002
594 #define FILE_ATTRIBUTE_SYSTEM 0x0004
595 #define FILE_ATTRIBUTE_VOLUME 0x0008
596 #define FILE_ATTRIBUTE_DIRECTORY 0x0010
597 #define FILE_ATTRIBUTE_ARCHIVE 0x0020
598 #define FILE_ATTRIBUTE_DEVICE 0x0040
599 #define FILE_ATTRIBUTE_NORMAL 0x0080
600 #define FILE_ATTRIBUTE_TEMPORARY 0x0100
601 #define FILE_ATTRIBUTE_SPARSE 0x0200
602 #define FILE_ATTRIBUTE_REPARSE_POINT 0x0400
603 #define FILE_ATTRIBUTE_COMPRESSED 0x0800
604 #define FILE_ATTRIBUTE_OFFLINE 0x1000
605 #define FILE_ATTRIBUTE_NONINDEXED 0x2000
606 #define FILE_ATTRIBUTE_ENCRYPTED 0x4000
608 /* Flags - combined with attributes. */
609 #define FILE_FLAG_WRITE_THROUGH 0x80000000L
610 #define FILE_FLAG_NO_BUFFERING 0x20000000L
611 #define FILE_FLAG_RANDOM_ACCESS 0x10000000L
612 #define FILE_FLAG_SEQUENTIAL_SCAN 0x08000000L
613 #define FILE_FLAG_DELETE_ON_CLOSE 0x04000000L
614 #define FILE_FLAG_BACKUP_SEMANTICS 0x02000000L
615 #define FILE_FLAG_POSIX_SEMANTICS 0x01000000L
617 /* Responses when opening a file. */
618 #define FILE_WAS_SUPERSEDED 0
619 #define FILE_WAS_OPENED 1
620 #define FILE_WAS_CREATED 2
621 #define FILE_WAS_OVERWRITTEN 3
623 /* File type flags */
624 #define FILE_TYPE_DISK 0
625 #define FILE_TYPE_BYTE_MODE_PIPE 1
626 #define FILE_TYPE_MESSAGE_MODE_PIPE 2
627 #define FILE_TYPE_PRINTER 3
628 #define FILE_TYPE_COMM_DEVICE 4
629 #define FILE_TYPE_UNKNOWN 0xFFFF
631 /* Flag for NT transact rename call. */
632 #define RENAME_REPLACE_IF_EXISTS 1
634 /* flags for SMBntrename call */
635 #define RENAME_FLAG_MOVE_CLUSTER_INFORMATION 0x102 /* ???? */
636 #define RENAME_FLAG_HARD_LINK 0x103
637 #define RENAME_FLAG_RENAME 0x104
638 #define RENAME_FLAG_COPY 0x105
640 /* Filesystem Attributes. */
641 #define FILE_CASE_SENSITIVE_SEARCH 0x01
642 #define FILE_CASE_PRESERVED_NAMES 0x02
643 #define FILE_UNICODE_ON_DISK 0x04
644 /* According to cifs9f, this is 4, not 8 */
645 /* Acconding to testing, this actually sets the security attribute! */
646 #define FILE_PERSISTENT_ACLS 0x08
647 /* These entries added from cifs9f --tsb */
648 #define FILE_FILE_COMPRESSION 0x10
649 #define FILE_VOLUME_QUOTAS 0x20
650 /* I think this is wrong. JRA #define FILE_DEVICE_IS_MOUNTED 0x20 */
651 #define FILE_VOLUME_SPARSE_FILE 0x40
652 #define FILE_VOLUME_IS_COMPRESSED 0x8000
654 /* ChangeNotify flags. */
655 #define FILE_NOTIFY_CHANGE_FILE 0x001
656 #define FILE_NOTIFY_CHANGE_DIR_NAME 0x002
657 #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x004
658 #define FILE_NOTIFY_CHANGE_SIZE 0x008
659 #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x010
660 #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x020
661 #define FILE_NOTIFY_CHANGE_CREATION 0x040
662 #define FILE_NOTIFY_CHANGE_EA 0x080
663 #define FILE_NOTIFY_CHANGE_SECURITY 0x100
664 #define FILE_NOTIFY_CHANGE_FILE_NAME 0x200
666 /* change notify action results */
667 #define NOTIFY_ACTION_ADDED 1
668 #define NOTIFY_ACTION_REMOVED 2
669 #define NOTIFY_ACTION_MODIFIED 3
670 #define NOTIFY_ACTION_OLD_NAME 4
671 #define NOTIFY_ACTION_NEW_NAME 5
672 #define NOTIFY_ACTION_ADDED_STREAM 6
673 #define NOTIFY_ACTION_REMOVED_STREAM 7
674 #define NOTIFY_ACTION_MODIFIED_STREAM 8
676 /* seek modes for smb_seek */
677 #define SEEK_MODE_START 0
678 #define SEEK_MODE_CURRENT 1
679 #define SEEK_MODE_END 2
681 /* where to find the base of the SMB packet proper */
682 /* REWRITE TODO: smb_base needs to be removed */
683 #define smb_base(buf) (((char *)(buf))+4)
685 /* we don't allow server strings to be longer than 48 characters as
686 otherwise NT will not honour the announce packets */
687 #define MAX_SERVER_STRING_LENGTH 48
690 #define SMB_SUCCESS 0 /* The request was successful. */
693 void dfs_unlogin(void);
694 extern int dcelogin_atmost_once;
698 char *strdup(char *s);
702 #define SIGNAL_CAST (RETSIGTYPE (*)(int))
709 /* these are used in NetServerEnum to choose what to receive */
710 #define SV_TYPE_WORKSTATION 0x00000001
711 #define SV_TYPE_SERVER 0x00000002
712 #define SV_TYPE_SQLSERVER 0x00000004
713 #define SV_TYPE_DOMAIN_CTRL 0x00000008
714 #define SV_TYPE_DOMAIN_BAKCTRL 0x00000010
715 #define SV_TYPE_TIME_SOURCE 0x00000020
716 #define SV_TYPE_AFP 0x00000040
717 #define SV_TYPE_NOVELL 0x00000080
718 #define SV_TYPE_DOMAIN_MEMBER 0x00000100
719 #define SV_TYPE_PRINTQ_SERVER 0x00000200
720 #define SV_TYPE_DIALIN_SERVER 0x00000400
721 #define SV_TYPE_SERVER_UNIX 0x00000800
722 #define SV_TYPE_NT 0x00001000
723 #define SV_TYPE_WFW 0x00002000
724 #define SV_TYPE_SERVER_MFPN 0x00004000
725 #define SV_TYPE_SERVER_NT 0x00008000
726 #define SV_TYPE_POTENTIAL_BROWSER 0x00010000
727 #define SV_TYPE_BACKUP_BROWSER 0x00020000
728 #define SV_TYPE_MASTER_BROWSER 0x00040000
729 #define SV_TYPE_DOMAIN_MASTER 0x00080000
730 #define SV_TYPE_SERVER_OSF 0x00100000
731 #define SV_TYPE_SERVER_VMS 0x00200000
732 #define SV_TYPE_WIN95_PLUS 0x00400000
733 #define SV_TYPE_DFS_SERVER 0x00800000
734 #define SV_TYPE_ALTERNATE_XPORT 0x20000000
735 #define SV_TYPE_LOCAL_LIST_ONLY 0x40000000
736 #define SV_TYPE_DOMAIN_ENUM 0x80000000
737 #define SV_TYPE_ALL 0xFFFFFFFF
739 /* This was set by JHT in liaison with Jeremy Allison early 1997
741 * Version 4.0 - never made public
742 * Version 4.10 - New to 1.9.16p2, lost in space 1.9.16p3 to 1.9.16p9
743 * - Reappeared in 1.9.16p11 with fixed smbd services
744 * Version 4.20 - To indicate that nmbd and browsing now works better
745 * Version 4.50 - Set at release of samba-2.2.0 by JHT
747 * Note: In the presence of NT4.X do not set above 4.9
748 * Setting this above 4.9 can have undesired side-effects.
749 * This may change again in Samba-3.0 after further testing. JHT
752 #define DEFAULT_MAJOR_VERSION 0x04
753 #define DEFAULT_MINOR_VERSION 0x09
755 /* Browser Election Values */
756 #define BROWSER_ELECTION_VERSION 0x010f
757 #define BROWSER_CONSTANT 0xaa55
759 /* Sercurity mode bits. */
760 #define NEGOTIATE_SECURITY_USER_LEVEL 0x01
761 #define NEGOTIATE_SECURITY_CHALLENGE_RESPONSE 0x02
762 #define NEGOTIATE_SECURITY_SIGNATURES_ENABLED 0x04
763 #define NEGOTIATE_SECURITY_SIGNATURES_REQUIRED 0x08
765 /* NT Flags2 bits - cifs6.txt section 3.1.2 */
767 #define FLAGS2_LONG_PATH_COMPONENTS 0x0001
768 #define FLAGS2_EXTENDED_ATTRIBUTES 0x0002
769 #define FLAGS2_SMB_SECURITY_SIGNATURES 0x0004
770 #define FLAGS2_IS_LONG_NAME 0x0040
771 #define FLAGS2_EXTENDED_SECURITY 0x0800
772 #define FLAGS2_DFS_PATHNAMES 0x1000
773 #define FLAGS2_READ_PERMIT_NO_EXECUTE 0x2000
774 #define FLAGS2_32_BIT_ERROR_CODES 0x4000
775 #define FLAGS2_UNICODE_STRINGS 0x8000
777 #define FLAGS2_WIN2K_SIGNATURE 0xC852 /* Hack alert ! For now... JRA. */
779 /* Capabilities. see ftp.microsoft.com/developr/drg/cifs/cifs/cifs4.txt */
781 #define CAP_RAW_MODE 0x0001
782 #define CAP_MPX_MODE 0x0002
783 #define CAP_UNICODE 0x0004
784 #define CAP_LARGE_FILES 0x0008
785 #define CAP_NT_SMBS 0x0010
786 #define CAP_RPC_REMOTE_APIS 0x0020
787 #define CAP_STATUS32 0x0040
788 #define CAP_LEVEL_II_OPLOCKS 0x0080
789 #define CAP_LOCK_AND_READ 0x0100
790 #define CAP_NT_FIND 0x0200
791 #define CAP_DFS 0x1000
792 #define CAP_W2K_SMBS 0x2000
793 #define CAP_LARGE_READX 0x4000
794 #define CAP_LARGE_WRITEX 0x8000
795 #define CAP_UNIX 0x800000 /* Capabilities for UNIX extensions. Created by HP. */
796 #define CAP_EXTENDED_SECURITY 0x80000000
799 * Global value meaing that the smb_uid field should be
800 * ingored (in share level security and protocol level == CORE)
803 #define UID_FIELD_INVALID 0
804 #define VUID_OFFSET 100 /* Amount to bias returned vuid numbers */
807 #define LOCKING_ANDX_SHARED_LOCK 0x1
808 #define LOCKING_ANDX_OPLOCK_RELEASE 0x2
809 #define LOCKING_ANDX_CHANGE_LOCKTYPE 0x4
810 #define LOCKING_ANDX_CANCEL_LOCK 0x8
811 #define LOCKING_ANDX_LARGE_FILES 0x10
814 #define OPLOCKLEVEL_NONE 0
815 #define OPLOCKLEVEL_II 1
822 #define EXCLUSIVE_OPLOCK 1
823 #define BATCH_OPLOCK 2
824 #define LEVEL_II_OPLOCK 4
826 #define CORE_OPLOCK_GRANTED (1<<5)
827 #define EXTENDED_OPLOCK_GRANTED (1<<15)
830 * Return values for oplock types.
833 #define NO_OPLOCK_RETURN 0
834 #define EXCLUSIVE_OPLOCK_RETURN 1
835 #define BATCH_OPLOCK_RETURN 2
836 #define LEVEL_II_OPLOCK_RETURN 3
839 * Loopback command offsets.
842 #define OPBRK_CMD_LEN_OFFSET 0
843 #define OPBRK_CMD_PORT_OFFSET 4
844 #define OPBRK_CMD_HEADER_LEN 6
846 #define OPBRK_MESSAGE_CMD_OFFSET 0
849 #define OPLOCK_BREAK_CMD 0x1
850 #define KERNEL_OPLOCK_BREAK_CMD 0x2
851 #define LEVEL_II_OPLOCK_BREAK_CMD 0x3
852 #define ASYNC_LEVEL_II_OPLOCK_BREAK_CMD 0x4
855 * Capabilities abstracted for different systems.
858 #define KERNEL_OPLOCK_CAPABILITY 0x1
861 * Oplock break command code sent via the kernel interface (if it exists).
865 * 0 2 2+devsize 2+devsize+inodesize
866 * +----+--------+--------+----------+
867 * | cmd| dev | inode | fileid |
868 * +----+--------+--------+----------+
870 #define KERNEL_OPLOCK_BREAK_DEV_OFFSET 2
871 #define KERNEL_OPLOCK_BREAK_INODE_OFFSET (KERNEL_OPLOCK_BREAK_DEV_OFFSET + sizeof(SMB_DEV_T))
872 #define KERNEL_OPLOCK_BREAK_FILEID_OFFSET (KERNEL_OPLOCK_BREAK_INODE_OFFSET + sizeof(SMB_INO_T))
873 #define KERNEL_OPLOCK_BREAK_MSG_LEN (KERNEL_OPLOCK_BREAK_FILEID_OFFSET + sizeof(unsigned long))
876 #define CMD_REPLY 0x8000
878 #include "smb_macros.h"
880 /* A netbios name structure. */
884 unsigned int name_type;
888 /* A netbios node status array element. */
903 uchar smb_lm_pwd[16];
904 uchar smb_nt_pwd[16];
906 uchar smb_lm_owf[24];
907 uchar smb_nt_owf[128];
910 uchar lm_cli_chal[8];
911 uchar nt_cli_chal[128];
912 size_t nt_cli_chal_len;
917 #include "rpc_secdes.h"
919 typedef struct user_struct
921 struct user_struct *next, *prev;
922 uint16_t vuid; /* Tag for this entry. */
924 DATA_BLOB session_key;
926 char *session_keystr; /* used by utmp and pam session code.
930 struct auth_serversupplied_info *server_info;
934 struct unix_error_map {
944 * Size of new password account encoding string. This is enough space to
945 * hold 11 ACB characters, plus the surrounding [] and a terminating null.
946 * Do not change unless you are adding new ACB bits!
949 #define NEW_PW_FORMAT_SPACE_PADDED_LEN 14
952 Do you want session setups at user level security with a invalid
953 password to be rejected or allowed in as guest? WinNT rejects them
954 but it can be a pain as it means "net view" needs to use a password
956 You have 3 choices in the setting of map_to_guest:
958 "NEVER_MAP_TO_GUEST" means session setups with an invalid password
959 are rejected. This is the default.
961 "MAP_TO_GUEST_ON_BAD_USER" means session setups with an invalid password
962 are rejected, unless the username does not exist, in which case it
963 is treated as a guest login
965 "MAP_TO_GUEST_ON_BAD_PASSWORD" means session setups with an invalid password
966 are treated as a guest login
968 Note that map_to_guest only has an effect in user or server
972 #define NEVER_MAP_TO_GUEST 0
973 #define MAP_TO_GUEST_ON_BAD_USER 1
974 #define MAP_TO_GUEST_ON_BAD_PASSWORD 2
976 #define SAFE_NETBIOS_CHARS ". -_"
978 /* generic iconv conversion structure */
980 size_t (*direct)(void *cd, const char **inbuf, size_t *inbytesleft,
981 char **outbuf, size_t *outbytesleft);
982 size_t (*pull)(void *cd, const char **inbuf, size_t *inbytesleft,
983 char **outbuf, size_t *outbytesleft);
984 size_t (*push)(void *cd, const char **inbuf, size_t *inbytesleft,
985 char **outbuf, size_t *outbytesleft);
986 void *cd_direct, *cd_pull, *cd_push;
987 char *from_name, *to_name;
990 /* The maximum length of a trust account password.
991 Used when we randomly create it, 15 char passwords
992 exceed NT4's max password length */
994 #define DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH 14
997 /* a set of flags to control handling of request structures */
998 #define REQ_CONTROL_PROTECTED (1<<0) /* don't destroy this request */
999 #define REQ_CONTROL_LARGE (1<<1) /* allow replies larger than max_xmit */
1000 #define REQ_CONTROL_ASYNC (1<<2) /* the backend will answer this one later */
1002 /* passed to br lock code */
1003 enum brl_type {READ_LOCK, WRITE_LOCK, PENDING_LOCK};
1005 #include "popt_common.h"