converted another bunch of stuff to NTSTATUS
[samba.git] / source3 / include / smb.h
index 68df3f250c744edff4efb8dfd6e4f8a58e159544..ce6f0c794a0344a6d0d5f49e0ae9274bfeecf9ce 100644 (file)
@@ -27,6 +27,7 @@
 
 #define BUFFER_SIZE (0xFFFF)
 #define SAFETY_MARGIN 1024
+#define LARGE_WRITEX_HDR_SIZE 65
 
 #define NMB_PORT 137
 #define DGRAM_PORT 138
@@ -50,6 +51,13 @@ typedef int BOOL;
 #define DEF_CREATE_MASK (0755)
 #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
+
 /* how long to wait for secondary SMB packets (milli-seconds) */
 #define SMB_SECONDARY_WAIT (60*1000)
 
@@ -115,6 +123,11 @@ implemented */
 #define GET_DELETE_ON_CLOSE_FLAG(x) (((x) & DELETE_ON_CLOSE_FLAG) ? True : False)
 #define SET_DELETE_ON_CLOSE_FLAG(x) ((x) ? DELETE_ON_CLOSE_FLAG : 0)
 
+/* was delete access requested in NT open ? */
+#define DELETE_ACCESS_REQUESTED (1<<17)
+#define GET_DELETE_ACCESS_REQUESTED(x) (((x) & DELETE_ACCESS_REQUESTED) ? True : False)
+#define SET_DELETE_ACCESS_REQUESTED(x) ((x) ? DELETE_ACCESS_REQUESTED : 0)
+
 /* open disposition values */
 #define FILE_EXISTS_FAIL 0
 #define FILE_EXISTS_OPEN 1
@@ -139,116 +152,12 @@ implemented */
 #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) */
