/* Default number of hash buckets used in shared memory share mode */
#ifndef SHMEM_HASH_SIZE
+#ifdef SEMMSL
+#define SHMEM_HASH_SIZE (SEMMSL-1)
+#else
#define SHMEM_HASH_SIZE 113
#endif
+#endif
#define NMB_PORT 137
#define DGRAM_PORT 138
typedef int BOOL;
/* offset in shared memory */
-typedef int smb_shm_offset_t;
-#define NULL_OFFSET (smb_shm_offset_t)(0)
+#define NULL_OFFSET (int)(0)
+/* limiting size of ipc replies */
+#define REALLOC(ptr,size) Realloc(ptr,MAX((size),4*1024))
/*
Samba needs type definitions for int16, int32, uint16 and uint32.
#define DENY_FCB 7
/* share types */
-#define STYPE_DISKTREE 0 /* Disk drive */
-#define STYPE_PRINTQ 1 /* Spooler queue */
-#define STYPE_DEVICE 2 /* Serial device */
-#define STYPE_IPC 3 /* Interprocess communication (IPC) */
+#define STYPE_DISKTREE 0 /* Disk drive */
+#define STYPE_PRINTQ 1 /* Spooler queue */
+#define STYPE_DEVICE 2 /* Serial device */
+#define STYPE_IPC 3 /* Interprocess communication (IPC) */
+#define STYPE_HIDDEN 0x80000000 /* share is a hidden one (ends with $) */
/* SMB X/Open error codes for the ERRdos error class */
#define ERRbadfunc 1 /* Invalid function (or system call) */
typedef fstring string;
+/* pipe strings */
+#define PIPE_LANMAN "\\PIPE\\LANMAN"
+#define PIPE_SRVSVC "\\PIPE\\srvsvc"
+#define PIPE_NETLOGON "\\PIPE\\NETLOGON"
+#define PIPE_NTLSA "\\PIPE\\ntlsa"
+#define PIPE_LSARPC "\\PIPE\\lsarpc"
+
/* NETLOGON opcodes and data structures */
+enum RPC_PKT_TYPE
+{
+ RPC_REQUEST = 0x00,
+ RPC_RESPONSE = 0x02,
+ RPC_BIND = 0x0B,
+ RPC_BINDACK = 0x0C
+};
+
#define NET_QUERYFORPDC 7 /* Query for PDC */
#define NET_QUERYFORPDC_R 12 /* Response to Query for PDC */
#define NET_SAMLOGON 18
#define NETSERVERGETINFO 0x15
#define NETSHAREENUM 0x0f
+/* well-known RIDs - Relative IDs */
+
+/* RIDs - Well-known users ... */
+#define DOMAIN_USER_RID_ADMIN (0x000001F4L)
+#define DOMAIN_USER_RID_GUEST (0x000001F5L)
+
+/* RIDs - well-known groups ... */
+#define DOMAIN_GROUP_RID_ADMINS (0x00000200L)
+#define DOMAIN_GROUP_RID_USERS (0x00000201L)
+#define DOMAIN_GROUP_RID_GUESTS (0x00000202L)
+
+/* RIDs - well-known aliases ... */
+#define DOMAIN_ALIAS_RID_ADMINS (0x00000220L)
+#define DOMAIN_ALIAS_RID_USERS (0x00000221L)
+#define DOMAIN_ALIAS_RID_GUESTS (0x00000222L)
+#define DOMAIN_ALIAS_RID_POWER_USERS (0x00000223L)
+
+#define DOMAIN_ALIAS_RID_ACCOUNT_OPS (0x00000224L)
+#define DOMAIN_ALIAS_RID_SYSTEM_OPS (0x00000225L)
+#define DOMAIN_ALIAS_RID_PRINT_OPS (0x00000226L)
+#define DOMAIN_ALIAS_RID_BACKUP_OPS (0x00000227L)
+
+#define DOMAIN_ALIAS_RID_REPLICATOR (0x00000228L)
+
+
+
/* 32 bit time (sec) since 01jan1970 - cifs6.txt, section 3.5, page 30 */
typedef struct time_info
{
} NTTIME;
-#define MAXSUBAUTHS 10 /* max sub authorities in a SID */
+#define MAXSUBAUTHS 15 /* max sub authorities in a SID */
/* DOM_SID - security id */
typedef struct sid_info
{
- uint8 sid_no; /* SID revision number */
+ uint8 sid_rev_num; /* SID revision number */
uint8 num_auths; /* number of sub-authorities */
uint8 id_auth[6]; /* Identifier Authority */
- uint16 sub_auths[MAXSUBAUTHS]; /* pointer to sub-authorities. */
+ uint32 sub_auths[MAXSUBAUTHS]; /* pointer to sub-authorities. */
} DOM_SID;
} DOM_RID2;
+/* DOM_CLNT_SRV - client / server names */
+typedef struct clnt_srv_info
+{
+ uint32 undoc_buffer; /* undocumented 32 bit buffer pointer */
+ UNISTR2 uni_logon_srv; /* logon server name */
+ uint32 undoc_buffer2; /* undocumented 32 bit buffer pointer */
+ UNISTR2 uni_comp_name; /* client machine name */
+
+} DOM_CLNT_SRV;
+
/* DOM_LOG_INFO - login info */
typedef struct log_info
{
} DOM_CLNT_INFO;
+/* DOM_CLNT_INFO2 - client info */
+typedef struct clnt_info2
+{
+ DOM_CLNT_SRV login;
+ uint32 ptr_cred;
+ DOM_CRED cred;
+
+} DOM_CLNT_INFO2;
+
/* DOM_LOGON_ID - logon id */
typedef struct logon_info
{
/* DOM_ID_INFO_1 */
typedef struct id_info_1
{
+ uint32 ptr_id_info1; /* pointer to id_info_1 */
UNIHDR hdr_domain_name; /* domain name unicode header */
- uint32 param; /* param control */
+ uint32 param_ctrl; /* param control */
DOM_LOGON_ID logon_id; /* logon ID */
UNIHDR hdr_user_name; /* user name unicode header */
- UNIHDR hdr_workgroup_name; /* workgroup name unicode header */
+ UNIHDR hdr_wksta_name; /* workgroup name unicode header */
ARC4_OWF arc4_lm_owf; /* arc4 LM OWF Password */
ARC4_OWF arc4_nt_owf; /* arc4 NT OWF Password */
UNISTR2 uni_domain_name; /* domain name unicode string */
UNISTR2 uni_user_name; /* user name unicode string */
- UNISTR2 uni_workgroup_name; /* workgroup name unicode string */
+ UNISTR2 uni_wksta_name; /* workgroup name unicode string */
} DOM_ID_INFO_1;
/* SAM_INFO - sam logon/off id structure */
typedef struct sam_info
{
- DOM_CLNT_INFO client;
- DOM_CRED rtn_cred; /* return credentials */
- uint16 logon_level;
- uint32 auth_level; /* undocumented */
+ DOM_CLNT_INFO2 client;
+ uint32 ptr_rtn_cred; /* pointer to return credentials */
+ DOM_CRED rtn_cred; /* return credentials */
+ uint16 logon_level;
+ uint16 switch_value;
union
{
- DOM_ID_INFO_1 id1; /* auth-level 1 */
+ DOM_ID_INFO_1 *id1; /* auth-level 1 */
} auth;
/* DOM_GID - group id + user attributes */
typedef struct gid_info
{
- uint32 gid; /* group id */
+ uint32 g_rid; /* a group RID */
uint32 attr;
} DOM_GID;
uint32 alloc_hint; /* allocation hint - data size (bytes) minus header and tail. */
uint16 context_id; /* 0 - presentation context identifier */
uint8 cancel_count; /* 0 - cancel count */
- uint8 reserved; /* 0 - reserved */
+ uint8 opnum; /* request: 0 - reserved. response: opnum */
} RPC_HDR;
} LSA_POL_HND;
+/* OBJ_ATTR (object attributes) */
+typedef struct object_attributes_info
+{
+ uint32 len; /* 0x18 - length (in bytes) inc. the length field. */
+ uint32 ptr_root_dir; /* 0 - root directory (pointer) */
+ uint32 ptr_obj_name; /* 0 - object name (pointer) */
+ uint32 attributes; /* 0 - attributes (undocumented) */
+ uint32 ptr_sec_desc; /* 0 - security descriptior (pointer) */
+ uint32 sec_qos; /* 0 - security quality of service */
+
+} LSA_OBJ_ATTR;
+
+/* LSA_Q_OPEN_POL - LSA Query Open Policy */
+typedef struct lsa_q_open_pol_info
+{
+ UNISTR2 uni_server_name; /* server name, starting with two '\'s */
+ LSA_OBJ_ATTR attr ; /* object attributes */
+
+ uint32 des_access; /* desired access attributes */
+
+} LSA_Q_OPEN_POL;
/* LSA_R_OPEN_POL - response to LSA Open Policy */
typedef struct lsa_r_open_pol_info
{
DOM_QUERY_3 id3;
DOM_QUERY_5 id5;
+
} dom;
- uint32 status; /* return code */
+ uint32 status; /* return code */
} LSA_R_QUERY_INFO;
+/* LSA_Q_CLOSE */
+typedef struct lsa_q_close_info
+{
+ LSA_POL_HND pol; /* policy handle */
+
+} LSA_Q_CLOSE;
+
+/* LSA_R_CLOSE */
+typedef struct lsa_r_close_info
+{
+ LSA_POL_HND pol; /* policy handle. should be all zeros. */
+
+ uint32 status; /* return code */
+
+} LSA_R_CLOSE;
+
+
#define MAX_REF_DOMAINS 10
/* DOM_R_REF */
/* LSA_USER_INFO */
typedef struct lsa_q_user_info
{
- uint32 undoc_buffer;
+ uint32 ptr_user_info;
NTTIME logon_time; /* logon time */
NTTIME logoff_time; /* logoff time */
uint32 buffer_groups; /* undocumented buffer pointer to groups. */
uint32 user_flgs; /* user flags */
- char sess_key[16]; /* unused user session key */
+ char user_sess_key[16]; /* unused user session key */
UNIHDR hdr_logon_srv; /* logon server unicode string header */
UNIHDR hdr_logon_dom; /* logon domain unicode string header */
uint32 buffer_dom_id; /* undocumented logon domain id pointer */
- char padding[40]; /* unused padding bytes? */
+ char padding[40]; /* unused padding bytes. expansion room */
uint32 num_other_sids; /* 0 - num_sids */
uint32 buffer_other_sids; /* NULL - undocumented pointer to SIDs. */
uint32 buffer_creds; /* undocumented buffer pointer */
DOM_CRED srv_creds; /* server credentials. server time stamp appears to be ignored. */
- uint32 buffer_user;
+ uint16 switch_value; /* 3 - indicates type of USER INFO */
LSA_USER_INFO *user;
uint32 auth_resp; /* 1 - Authoritative response; 0 - Non-Auth? */
} LSA_R_SAM_LOGOFF;
+
+/* SH_INFO_1 (pointers to level 1 share info strings) */
+typedef struct ptr_share_info1
+{
+ uint32 ptr_netname; /* pointer to net name. */
+ uint32 type; /* type of share. 0 - undocumented. */
+ uint32 ptr_remark; /* pointer to comment. */
+
+} SH_INFO_1;
+
+/* SH_INFO_1_STR (level 1 share info strings) */
+typedef struct str_share_info1
+{
+ UNISTR2 uni_netname; /* unicode string of net name */
+ UNISTR2 uni_remark; /* unicode string of comment. */
+
+} SH_INFO_1_STR;
+
+/* oops - this is going to take up a *massive* amount of stack. */
+/* the UNISTR2s already have 1024 uint16 chars in them... */
+#define MAX_SHARE_ENTRIES 32
+
+/* SHARE_INFO_1_CONTAINER */
+typedef struct share_info_ctr
+{
+ uint32 num_entries_read; /* EntriesRead */
+ uint32 ptr_share_info; /* Buffer */
+ uint32 num_entries_read2; /* EntriesRead */
+ SH_INFO_1 info_1 [MAX_SHARE_ENTRIES]; /* share entry pointers */
+ SH_INFO_1_STR info_1_str[MAX_SHARE_ENTRIES]; /* share entry strings */
+ uint32 num_entries_read3; /* EntriesRead2 */
+ uint32 padding; /* padding */
+
+} SHARE_INFO_1_CTR;
+
+
+/* SRV_Q_NET_SHARE_ENUM */
+typedef struct q_net_share_enum_info
+{
+ uint32 ptr_srv_name; /* pointer (to server name?) */
+ UNISTR2 uni_srv_name; /* server name */
+
+ uint32 share_level; /* share level */
+ uint32 switch_value; /* switch value */
+
+ uint32 ptr_share_info; /* pointer to SHARE_INFO_1_CTR */
+
+ union
+ {
+ SHARE_INFO_1_CTR info1; /* share info with 0 entries */
+
+ } share;
+
+ uint32 preferred_len; /* preferred maximum length (0xffff ffff) */
+
+} SRV_Q_NET_SHARE_ENUM;
+
+
+/* SRV_R_NET_SHARE_ENUM */
+typedef struct r_net_share_enum_info
+{
+ uint32 share_level; /* share level */
+ uint32 switch_value; /* switch value */
+
+ uint32 ptr_share_info; /* pointer to SHARE_INFO_1_CTR */
+ union
+ {
+ SHARE_INFO_1_CTR info1; /* share info container */
+
+ } share;
+
+ uint32 status; /* return status */
+
+} SRV_R_NET_SHARE_ENUM;
+
+
+
/*
Yet to be turned into structures:
};
+struct cli_state {
+ int fd;
+ int cnum;
+ int pid;
+ int mid;
+ int uid;
+ int protocol;
+ int sec_mode;
+ int error;
+ int privilages;
+ fstring eff_name;
+ fstring desthost;
+ char cryptkey[8];
+ uint32 sesskey;
+ int serverzone;
+ uint32 servertime;
+ int readbraw_supported;
+ int writebraw_supported;
+ int timeout;
+ int max_xmit;
+ char *outbuf;
+ char *inbuf;
+ int bufsize;
+ int initialised;
+};
+
struct current_user
{
int cnum, id;
time_t atime;
time_t ctime;
pstring name;
+
} file_info;
{
DOM_CHAL clnt_chal; /* Initial challenge received from client */
DOM_CHAL srv_chal; /* Initial server challenge */
- DOM_CHAL clnt_cred; /* Last client credential */
- DOM_CHAL srv_cred; /* Last server credential */
+ DOM_CRED clnt_cred; /* Last client credential */
+ DOM_CRED srv_cred; /* Last server credential */
uint32 sess_key[2]; /* Session key */
uchar md4pw[16]; /* md4(machine password) */
int *igroups; /* an integer version - some OSes are broken :-( */
int *attrs; /* attributes associated with each gid */
-#if (defined(NETGROUP) && defined(AUTOMOUNT))
- char *home_share; /* to store NIS home of a user - simeon */
-#endif
-
int n_sids;
int *sids;
struct in_addr nmask;
};
-/* share mode record pointed to in shared memory hash bucket */
-typedef struct
-{
- smb_shm_offset_t next_offset; /* offset of next record in chain from hash bucket */
- int locking_version;
- int32 st_dev;
- int32 st_ino;
- int num_share_mode_entries;
- smb_shm_offset_t share_mode_entries; /* Chain of share mode entries for this file */
- char file_name[1];
-} share_mode_record;
-
-/* share mode entry pointed to by share_mode_record struct */
-typedef struct
-{
- smb_shm_offset_t next_share_mode_entry;
- int pid;
- uint16 op_port;
- uint16 op_type;
- int share_mode;
- struct timeval time;
-} share_mode_entry;
-
/* struct returned by get_share_modes */
typedef struct
{
uint16 op_type;
int share_mode;
struct timeval time;
-} min_share_mode_entry;
+} share_mode_entry;
-/* Token returned by lock_share_entry (actually ignored by FAST_SHARE_MODES code) */
-typedef int share_lock_token;
/* Conversion to hash entry index from device and inode numbers. */
#define HASH_ENTRY(dev,ino) ((( (uint32)(dev) )* ( (uint32)(ino) )) % lp_shmem_hash_size())
+/* each implementation of the share mode code needs
+ to support the following operations */
+struct share_ops {
+ BOOL (*stop_mgmt)(void);
+ BOOL (*lock_entry)(int , uint32 , uint32 , int *);
+ BOOL (*unlock_entry)(int , uint32 , uint32 , int );
+ BOOL (*get_entries)(int , int , uint32 , uint32 , share_mode_entry **);
+ void (*del_entry)(int , int );
+ BOOL (*set_entry)(int , int , uint16 , uint16 );
+ BOOL (*remove_oplock)(int , int);
+ int (*forall)(void (*)(share_mode_entry *, char *));
+ void (*status)(FILE *);
+};
+
+/* each implementation of the shared memory code needs
+ to support the following operations */
+struct shmem_ops {
+ BOOL (*close)( void );
+ int (*alloc)(int );
+ BOOL (*free)(int );
+ int (*get_userdef_off)(void);
+ void *(*offset2addr)(int );
+ int (*addr2offset)(void *addr);
+ BOOL (*lock_hash_entry)(unsigned int);
+ BOOL (*unlock_hash_entry)( unsigned int );
+ BOOL (*get_usage)(int *,int *,int *);
+};
+
+
/* this is used for smbstatus */
struct connect_record
{
#define LOCKING_VERSION 4
#endif /* LOCKING_VERSION */
-#if !defined(FAST_SHARE_MODES)
-/*
- * Defines for slow share modes.
- */
-
-/*
- * Locking file header lengths & offsets.
- */
-#define SMF_VERSION_OFFSET 0
-#define SMF_NUM_ENTRIES_OFFSET 4
-#define SMF_FILENAME_LEN_OFFSET 8
-#define SMF_HEADER_LENGTH 10
-
-#define SMF_ENTRY_LENGTH 20
-
-/*
- * Share mode record offsets.
- */
-
-#define SME_SEC_OFFSET 0
-#define SME_USEC_OFFSET 4
-#define SME_SHAREMODE_OFFSET 8
-#define SME_PID_OFFSET 12
-#define SME_PORT_OFFSET 16
-#define SME_OPLOCK_TYPE_OFFSET 18
-
-#endif /* FAST_SHARE_MODES */
-
/* these are useful macros for checking validity of handles */
#define VALID_FNUM(fnum) (((fnum) >= 0) && ((fnum) < MAX_OPEN_FILES))
#define OPEN_FNUM(fnum) (VALID_FNUM(fnum) && Files[fnum].open)
/*
* Core protocol.
*/
-#define CORE_OPLOCK_REQUEST(inbuf) (((CVAL(inbuf,smb_flg)|(1<<5))>>5) | \
- ((CVAL(inbuf,smb_flg)|(1<<6))>>5))
+#define CORE_OPLOCK_REQUEST(inbuf) ((CVAL(inbuf,smb_flg)&((1<<5)|(1<<6)))>>5)
/*
* Extended protocol.
*/
-#define EXTENDED_OPLOCK_REQUEST(inbuf) (((SVAL(inbuf,smb_vwv2)|(1<<1))>>1) | \
- ((SVAL(inbuf,smb_vwv2)|(1<<2))>>1))
+#define EXTENDED_OPLOCK_REQUEST(inbuf) ((SVAL(inbuf,smb_vwv2)&((1<<1)|(1<<2)))>>1)
/* Lock types. */
#define LOCKING_ANDX_SHARED_LOCK 0x1