Makefile: Added nttrans.o
[kai/samba.git] / source / include / smb.h
index 0acc5cbfa340f79981fe8a7a8f80de20ec278186..ca295f3b42bda545236256cfe6cee44402be1275 100644 (file)
@@ -100,10 +100,12 @@ typedef unsigned int uint32;
 /* debugging code */
 #ifndef SYSLOG
 #define DEBUG(level,body) ((DEBUGLEVEL>=(level))?(Debug1 body):0)
+#define DEBUGLVL(level) (DEBUGLEVEL>=(level))
 #else
 extern int syslog_level;
 
 #define DEBUG(level,body) ((DEBUGLEVEL>=(level))? (syslog_level = (level), Debug1 body):0)
+#define DEBUGLVL(level) ( DEBUGLEVEL >= (syslog_level=(level)) )
 #endif
 
 /* this defines the error codes that receive_smb can put in smb_read_error */
@@ -162,6 +164,7 @@ implemented */
 #define ERRnofiles 18 /* no more files found in file search */
 #define ERRbadshare 32 /* Share mode on file conflict with open mode */
 #define ERRlock 33 /* Lock request conflicts with existing lock */
+#define ERRunsup 50 /* Request unsupported, returned by Win 95, RJS 20Jun98 */
 #define ERRfilexists 80 /* File in operation already exists */
 #define ERRcannotopen 110 /* Cannot open the file specified */
 #define ERRunknownlevel 124
@@ -237,8 +240,6 @@ implemented */
 
 typedef char pstring[1024];
 typedef char fstring[128];
-typedef fstring string;
-
 
 /* pipe strings */
 #define PIPE_LANMAN   "\\PIPE\\LANMAN"
@@ -251,12 +252,6 @@ typedef fstring string;
 #define PIPE_LSASS    "\\PIPE\\lsass"
 #define PIPE_LSARPC   "\\PIPE\\lsarpc"
 
-/* 32 bit time (sec) since 01jan1970 - cifs6.txt, section 3.5, page 30 */
-typedef struct time_info
-{
-  uint32 time;
-
-} UTIME;
 
 /* 64 bit time (100usec) since ????? - cifs6.txt, section 3.5, page 30 */
 typedef struct nttime_info
@@ -279,40 +274,120 @@ typedef struct nttime_info
 #define ACB_PWNOEXP    0x0200  /* 1 = User password does not expire */
 #define ACB_AUTOLOCK   0x0400  /* 1 = Account auto locked */
  
+#define MAX_HOURS_LEN 32
+
+struct sam_passwd
+{
+       time_t logon_time;            /* logon time */
+       time_t logoff_time;           /* logoff time */
+       time_t kickoff_time;          /* kickoff time */
+       time_t pass_last_set_time;    /* password last set time */
+       time_t pass_can_change_time;  /* password can change time */
+       time_t pass_must_change_time; /* password must change time */
+
+       char *smb_name;     /* username string */
+       char *full_name;    /* user's full name string */
+       char *home_dir;     /* home directory string */
+       char *dir_drive;    /* home directory drive string */
+       char *logon_script; /* logon script string */
+       char *profile_path; /* profile path string */
+       char *acct_desc  ;  /* user description string */
+       char *workstations; /* login from workstations string */
+       char *unknown_str ; /* don't know what this is, yet. */
+       char *munged_dial ; /* munged path name and dial-back tel number */
+
+       int smb_userid;       /* this is actually the unix uid_t */
+       int smb_grpid;        /* this is actually the unix gid_t */
+       uint32 user_rid;      /* Primary User ID */
+       uint32 group_rid;     /* Primary Group ID */
+
+       unsigned char *smb_passwd; /* Null if no password */
+       unsigned char *smb_nt_passwd; /* Null if no password */
+
+       uint16 acct_ctrl; /* account info (ACB_xxxx bit-mask) */
+       uint32 unknown_3; /* 0x00ff ffff */
+
+       uint16 logon_divs; /* 168 - number of hours in a week */
+       uint32 hours_len; /* normally 21 bytes */
+       uint8 hours[MAX_HOURS_LEN];
+
+       uint32 unknown_5; /* 0x0002 0000 */
+       uint32 unknown_6; /* 0x0000 04ec */
+};
+
 struct smb_passwd
 {
-       int smb_userid;
-       char *smb_name;
+       int smb_userid;     /* this is actually the unix uid_t */
+       char *smb_name;     /* username string */
+
        unsigned char *smb_passwd; /* Null if no password */
        unsigned char *smb_nt_passwd; /* Null if no password */
-       /* Other fields / flags may be added later */
-        uint16 acct_ctrl;
+
+       uint16 acct_ctrl; /* account info (ACB_xxxx bit-mask) */
+       time_t pass_last_set_time;    /* password last set time */
+};
+
+
+struct sam_disp_info
+{
+       uint32 user_rid;      /* Primary User ID */
+       char *smb_name;     /* username string */
+       char *full_name;    /* user's full name string */
 };
 