-#define ERRbadfile 2 /* File not found (pathname error) */
-#define ERRbadpath 3 /* Directory not found */
-#define ERRnofids 4 /* Too many open files */
-#define ERRnoaccess 5 /* Access denied */
-#define ERRbadfid 6 /* Invalid fid */
-#define ERRnomem 8 /* Out of memory */
-#define ERRbadmem 9 /* Invalid memory block address */
-#define ERRbadenv 10 /* Invalid environment */
-#define ERRbadaccess 12 /* Invalid open mode */
-#define ERRbaddata 13 /* Invalid data (only from ioctl call) */
-#define ERRres 14 /* reserved */
-#define ERRbaddrive 15 /* Invalid drive */
-#define ERRremcd 16 /* Attempt to delete current directory */
-#define ERRdiffdevice 17 /* rename/move across different filesystems */
-#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 ERRnosuchshare 67 /* You specified an invalid share name */
-#define ERRfilexists 80 /* File in operation already exists */
-#define ERRcannotopen 110 /* Cannot open the file specified */
-#define ERRunknownlevel 124
-#define ERRrename 183
-#define ERRbadpipe 230 /* Named pipe invalid */
-#define ERRpipebusy 231 /* All instances of pipe are busy */
-#define ERRpipeclosing 232 /* named pipe close in progress */
-#define ERRnotconnected 233 /* No process on other end of named pipe */
-#define ERRmoredata 234 /* More data to be returned */
-#define ERRbaddirectory 267 /* Invalid directory name in a path. */
-#define ERRunknownipc 2142
-
-#define ERROR_INVALID_FUNCTION           (1)
-#define ERROR_ACCESS_DENIED              (5)
-#define ERROR_INVALID_HANDLE             (6)
-#define ERROR_NOT_ENOUGH_MEMORY                  (8)
-#define ERROR_INVALID_PARAMETER                 (87)
-#define ERROR_INSUFFICIENT_BUFFER      (122)
-#define ERROR_INVALID_NAME             (123)
-#define ERROR_INVALID_LEVEL            (124)
-#define ERROR_NO_MORE_ITEMS            (259)
-#define ERROR_EAS_DIDNT_FIT            (275) /* Extended attributes didn't fit */
-#define ERROR_EAS_NOT_SUPPORTED                (282) /* Extended attributes not supported */
-#define ERROR_NOTIFY_ENUM_DIR         (1022) /* Buffer too small to return change notify. */
-#define ERROR_INVALID_PRINTER_NAME     (1801)
-#define ERROR_INVALID_DATATYPE        (1804)
-
-/* here's a special one from observing NT */
-#define ERRnoipc 66 /* don't support ipc */
-
-/* Error codes for the ERRSRV class */
-
-#define ERRerror 1 /* Non specific error code */
-#define ERRbadpw 2 /* Bad password */
-#define ERRbadtype 3 /* reserved */
-#define ERRaccess 4 /* No permissions to do the requested operation */
-#define ERRinvnid 5 /* tid invalid */
-#define ERRinvnetname 6 /* Invalid servername */
-#define ERRinvdevice 7 /* Invalid device */
-#define ERRqfull 49 /* Print queue full */
-#define ERRqtoobig 50 /* Queued item too big */
-#define ERRinvpfid 52 /* Invalid print file in smb_fid */
-#define ERRsmbcmd 64 /* Unrecognised command */
-#define ERRsrverror 65 /* smb server internal error */
-#define ERRfilespecs 67 /* fid and pathname invalid combination */
-#define ERRbadlink 68 /* reserved */
-#define ERRbadpermits 69 /* Access specified for a file is not valid */
-#define ERRbadpid 70 /* reserved */
-#define ERRsetattrmode 71 /* attribute mode invalid */
-#define ERRpaused 81 /* Message server paused */
-#define ERRmsgoff 82 /* Not receiving messages */
-#define ERRnoroom 83 /* No room for message */
-#define ERRrmuns 87 /* too many remote usernames */
-#define ERRtimeout 88 /* operation timed out */
-#define ERRnoresource  89 /* No resources currently available for request. */
-#define ERRtoomanyuids 90 /* too many userids */
-#define ERRbaduid 91 /* bad userid */
-#define ERRuseMPX 250 /* temporarily unable to use raw mode, use MPX mode */
-#define ERRuseSTD 251 /* temporarily unable to use raw mode, use standard mode */
-#define ERRcontMPX 252 /* resume MPX mode */
-#define ERRbadPW /* reserved */
-#define ERRnosupport 0xFFFF
-#define ERRunknownsmb 22 /* from NT 3.5 response */
-
-
-/* Error codes for the ERRHRD class */
-
-#define ERRnowrite 19 /* read only media */
-#define ERRbadunit 20 /* Unknown device */
-#define ERRnotready 21 /* Drive not ready */
-#define ERRbadcmd 22 /* Unknown command */
-#define ERRdata 23 /* Data (CRC) error */
-#define ERRbadreq 24 /* Bad request structure length */
-#define ERRseek 25
-#define ERRbadmedia 26
-#define ERRbadsector 27
-#define ERRnopaper 28
-#define ERRwrite 29 /* write fault */
-#define ERRread 30 /* read fault */
-#define ERRgeneral 31 /* General hardware failure */
-#define ERRwrongdisk 34
-#define ERRFCBunavail 35
-#define ERRsharebufexc 36 /* share buffer exceeded */
-#define ERRdiskfull 39
+#include "doserr.h"
 
 #ifndef _PSTRING
 
 #define PSTRING_LEN 1024
-#define FSTRING_LEN 128
+#define FSTRING_LEN 256
 
 typedef char pstring[PSTRING_LEN];
 typedef char fstring[FSTRING_LEN];
@@ -264,8 +173,18 @@ typedef char fstring[FSTRING_LEN];
 typedef uint16 smb_ucs2_t;
 
 /* ucs2 string types. */
-typedef smb_ucs2_t wpstring[1024];
-typedef smb_ucs2_t wfstring[128];
+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)
 
 /* pipe string names */
 #define PIPE_LANMAN   "\\PIPE\\LANMAN"
@@ -286,9 +205,21 @@ typedef struct nttime_info
 {
   uint32 low;
   uint32 high;
-
 } NTTIME;
 
