Restructuring of vfs layer to include a "this" pointer - can be an fsp or
[kamenim/samba-autobuild/.git] / source3 / include / smb.h
index f61c8cbbadc851a0dd2f6b8c49782ae25c0cb226..24211b0d50ddeb671e95fb7b6688d0970e041ae7 100644 (file)
@@ -34,6 +34,7 @@
 
 #define False (0)
 #define True (1)
+#define Auto (2)
 
 #ifndef _BOOL
 typedef int BOOL;
@@ -179,12 +180,15 @@ implemented */
 #define ERROR_INSUFFICIENT_BUFFER      (122)
 #define ERROR_INVALID_NAME             (123)
 #define ERROR_INVALID_LEVEL            (124)
+#define ERROR_MORE_DATA         (234)
 #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_UNKNOWN_PRINTER_DRIVER   (1797)
 #define ERROR_INVALID_PRINTER_NAME     (1801)
 #define ERROR_INVALID_DATATYPE        (1804)
+#define ERROR_INVALID_ENVIRONMENT      (1805)
 
 /* here's a special one from observing NT */
 #define ERRnoipc 66 /* don't support ipc */
@@ -278,6 +282,7 @@ typedef smb_ucs2_t wfstring[128];
 #define PIPE_LSASS    "\\PIPE\\lsass"
 #define PIPE_LSARPC   "\\PIPE\\lsarpc"
 #define PIPE_SPOOLSS  "\\PIPE\\spoolss"
+#define PIPE_NETDFS   "\\PIPE\\netdfs"
 
 /* 64 bit time (100usec) since ????? - cifs6.txt, section 3.5, page 30 */
 typedef struct nttime_info
@@ -361,16 +366,29 @@ struct sam_disp_info
        char *full_name;    /* user's full name string */
 };
 
+typedef struct
+{
+        uint32 pid;
+        uint16 vuid;
+
+}
+vuser_key;
+
+
 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
 {
@@ -384,7 +402,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 ***/
 
@@ -542,8 +579,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 */
@@ -557,6 +595,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;
@@ -575,6 +614,7 @@ struct current_user
        gid_t gid;
        int ngroups;
        gid_t *groups;
+       NT_USER_TOKEN *nt_user_token;
 };
 
 /*
@@ -583,8 +623,7 @@ struct current_user
 
 #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 };     
-
+                       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
@@ -603,25 +642,12 @@ struct dcinfo
 };
 
 
-typedef struct
-{
-       uid_t uid; /* uid of a validated user */
-       gid_t gid; /* gid 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;
-
-       /* following groups stuff added by ih */
-       /* This groups info is needed for when we become_user() for this uid */
-       int n_groups;
-       gid_t *groups;
-
-       /* per-user authentication information on NT RPCs */
-       /* lkclXXXX - THIS SHOULD NOT BE HERE! */
-       struct dcinfo dc;
-} user_struct;
+typedef struct {
+       fstring smb_name; /* user name from the client */
+       fstring unix_name; /* unix user name of a validated user */
+       fstring full_name; /* to store full name (such as "Joe Bloggs") from gecos field of password file */
+       fstring domain; /* domain that the client specified */
+} userdom_struct;
 
 enum {LPQ_QUEUED,LPQ_PAUSED,LPQ_SPOOLING,LPQ_PRINTING};
 
@@ -681,35 +707,6 @@ 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.
@@ -1163,21 +1160,22 @@ 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 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_R (READ_CONTROL_ACCESS|SYNCHRONIZE_ACCESS|\
                        FILE_READ_ATTRIBUTES|FILE_READ_EA|FILE_READ_DATA)
 #define UNIX_ACCESS_W (READ_CONTROL_ACCESS|SYNCHRONIZE_ACCESS|\
