#define SMB_PORT2 139
#define SMB_PORTS "445 139"
-#define False (0)
-#define True (1)
-#define Auto (2)
-
-enum smb_signing_state {SMB_SIGNING_OFF, SMB_SIGNING_SUPPORTED, SMB_SIGNING_REQUIRED};
-
-#ifndef _BOOL
-typedef int BOOL;
-#define _BOOL /* So we don't typedef BOOL again in vfs.h */
-#endif
-
-/* string manipulation flags - see clistr.c and srvstr.c */
-#define STR_TERMINATE 1
-#define STR_UPPER 2
-#define STR_ASCII 4
-#define STR_UNICODE 8
-#define STR_NOALIGN 16
-#define STR_NO_RANGE_CHECK 32
-#define STR_LEN8BIT 64
-#define STR_TERMINATE_ASCII 128 /* only terminate if ascii */
-#define STR_LEN_NOTERM 256 /* the length field is the unterminated length */
-
-/* Debugging stuff */
-#include "debug.h"
-
-/* types of socket errors */
-enum socket_error {SOCKET_READ_TIMEOUT,
- SOCKET_READ_EOF,
- SOCKET_READ_ERROR,
- SOCKET_WRITE_ERROR,
- SOCKET_READ_BAD_SIG};
+enum smb_signing_state {SMB_SIGNING_OFF, SMB_SIGNING_SUPPORTED,
+ SMB_SIGNING_REQUIRED, SMB_SIGNING_AUTO};
/* deny modes */
#define DENY_DOS 0
/* ntcreatex flags field. */
#define NTCREATEX_FLAGS_REQUEST_OPLOCK 0x02
#define NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK 0x04
-#define NTCREATEX_FLAGS_OPEN_DIRECTORY 0x08
+#define NTCREATEX_FLAGS_OPEN_DIRECTORY 0x08 /* TODO: opens parent? we need
+ a test suite for this */
#define NTCREATEX_FLAGS_EXTENDED 0x10
/* the ntcreatex access_mask field
#define NTCREATEX_DISP_OVERWRITE_IF 5 /* if exists overwrite, else create */
/* ntcreatex create_options field */
-#define NTCREATEX_OPTIONS_DIRECTORY 0x0001
-#define NTCREATEX_OPTIONS_WRITE_THROUGH 0x0002
-#define NTCREATEX_OPTIONS_SEQUENTIAL_ONLY 0x0004
-#define NTCREATEX_OPTIONS_SYNC_ALERT 0x0010
-#define NTCREATEX_OPTIONS_ASYNC_ALERT 0x0020
-#define NTCREATEX_OPTIONS_NON_DIRECTORY_FILE 0x0040
-#define NTCREATEX_OPTIONS_NO_EA_KNOWLEDGE 0x0200
-#define NTCREATEX_OPTIONS_EIGHT_DOT_THREE_ONLY 0x0400
-#define NTCREATEX_OPTIONS_RANDOM_ACCESS 0x0800
-#define NTCREATEX_OPTIONS_DELETE_ON_CLOSE 0x1000
-#define NTCREATEX_OPTIONS_OPEN_BY_FILE_ID 0x2000
+#define NTCREATEX_OPTIONS_DIRECTORY 0x0001
+#define NTCREATEX_OPTIONS_WRITE_THROUGH 0x0002
+#define NTCREATEX_OPTIONS_SEQUENTIAL_ONLY 0x0004
+#define NTCREATEX_OPTIONS_SYNC_ALERT 0x0010
+#define NTCREATEX_OPTIONS_ASYNC_ALERT 0x0020
+#define NTCREATEX_OPTIONS_NON_DIRECTORY_FILE 0x0040
+#define NTCREATEX_OPTIONS_NO_EA_KNOWLEDGE 0x0200
+#define NTCREATEX_OPTIONS_EIGHT_DOT_THREE_ONLY 0x0400
+#define NTCREATEX_OPTIONS_RANDOM_ACCESS 0x0800
+#define NTCREATEX_OPTIONS_DELETE_ON_CLOSE 0x1000
+#define NTCREATEX_OPTIONS_OPEN_BY_FILE_ID 0x2000
+
+/* create options these bits are for private use by backends, they are
+ not valid on the wire */
+#define NTCREATEX_OPTIONS_PRIVATE_MASK 0xFF000000
+#define NTCREATEX_OPTIONS_PRIVATE_DENY_DOS 0x01000000
+#define NTCREATEX_OPTIONS_PRIVATE_DENY_FCB 0x02000000
+
/* ntcreatex impersonation field */
#define NTCREATEX_IMPERSONATION_ANONYMOUS 0
incorrect parameters - what does it mean? maybe created temporary file? */
#define NTCREATEX_ACTION_UNKNOWN 5
-#include "doserr.h"
-
-/*
- * SMB UCS2 (16-bit unicode) internal type.
- */
-
-typedef uint16_t smb_ucs2_t;
-
-/* ucs2 string types. */
-typedef smb_ucs2_t wpstring[PSTRING_LEN];
-typedef smb_ucs2_t wfstring[FSTRING_LEN];
-
-#ifdef WORDS_BIGENDIAN
-#define UCS2_SHIFT 8
-#else
-#define UCS2_SHIFT 0
-#endif
-
-/* turn a 7 bit character into a ucs2 character */
-#define UCS2_CHAR(c) ((c) << UCS2_SHIFT)
-
-/* for compatibility */
-#define SID_NAME_USE samr_SidType
-
-/*
- * The complete list of SIDS belonging to this user.
- * Created when a vuid is registered.
- * The definition of the user_sids array is as follows :
- *
- * token->user_sids[0] = primary user SID.
- * token->user_sids[1] = primary group SID.
- * token->user_sids[2..num_sids] = supplementary group SIDS.
- */
-
-#define PRIMARY_USER_SID_INDEX 0
-#define PRIMARY_GROUP_SID_INDEX 1
-typedef struct nt_user_token {
- size_t num_sids;
- struct dom_sid **user_sids;
-} NT_USER_TOKEN;
+struct security_token {
+ struct dom_sid *user_sid;
+ struct dom_sid *group_sid;
+ uint32_t num_sids;
+ struct dom_sid **sids;
+ uint64_t privilege_mask;
+};
/* used to hold an arbitrary blob of data */
typedef struct data_blob {
uint8_t *data;
size_t length;
- void (*free)(struct data_blob *data_blob);
} DATA_BLOB;
-#include "enums.h"
-#include "events.h"
-#include "librpc/gen_ndr/ndr_misc.h"
-#include "smb_interfaces.h"
-#include "librpc/ndr/libndr.h"
-
-
-/* used for server information: client, nameserv and ipc */
-struct server_info_struct
-{
- fstring name;
- uint32_t type;
- fstring comment;
- fstring domain; /* used ONLY in ipc.c NOT namework.c */
- BOOL server_added; /* used ONLY in ipc.c NOT namework.c */
-};
-
-
-/* used for network interfaces */
-struct interface
-{
- struct interface *next, *prev;
- struct in_addr ip;
- struct in_addr bcast;
- struct in_addr nmask;
-};
-
-#define NT_HASH_LEN 16
-#define LM_HASH_LEN 16
-
-/*
- * Flags for account policy.
- */
-#define AP_MIN_PASSWORD_LEN 1
-#define AP_PASSWORD_HISTORY 2
-#define AP_USER_MUST_LOGON_TO_CHG_PASS 3
-#define AP_MAX_PASSWORD_AGE 4
-#define AP_MIN_PASSWORD_AGE 5
-#define AP_LOCK_ACCOUNT_DURATION 6
-#define AP_RESET_COUNT_TIME 7
-#define AP_BAD_ATTEMPT_LOCKOUT 8
-#define AP_TIME_TO_LOGOUT 9
-
-
-/*
- * Flags for local user manipulation.
- */
-
-#define LOCAL_ADD_USER 0x1
-#define LOCAL_DELETE_USER 0x2
-#define LOCAL_DISABLE_USER 0x4
-#define LOCAL_ENABLE_USER 0x8
-#define LOCAL_TRUST_ACCOUNT 0x10
-#define LOCAL_SET_NO_PASSWORD 0x20
-#define LOCAL_SET_PASSWORD 0x40
-#define LOCAL_SET_LDAP_ADMIN_PW 0x80
-#define LOCAL_INTERDOM_ACCOUNT 0x100
-#define LOCAL_AM_ROOT 0x200 /* Act as root */
-
-/* key and data in the connections database - used in smbstatus and smbd */
-struct connections_key {
- pid_t pid;
- int cnum;
- fstring name;
-};
-
-struct connections_data {
- int magic;
- pid_t pid;
- int cnum;
- uid_t uid;
- gid_t gid;
- char name[24];
- char addr[24];
- char machine[FSTRING_LEN];
- time_t start;
- uint32_t bcast_msg_flags;
-};
-
-/* the following are used by loadparm for option lists */
-typedef enum
-{
- P_BOOL,P_BOOLREV,P_CHAR,P_INTEGER,P_OCTAL,P_LIST,
- P_STRING,P_USTRING,P_ENUM,P_SEP
-} parm_type;
-
-typedef enum
-{
- P_LOCAL,P_GLOBAL,P_SEPARATOR,P_NONE
-} parm_class;
-
-struct enum_list {
- int value;
- const char *name;
-};
-
-struct parm_struct
-{
- const char *label;
- parm_type type;
- parm_class class;
- void *ptr;
- BOOL (*special)(const char *, char **);
- const struct enum_list *enum_list;
- uint_t flags;
- union {
- BOOL bvalue;
- int ivalue;
- char *svalue;
- char cvalue;
- char **lvalue;
- } def;
-};
-
-struct bitmap {
- uint32_t *b;
- uint_t n;
-};
-
-#define FLAG_BASIC 0x0001 /* fundamental options */
-#define FLAG_SHARE 0x0002 /* file sharing options */
-#define FLAG_PRINT 0x0004 /* printing options */
-#define FLAG_GLOBAL 0x0008 /* local options that should be globally settable in SWAT */
-#define FLAG_WIZARD 0x0010 /* Parameters that the wizard will operate on */
-#define FLAG_ADVANCED 0x0020 /* Parameters that the wizard will operate on */
-#define FLAG_DEVELOPER 0x0040 /* Parameters that the wizard will operate on */
-#define FLAG_DEPRECATED 0x1000 /* options that should no longer be used */
-#define FLAG_HIDE 0x2000 /* options that should be hidden in SWAT */
-#define FLAG_DOS_STRING 0x4000 /* convert from UNIX to DOS codepage when reading this string. */
-#define FLAG_CMDLINE 0x8000 /* this option was set from the command line */
+/* 64 bit time (100 nanosec) 1601 - cifs6.txt, section 3.5, page 30 */
+typedef uint64_t NTTIME;
+/* 64 bit time (1 sec) 1601 - in the NDR blob but mapped to NTTIME */
+#define NTTIME_1sec NTTIME
-#ifndef LOCKING_VERSION
-#define LOCKING_VERSION 4
-#endif /* LOCKING_VERSION */
+/* 8 byte aligned 'hyper' type from MS IDL */
+typedef uint64_t HYPER_T;
/* the basic packet size, assuming no words or bytes. Does not include the NBT header */
otherwise NT will not honour the announce packets */
#define MAX_SERVER_STRING_LENGTH 48
-#ifndef SIGNAL_CAST
-#define SIGNAL_CAST (RETSIGTYPE (*)(int))
-#endif
-
-#ifndef SELECT_CAST
-#define SELECT_CAST
-#endif
-
-/* these are used in NetServerEnum to choose what to receive */
-#define SV_TYPE_WORKSTATION 0x00000001
-#define SV_TYPE_SERVER 0x00000002
-#define SV_TYPE_SQLSERVER 0x00000004
-#define SV_TYPE_DOMAIN_CTRL 0x00000008
-#define SV_TYPE_DOMAIN_BAKCTRL 0x00000010
-#define SV_TYPE_TIME_SOURCE 0x00000020
-#define SV_TYPE_AFP 0x00000040
-#define SV_TYPE_NOVELL 0x00000080
-#define SV_TYPE_DOMAIN_MEMBER 0x00000100
-#define SV_TYPE_PRINTQ_SERVER 0x00000200
-#define SV_TYPE_DIALIN_SERVER 0x00000400
-#define SV_TYPE_SERVER_UNIX 0x00000800
-#define SV_TYPE_NT 0x00001000
-#define SV_TYPE_WFW 0x00002000
-#define SV_TYPE_SERVER_MFPN 0x00004000
-#define SV_TYPE_SERVER_NT 0x00008000
-#define SV_TYPE_POTENTIAL_BROWSER 0x00010000
-#define SV_TYPE_BACKUP_BROWSER 0x00020000
-#define SV_TYPE_MASTER_BROWSER 0x00040000
-#define SV_TYPE_DOMAIN_MASTER 0x00080000
-#define SV_TYPE_SERVER_OSF 0x00100000
-#define SV_TYPE_SERVER_VMS 0x00200000
-#define SV_TYPE_WIN95_PLUS 0x00400000
-#define SV_TYPE_DFS_SERVER 0x00800000
-#define SV_TYPE_ALTERNATE_XPORT 0x20000000
-#define SV_TYPE_LOCAL_LIST_ONLY 0x40000000
-#define SV_TYPE_DOMAIN_ENUM 0x80000000
-#define SV_TYPE_ALL 0xFFFFFFFF
-
/* This was set by JHT in liaison with Jeremy Allison early 1997
* History:
* Version 4.0 - never made public
#define NEGOTIATE_SECURITY_SIGNATURES_REQUIRED 0x08
/* NT Flags2 bits - cifs6.txt section 3.1.2 */
-
#define FLAGS2_LONG_PATH_COMPONENTS 0x0001
#define FLAGS2_EXTENDED_ATTRIBUTES 0x0002
#define FLAGS2_SMB_SECURITY_SIGNATURES 0x0004
#define FLAGS2_IS_LONG_NAME 0x0040
#define FLAGS2_EXTENDED_SECURITY 0x0800
#define FLAGS2_DFS_PATHNAMES 0x1000
-#define FLAGS2_READ_PERMIT_NO_EXECUTE 0x2000
+#define FLAGS2_READ_PERMIT_EXECUTE 0x2000
#define FLAGS2_32_BIT_ERROR_CODES 0x4000
#define FLAGS2_UNICODE_STRINGS 0x8000
-#define FLAGS2_WIN2K_SIGNATURE 0xC852 /* Hack alert ! For now... JRA. */
-
-/* Capabilities. see ftp.microsoft.com/developr/drg/cifs/cifs/cifs4.txt */
-
-#define CAP_RAW_MODE 0x0001
-#define CAP_MPX_MODE 0x0002
-#define CAP_UNICODE 0x0004
-#define CAP_LARGE_FILES 0x0008
-#define CAP_NT_SMBS 0x0010
-#define CAP_RPC_REMOTE_APIS 0x0020
-#define CAP_STATUS32 0x0040
-#define CAP_LEVEL_II_OPLOCKS 0x0080
-#define CAP_LOCK_AND_READ 0x0100
-#define CAP_NT_FIND 0x0200
-#define CAP_DFS 0x1000
-#define CAP_W2K_SMBS 0x2000
-#define CAP_LARGE_READX 0x4000
-#define CAP_LARGE_WRITEX 0x8000
-#define CAP_UNIX 0x800000 /* Capabilities for UNIX extensions. Created by HP. */
-#define CAP_EXTENDED_SECURITY 0x80000000
+
+/* CIFS protocol capabilities */
+#define CAP_RAW_MODE 0x00000001
+#define CAP_MPX_MODE 0x00000002
+#define CAP_UNICODE 0x00000004
+#define CAP_LARGE_FILES 0x00000008
+#define CAP_NT_SMBS 0x00000010
+#define CAP_RPC_REMOTE_APIS 0x00000020
+#define CAP_STATUS32 0x00000040
+#define CAP_LEVEL_II_OPLOCKS 0x00000080
+#define CAP_LOCK_AND_READ 0x00000100
+#define CAP_NT_FIND 0x00000200
+#define CAP_DFS 0x00001000
+#define CAP_W2K_SMBS 0x00002000
+#define CAP_LARGE_READX 0x00004000
+#define CAP_LARGE_WRITEX 0x00008000
+#define CAP_UNIX 0x00800000 /* Capabilities for UNIX extensions. Created by HP. */
+#define CAP_EXTENDED_SECURITY 0x80000000
/*
- * Global value meaing that the smb_uid field should be
+ * Global value meaning that the smb_uid field should be
* ingored (in share level security and protocol level == CORE)
*/
#define VUID_OFFSET 100 /* Amount to bias returned vuid numbers */
/* Lock types. */
-#define LOCKING_ANDX_SHARED_LOCK 0x1
-#define LOCKING_ANDX_OPLOCK_RELEASE 0x2
-#define LOCKING_ANDX_CHANGE_LOCKTYPE 0x4
-#define LOCKING_ANDX_CANCEL_LOCK 0x8
-#define LOCKING_ANDX_LARGE_FILES 0x10
-
-/* Oplock levels */
-#define OPLOCKLEVEL_NONE 0
-#define OPLOCKLEVEL_II 1
+#define LOCKING_ANDX_SHARED_LOCK 0x01
+#define LOCKING_ANDX_OPLOCK_RELEASE 0x02
+#define LOCKING_ANDX_CHANGE_LOCKTYPE 0x04
+#define LOCKING_ANDX_CANCEL_LOCK 0x08
+#define LOCKING_ANDX_LARGE_FILES 0x10
/*
* Bits we test with.
*/
-#define NO_OPLOCK 0
-#define EXCLUSIVE_OPLOCK 1
-#define BATCH_OPLOCK 2
-#define LEVEL_II_OPLOCK 4
+#define OPLOCK_NONE 0
+#define OPLOCK_EXCLUSIVE 1
+#define OPLOCK_BATCH 2
+#define OPLOCK_LEVEL_II 4
#define CORE_OPLOCK_GRANTED (1<<5)
#define EXTENDED_OPLOCK_GRANTED (1<<15)
#define BATCH_OPLOCK_RETURN 2
#define LEVEL_II_OPLOCK_RETURN 3
-/*
- * Loopback command offsets.
- */
-
-#define OPBRK_CMD_LEN_OFFSET 0
-#define OPBRK_CMD_PORT_OFFSET 4
-#define OPBRK_CMD_HEADER_LEN 6
-
-#define OPBRK_MESSAGE_CMD_OFFSET 0
-
-/* Message types */
-#define OPLOCK_BREAK_CMD 0x1
-#define KERNEL_OPLOCK_BREAK_CMD 0x2
-#define LEVEL_II_OPLOCK_BREAK_CMD 0x3
-#define ASYNC_LEVEL_II_OPLOCK_BREAK_CMD 0x4
-
-/*
- * Capabilities abstracted for different systems.
- */
-
-#define KERNEL_OPLOCK_CAPABILITY 0x1
-
-/*
- * Oplock break command code sent via the kernel interface (if it exists).
- *
- * Form of this is :
- *
- * 0 2 2+devsize 2+devsize+inodesize
- * +----+--------+--------+----------+
- * | cmd| dev | inode | fileid |
- * +----+--------+--------+----------+
- */
-#define KERNEL_OPLOCK_BREAK_DEV_OFFSET 2
-#define KERNEL_OPLOCK_BREAK_INODE_OFFSET (KERNEL_OPLOCK_BREAK_DEV_OFFSET + sizeof(SMB_DEV_T))
-#define KERNEL_OPLOCK_BREAK_FILEID_OFFSET (KERNEL_OPLOCK_BREAK_INODE_OFFSET + sizeof(SMB_INO_T))
-#define KERNEL_OPLOCK_BREAK_MSG_LEN (KERNEL_OPLOCK_BREAK_FILEID_OFFSET + sizeof(unsigned long))
-
-
#define CMD_REPLY 0x8000
-#include "smb_macros.h"
-
-/* A netbios name structure. */
-struct nmb_name {
- char name[17];
- char scope[64];
- uint_t name_type;
-};
-
-
-/* A netbios node status array element. */
-struct node_status {
- char name[16];
- uint8_t type;
- uint8_t flags;
-};
-
-#include "rpc_secdes.h"
-
-typedef struct user_struct
-{
- struct user_struct *next, *prev;
- uint16_t vuid; /* Tag for this entry. */
-
- char *session_keystr; /* used by utmp and pam session code.
- TDB key string */
- int homes_snum;
-
- struct auth_session_info *session_info;
-
-} user_struct;
-
-#include "client.h"
-
-/*
- Do you want session setups at user level security with a invalid
- password to be rejected or allowed in as guest? WinNT rejects them
- but it can be a pain as it means "net view" needs to use a password
-
- You have 3 choices in the setting of map_to_guest:
-
- "NEVER_MAP_TO_GUEST" means session setups with an invalid password
- are rejected. This is the default.
-
- "MAP_TO_GUEST_ON_BAD_USER" means session setups with an invalid password
- are rejected, unless the username does not exist, in which case it
- is treated as a guest login
-
- "MAP_TO_GUEST_ON_BAD_PASSWORD" means session setups with an invalid password
- are treated as a guest login
-
- Note that map_to_guest only has an effect in user or server
- level security.
-*/
-
-#define NEVER_MAP_TO_GUEST 0
-#define MAP_TO_GUEST_ON_BAD_USER 1
-#define MAP_TO_GUEST_ON_BAD_PASSWORD 2
-
-#define SAFE_NETBIOS_CHARS ". -_"
-
-/* generic iconv conversion structure */
-typedef struct {
- size_t (*direct)(void *cd, const char **inbuf, size_t *inbytesleft,
- char **outbuf, size_t *outbytesleft);
- size_t (*pull)(void *cd, const char **inbuf, size_t *inbytesleft,
- char **outbuf, size_t *outbytesleft);
- size_t (*push)(void *cd, const char **inbuf, size_t *inbytesleft,
- char **outbuf, size_t *outbytesleft);
- void *cd_direct, *cd_pull, *cd_push;
- char *from_name, *to_name;
-} *smb_iconv_t;
-
/* 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
+/* passed to br lock code */
+enum brl_type {READ_LOCK, WRITE_LOCK, PENDING_READ_LOCK, PENDING_WRITE_LOCK};
-/* a set of flags to control handling of request structures */
-#define REQ_CONTROL_PROTECTED (1<<0) /* don't destroy this request */
-#define REQ_CONTROL_LARGE (1<<1) /* allow replies larger than max_xmit */
-#define REQ_CONTROL_ASYNC (1<<2) /* the backend will answer this one later */
+/* string manipulation flags - see clistr.c and srvstr.c */
+#define STR_TERMINATE 1
+#define STR_UPPER 2
+#define STR_ASCII 4
+#define STR_UNICODE 8
+#define STR_NOALIGN 16
+#define STR_NO_RANGE_CHECK 32
+#define STR_LEN8BIT 64
+#define STR_TERMINATE_ASCII 128 /* only terminate if ascii */
+#define STR_LEN_NOTERM 256 /* the length field is the unterminated length */
-/* passed to br lock code */
-enum brl_type {READ_LOCK, WRITE_LOCK, PENDING_LOCK};
-#include "popt_common.h"
+/*
+ filesystem attribute bits
+*/
+#define FS_ATTR_CASE_SENSITIVE_SEARCH 0x00000001
+#define FS_ATTR_CASE_PRESERVED_NAMES 0x00000002
+#define FS_ATTR_UNICODE_ON_DISK 0x00000004
+#define FS_ATTR_PERSISTANT_ACLS 0x00000008
+#define FS_ATTR_COMPRESSION 0x00000010
+#define FS_ATTR_QUOTAS 0x00000020
+#define FS_ATTR_SPARSE_FILES 0x00000040
+#define FS_ATTR_REPARSE_POINTS 0x00000080
+#define FS_ATTR_REMOTE_STORAGE 0x00000100
+#define FS_ATTR_LFN_SUPPORT 0x00004000
+#define FS_ATTR_IS_COMPRESSED 0x00008000
+#define FS_ATTR_OBJECT_IDS 0x00010000
+#define FS_ATTR_ENCRYPTION 0x00020000
+#define FS_ATTR_NAMED_STREAMS 0x00040000
+
#endif /* _SMB_H */