+#ifdef __GNUC__XX_NOT_YET
+typedef struct {uint32 v;} NTSTATUS;
+#define NT_STATUS(x) ((NTSTATUS) { x })
+#define NT_STATUS_V(x) ((x).v)
+#else
+typedef uint32 NTSTATUS;
+#define NT_STATUS(x) (x)
+#define NT_STATUS_V(x) (x)
+#endif
+
+#define NT_STATUS_IS_OK(x) (NT_STATUS_V(x) == 0)
+#define NT_STATUS_IS_ERR(x) ((NT_STATUS_V(x) & 0xc0000000) == 0xc0000000)
+
 /* Allowable account control bits */
 #define ACB_DISABLED   0x0001  /* 1 = User account disabled */
 #define ACB_HOMDIRREQ  0x0002  /* 1 = Home directory required */
@@ -304,75 +235,36 @@ typedef struct nttime_info
  
 #define MAX_HOURS_LEN 32
 
-struct sam_passwd
+struct sam_disp_info
 {
-       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 */
-
+       uint32 user_rid;      /* Primary User ID */
        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 */
-
-       uid_t smb_userid;       /* this is actually the unix uid_t */
-       gid_t 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
+typedef struct
 {
-       uid_t smb_userid;     /* this is actually the unix uid_t */
-       char *smb_name;     /* username string */
+        uint32 pid;
+        uint16 vuid;
 
-       unsigned char *smb_passwd; /* Null if no password */
-       unsigned char *smb_nt_passwd; /* Null if no password */
+}
+vuser_key;
 
-       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 */
-};
 
 struct use_info
 {
        BOOL connected;
        char *srv_name;
+       vuser_key key;
        char *user_name;
        char *domain;
 };
 
+#ifndef MAXSUBAUTHS
 #define MAXSUBAUTHS 15 /* max sub authorities in a SID */
+#endif
 
+#ifndef _DOM_SID
 /* DOM_SID - security id */
 typedef struct sid_info
 {
@@ -386,7 +278,26 @@ typedef struct sid_info
   uint32 sub_auths[MAXSUBAUTHS];  /* pointer to sub-authorities. */
 
 } DOM_SID;
+#define _DOM_SID
+#endif
 
+/*
+ * 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.
+ */
+
+#ifndef _NT_USER_TOKEN
+typedef struct _nt_user_token {
+       size_t num_sids;
+       DOM_SID *user_sids;
+} NT_USER_TOKEN;
+#define _NT_USER_TOKEN
+#endif
 
 /*** query a local group, get a list of these: shows who is in that group ***/
 
@@ -431,25 +342,12 @@ typedef struct domain_grp_member_info
 
 } DOMAIN_GRP_MEMBER;
 
-/* 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;
-
 /* Structure used when SMBwritebmpx is active */
 typedef struct
 {
@@ -484,7 +382,6 @@ typedef struct files_struct
        SMB_OFF_T size;
        mode_t mode;
        uint16 vuid;
-       write_bmpx_struct *wbmpx_ptr;
        write_cache *wcp;
        struct timeval open_time;
        int share_mode;
@@ -544,8 +441,9 @@ typedef struct connection_struct
        char *connectpath;
        char *origpath;
 
-        struct vfs_ops vfs_ops;                   /* Filesystem operations */
-        struct vfs_connection_struct *vfs_conn;   /* VFS specific connection stuff */
+       struct vfs_ops vfs_ops;                   /* Filesystem operations */
+       /* Handle on dlopen() call */
+       void *dl_handle;
 
        char *user; /* name of user who *opened* this connection */
        uid_t uid; /* uid of user who *opened* this connection */
@@ -559,6 +457,7 @@ typedef struct connection_struct
        /* This groups info is valid for the user that *opened* the connection */
        int ngroups;
        gid_t *groups;
+       NT_USER_TOKEN *nt_user_token;
        
        time_t lastused;
        BOOL used;
@@ -577,34 +476,14 @@ struct current_user
        gid_t gid;
        int ngroups;
        gid_t *groups;
+       NT_USER_TOKEN *nt_user_token;
 };
 