@@ -1267,7 +1265,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
@@ -1276,6 +1274,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)
@@ -1328,53 +1327,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
@@ -1455,6 +1407,15 @@ enum protocol_types {PROTOCOL_NONE,PROTOCOL_CORE,PROTOCOL_COREPLUS,PROTOCOL_LANM
 /* security levels */
 enum security_types {SEC_SHARE,SEC_USER,SEC_SERVER,SEC_DOMAIN};
 
+/* server roles */
+enum server_types
+{
+       ROLE_STANDALONE,
+       ROLE_DOMAIN_MEMBER,
+       ROLE_DOMAIN_BDC,
+       ROLE_DOMAIN_PDC
+};
+
 /* printing types */
 enum printing_types {PRINT_BSD,PRINT_SYSV,PRINT_AIX,PRINT_HPUX,
                     PRINT_QNX,PRINT_PLP,PRINT_LPRNG,PRINT_SOFTQ,PRINT_CUPS};
@@ -1600,6 +1561,7 @@ extern int chain_size;
 #define OPLOCK_BREAK_INODE_OFFSET (OPLOCK_BREAK_DEV_OFFSET + sizeof(SMB_DEV_T))
 #define OPLOCK_BREAK_MSG_LEN (OPLOCK_BREAK_INODE_OFFSET + sizeof(SMB_INO_T))
 
+#define KERNEL_OPLOCK_BREAK_CMD 0x2
 #define LEVEL_II_OPLOCK_BREAK_CMD 0x3
 
 /*
@@ -1608,9 +1570,8 @@ extern int chain_size;
 
 #define KERNEL_OPLOCK_CAPABILITY 0x1
 
-#if defined(HAVE_KERNEL_OPLOCKS)
 /*
- * Oplock break command code sent via the kernel interface.
+ * Oplock break command code sent via the kernel interface (if it exists).
  *
  * Form of this is :
  *
@@ -1619,16 +1580,36 @@ extern int chain_size;
  *  | cmd| dev    |  inode |
  *  +----+--------+--------+
  */
-
-#define KERNEL_OPLOCK_BREAK_CMD 0x2
 #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_MSG_LEN (KERNEL_OPLOCK_BREAK_INODE_OFFSET + sizeof(SMB_INO_T))
 
-#endif /* HAVE_KERNEL_OPLOCKS */
+
+/* if a kernel does support oplocks then a structure of the following
+   typee is used to describe how to interact with the kernel */
+struct kernel_oplocks {
+       BOOL (*receive_message)(fd_set *fds, char *buffer, int buffer_len);
+       BOOL (*set_oplock)(files_struct *fsp, int oplock_type);
+       void (*release_oplock)(files_struct *fsp);
+       BOOL (*parse_message)(char *msg_start, int msg_len, SMB_INO_T *inode, SMB_DEV_T *dev);
+       BOOL (*msg_waiting)(fd_set *fds);
+       int notification_fd;
+};
+
 
 #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. */
@@ -1675,10 +1656,46 @@ struct ntdom_info
 
        int max_recv_frag;
        int max_xmit_frag;
+
+       vuser_key key;
+};
+
+/*
+ * Network Computing Architechture Context Name Named Pipe
+ * See MSDN docs for more information
+ */
+struct ncacn_np
+{
+        fstring pipe_name;
+        struct cli_state *smb;
+        uint16 fnum;
+        BOOL initialised;
 };
 
-#include "nt_printing.h"
 #include "rpc_creds.h"
+#include "rpc_secdes.h"
+#include "nt_printing.h"
+
+typedef struct
+{
+       uid_t uid; /* uid of a validated user */
+       gid_t gid; /* gid of a validated user */
+
+       userdom_struct user;
+       BOOL guest;
+
+       /* following groups stuff added by ih */
+       /* This groups info is needed for when we become_user() for this uid */
+       int n_groups;
+       gid_t *groups;
+
+       NT_USER_TOKEN *nt_user_token;
+
+       /* per-user authentication information on NT RPCs */
+       /* lkclXXXX - THIS SHOULD NOT BE HERE! */
+       struct dcinfo dc;
+} user_struct;
+
 #include "ntdomain.h"
 
 #include "client.h"
@@ -1715,4 +1732,6 @@ struct ntdom_info
 #define MAP_TO_GUEST_ON_BAD_USER 1
 #define MAP_TO_GUEST_ON_BAD_PASSWORD 2
 
+#include "nsswitch/winbindd_nss.h"
+
 #endif /* _SMB_H */