+/* DOM_CHAL - challenge info */
+typedef struct chal_info
+{
+  uchar data[8]; /* credentials */
+} DOM_CHAL;
+
+/* 32 bit time (sec) since 01jan1970 - cifs6.txt, section 3.5, page 30 */
+typedef struct time_info
+{
+  uint32 time;
+} UTIME;
+
+/* DOM_CREDs - timestamped client or server credentials */
+typedef struct cred_info
+{  
+  DOM_CHAL challenge; /* credentials */
+  UTIME timestamp;    /* credential time-stamp */
+} DOM_CRED;
+
 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;
+  int fd;
+  int cnum;
+  int pid;
+  int mid;
+  int uid;
+  int protocol;
+  int sec_mode;
+  int rap_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;
+  /*
+   * Only used in NT domain calls.
+   */
+  uint32 nt_error;                   /* NT RPC error code. */
+  uint16 nt_pipe_fnum;               /* Pipe handle. */
+  unsigned char sess_key[16];        /* Current session key. */
+  DOM_CRED clnt_cred;                /* Client credential. */
+  fstring mach_acct;                 /* MYNAME$. */
+  fstring srv_name_slash;            /* \\remote server. */
+  fstring clnt_name_slash;            /* \\local client. */
 };
 
 
@@ -361,6 +436,8 @@ typedef struct
 typedef struct
 {
   uint16 ref_count;
+  uint16 uid_cache_count;
+  uid_t uid_users_cache[10];
   uint32 dev;
   uint32 inode;
   int fd;
@@ -443,20 +520,6 @@ typedef struct
 
 } connection_struct;
 