-/*
- * Reasons for cache flush.
- */
-
-#define NUM_FLUSH_REASONS 8 /* Keep this in sync with the enum below. */
-enum flush_reason_enum { SEEK_FLUSH, READ_FLUSH, WRITE_FLUSH, READRAW_FLUSH,
-                         OPLOCK_RELEASE_FLUSH, CLOSE_FLUSH, SYNC_FLUSH, SIZECHANGE_FLUSH };     
-
 /* Defines for the sent_oplock_break field above. */
 #define NO_BREAK_SENT 0
 #define EXCLUSIVE_BREAK_SENT 1
 #define LEVEL_II_BREAK_SENT 2
 
-/* Domain controller authentication protocol info */
-struct dcinfo
-{
-  DOM_CHAL clnt_chal; /* Initial challenge received from client */
-  DOM_CHAL srv_chal;  /* Initial server challenge */
-  DOM_CRED clnt_cred; /* Last client credential */
-  DOM_CRED srv_cred;  /* Last server credential */
-
-  uchar  sess_key[8]; /* Session key */
-  uchar  md4pw[16];   /* md4(machine password) */
-};
-
-
 typedef struct {
        fstring smb_name; /* user name from the client */
        fstring unix_name; /* unix user name of a validated user */
@@ -612,7 +491,10 @@ typedef struct {
        fstring domain; /* domain that the client specified */
 } userdom_struct;
 
-enum {LPQ_QUEUED,LPQ_PAUSED,LPQ_SPOOLING,LPQ_PRINTING};
+/* Extra fields above "LPQ_PRINTING" are used to map extra NT status codes. */
+
+enum {LPQ_QUEUED=0,LPQ_PAUSED,LPQ_SPOOLING,LPQ_PRINTING,LPQ_ERROR,LPQ_DELETING,
+      LPQ_OFFLINE,LPQ_PAPEROUT,LPQ_PRINTED,LPQ_DELETED,LPQ_BLOCKED,LPQ_USER_INTERVENTION};
 
 typedef struct _print_queue_struct
 {
@@ -630,6 +512,7 @@ enum {LPSTAT_OK, LPSTAT_STOPPED, LPSTAT_ERROR};
 typedef struct
 {
   fstring message;
+  int qcount;
   int status;
 }  print_status_struct;
 
@@ -670,98 +553,47 @@ typedef struct
 #define SHAREMODE_FN(fn) \
        void (*fn)(share_mode_entry *, char*)
 
-/* each implementation of the share mode code needs
-   to support the following operations */
-struct share_ops {
-       BOOL (*stop_mgmt)(void);
-       BOOL (*lock_entry)(connection_struct *, SMB_DEV_T , SMB_INO_T , int *);
-       BOOL (*unlock_entry)(connection_struct *, SMB_DEV_T , SMB_INO_T , int );
-       int (*get_entries)(connection_struct *, int , SMB_DEV_T , SMB_INO_T , share_mode_entry **);
-       void (*del_entry)(int , files_struct *);
-       BOOL (*set_entry)(int, files_struct *, uint16 , uint16 );
-    BOOL (*mod_entry)(int, files_struct *, void (*)(share_mode_entry *, SMB_DEV_T, SMB_INO_T, void *), void *);
-       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 (*shm_close)( void );
-       int (*shm_alloc)(int );
-       BOOL (*shm_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 *);
-       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 *);
-  SMB_BIG_UINT (*getsmbpwpos)(void *);
-  BOOL (*setsmbpwpos)(void *, SMB_BIG_UINT);
-
-  /*
-   * smb password database query functions.
-   */
-  struct smb_passwd *(*getsmbpwnam)(char *);
-  struct smb_passwd *(*getsmbpwuid)(uid_t);
-  struct smb_passwd *(*getsmbpwrid)(uint32);
-  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);
-  BOOL (*del_smbpwd_entry)(const char *);
-
-  /*
-   * 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 *);
+typedef 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 */
 
-#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
-};
+       pstring username;     /* UNIX username string */
+       pstring domain;       /* Windows Domain name */
+       pstring nt_username;  /* Windows username string */
+       pstring full_name;    /* user's full name string */
+       pstring home_dir;     /* home directory string */
+       pstring dir_drive;    /* home directory drive string */
+       pstring logon_script; /* logon script string */
+       pstring profile_path; /* profile path string */
+       pstring acct_desc  ;  /* user description string */
+       pstring workstations; /* login from workstations string */
+       pstring unknown_str ; /* don't know what this is, yet. */
+       pstring munged_dial ; /* munged path name and dial-back tel number */
+
+        uid_t uid;          /* this is actually the unix uid_t */
+        gid_t gid;          /* this is actually the unix gid_t */
+        uint32 user_rid;    /* Primary User ID */
+        uint32 group_rid;   /* Primary Group ID */
+
+        unsigned char *lm_pw; /* Null if no password */
+        unsigned char *nt_pw; /* 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 */
+       
+} SAM_ACCOUNT;
 
 /*
  * Flags for local user manipulation.
@@ -789,7 +621,7 @@ struct connections_data {
        gid_t gid;
        char name[24];
        char addr[24];
-       char machine[128];
+       char machine[FSTRING_LEN];
        time_t start;
 };
 
@@ -812,7 +644,7 @@ struct locking_data {
 /* the following are used by loadparm for option lists */
 typedef enum
 {
-  P_BOOL,P_BOOLREV,P_CHAR,P_INTEGER,P_OCTAL,
+  P_BOOL,P_BOOLREV,P_CHAR,P_INTEGER,P_OCTAL,P_LIST,
   P_STRING,P_USTRING,P_GSTRING,P_UGSTRING,P_ENUM,P_SEP
 } parm_type;
 
