1996-05-04 11:50:46 +04:00
/*
2002-01-30 09:08:46 +03:00
Unix SMB / CIFS implementation .
2002-01-14 09:15:07 +03:00
SMB parameters and setup , plus a whole lot more .
2000-03-10 21:10:10 +03:00
Copyright ( C ) Andrew Tridgell 1992 - 2000
2002-09-25 19:19:00 +04:00
Copyright ( C ) John H Terpstra 1996 - 2002
2000-03-10 21:10:10 +03:00
Copyright ( C ) Luke Kenneth Casson Leighton 1996 - 2000
Copyright ( C ) Paul Ashton 1998 - 2000
2002-01-25 03:35:14 +03:00
Copyright ( C ) Simo Sorce 2001 - 2002
2002-01-14 09:15:07 +03:00
Copyright ( C ) Martin Pool 2002
1996-05-04 11:50:46 +04:00
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
2007-07-09 23:25:36 +04:00
the Free Software Foundation ; either version 3 of the License , or
1996-05-04 11:50:46 +04:00
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
2007-07-10 04:52:41 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
1996-05-04 11:50:46 +04:00
*/
2000-02-03 07:47:50 +03:00
1996-05-04 11:50:46 +04:00
# ifndef _SMB_H
# define _SMB_H
2011-03-24 07:35:28 +03:00
# include "libcli/smb/smb_common.h"
2011-05-02 06:05:02 +04:00
# include "libds/common/roles.h"
2011-03-24 07:35:28 +03:00
2005-10-07 19:43:32 +04:00
/* logged when starting the various Samba daemons */
2014-01-02 17:04:26 +04:00
# define COPYRIGHT_STARTUP_MESSAGE "Copyright Andrew Tridgell and the Samba Team 1992-2014"
2005-10-07 19:43:32 +04:00
1996-05-04 11:50:46 +04:00
# define SAFETY_MARGIN 1024
2001-05-24 23:28:22 +04:00
# define LARGE_WRITEX_HDR_SIZE 65
2013-12-06 16:56:12 +04:00
# define LARGE_WRITEX_BUFFER_SIZE (128*1024)
1996-05-04 11:50:46 +04:00
1996-06-04 10:42:03 +04:00
# define NMB_PORT 137
# define DGRAM_PORT 138
2012-02-15 07:51:35 +04:00
# define NBT_SMB_PORT 139 /* Port for SMB over NBT transport (IETF STD#19). */
# define TCP_SMB_PORT 445 /* Port for SMB over naked TCP transport. */
2002-08-17 21:00:51 +04:00
# define SMB_PORTS "445 139"
1996-06-04 10:42:03 +04:00
2003-07-31 03:49:29 +04:00
# define Undefined (-1)
2007-10-19 04:40:25 +04:00
# define False false
# define True true
2000-05-29 03:34:34 +04:00
# define Auto (2)
2003-07-16 03:05:57 +04:00
# define Required (3)
1996-05-04 11:50:46 +04:00
# define SIZEOFWORD 2
# ifndef DEF_CREATE_MASK
# define DEF_CREATE_MASK (0755)
# endif
2001-03-10 14:35:25 +03:00
/* string manipulation flags - see clistr.c and srvstr.c */
# define STR_TERMINATE 1
2001-07-04 11:15:53 +04:00
# define STR_UPPER 2
# define STR_ASCII 4
# define STR_UNICODE 8
# define STR_NOALIGN 16
2003-06-06 09:15:28 +04:00
# define STR_TERMINATE_ASCII 128
2001-03-10 14:35:25 +03:00
1996-08-21 18:15:09 +04:00
/* how long to wait for secondary SMB packets (milli-seconds) */
# define SMB_SECONDARY_WAIT (60*1000)
1996-06-10 09:16:19 +04:00
1996-05-04 11:50:46 +04:00
# define DIR_STRUCT_SIZE 43
/* deny modes */
# define DENY_DOS 0
# define DENY_ALL 1
# define DENY_WRITE 2
# define DENY_READ 3
# define DENY_NONE 4
# define DENY_FCB 7
1998-10-23 04:58:28 +04:00
/* open modes */
# define DOS_OPEN_RDONLY 0
# define DOS_OPEN_WRONLY 1
# define DOS_OPEN_RDWR 2
2005-03-31 23:10:59 +04:00
# define DOS_OPEN_EXEC 3
1998-10-23 04:58:28 +04:00
# define DOS_OPEN_FCB 0xF
/* define shifts and masks for share and open modes. */
2005-07-08 08:51:27 +04:00
# define OPENX_MODE_MASK 0xF
# define DENY_MODE_SHIFT 4
# define DENY_MODE_MASK 0x7
# define GET_OPENX_MODE(x) ((x) & OPENX_MODE_MASK)
# define SET_OPENX_MODE(x) ((x) & OPENX_MODE_MASK)
# define GET_DENY_MODE(x) (((x)>>DENY_MODE_SHIFT) & DENY_MODE_MASK)
# define SET_DENY_MODE(x) (((x) & DENY_MODE_MASK) <<DENY_MODE_SHIFT)
1998-10-23 04:58:28 +04:00
1998-10-23 07:34:50 +04:00
/* Sync on open file (not sure if used anymore... ?) */
# define FILE_SYNC_OPENMODE (1<<14)
# define GET_FILE_SYNC_OPENMODE(x) (((x) & FILE_SYNC_OPENMODE) ? True : False)
1998-10-23 04:58:28 +04:00
/* open disposition values */
2005-07-08 08:51:27 +04:00
# define OPENX_FILE_EXISTS_FAIL 0
# define OPENX_FILE_EXISTS_OPEN 1
# define OPENX_FILE_EXISTS_TRUNCATE 2
1998-10-23 04:58:28 +04:00
/* mask for open disposition. */
2005-07-08 08:51:27 +04:00
# define OPENX_FILE_OPEN_MASK 0x3
1998-10-23 04:58:28 +04:00
2005-07-08 08:51:27 +04:00
# define GET_FILE_OPENX_DISPOSITION(x) ((x) & FILE_OPEN_MASK)
# define SET_FILE_OPENX_DISPOSITION(x) ((x) & FILE_OPEN_MASK)
1998-10-23 04:58:28 +04:00
/* The above can be OR'ed with... */
2005-07-08 08:51:27 +04:00
# define OPENX_FILE_CREATE_IF_NOT_EXIST 0x10
# define OPENX_FILE_FAIL_IF_NOT_EXIST 0
1998-10-23 04:58:28 +04:00
1998-11-10 22:05:00 +03:00
/* pipe string names */
1998-05-08 21:53:17 +04:00
2000-08-04 02:38:43 +04:00
# ifndef MAXSUBAUTHS
1998-10-24 01:45:16 +04:00
# define MAXSUBAUTHS 15 /* max sub authorities in a SID */
2000-08-04 02:38:43 +04:00
# endif
1998-10-24 01:45:16 +04:00
2003-04-15 23:51:17 +04:00
# define SID_MAX_SIZE ((size_t)(8+(MAXSUBAUTHS*4)))
2010-08-26 14:04:11 +04:00
# include "librpc/gen_ndr/security.h"
2008-01-15 17:43:19 +03:00
2005-09-30 21:13:37 +04:00
struct idle_event ;
struct share_mode_entry ;
2006-09-04 01:07:16 +04:00
struct uuid ;
2008-03-10 23:08:29 +03:00
struct named_mutex ;
2008-12-27 20:43:03 +03:00
struct wb_context ;
2009-01-30 00:54:55 +03:00
struct rpc_cli_smbd_conn ;
2009-04-25 22:02:24 +04:00
struct fncall_context ;
2005-09-30 21:13:37 +04:00
2007-01-17 19:23:45 +03:00
/* the basic packet size, assuming no words or bytes */
# define smb_size 39
struct notify_change {
uint32_t action ;
2007-01-31 17:19:09 +03:00
const char * name ;
2007-01-17 19:23:45 +03:00
} ;
2007-01-17 21:23:37 +03:00
struct notify_mid_map ;
2012-04-04 16:51:43 +04:00
struct notify_db_entry ;
2007-02-01 16:36:02 +03:00
struct notify_event ;
2007-02-02 17:55:21 +03:00
struct notify_change_request ;
2007-01-31 16:47:37 +03:00
struct sys_notify_backend ;
struct sys_notify_context {
2013-02-18 12:56:41 +04:00
struct tevent_context * ev ;
2007-02-01 16:36:02 +03:00
void * private_data ; /* For use by the system backend */
2007-01-31 16:47:37 +03:00
} ;
2007-01-17 21:23:37 +03:00
2003-04-15 23:51:17 +04:00
# include "ntquotas.h"
2003-05-12 03:34:18 +04:00
# include "sysquotas.h"
2003-04-15 23:51:17 +04:00
2000-02-03 07:47:50 +03:00
/* Include VFS stuff */
2002-03-12 03:08:08 +03:00
# include "smb_acls.h"
2000-02-03 07:47:50 +03:00
# include "vfs.h"
2006-02-02 23:44:50 +03:00
struct current_user {
2012-06-05 12:28:49 +04:00
struct connection_struct * conn ;
2012-06-05 17:21:52 +04:00
uint64_t vuid ; /* SMB2 compat */
2011-02-11 10:49:15 +03:00
struct security_unix_token ut ;
2010-08-26 16:08:22 +04:00
struct security_token * nt_user_token ;
1998-08-14 21:38:29 +04:00
} ;
1997-10-10 18:48:05 +04:00
1999-12-13 16:27:58 +03:00
/* Defines for the sent_oplock_break field above. */
# define NO_BREAK_SENT 0
2005-07-15 23:32:56 +04:00
# define BREAK_TO_NONE_SENT 1
1999-12-13 16:27:58 +03:00
# define LEVEL_II_BREAK_SENT 2
2000-05-02 17:55:42 +04:00
typedef struct {
fstring smb_name ; /* user name from the client */
fstring unix_name ; /* unix user name of a validated user */
fstring domain ; /* domain that the client specified */
} userdom_struct ;
1996-06-29 22:49:20 +04:00
/* used for network interfaces */
2006-02-02 23:44:50 +03:00
struct interface {
1999-12-13 16:27:58 +03:00
struct interface * next , * prev ;
2007-10-11 05:25:16 +04:00
char * name ;
int flags ;
struct sockaddr_storage ip ;
struct sockaddr_storage netmask ;
struct sockaddr_storage bcast ;
1996-06-29 22:49:20 +04:00
} ;
2007-02-07 00:05:34 +03:00
# define SHARE_MODE_FLAG_POSIX_OPEN 0x1
2011-03-24 17:31:06 +03:00
# include "librpc/gen_ndr/server_id.h"
2006-01-13 01:17:54 +03:00
/* oplock break message definition - linearization of share_mode_entry.
Offset Data length .
2007-05-07 13:35:35 +04:00
0 struct server_id pid 4
2010-04-13 08:40:28 +04:00
4 uint16 op_mid 8
12 uint16 op_type 2
14 uint32 access_mask 4
18 uint32 share_access 4
22 uint32 private_options 4
26 uint32 time sec 4
30 uint32 time usec 4
34 uint64 dev 8 bytes
42 uint64 inode 8 bytes
50 uint64 extid 8 bytes
58 unsigned long file_id 4 bytes
62 uint32 uid 4 bytes
66 uint16 flags 2 bytes
2011-01-26 01:01:52 +03:00
68 uint32 name_hash 4 bytes
72
2006-01-13 01:17:54 +03:00
*/
2010-04-13 08:40:28 +04:00
# define OP_BREAK_MSG_PID_OFFSET 0
# define OP_BREAK_MSG_MID_OFFSET 4
# define OP_BREAK_MSG_OP_TYPE_OFFSET 12
# define OP_BREAK_MSG_ACCESS_MASK_OFFSET 14
# define OP_BREAK_MSG_SHARE_ACCESS_OFFSET 18
# define OP_BREAK_MSG_PRIV_OFFSET 22
# define OP_BREAK_MSG_TIME_SEC_OFFSET 26
# define OP_BREAK_MSG_TIME_USEC_OFFSET 30
# define OP_BREAK_MSG_DEV_OFFSET 34
# define OP_BREAK_MSG_INO_OFFSET 42
# define OP_BREAK_MSG_EXTID_OFFSET 50
# define OP_BREAK_MSG_FILE_ID_OFFSET 58
# define OP_BREAK_MSG_UID_OFFSET 62
# define OP_BREAK_MSG_FLAGS_OFFSET 66
2011-01-26 01:01:52 +03:00
# define OP_BREAK_MSG_NAME_HASH_OFFSET 68
2010-04-13 08:40:28 +04:00
2011-01-26 01:01:52 +03:00
# define OP_BREAK_MSG_VNN_OFFSET 72
# define MSG_SMB_SHARE_MODE_ENTRY_SIZE 76
2006-01-13 01:17:54 +03:00
2002-01-02 10:41:54 +03:00
# define NT_HASH_LEN 16
# define LM_HASH_LEN 16
1996-05-04 11:50:46 +04:00
/* offsets into message for common items */
2011-07-12 11:40:56 +04:00
# define smb_com (NBT_HDR_SIZE+HDR_COM)
# define smb_rcls (NBT_HDR_SIZE+HDR_RCLS)
# define smb_reh (NBT_HDR_SIZE+HDR_REH)
# define smb_err (NBT_HDR_SIZE+HDR_ERR)
# define smb_flg (NBT_HDR_SIZE+HDR_FLG)
# define smb_flg2 (NBT_HDR_SIZE+HDR_FLG2)
# define smb_pidhigh (NBT_HDR_SIZE+HDR_PIDHIGH)
# define smb_ss_field (NBT_HDR_SIZE+HDR_SS_FIELD)
# define smb_tid (NBT_HDR_SIZE+HDR_TID)
# define smb_pid (NBT_HDR_SIZE+HDR_PID)
# define smb_uid (NBT_HDR_SIZE+HDR_UID)
# define smb_mid (NBT_HDR_SIZE+HDR_MID)
# define smb_wct (NBT_HDR_SIZE+HDR_WCT)
# define smb_vwv (NBT_HDR_SIZE+HDR_VWV)
# define smb_vwv0 (smb_vwv+( 0*2))
# define smb_vwv1 (smb_vwv+( 1*2))
# define smb_vwv2 (smb_vwv+( 2*2))
# define smb_vwv3 (smb_vwv+( 3*2))
# define smb_vwv4 (smb_vwv+( 4*2))
# define smb_vwv5 (smb_vwv+( 5*2))
# define smb_vwv6 (smb_vwv+( 6*2))
# define smb_vwv7 (smb_vwv+( 7*2))
# define smb_vwv8 (smb_vwv+( 8*2))
# define smb_vwv9 (smb_vwv+( 9*2))
# define smb_vwv10 (smb_vwv+(10*2))
# define smb_vwv11 (smb_vwv+(11*2))
# define smb_vwv12 (smb_vwv+(12*2))
# define smb_vwv13 (smb_vwv+(13*2))
# define smb_vwv14 (smb_vwv+(14*2))
# define smb_vwv15 (smb_vwv+(15*2))
# define smb_vwv16 (smb_vwv+(16*2))
# define smb_vwv17 (smb_vwv+(17*2))
1996-05-04 11:50:46 +04:00
2003-04-15 23:51:17 +04:00
/* These are the NT transact_get_user_quota sub commands */
# define TRANSACT_GET_USER_QUOTA_LIST_CONTINUE 0x0000
# define TRANSACT_GET_USER_QUOTA_LIST_START 0x0100
# define TRANSACT_GET_USER_QUOTA_FOR_SID 0x0101
1999-12-13 16:27:58 +03:00
/* Relevant IOCTL codes */
# define IOCTL_QUERY_JOB_INFO 0x530060
1996-05-04 11:50:46 +04:00
/* these are the trans2 sub fields for primary requests */
# define smb_tpscnt smb_vwv0
# define smb_tdscnt smb_vwv1
# define smb_mprcnt smb_vwv2
# define smb_mdrcnt smb_vwv3
# define smb_msrcnt smb_vwv4
# define smb_flags smb_vwv5
# define smb_timeout smb_vwv6
# define smb_pscnt smb_vwv9
# define smb_psoff smb_vwv10
# define smb_dscnt smb_vwv11
# define smb_dsoff smb_vwv12
# define smb_suwcnt smb_vwv13
# define smb_setup smb_vwv14
# define smb_setup0 smb_setup
# define smb_setup1 (smb_setup+2)
# define smb_setup2 (smb_setup+4)
/* these are for the secondary requests */
# define smb_spscnt smb_vwv2
# define smb_spsoff smb_vwv3
# define smb_spsdisp smb_vwv4
# define smb_sdscnt smb_vwv5
# define smb_sdsoff smb_vwv6
# define smb_sdsdisp smb_vwv7
# define smb_sfid smb_vwv8
/* and these for responses */
# define smb_tprcnt smb_vwv0
# define smb_tdrcnt smb_vwv1
# define smb_prcnt smb_vwv3
# define smb_proff smb_vwv4
# define smb_prdisp smb_vwv5
# define smb_drcnt smb_vwv6
# define smb_droff smb_vwv7
# define smb_drdisp smb_vwv8
1998-05-08 05:23:11 +04:00
/* these are for the NT trans primary request. */
# define smb_nt_MaxSetupCount smb_vwv0
# define smb_nt_Flags (smb_vwv0 + 1)
# define smb_nt_TotalParameterCount (smb_vwv0 + 3)
# define smb_nt_TotalDataCount (smb_vwv0 + 7)
# define smb_nt_MaxParameterCount (smb_vwv0 + 11)
# define smb_nt_MaxDataCount (smb_vwv0 + 15)
# define smb_nt_ParameterCount (smb_vwv0 + 19)
# define smb_nt_ParameterOffset (smb_vwv0 + 23)
# define smb_nt_DataCount (smb_vwv0 + 27)
# define smb_nt_DataOffset (smb_vwv0 + 31)
# define smb_nt_SetupCount (smb_vwv0 + 35)
# define smb_nt_Function (smb_vwv0 + 36)
1998-08-03 23:07:55 +04:00
# define smb_nt_SetupStart (smb_vwv0 + 38)
1998-05-08 05:23:11 +04:00
/* these are for the NT trans secondary request. */
# define smb_nts_TotalParameterCount (smb_vwv0 + 3)
# define smb_nts_TotalDataCount (smb_vwv0 + 7)
# define smb_nts_ParameterCount (smb_vwv0 + 11)
# define smb_nts_ParameterOffset (smb_vwv0 + 15)
# define smb_nts_ParameterDisplacement (smb_vwv0 + 19)
# define smb_nts_DataCount (smb_vwv0 + 23)
# define smb_nts_DataOffset (smb_vwv0 + 27)
# define smb_nts_DataDisplacement (smb_vwv0 + 31)
1998-07-09 04:41:32 +04:00
/* these are for the NT trans reply. */
# define smb_ntr_TotalParameterCount (smb_vwv0 + 3)
# define smb_ntr_TotalDataCount (smb_vwv0 + 7)
# define smb_ntr_ParameterCount (smb_vwv0 + 11)
# define smb_ntr_ParameterOffset (smb_vwv0 + 15)
# define smb_ntr_ParameterDisplacement (smb_vwv0 + 19)
# define smb_ntr_DataCount (smb_vwv0 + 23)
# define smb_ntr_DataOffset (smb_vwv0 + 27)
# define smb_ntr_DataDisplacement (smb_vwv0 + 31)
1998-05-23 06:00:21 +04:00
/* these are for the NT create_and_X */
# define smb_ntcreate_NameLength (smb_vwv0 + 5)
# define smb_ntcreate_Flags (smb_vwv0 + 7)
1998-09-18 03:06:57 +04:00
# define smb_ntcreate_RootDirectoryFid (smb_vwv0 + 11)
1998-05-23 06:00:21 +04:00
# define smb_ntcreate_DesiredAccess (smb_vwv0 + 15)
# define smb_ntcreate_AllocationSize (smb_vwv0 + 19)
# define smb_ntcreate_FileAttributes (smb_vwv0 + 27)
# define smb_ntcreate_ShareAccess (smb_vwv0 + 31)
# define smb_ntcreate_CreateDisposition (smb_vwv0 + 35)
# define smb_ntcreate_CreateOptions (smb_vwv0 + 39)
# define smb_ntcreate_ImpersonationLevel (smb_vwv0 + 43)
# define smb_ntcreate_SecurityFlags (smb_vwv0 + 47)
2000-03-10 00:45:16 +03:00
/* Named pipe write mode flags. Used in writeX calls. */
# define PIPE_RAW_MODE 0x4
# define PIPE_START_MESSAGE 0x8
2000-12-04 10:26:56 +03:00
/* the desired access to use when opening a pipe */
# define DESIRED_ACCESS_PIPE 0x2019f
1998-07-01 01:19:40 +04:00
1999-12-13 16:27:58 +03:00
/* Mapping of access rights to UNIX perms. */
2001-05-19 00:16:55 +04:00
# define UNIX_ACCESS_RWX FILE_GENERIC_ALL
# define UNIX_ACCESS_R FILE_GENERIC_READ
# define UNIX_ACCESS_W FILE_GENERIC_WRITE
# define UNIX_ACCESS_X FILE_GENERIC_EXECUTE
2005-05-24 00:47:43 +04:00
/* Mapping of access rights to UNIX perms. for a UNIX directory. */
# define UNIX_DIRECTORY_ACCESS_RWX FILE_GENERIC_ALL
# define UNIX_DIRECTORY_ACCESS_R FILE_GENERIC_READ
2009-02-03 04:10:27 +03:00
# define UNIX_DIRECTORY_ACCESS_W (FILE_GENERIC_WRITE|FILE_DELETE_CHILD)
2005-05-24 00:47:43 +04:00
# define UNIX_DIRECTORY_ACCESS_X FILE_GENERIC_EXECUTE
2001-05-19 00:16:55 +04:00
#if 0
/*
* This is the old mapping we used to use . To get W2KSP2 profiles
* working we need to map to the canonical file perms .
*/
1999-12-13 16:27:58 +03:00
# define UNIX_ACCESS_RWX (UNIX_ACCESS_R|UNIX_ACCESS_W|UNIX_ACCESS_X)
# define UNIX_ACCESS_R (READ_CONTROL_ACCESS|SYNCHRONIZE_ACCESS|\
FILE_READ_ATTRIBUTES | FILE_READ_EA | FILE_READ_DATA )
# define UNIX_ACCESS_W (READ_CONTROL_ACCESS|SYNCHRONIZE_ACCESS|\
FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | \
FILE_APPEND_DATA | FILE_WRITE_DATA )
# define UNIX_ACCESS_X (READ_CONTROL_ACCESS|SYNCHRONIZE_ACCESS|\
FILE_EXECUTE | FILE_READ_ATTRIBUTES )
2001-05-19 00:16:55 +04:00
# endif
1999-12-13 16:27:58 +03:00
# define UNIX_ACCESS_NONE (WRITE_OWNER_ACCESS)
1998-05-26 23:37:31 +04:00
1998-05-23 06:00:21 +04:00
/* Flags field. */
# define REQUEST_OPLOCK 2
# define REQUEST_BATCH_OPLOCK 4
# define OPEN_DIRECTORY 8
2004-02-25 05:15:34 +03:00
# define EXTENDED_RESPONSE_REQUIRED 0x10
1998-05-23 06:00:21 +04:00
2008-08-19 18:34:50 +04:00
# define NTCREATEX_OPTIONS_MUST_IGNORE_MASK (0x008F0480)
# define NTCREATEX_OPTIONS_INVALID_PARAM_MASK (0xFF100030)
/*
* Private create options used by the ntcreatex processing code . From Samba4 .
2010-03-06 02:10:30 +03:00
* We reuse some ignored flags for private use . Passed in the private_flags
* argument .
2008-08-19 18:34:50 +04:00
*/
2010-03-06 02:10:30 +03:00
# define NTCREATEX_OPTIONS_PRIVATE_DENY_DOS 0x0001
# define NTCREATEX_OPTIONS_PRIVATE_DENY_FCB 0x0002
2005-07-08 08:51:27 +04:00
2008-01-20 01:25:36 +03:00
/* Private options for streams support */
2010-03-06 02:10:30 +03:00
# define NTCREATEX_OPTIONS_PRIVATE_STREAM_DELETE 0x0004
/* Private options for printer support */
# define NTCREATEX_OPTIONS_PRIVATE_DELETE_ON_CLOSE 0x0008
2008-01-20 01:25:36 +03:00
1998-07-11 05:25:02 +04:00
/* Flag for NT transact rename call. */
# define RENAME_REPLACE_IF_EXISTS 1
2004-03-03 23:55:59 +03:00
/* flags for SMBntrename call (from Samba4) */
# define RENAME_FLAG_MOVE_CLUSTER_INFORMATION 0x102 /* ???? */
# define RENAME_FLAG_HARD_LINK 0x103
# define RENAME_FLAG_RENAME 0x104
# define RENAME_FLAG_COPY 0x105
1998-08-03 23:07:55 +04:00
/* ChangeNotify flags. */
2007-01-31 15:42:24 +03:00
# define FILE_NOTIFY_CHANGE_FILE_NAME 0x001
1998-08-03 23:07:55 +04:00
# define FILE_NOTIFY_CHANGE_DIR_NAME 0x002
# define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x004
# define FILE_NOTIFY_CHANGE_SIZE 0x008
# define FILE_NOTIFY_CHANGE_LAST_WRITE 0x010
# define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x020
# define FILE_NOTIFY_CHANGE_CREATION 0x040
# define FILE_NOTIFY_CHANGE_EA 0x080
# define FILE_NOTIFY_CHANGE_SECURITY 0x100
2007-01-31 15:42:24 +03:00
# define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200
# define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400
# define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
1998-08-03 23:07:55 +04:00
2007-01-17 19:23:45 +03:00
# define FILE_NOTIFY_CHANGE_NAME \
( FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME )
2012-03-22 15:16:52 +04:00
# define FILE_NOTIFY_CHANGE_ALL \
( FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME | \
FILE_NOTIFY_CHANGE_ATTRIBUTES | FILE_NOTIFY_CHANGE_SIZE | \
FILE_NOTIFY_CHANGE_LAST_WRITE | FILE_NOTIFY_CHANGE_LAST_ACCESS | \
FILE_NOTIFY_CHANGE_CREATION | FILE_NOTIFY_CHANGE_EA | \
FILE_NOTIFY_CHANGE_SECURITY | FILE_NOTIFY_CHANGE_STREAM_NAME | \
FILE_NOTIFY_CHANGE_STREAM_SIZE | FILE_NOTIFY_CHANGE_STREAM_WRITE )
2007-01-17 19:23:45 +03:00
/* change notify action results */
# define NOTIFY_ACTION_ADDED 1
# define NOTIFY_ACTION_REMOVED 2
# define NOTIFY_ACTION_MODIFIED 3
# define NOTIFY_ACTION_OLD_NAME 4
# define NOTIFY_ACTION_NEW_NAME 5
# define NOTIFY_ACTION_ADDED_STREAM 6
# define NOTIFY_ACTION_REMOVED_STREAM 7
# define NOTIFY_ACTION_MODIFIED_STREAM 8
2013-05-29 19:11:44 +04:00
/*
* Timestamp format used in " previous versions " :
2013-12-12 15:08:58 +04:00
* This is the windows - level format of the @ GMT - token .
2013-05-29 19:11:44 +04:00
* It is a fixed format not to be confused with the
* format for the POSIX - Level token of the shadow_copy2
* VFS module that can be configured via the " shadow:format "
* configuration option but defaults to the same format .
* See the shadow_copy2 module .
*/
2013-08-29 21:36:00 +04:00
# define GMT_NAME_LEN 24 /* length of a @GMT- name */
# define GMT_FORMAT "@GMT-%Y.%m.%d-%H.%M.%S"
2006-12-29 00:50:31 +03:00
1996-05-04 11:50:46 +04:00
/* where to find the base of the SMB packet proper */
2011-05-05 21:41:59 +04:00
# define smb_base(buf) (((const char *)(buf))+4)
1996-05-04 11:50:46 +04:00
1999-12-13 16:27:58 +03:00
/* we don't allow server strings to be longer than 48 characters as
otherwise NT will not honour the announce packets */
# define MAX_SERVER_STRING_LENGTH 48
1998-04-10 00:48:48 +04:00
# define SMB_SUCCESS 0 /* The request was successful. */
1996-05-04 11:50:46 +04:00
1998-07-29 07:08:05 +04:00
# ifdef WITH_DFS
1996-05-04 11:50:46 +04:00
void dfs_unlogin ( void ) ;
extern int dcelogin_atmost_once ;
# endif
1996-06-04 10:42:03 +04:00
1996-05-04 11:50:46 +04:00
# ifdef NOSTRDUP
char * strdup ( char * s ) ;
# endif
1996-06-04 10:42:03 +04:00
1996-05-04 11:50:46 +04:00
# ifndef SELECT_CAST
# define SELECT_CAST
# endif
2001-04-13 06:51:58 +04:00
/* This was set by JHT in liaison with Jeremy Allison early 1997
* History :
* Version 4.0 - never made public
* Version 4.10 - New to 1.9 .16 p2 , lost in space 1.9 .16 p3 to 1.9 .16 p9
* - Reappeared in 1.9 .16 p11 with fixed smbd services
* Version 4.20 - To indicate that nmbd and browsing now works better
* Version 4.50 - Set at release of samba - 2.2 .0 by JHT
*
* Note : In the presence of NT4 . X do not set above 4.9
* Setting this above 4.9 can have undesired side - effects .
* This may change again in Samba - 3.0 after further testing . JHT
2013-07-09 12:56:49 +04:00
*
* Version 6.1 - For older smb server versions , MMC doesn ' t let offline
* settings to be configured during share creation . Changing
* it to 6.1 to mimic Win2K8R2 .
*
2001-04-13 06:51:58 +04:00
*/
2013-07-09 12:56:49 +04:00
# define SAMBA_MAJOR_NBT_ANNOUNCE_VERSION 0x06
# define SAMBA_MINOR_NBT_ANNOUNCE_VERSION 0x01
1997-03-15 17:47:00 +03:00
/* Browser Election Values */
1997-03-15 17:58:30 +03:00
# define BROWSER_ELECTION_VERSION 0x010f
1997-03-15 17:47:00 +03:00
# define BROWSER_CONSTANT 0xaa55
1996-05-04 11:50:46 +04:00
2009-09-15 02:30:05 +04:00
/* File Status Flags. See:
http : //msdn.microsoft.com/en-us/library/cc246334(PROT.13).aspx
*/
# define NO_EAS 0x1
# define NO_SUBSTREAMS 0x2
# define NO_REPARSETAG 0x4
1997-09-05 00:26:07 +04:00
/* Remote architectures we know about. */
2004-06-15 22:36:45 +04:00
enum remote_arch_types { RA_UNKNOWN , RA_WFWG , RA_OS2 , RA_WIN95 , RA_WINNT ,
2007-02-09 00:48:09 +03:00
RA_WIN2K , RA_WINXP , RA_WIN2K3 , RA_VISTA ,
2011-02-25 03:25:30 +03:00
RA_SAMBA , RA_CIFSFS , RA_WINXP64 , RA_OSX } ;
1996-05-04 11:50:46 +04:00
1996-10-26 00:48:25 +04:00
/*
2012-06-06 16:51:13 +04:00
* Global value meaning that the smb_uid field should be
1996-10-26 00:48:25 +04:00
* ingored ( in share level security and protocol level = = CORE )
*/
# define UID_FIELD_INVALID 0
# define VUID_OFFSET 100 /* Amount to bias returned vuid numbers */
2012-06-06 17:23:55 +04:00
# define TID_FIELD_INVALID 0
2012-06-06 17:12:08 +04:00
2012-06-13 19:18:59 +04:00
# define FNUM_FIELD_INVALID 0
2012-06-12 16:35:39 +04:00
1997-09-26 23:26:56 +04:00
/*
* Size of buffer to use when moving files across filesystems .
*/
1997-07-01 05:19:13 +04:00
# define COPYBUF_SIZE (8*1024)
1997-09-26 23:26:56 +04:00
/*
* Map the Core and Extended Oplock requesst bits down
* to common bits ( EXCLUSIVE_OPLOCK & BATCH_OPLOCK ) .
*/
/*
* Core protocol .
*/
1998-09-18 03:06:57 +04:00
# define CORE_OPLOCK_REQUEST(inbuf) \
( ( CVAL ( inbuf , smb_flg ) & ( FLAG_REQUEST_OPLOCK | FLAG_REQUEST_BATCH_OPLOCK ) ) > > 5 )
1997-09-26 23:26:56 +04:00
/*
* Extended protocol .
*/
1997-10-27 15:02:34 +03:00
# define EXTENDED_OPLOCK_REQUEST(inbuf) ((SVAL(inbuf,smb_vwv2)&((1<<1)|(1<<2)))>>1)
1997-09-26 23:26:56 +04:00
/*
* Bits we test with .
2006-05-30 22:17:37 +04:00
* Note these must fit into 16 - bits .
1997-09-26 23:26:56 +04:00
*/
2006-05-30 22:17:37 +04:00
2011-10-24 13:39:28 +04:00
# define NO_OPLOCK OPLOCK_NONE
# define EXCLUSIVE_OPLOCK OPLOCK_EXCLUSIVE
# define BATCH_OPLOCK OPLOCK_BATCH
# define LEVEL_II_OPLOCK OPLOCK_LEVEL_II
2006-05-30 22:17:37 +04:00
/* The following are Samba-private. */
2007-02-07 00:05:34 +03:00
# define INTERNAL_OPEN_ONLY 0x8
2013-09-11 20:07:33 +04:00
/* #define FAKE_LEVEL_II_OPLOCK 0x10 */ /* Not used anymore */
/* Client requested no_oplock, but we have to
2005-09-30 21:13:37 +04:00
* inform potential level2 holders on
* write . */
2013-04-26 17:05:50 +04:00
/* #define DEFERRED_OPEN_ENTRY 0x20 */ /* Not used anymore */
2011-12-14 13:35:56 +04:00
/* #define UNUSED_SHARE_MODE_ENTRY 0x40 */ /* Not used anymore */
2013-09-04 19:26:30 +04:00
/* #define FORCE_OPLOCK_BREAK_TO_NONE 0x80 */ /* Not used anymore */
2006-05-30 22:17:37 +04:00
/* None of the following should ever appear in fsp->oplock_request. */
2013-09-04 19:26:30 +04:00
# define SAMBA_PRIVATE_OPLOCK_MASK (INTERNAL_OPEN_ONLY)
1999-12-13 16:27:58 +03:00
2005-07-08 08:51:27 +04:00
# define EXCLUSIVE_OPLOCK_TYPE(lck) ((lck) & ((unsigned int)EXCLUSIVE_OPLOCK|(unsigned int)BATCH_OPLOCK))
# define BATCH_OPLOCK_TYPE(lck) ((lck) & (unsigned int)BATCH_OPLOCK)
2013-09-11 20:07:33 +04:00
# define LEVEL_II_OPLOCK_TYPE(lck) ((lck) & (unsigned int)LEVEL_II_OPLOCK)
2005-09-30 21:13:37 +04:00
2006-01-13 01:17:54 +03:00
/* kernel_oplock_message definition.
2005-09-30 21:13:37 +04:00
struct kernel_oplock_message {
2009-02-16 10:45:28 +03:00
uint64_t dev ;
uint64_t inode ;
unit64_t extid ;
2005-09-30 21:13:37 +04:00
unsigned long file_id ;
} ;
1997-09-26 23:26:56 +04:00
2006-01-13 01:17:54 +03:00
Offset Data length .
2009-02-16 10:45:28 +03:00
0 uint64_t dev 8 bytes
8 uint64_t inode 8 bytes
16 uint64_t extid 8 bytes
24 unsigned long file_id 4 bytes
28
2006-01-13 01:17:54 +03:00
*/
2009-02-16 10:45:28 +03:00
# define MSG_SMB_KERNEL_BREAK_SIZE 28
2006-01-13 01:17:54 +03:00
/* file_renamed_message definition.
2005-12-13 21:11:50 +03:00
struct file_renamed_message {
2009-02-16 10:45:28 +03:00
uint64_t dev ;
uint64_t inode ;
2006-01-13 01:17:54 +03:00
char names [ 1 ] ; A variable area containing sharepath and filename .
2005-12-13 21:11:50 +03:00
} ;
2006-01-13 01:17:54 +03:00
Offset Data length .
2009-02-16 10:45:28 +03:00
0 uint64_t dev 8 bytes
8 uint64_t inode 8 bytes
16 unit64_t extid 8 bytes
24 char [ ] name zero terminated namelen bytes
minimum length = = 24.
2006-01-13 01:17:54 +03:00
*/
2009-02-16 10:45:28 +03:00
# define MSG_FILE_RENAMED_MIN_SIZE 24
2006-01-13 01:17:54 +03:00
1999-12-13 16:27:58 +03:00
/*
2005-07-08 08:51:27 +04:00
* On the wire return values for oplock types .
1999-12-13 16:27:58 +03:00
*/
2005-07-08 08:51:27 +04:00
# define CORE_OPLOCK_GRANTED (1<<5)
# define EXTENDED_OPLOCK_GRANTED (1<<15)
1999-12-13 16:27:58 +03:00
# define NO_OPLOCK_RETURN 0
# define EXCLUSIVE_OPLOCK_RETURN 1
# define BATCH_OPLOCK_RETURN 2
# define LEVEL_II_OPLOCK_RETURN 3
2005-07-08 08:51:27 +04:00
/* Oplock levels */
# define OPLOCKLEVEL_NONE 0
# define OPLOCKLEVEL_II 1
1998-09-26 03:40:49 +04:00
/*
* Capabilities abstracted for different systems .
*/
2006-03-21 05:56:49 +03:00
enum smbd_capability {
2006-03-23 02:49:09 +03:00
KERNEL_OPLOCK_CAPABILITY ,
2008-05-28 15:20:16 +04:00
DMAPI_ACCESS_CAPABILITY ,
2013-12-10 12:10:21 +04:00
LEASE_CAPABILITY ,
DAC_OVERRIDE_CAPABILITY
2006-03-21 05:56:49 +03:00
} ;
1998-09-26 03:40:49 +04:00
2009-02-04 02:40:23 +03:00
/*
* Kernel oplocks capability flags .
*/
/* Level 2 oplocks are supported natively by kernel oplocks. */
# define KOPLOCKS_LEVEL2_SUPPORTED 0x1
/* The kernel notifies deferred openers when they can retry the open. */
# define KOPLOCKS_DEFERRED_OPEN_NOTIFICATION 0x2
/* The kernel notifies smbds when an oplock break times out. */
# define KOPLOCKS_TIMEOUT_NOTIFICATION 0x4
/* The kernel notifies smbds when an oplock is broken. */
# define KOPLOCKS_OPLOCK_BROKEN_NOTIFICATION 0x8
2009-01-09 16:02:18 +03:00
struct kernel_oplocks_ops ;
struct kernel_oplocks {
const struct kernel_oplocks_ops * ops ;
2009-02-04 02:40:23 +03:00
uint32_t flags ;
2009-01-09 16:02:18 +03:00
void * private_data ;
} ;
2009-02-03 22:56:35 +03:00
enum level2_contention_type {
LEVEL2_CONTEND_ALLOC_SHRINK ,
LEVEL2_CONTEND_ALLOC_GROW ,
LEVEL2_CONTEND_SET_FILE_LEN ,
LEVEL2_CONTEND_FILL_SPARSE ,
LEVEL2_CONTEND_WRITE ,
LEVEL2_CONTEND_WINDOWS_BRL ,
LEVEL2_CONTEND_POSIX_BRL
} ;
2000-06-10 17:38:07 +04:00
/* if a kernel does support oplocks then a structure of the following
typee is used to describe how to interact with the kernel */
2009-01-09 16:02:18 +03:00
struct kernel_oplocks_ops {
bool ( * set_oplock ) ( struct kernel_oplocks * ctx ,
files_struct * fsp , int oplock_type ) ;
void ( * release_oplock ) ( struct kernel_oplocks * ctx ,
2009-01-10 00:07:58 +03:00
files_struct * fsp , int oplock_type ) ;
2009-02-03 22:56:35 +03:00
void ( * contend_level2_oplocks_begin ) ( files_struct * fsp ,
enum level2_contention_type type ) ;
void ( * contend_level2_oplocks_end ) ( files_struct * fsp ,
enum level2_contention_type type ) ;
2000-06-10 17:38:07 +04:00
} ;
2000-02-03 07:47:50 +03:00
# include "smb_macros.h"
1998-08-21 13:43:21 +04:00
2004-03-13 03:28:53 +03:00
# define MAX_NETBIOSNAME_LEN 16
2004-03-16 00:45:45 +03:00
/* DOS character, NetBIOS namestring. Type used on the wire. */
2004-03-13 03:28:53 +03:00
typedef char nstring [ MAX_NETBIOSNAME_LEN ] ;
2004-03-16 00:45:45 +03:00
/* Unix character, NetBIOS namestring. Type used to manipulate name in nmbd. */
typedef char unstring [ MAX_NETBIOSNAME_LEN * 4 ] ;
2003-08-23 05:59:14 +04:00
1998-09-26 01:01:52 +04:00
/* A netbios name structure. */
struct nmb_name {
2003-08-23 05:59:14 +04:00
nstring name ;
2003-08-23 02:45:34 +04:00
char scope [ 64 ] ;
unsigned int name_type ;
1998-09-26 01:01:52 +04:00
} ;
2000-12-20 06:22:51 +03:00
/* A netbios node status array element. */
2010-12-28 13:55:47 +03:00
struct node_status {
2003-08-23 05:59:14 +04:00
nstring name ;
2000-12-20 06:22:51 +03:00
unsigned char type ;
unsigned char flags ;
2010-12-28 13:55:47 +03:00
} ;
2000-12-20 06:22:51 +03:00
2004-04-16 07:57:30 +04:00
/* The extra info from a NetBIOS node status query */
struct node_status_extra {
unsigned char mac_addr [ 6 ] ;
/* There really is more here ... */
} ;
2001-06-23 11:22:16 +04:00
# define SAFE_NETBIOS_CHARS ". -_"
2001-12-05 14:00:26 +03:00
/* The maximum length of a trust account password.
Used when we randomly create it , 15 char passwords
exceed NT4 ' s max password length */
# define DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH 14
2003-06-25 21:41:05 +04:00
# define PORT_NONE 0
2003-06-25 23:39:16 +04:00
# ifndef LDAP_PORT
# define LDAP_PORT 389
# endif
2008-06-27 18:22:39 +04:00
# define LDAP_GC_PORT 3268
2003-06-25 21:41:05 +04:00
/* used by the IP comparison function */
struct ip_service {
2007-10-25 01:16:54 +04:00
struct sockaddr_storage ss ;
2003-06-25 21:41:05 +04:00
unsigned port ;
} ;
2004-03-27 05:13:58 +03:00
struct ea_struct {
uint8 flags ;
char * name ;
DATA_BLOB value ;
} ;
2005-03-31 04:36:22 +04:00
struct ea_list {
struct ea_list * next , * prev ;
struct ea_struct ea ;
} ;
2004-03-31 06:20:16 +04:00
/* EA names used internally in Samba. KEEP UP TO DATE with prohibited_ea_names in trans2.c !. */
# define SAMBA_POSIX_INHERITANCE_EA_NAME "user.SAMBA_PAI"
2004-04-02 22:46:19 +04:00
/* EA to use for DOS attributes */
# define SAMBA_XATTR_DOS_ATTRIB "user.DOSATTRIB"
2008-01-21 22:24:23 +03:00
/* Prefix for DosStreams in the vfs_streams_xattr module */
# define SAMBA_XATTR_DOSSTREAM_PREFIX "user.DosStream."
2009-10-30 02:14:12 +03:00
/* Prefix for xattrs storing streams. */
# define SAMBA_XATTR_MARKER "user.SAMBA_STREAMS"
2004-04-02 22:46:19 +04:00
2006-02-04 01:19:41 +03:00
/* usershare error codes. */
enum usershare_err {
USERSHARE_OK = 0 ,
USERSHARE_MALFORMED_FILE ,
USERSHARE_BAD_VERSION ,
USERSHARE_MALFORMED_PATH ,
USERSHARE_MALFORMED_COMMENT_DEF ,
USERSHARE_MALFORMED_ACL_DEF ,
USERSHARE_ACL_ERR ,
USERSHARE_PATH_NOT_ABSOLUTE ,
USERSHARE_PATH_IS_DENIED ,
USERSHARE_PATH_NOT_ALLOWED ,
USERSHARE_PATH_NOT_DIRECTORY ,
2010-03-27 03:09:58 +03:00
USERSHARE_POSIX_ERR ,
USERSHARE_MALFORMED_SHARENAME_DEF ,
USERSHARE_BAD_SHARENAME
2006-02-04 01:19:41 +03:00
} ;
2006-02-02 23:44:50 +03:00
/* Different reasons for closing a file. */
enum file_close_type { NORMAL_CLOSE = 0 , SHUTDOWN_CLOSE , ERROR_CLOSE } ;
2008-01-22 13:33:17 +03:00
/* Used in SMB_FS_OBJECTID_INFORMATION requests. Must be exactly 48 bytes. */
# define SAMBA_EXTENDED_INFO_MAGIC 0x536d4261 /* "SmBa" */
# define SAMBA_EXTENDED_INFO_VERSION_STRING_LENGTH 28
struct smb_extended_info {
uint32 samba_magic ; /* Always SAMBA_EXTRA_INFO_MAGIC */
uint32 samba_version ; /* Major/Minor/Release/Revision */
uint32 samba_subversion ; /* Prerelease/RC/Vendor patch */
NTTIME samba_gitcommitdate ;
char samba_version_string [ SAMBA_EXTENDED_INFO_VERSION_STRING_LENGTH ] ;
} ;
2011-05-03 18:25:20 +04:00
/*
* Reasons for cache flush .
*/
enum flush_reason_enum {
2013-11-22 09:33:33 +04:00
SAMBA_SEEK_FLUSH ,
SAMBA_READ_FLUSH ,
SAMBA_WRITE_FLUSH ,
SAMBA_READRAW_FLUSH ,
SAMBA_OPLOCK_RELEASE_FLUSH ,
SAMBA_CLOSE_FLUSH ,
SAMBA_SYNC_FLUSH ,
SAMBA_SIZECHANGE_FLUSH ,
2011-05-03 18:25:20 +04:00
/* NUM_FLUSH_REASONS must remain the last value in the enumeration. */
2013-11-22 09:33:33 +04:00
SAMBA_NUM_FLUSH_REASONS } ;
2011-05-03 18:25:20 +04:00
1998-03-12 00:11:04 +03:00
# endif /* _SMB_H */