-/* DOM_CHAL - challenge info */
-typedef struct chal_info
-{
-  uchar data[8]; /* credentials */
-} DOM_CHAL;
-
-/* DOM_CREDs - timestamped client or server credentials */
-typedef struct cred_info
-{  
-  DOM_CHAL challenge; /* credentials */
-  UTIME timestamp;    /* credential time-stamp */
-
-} DOM_CRED;
-
 /* Domain controller authentication protocol info */
 struct dcinfo
 {
@@ -474,7 +537,8 @@ typedef struct
   int uid; /* uid of a validated user */
   int gid; /* gid of a validated user */
 
-  fstring name; /* name of a validated user */
+  fstring requested_name; /* user name from the client */
+  fstring name; /* unix user name of a validated user */
   fstring real_name;   /* to store real name from password file - simeon */
   BOOL guest;
 
@@ -575,8 +639,70 @@ struct shmem_ops {
        unsigned (*hash_size)(void);
 };
 
+/*
+ * Each implementation of the password database code needs
+ * to support the following operations.
+ */
+
+struct passdb_ops {
+  /*
+   * Password database ops.
+   */
+  void *(*startsmbpwent)(BOOL);
+  void (*endsmbpwent)(void *);
+  unsigned long (*getsmbpwpos)(void *);
+  BOOL (*setsmbpwpos)(void *, unsigned long);
+
+  /*
+   * smb password database query functions.
+   */
+  struct smb_passwd *(*getsmbpwnam)(char *);
+  struct smb_passwd *(*getsmbpwuid)(uid_t);
+  struct smb_passwd *(*getsmbpwent)(void *);
+
+  /*
+   * smb password database modification functions.
+   */
+  BOOL (*add_smbpwd_entry)(struct smb_passwd *);
+  BOOL (*mod_smbpwd_entry)(struct smb_passwd *, BOOL);
+
+  /*
+   * Functions that manupulate a struct sam_passwd.
+   */
+  struct sam_passwd *(*getsam21pwent)(void *);
+
+  /*
+   * sam password database query functions.
+   */
+  struct sam_passwd *(*getsam21pwnam)(char *);
+  struct sam_passwd *(*getsam21pwuid)(uid_t);
+  struct sam_passwd *(*getsam21pwrid)(uint32);
+
+  /*
+   * sam password database modification functions.
+   */
+  BOOL (*add_sam21pwd_entry)(struct sam_passwd *);
+  BOOL (*mod_sam21pwd_entry)(struct sam_passwd *, BOOL);
+
+  /*
+   * sam query display info functions.
+   */
+  struct sam_disp_info *(*getsamdispnam)(char *);
+  struct sam_disp_info *(*getsamdisprid)(uint32);
+  struct sam_disp_info *(*getsamdispent)(void *);
+
+#if 0
+  /*
+   * password checking functions
+   */
+  struct smb_passwd *(*smb_password_chal  )(char *username, char lm_pass[24], char nt_pass[24], char chal[8]);
+  struct smb_passwd *(*smb_password_check )(char *username, char lm_hash[16], char nt_hash[16]);
+  struct passwd     *(*unix_password_check)(char *username, char *pass, int pass_len);
+#endif
+};
 
 /* this is used for smbstatus */
+
 struct connect_record
 {
   int magic;
@@ -632,7 +758,7 @@ struct parm_struct
        parm_type type;
        parm_class class;
        void *ptr;
-       BOOL (*special)();
+       BOOL (*special)(char *, char **);
        struct enum_list *enum_list;
        unsigned flags;
        union {
@@ -883,20 +1009,154 @@ struct parm_struct
 #define smb_droff smb_vwv7
 #define smb_drdisp smb_vwv8
 
+/* 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)
+#define smb_nt_SetupStart (smb_vwv0 + 39)
+
+/* 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)
+
+/* 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)
+
+/* these are for the NT create_and_X */
+#define smb_ntcreate_NameLength (smb_vwv0 + 5)
+#define smb_ntcreate_Flags (smb_vwv0 + 7)
+#define smb_ntcreate_RootDirectoryFid (smb_wvw0 + 11)
+#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)
+
+/* these are the constants used in the above call. */
+/* DesiredAccess */
+/* File Specific access rights. */
+#define FILE_READ_DATA        0x001
+#define FILE_WRITE_DATA       0x002
+#define FILE_APPEND_DATA      0x004
+#define FILE_READ_EA          0x008
+#define FILE_WRITE_EA         0x010
+#define FILE_EXECUTE          0x020
+#define FILE_DELETE_CHILD     0x040
+#define FILE_READ_ATTRIBUTES  0x080
+#define FILE_WRITE_ATTRIBUTES 0x100
+/* Generic access masks & rights. */
+#define SPECIFIC_RIGHTS_MASK 0x00FFFFL
+#define STANDARD_RIGHTS_MASK 0xFF0000L
+#define DELETE_ACCESS        (1L<<16)
+#define READ_CONTROL_ACCESS  (1L<<17)
+#define WRITE_DAC_ACCESS     (1L<<18)
+#define WRITE_OWNER_ACCESS   (1L<<19)
+#define SYNCHRONIZE_ACCESS   (1L<<20)
+#define SYSTEM_SECURITY_ACCESS (1L<<24)
+
+/* Flags field. */
+#define REQUEST_OPLOCK 2
+#define REQUEST_BATCH_OPLOCK 4
+#define OPEN_DIRECTORY 8
+
+/* ShareAccess field. */
+#define FILE_SHARE_NONE 0 /* Cannot be used in bitmask. */
+#define FILE_SHARE_READ 1
+#define FILE_SHARE_WRITE 2
+#define FILE_SHARE_DELETE 4
+
+/* FileAttributesField */
+#define FILE_ATTRIBUTE_READONLY aRONLY
+#define FILE_ATTRIBUTE_HIDDEN aHIDDEN
+#define FILE_ATTRIBUTE_SYSTEM aSYSTEM
+#define FILE_ATTRIBUTE_DIRECTORY aDIR
+#define FILE_ATTRIBUTE_ARCHIVE aARCH
+#define FILE_ATTRIBUTE_NORMAL 0x80L
+#define FILE_ATTRIBUTE_TEMPORARY 0x100L
+#define FILE_ATTRIBUTE_COMPRESSED 0x800L
+#define SAMBA_ATTRIBUTES_MASK 0x7F
+
+/* Flags - combined with attributes. */
+#define FILE_FLAG_WRITE_THROUGH    0x80000000L
+#define FILE_FLAG_NO_BUFFERING     0x20000000L
+#define FILE_FLAG_RANDOM_ACCESS    0x10000000L
+#define FILE_FLAG_SEQUENTIAL_SCAN  0x08000000L
+#define FILE_FLAG_DELETE_ON_CLOSE  0x04000000L
+#define FILE_FLAG_BACKUP_SEMANTICS 0x02000000L
+#define FILE_FLAG_POSIX_SEMANTICS  0x01000000L
+
+/* CreateDisposition field. */
+#define FILE_SUPERSEDE 0
+#define FILE_OPEN 1
+#define FILE_CREATE 2
+#define FILE_OPEN_IF 3
+#define FILE_OVERWRITE 4
+#define FILE_OVERWRITE_IF 5
+
+/* Responses when opening a file. */
+#define FILE_WAS_OPENED 1
+#define FILE_WAS_CREATED 2
+#define FILE_WAS_OVERWRITTEN 3
+
+/* File type flags */
+#define FILE_TYPE_DISK  0
+#define FILE_TYPE_BYTE_MODE_PIPE 1
+#define FILE_TYPE_MESSAGE_MODE_PIPE 2
+#define FILE_TYPE_PRINTER 3
+#define FILE_TYPE_COMM_DEVICE 4
+#define FILE_TYPE_UNKNOWN 0xFFFF
+
+/* Flag for NT transact rename call. */
+#define RENAME_REPLACE_IF_EXISTS 1
+
+/* Filesystem Attributes. */
+#define FILE_CASE_SENSITIVE_SEARCH 0x1
+#define FILE_CASE_PRESERVED_NAMES 0x2
+#define FILE_UNICODE_ON_DISK 0x4
+#define FILE_PERISITANT_ACLS 0x8
+
 /* where to find the base of the SMB packet proper */
 #define smb_base(buf) (((char *)(buf))+4)
 
 
-#define SUCCESS 0  /* The request was successful. */
+#define SMB_SUCCESS 0  /* The request was successful. */
 #define ERRDOS 0x01 /*  Error is from the core DOS operating system set. */
 #define ERRSRV 0x02  /* Error is generated by the server network file manager.*/
 #define ERRHRD 0x03  /* Error is an hardware error. */
 #define ERRCMD 0xFF  /* Command was not in the "SMB" format. */
 
 #ifdef __STDC__
-int Debug1(char *, ...);
+int Debug1(char *, ...); 
+int slprintf(char *str, int n, char *format, ...);
 #else
-int Debug1();
+int Debug1(); 
+int slprintf();
 #endif
 
 #ifdef DFS_AUTH
@@ -1060,11 +1320,11 @@ char *Strstr(char *s, char *p);
 enum protocol_types {PROTOCOL_NONE,PROTOCOL_CORE,PROTOCOL_COREPLUS,PROTOCOL_LANMAN1,PROTOCOL_LANMAN2,PROTOCOL_NT1};
 
 /* security levels */
-enum security_types {SEC_SHARE,SEC_USER,SEC_SERVER};
+enum security_types {SEC_SHARE,SEC_USER,SEC_SERVER,SEC_DOMAIN};
 
 /* printing types */
 enum printing_types {PRINT_BSD,PRINT_SYSV,PRINT_AIX,PRINT_HPUX,
-                    PRINT_QNX,PRINT_PLP,PRINT_LPRNG};
+                    PRINT_QNX,PRINT_PLP,PRINT_LPRNG,PRINT_SOFTQ};
 
 /* Remote architectures we know about. */
 enum remote_arch_types {RA_UNKNOWN, RA_WFWG, RA_OS2, RA_WIN95, RA_WINNT, RA_SAMBA};
@@ -1072,6 +1332,10 @@ enum remote_arch_types {RA_UNKNOWN, RA_WFWG, RA_OS2, RA_WIN95, RA_WINNT, RA_SAMB
 /* case handling */
 enum case_handling {CASE_LOWER,CASE_UPPER};
 
+#ifdef USE_SSL
+/* SSL version options */
+enum ssl_version_enum {SMB_SSL_V2,SMB_SSL_V3,SMB_SSL_V23,SMB_SSL_TLS1};
+#endif /* USE_SSL */
 
 /* Macros to get at offsets within smb_lkrng and smb_unlkrng
    structures. We cannot define these as actual structures
@@ -1115,6 +1379,7 @@ enum case_handling {CASE_LOWER,CASE_UPPER};
 #define KANJI_CODEPAGE 932
 #define HANGUL_CODEPAGE 949
 #define BIG5_CODEPAGE 950
+#define SIMPLIFIED_CHINESE_CODEPAGE 936
 
 #ifdef KANJI
 /*