@@ -851,6 +683,7 @@ struct parm_struct
                int ivalue;
                char *svalue;
                char cvalue;
+               char **lvalue;
        } def;
 };
 
@@ -865,7 +698,6 @@ struct bitmap {
 #define FLAG_GLOBAL    0x08 /* local options that should be globally settable in SWAT */
 #define FLAG_DEPRECATED 0x10 /* options that should no longer be used */
 #define FLAG_HIDE      0x20 /* options that should be hidden in SWAT */
-#define FLAG_DOS_STRING 0x40 /* convert from UNIX to DOS codepage when reading this string. */
 
 #ifndef LOCKING_VERSION
 #define LOCKING_VERSION 4
@@ -1141,7 +973,10 @@ struct bitmap {
 #define FILE_READ_ATTRIBUTES  0x080
 #define FILE_WRITE_ATTRIBUTES 0x100
 
-#define FILE_ALL_ATTRIBUTES   0x1FF
+#define FILE_ALL_ACCESS       0x1FF
+
+/* the desired access to use when opening a pipe */
+#define DESIRED_ACCESS_PIPE 0x2019f
  
 /* Generic access masks & rights. */
 #define SPECIFIC_RIGHTS_MASK 0x00FFFFL
@@ -1152,21 +987,45 @@ struct bitmap {
 #define WRITE_OWNER_ACCESS   (1L<<19)
 #define SYNCHRONIZE_ACCESS   (1L<<20)
 
+/* Combinations of standard masks. */
+#define STANDARD_RIGHTS_ALL_ACCESS (DELETE_ACCESS|READ_CONTROL_ACCESS|WRITE_DAC_ACCESS|WRITE_OWNER_ACCESS|SYNCHRONIZE_ACCESS)
+#define STANDARD_RIGHTS_EXECUTE_ACCESS (READ_CONTROL_ACCESS)
+#define STANDARD_RIGHTS_READ_ACCESS (READ_CONTROL_ACCESS)
+#define STANDARD_RIGHTS_REQUIRED_ACCESS (DELETE_ACCESS|READ_CONTROL_ACCESS|WRITE_DAC_ACCESS|WRITE_OWNER_ACCESS)
+#define STANDARD_RIGHTS_WRITE_ACCESS (READ_CONTROL_ACCESS)
+
 #define SYSTEM_SECURITY_ACCESS (1L<<24)
+#define MAXIMUM_ALLOWED_ACCESS (1L<<25)
 #define GENERIC_ALL_ACCESS   (1<<28)
 #define GENERIC_EXECUTE_ACCESS  (1<<29)
 #define GENERIC_WRITE_ACCESS   (1<<30)
 #define GENERIC_READ_ACCESS   (((unsigned)1)<<31)
 
-#define FILE_ALL_STANDARD_ACCESS 0x1F0000
+/* Mapping of generic access rights for files to specific rights. */
+
+#define FILE_GENERIC_ALL (STANDARD_RIGHTS_REQUIRED_ACCESS| SYNCHRONIZE_ACCESS|FILE_ALL_ACCESS)
+
+#define FILE_GENERIC_READ (STANDARD_RIGHTS_READ_ACCESS|FILE_READ_DATA|FILE_READ_ATTRIBUTES|\
+                                                       FILE_READ_EA|SYNCHRONIZE_ACCESS)
+
+#define FILE_GENERIC_WRITE (STANDARD_RIGHTS_WRITE_ACCESS|FILE_WRITE_DATA|FILE_WRITE_ATTRIBUTES|\
+                                                       FILE_WRITE_EA|FILE_APPEND_DATA|SYNCHRONIZE_ACCESS)
+
+#define FILE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE_ACCESS|FILE_READ_ATTRIBUTES|\
+                                                               FILE_EXECUTE|SYNCHRONIZE_ACCESS)
 
 /* Mapping of access rights to UNIX perms. */
-#if 0 /* Don't use all here... JRA. */
-#define UNIX_ACCESS_RWX (FILE_ALL_ATTRIBUTES|FILE_ALL_STANDARD_ACCESS)
-#else
-#define UNIX_ACCESS_RWX (UNIX_ACCESS_R|UNIX_ACCESS_W|UNIX_ACCESS_X)
-#endif
+#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
 
+#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.
+ */
+#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|\
@@ -1174,6 +1033,7 @@ struct bitmap {
                        FILE_APPEND_DATA|FILE_WRITE_DATA)
 #define UNIX_ACCESS_X (READ_CONTROL_ACCESS|SYNCHRONIZE_ACCESS|\
                        FILE_EXECUTE|FILE_READ_ATTRIBUTES)
+#endif
 
 #define UNIX_ACCESS_NONE (WRITE_OWNER_ACCESS)
 
@@ -1256,7 +1116,7 @@ struct bitmap {
 #define FILE_VOLUME_IS_COMPRESSED 0x8000
 
 /* ChangeNotify flags. */
-#define FILE_NOTIFY_CHANGE_FILE_NAME   0x001
+#define FILE_NOTIFY_CHANGE_FILE        0x001
 #define FILE_NOTIFY_CHANGE_DIR_NAME    0x002
 #define FILE_NOTIFY_CHANGE_ATTRIBUTES  0x004
 #define FILE_NOTIFY_CHANGE_SIZE        0x008
@@ -1265,6 +1125,7 @@ struct bitmap {
 #define FILE_NOTIFY_CHANGE_CREATION    0x040
 #define FILE_NOTIFY_CHANGE_EA          0x080
 #define FILE_NOTIFY_CHANGE_SECURITY    0x100
+#define FILE_NOTIFY_CHANGE_FILE_NAME   0x200
 
 /* where to find the base of the SMB packet proper */
 #define smb_base(buf) (((char *)(buf))+4)
@@ -1275,30 +1136,6 @@ struct bitmap {
 
 
 #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 HAVE_STDARG_H
-int slprintf(char *str, int n, char *format, ...)
-#ifdef __GNUC__
-     __attribute__ ((format (printf, 3, 4)))
-#endif
-;
-#else
-int slprintf();
-#endif
-
-#ifdef HAVE_STDARG_H
-int fdprintf(int fd, char *format, ...)
-#ifdef __GNUC__
-     __attribute__ ((format (printf, 2, 3)))
-#endif
-;
-#else
-int fdprintf();
-#endif
 
 #ifdef WITH_DFS
 void dfs_unlogin(void);
@@ -1317,53 +1154,6 @@ char *strdup(char *s);
 #define SELECT_CAST
 #endif
 
-
-/* Some POSIX definitions for those without */
-#ifndef S_IFDIR
-#define S_IFDIR         0x4000
-#endif
-#ifndef S_ISDIR
-#define S_ISDIR(mode)   ((mode & 0xF000) == S_IFDIR)
-#endif
-#ifndef S_IRWXU
-#define S_IRWXU 00700           /* read, write, execute: owner */
-#endif
-#ifndef S_IRUSR
-#define S_IRUSR 00400           /* read permission: owner */
-#endif
-#ifndef S_IWUSR
-#define S_IWUSR 00200           /* write permission: owner */
-#endif
-#ifndef S_IXUSR
-#define S_IXUSR 00100           /* execute permission: owner */
-#endif
-#ifndef S_IRWXG
-#define S_IRWXG 00070           /* read, write, execute: group */
-#endif
-#ifndef S_IRGRP
-#define S_IRGRP 00040           /* read permission: group */
-#endif
-#ifndef S_IWGRP
-#define S_IWGRP 00020           /* write permission: group */
-#endif
-#ifndef S_IXGRP
-#define S_IXGRP 00010           /* execute permission: group */
-#endif
-#ifndef S_IRWXO
-#define S_IRWXO 00007           /* read, write, execute: other */
-#endif
-#ifndef S_IROTH
-#define S_IROTH 00004           /* read permission: other */
-#endif
-#ifndef S_IWOTH
-#define S_IWOTH 00002           /* write permission: other */
-#endif
-#ifndef S_IXOTH
-#define S_IXOTH 00001           /* execute permission: other */
-#endif
-
-
 /* these are used in NetServerEnum to choose what to receive */
 #define SV_TYPE_WORKSTATION         0x00000001
 #define SV_TYPE_SERVER              0x00000002
@@ -1394,17 +1184,21 @@ char *strdup(char *s);
 #define SV_TYPE_DOMAIN_ENUM         0x80000000
 #define SV_TYPE_ALL                 0xFFFFFFFF  
 
-/* what server type are we currently  - JHT Says we ARE 4.20 */
-/* this was set by JHT in liaison with Jeremy Allison early 1997 */
-/* setting to 4.20 at same time as announcing ourselves as NT Server */
-/* History: */
-/* Version 4.0 - never made public */
-/* Version 4.10 - New to 1.9.16p2, lost in space 1.9.16p3 to 1.9.16p9 */
-/*             - Reappeared in 1.9.16p11 with fixed smbd services */
-/* Version 4.20 - To indicate that nmbd and browsing now works better */
-
+/* 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.16p2, lost in space 1.9.16p3 to 1.9.16p9
+ *              - Reappeared in 1.9.16p11 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
+ */
 #define DEFAULT_MAJOR_VERSION 0x04
-#define DEFAULT_MINOR_VERSION 0x02
+#define DEFAULT_MINOR_VERSION 0x05
 
 /* Browser Election Values */
 #define BROWSER_ELECTION_VERSION       0x010f
@@ -1434,7 +1228,9 @@ char *strdup(char *s);
 #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_EXTENDED_SECURITY 0x80000000
 
 /* protocol types. It assumes that higher protocols include lower protocols
@@ -1455,7 +1251,12 @@ enum server_types
 
 /* printing types */
 enum printing_types {PRINT_BSD,PRINT_SYSV,PRINT_AIX,PRINT_HPUX,
-                    PRINT_QNX,PRINT_PLP,PRINT_LPRNG,PRINT_SOFTQ,PRINT_CUPS};
+                    PRINT_QNX,PRINT_PLP,PRINT_LPRNG,PRINT_SOFTQ,
+                    PRINT_CUPS,PRINT_LPRNT,PRINT_LPROS2
+#ifdef DEVELOPER
+,PRINT_TEST,PRINT_VLP
+#endif /* DEVELOPER */
+};
 
 /* Remote architectures we know about. */
 enum remote_arch_types {RA_UNKNOWN, RA_WFWG, RA_OS2, RA_WIN95, RA_WINNT, RA_WIN2K, RA_SAMBA};
@@ -1636,6 +1437,17 @@ struct kernel_oplocks {
 
 #define CMD_REPLY 0x8000
 
+/* this structure defines the functions for doing change notify in
+   various implementations */
+struct cnotify_fns {
+       void * (*register_notify)(connection_struct *conn, char *path, uint32 flags);
+       BOOL (*check_notify)(connection_struct *conn, uint16 vuid, char *path, uint32 flags, void *data, time_t t);
+       void (*remove_notify)(void *data);
+       int select_time;
+};
+
+
+
 #include "smb_macros.h"
 
 /* A netbios name structure. */
@@ -1645,6 +1457,16 @@ struct nmb_name {
   unsigned int name_type;
 };
 
+
+/* A netbios node status array element. */
+struct node_status {
+       char name[16];
+       unsigned char type;
+       unsigned char flags;
+};
+
+
+
 #define AGENT_CMD_CON       0
 #define AGENT_CMD_CON_ANON  2
 #define AGENT_CMD_CON_REUSE 1
@@ -1671,29 +1493,27 @@ struct pwd_info
        uchar sess_key[16];
 };
 
-struct ntdom_info
+/*
+ * Network Computing Architechture Context Name Named Pipe
+ * See MSDN docs for more information
+ */
+struct ncacn_np
 {
-       unsigned char sess_key[16];        /* Current session key. */
-       unsigned char ntlmssp_hash[258];   /* ntlmssp data. */
-       uint32 ntlmssp_cli_flgs;           /* ntlmssp client flags */
-       uint32 ntlmssp_srv_flgs;           /* ntlmssp server flags */
-       uint32 ntlmssp_seq_num;            /* ntlmssp sequence number */
-       DOM_CRED clnt_cred;                /* Client credential. */
-
-       int max_recv_frag;
-       int max_xmit_frag;
+        fstring pipe_name;
+        struct cli_state *smb;
+        uint16 fnum;
+        BOOL initialised;
 };
 
 #include "rpc_creds.h"
+#include "rpc_misc.h"
 #include "rpc_secdes.h"
 #include "nt_printing.h"
-#include "ntdomain.h"
-
-#include "client.h"
-#include "rpcclient.h"
 
-typedef struct
+typedef struct user_struct
 {
+       struct user_struct *next, *prev;
+       uint16 vuid; /* Tag for this entry. */
        uid_t uid; /* uid of a validated user */
        gid_t gid; /* gid of a validated user */
 
@@ -1705,18 +1525,16 @@ typedef struct
        int n_groups;
        gid_t *groups;
 
-#if 0
-       NET_USER_INFO_3 usr; /* This should not be here. */
-#else
-       DOM_SID user_sid;
-       DOM_SID *group_sids;
-#endif
+       NT_USER_TOKEN *nt_user_token;
 
-       /* per-user authentication information on NT RPCs */
-       /* lkclXXXX - THIS SHOULD NOT BE HERE! */
-       struct dcinfo dc;
+       int session_id; /* used by utmp and pam session code */
 } user_struct;
 
+#include "ntdomain.h"
+
+#include "client.h"
+#include "rpcclient.h"
+
 /*
  * Size of new password account encoding string. DO NOT CHANGE.
  */
@@ -1748,4 +1566,29 @@ typedef struct
 #define MAP_TO_GUEST_ON_BAD_USER 1
 #define MAP_TO_GUEST_ON_BAD_PASSWORD 2
 
+#define SAFE_NETBIOS_CHARS ". -_"
+
+#include "nsswitch/winbindd_nss.h"
+#include "smb_acls.h"
+
+/* Used by winbindd_glue functions */
+
+typedef struct {
+       struct cli_state *cli;
+       POLICY_HND handle;
+       TALLOC_CTX *mem_ctx;
+} CLI_POLICY_HND;
+
+
+/* generic iconv conversion structure */
+typedef struct {
+       size_t (*direct)(void *cd, char **inbuf, size_t *inbytesleft,
+                        char **outbuf, size_t *outbytesleft);
+       size_t (*pull)(void *cd, char **inbuf, size_t *inbytesleft,
+                      char **outbuf, size_t *outbytesleft);
+       size_t (*push)(void *cd, char **inbuf, size_t *inbytesleft,
+                      char **outbuf, size_t *outbytesleft);
+       void *cd_direct, *cd_pull, *cd_push;
+} *smb_iconv_t;
+
 #endif /* _SMB_H */