s3:smbd: add vfs_remove_all_fsp_extensions()
[kai/samba.git] / source3 / smbd / proto.h
index 4ec91a11dbf2e72c5916aee3ad88017abeedd711..693a498026b15685a859667b4e8bab862631fb62 100644 (file)
@@ -64,21 +64,22 @@ void srv_set_signing(struct smbd_server_connection *conn,
 
 /* The following definitions come from smbd/aio.c  */
 
+bool initialize_async_io_handler(void);
 NTSTATUS schedule_aio_read_and_X(connection_struct *conn,
                             struct smb_request *req,
-                            files_struct *fsp, SMB_OFF_T startpos,
+                            files_struct *fsp, off_t startpos,
                             size_t smb_maxcnt);
 NTSTATUS schedule_aio_write_and_X(connection_struct *conn,
                              struct smb_request *req,
                              files_struct *fsp, const char *data,
-                             SMB_OFF_T startpos,
+                             off_t startpos,
                              size_t numtowrite);
 NTSTATUS schedule_smb2_aio_read(connection_struct *conn,
                                struct smb_request *smbreq,
                                files_struct *fsp,
                                TALLOC_CTX *ctx,
                                DATA_BLOB *preadbuf,
-                               SMB_OFF_T startpos,
+                               off_t startpos,
                                size_t smb_maxcnt);
 NTSTATUS schedule_aio_smb2_write(connection_struct *conn,
                                struct smb_request *smbreq,
@@ -88,7 +89,6 @@ NTSTATUS schedule_aio_smb2_write(connection_struct *conn,
                                bool write_through);
 bool cancel_smb2_aio(struct smb_request *smbreq);
 int wait_for_aio_completion(files_struct *fsp);
-void cancel_aio_by_fsp(files_struct *fsp);
 void smbd_aio_complete_aio_ex(struct aio_extra *aio_ex);
 
 /* The following definitions come from smbd/blocking.c  */
@@ -149,7 +149,7 @@ bool conn_snum_used(struct smbd_server_connection *sconn, int snum);
 connection_struct *conn_find(struct smbd_server_connection *sconn,
                             unsigned cnum);
 connection_struct *conn_new(struct smbd_server_connection *sconn);
-bool conn_close_all(struct smbd_server_connection *sconn);
+void conn_close_all(struct smbd_server_connection *sconn);
 bool conn_idle_all(struct smbd_server_connection *sconn, time_t t);
 void conn_clear_vuid_caches(struct smbd_server_connection *sconn, uint16 vuid);
 void conn_free(connection_struct *conn);
@@ -169,6 +169,7 @@ bool claim_connection(connection_struct *conn, const char *name);
 
 /* The following definitions come from smbd/dfree.c  */
 
+void disk_norm(bool small_query, uint64_t *bsize,uint64_t *dfree,uint64_t *dsize);
 uint64_t sys_disk_free(connection_struct *conn, const char *path, bool small_query,
                               uint64_t *bsize,uint64_t *dfree,uint64_t *dsize);
 uint64_t get_dfree_info(connection_struct *conn,
@@ -184,7 +185,7 @@ bool make_dir_struct(TALLOC_CTX *ctx,
                        char *buf,
                        const char *mask,
                        const char *fname,
-                       SMB_OFF_T size,
+                       off_t size,
                        uint32 mode,
                        time_t date,
                        bool uc);
@@ -197,7 +198,9 @@ void dptr_closecnum(connection_struct *conn);
 void dptr_idlecnum(connection_struct *conn);
 void dptr_closepath(struct smbd_server_connection *sconn,
                    char *path,uint16 spid);
-NTSTATUS dptr_create(connection_struct *conn, files_struct *fsp,
+NTSTATUS dptr_create(connection_struct *conn,
+               struct smb_request *req,
+               files_struct *fsp,
                const char *path, bool old_handle, bool expect_close,uint16 spid,
                const char *wcard, bool wcard_has_wild, uint32 attr, struct dptr_struct **dptr_ret);
 void dptr_CloseDir(files_struct *fsp);
@@ -205,6 +208,8 @@ void dptr_SeekDir(struct dptr_struct *dptr, long offset);
 long dptr_TellDir(struct dptr_struct *dptr);
 bool dptr_has_wild(struct dptr_struct *dptr);
 int dptr_dnum(struct dptr_struct *dptr);
+bool dptr_get_priv(struct dptr_struct *dptr);
+void dptr_set_priv(struct dptr_struct *dptr);
 char *dptr_ReadDirName(TALLOC_CTX *ctx,
                        struct dptr_struct *dptr,
                        long *poffset,
@@ -224,7 +229,7 @@ bool get_dir_entry(TALLOC_CTX *ctx,
                const char *mask,
                uint32 dirtype,
                char **pp_fname_out,
-               SMB_OFF_T *size,
+               off_t *size,
                uint32 *mode,
                struct timespec *date,
                bool check_descend,
@@ -312,7 +317,7 @@ NTSTATUS can_set_delete_on_close(files_struct *fsp, uint32 dosmode);
 
 /* The following definitions come from smbd/fileio.c  */
 
-ssize_t read_file(files_struct *fsp,char *data,SMB_OFF_T pos,size_t n);
+ssize_t read_file(files_struct *fsp,char *data,off_t pos,size_t n);
 void update_write_time_handler(struct event_context *ctx,
                                       struct timed_event *te,
                                       struct timeval now,
@@ -322,10 +327,10 @@ void trigger_write_time_update_immediate(struct files_struct *fsp);
 ssize_t write_file(struct smb_request *req,
                        files_struct *fsp,
                        const char *data,
-                       SMB_OFF_T pos,
+                       off_t pos,
                        size_t n);
 void delete_write_cache(files_struct *fsp);
-void set_filelen_write_cache(files_struct *fsp, SMB_OFF_T file_size);
+void set_filelen_write_cache(files_struct *fsp, off_t file_size);
 ssize_t flush_write_cache(files_struct *fsp, enum flush_reason_enum reason);
 NTSTATUS sync_file(connection_struct *conn, files_struct *fsp, bool write_through);
 int fsp_stat(files_struct *fsp);
@@ -349,6 +354,13 @@ NTSTATUS filename_convert(TALLOC_CTX *mem_ctx,
                        uint32_t ucf_flags,
                        bool *ppath_contains_wcard,
                        struct smb_filename **pp_smb_fname);
+NTSTATUS filename_convert_with_privilege(TALLOC_CTX *mem_ctx,
+                       connection_struct *conn,
+                       struct smb_request *smbreq,
+                       const char *name_in,
+                       uint32_t ucf_flags,
+                       bool *ppath_contains_wcard,
+                       struct smb_filename **pp_smb_fname);
 
 /* The following definitions come from smbd/files.c  */
 
@@ -357,6 +369,7 @@ NTSTATUS file_new(struct smb_request *req, connection_struct *conn,
 void file_close_conn(connection_struct *conn);
 void file_close_pid(struct smbd_server_connection *sconn, uint16 smbpid,
                    int vuid);
+bool file_init_global(void);
 bool file_init(struct smbd_server_connection *sconn);
 void file_close_user(struct smbd_server_connection *sconn, int vuid);
 struct files_struct *files_forall(
@@ -384,6 +397,7 @@ NTSTATUS fsp_set_smb_fname(struct files_struct *fsp,
 
 /* The following definitions come from smbd/ipc.c  */
 
+NTSTATUS nt_status_np_pipe(NTSTATUS status);
 void send_trans_reply(connection_struct *conn,
                      struct smb_request *req,
                      char *rparam, int rparam_len,
@@ -444,7 +458,7 @@ bool is_msdfs_link(connection_struct *conn,
 struct junction_map;
 NTSTATUS get_referred_path(TALLOC_CTX *ctx,
                        const char *dfs_path,
-                       struct smbd_server_connection *sconn,
+                       bool allow_broken_path,
                        struct junction_map *jucn,
                        int *consumedcntp,
                        bool *self_referralp);
@@ -459,25 +473,22 @@ bool create_junction(TALLOC_CTX *ctx,
 bool create_msdfs_link(const struct junction_map *jucn);
 bool remove_msdfs_link(const struct junction_map *jucn);
 struct junction_map *enum_msdfs_links(TALLOC_CTX *ctx, size_t *p_num_jn);
-NTSTATUS resolve_dfspath(TALLOC_CTX *ctx,
-                       connection_struct *conn,
-                       bool dfs_pathnames,
-                       const char *name_in,
-                       char **pp_name_out);
 NTSTATUS resolve_dfspath_wcard(TALLOC_CTX *ctx,
                                connection_struct *conn,
                                bool dfs_pathnames,
                                const char *name_in,
                                bool allow_wcards,
+                               bool allow_broken_path,
                                char **pp_name_out,
                                bool *ppath_contains_wcard);
 NTSTATUS create_conn_struct(TALLOC_CTX *ctx,
-                               struct smbd_server_connection *sconn,
-                               connection_struct **pconn,
-                               int snum,
-                               const char *path,
-                               const struct auth_session_info *session_info,
-                               char **poldcwd);
+                           struct tevent_context *ev,
+                           struct messaging_context *msg,
+                           connection_struct **pconn,
+                           int snum,
+                           const char *path,
+                           const struct auth_session_info *session_info,
+                           char **poldcwd);
 
 /* The following definitions come from smbd/negprot.c  */
 
@@ -508,20 +519,15 @@ void remove_pending_change_notify_requests_by_fid(files_struct *fsp,
 void notify_fname(connection_struct *conn, uint32 action, uint32 filter,
                  const char *path);
 char *notify_filter_string(TALLOC_CTX *mem_ctx, uint32 filter);
-struct sys_notify_context *sys_notify_context_create(connection_struct *conn,
-                                                    TALLOC_CTX *mem_ctx,
+struct sys_notify_context *sys_notify_context_create(TALLOC_CTX *mem_ctx,
                                                     struct event_context *ev);
-NTSTATUS sys_notify_watch(struct sys_notify_context *ctx,
-                         struct notify_entry *e,
-                         void (*callback)(struct sys_notify_context *ctx,
-                                          void *private_data,
-                                          struct notify_event *ev),
-                         void *private_data, void *handle);
 
 /* The following definitions come from smbd/notify_inotify.c  */
 
 NTSTATUS inotify_watch(struct sys_notify_context *ctx,
-                      struct notify_entry *e,
+                      const char *path,
+                      uint32_t *filter,
+                      uint32_t *subdir_filter,
                       void (*callback)(struct sys_notify_context *ctx,
                                        void *private_data,
                                        struct notify_event *ev),
@@ -530,22 +536,33 @@ NTSTATUS inotify_watch(struct sys_notify_context *ctx,
 
 /* The following definitions come from smbd/notify_internal.c  */
 
-struct notify_context *notify_init(TALLOC_CTX *mem_ctx, struct server_id server,
+struct notify_context *notify_init(TALLOC_CTX *mem_ctx,
                                   struct messaging_context *messaging_ctx,
-                                  struct event_context *ev,
-                                  connection_struct *conn);
-bool notify_internal_parent_init(TALLOC_CTX *mem_ctx);
-NTSTATUS notify_add(struct notify_context *notify, struct notify_entry *e0,
+                                  struct event_context *ev);
+NTSTATUS notify_add(struct notify_context *notify,
+                   const char *path, uint32_t filter, uint32_t subdir_filter,
                    void (*callback)(void *, const struct notify_event *),
                    void *private_data);
 NTSTATUS notify_remove(struct notify_context *notify, void *private_data);
-NTSTATUS notify_remove_onelevel(struct notify_context *notify,
-                               const struct file_id *fid,
-                               void *private_data);
-void notify_onelevel(struct notify_context *notify, uint32_t action,
-                    uint32_t filter, struct file_id fid, const char *name);
 void notify_trigger(struct notify_context *notify,
                    uint32_t action, uint32_t filter, const char *path);
+void notify_walk_idx(struct notify_context *notify,
+                    void (*fn)(const char *path,
+                               uint32_t *vnns, size_t num_vnns,
+                               void *private_data),
+                    void *private_data);
+void notify_walk(struct notify_context *notify,
+                void (*fn)(const char *path,
+                           struct notify_db_entry *entries,
+                           size_t num_entries,
+                           time_t deleted_time, void *private_data),
+                void *private_data);
+void notify_cleanup(struct notify_context *notify);
+
+struct tevent_req *notify_cluster_proxy_send(
+       TALLOC_CTX *mem_ctx, struct tevent_context *ev,
+       struct notify_context *notify);
+int notify_cluster_proxy_recv(struct tevent_req *req);
 
 /* The following definitions come from smbd/ntquotas.c  */
 
@@ -645,13 +662,12 @@ NTSTATUS get_relative_fid_filename(connection_struct *conn,
 
 /* The following definitions come from smbd/oplock.c  */
 
-int32 get_number_of_exclusive_open_oplocks(void);
 void break_kernel_oplock(struct messaging_context *msg_ctx, files_struct *fsp);
 bool set_file_oplock(files_struct *fsp, int oplock_type);
 void release_file_oplock(files_struct *fsp);
 bool remove_oplock(files_struct *fsp);
 bool downgrade_oplock(files_struct *fsp);
-bool should_notify_deferred_opens(void);
+bool should_notify_deferred_opens(struct smbd_server_connection *sconn);
 void break_level2_to_none_async(files_struct *fsp);
 void reply_to_oplock_break_requests(files_struct *fsp);
 void contend_level2_oplocks_begin(files_struct *fsp,
@@ -665,6 +681,7 @@ void smbd_contend_level2_oplocks_end(files_struct *fsp,
 void share_mode_entry_to_message(char *msg, const struct share_mode_entry *e);
 void message_to_share_mode_entry(struct share_mode_entry *e, char *msg);
 bool init_oplocks(struct smbd_server_connection *sconn);
+void init_kernel_oplocks(struct smbd_server_connection *sconn);
 
 /* The following definitions come from smbd/oplock_irix.c  */
 
@@ -677,10 +694,6 @@ int linux_set_lease_sighandler(int fd);
 int linux_setlease(int fd, int leasetype);
 struct kernel_oplocks *linux_init_kernel_oplocks(struct smbd_server_connection *sconn);
 
-/* The following definitions come from smbd/oplock_onefs.c  */
-
-struct kernel_oplocks *onefs_init_kernel_oplocks(struct smbd_server_connection *sconn);
-
 /* The following definitions come from smbd/password.c  */
 
 user_struct *get_valid_user_struct(struct smbd_server_connection *sconn,
@@ -696,13 +709,6 @@ int register_existing_vuid(struct smbd_server_connection *sconn,
                        uint16 vuid,
                        struct auth_session_info *session_info,
                        DATA_BLOB response_blob);
-void add_session_user(struct smbd_server_connection *sconn, const char *user);
-void add_session_workgroup(struct smbd_server_connection *sconn,
-                          const char *workgroup);
-const char *get_session_workgroup(struct smbd_server_connection *sconn);
-bool authorise_login(struct smbd_server_connection *sconn,
-                    int snum, fstring user, DATA_BLOB password,
-                    bool *guest);
 
 /* The following definitions come from smbd/pipes.c  */
 
@@ -776,15 +782,28 @@ bool push_deferred_open_message_smb(struct smb_request *req,
                                size_t priv_len);
 NTSTATUS allow_new_trans(struct trans_state *list, uint64_t mid);
 void reply_outbuf(struct smb_request *req, uint8 num_words, uint32 num_bytes);
+void smb_request_done(struct smb_request *req);
 const char *smb_fn_name(int type);
 void add_to_common_flags2(uint32 v);
 void remove_from_common_flags2(uint32 v);
 void construct_reply_common_req(struct smb_request *req, char *outbuf);
-size_t req_wct_ofs(struct smb_request *req);
-void chain_reply(struct smb_request *req);
+bool smb1_is_chain(const uint8_t *buf);
+bool smb1_walk_chain(const uint8_t *buf,
+                    bool (*fn)(uint8_t cmd,
+                               uint8_t wct, const uint16_t *vwv,
+                               uint16_t num_bytes, const uint8_t *bytes,
+                               void *private_data),
+                    void *private_data);
+unsigned smb1_chain_length(const uint8_t *buf);
+bool smb1_parse_chain(TALLOC_CTX *mem_ctx, const uint8_t *buf,
+                     struct smbd_server_connection *sconn,
+                     bool encrypted, uint32_t seqnum,
+                     struct smb_request ***reqs, unsigned *num_reqs);
 bool req_is_in_chain(struct smb_request *req);
 void smbd_process(struct tevent_context *ev_ctx,
-                 struct smbd_server_connection *sconn);
+                 struct messaging_context *msg_ctx,
+                 int sock_fd,
+                 bool interactive);
 bool fork_echo_handler(struct smbd_server_connection *sconn);
 
 /* The following definitions come from smbd/quotas.c  */
@@ -856,7 +875,7 @@ NTSTATUS unlink_internals(connection_struct *conn, struct smb_request *req,
                          uint32 dirtype, struct smb_filename *smb_fname,
                          bool has_wild);
 void reply_unlink(struct smb_request *req);
-ssize_t fake_sendfile(files_struct *fsp, SMB_OFF_T startpos, size_t nread);
+ssize_t fake_sendfile(files_struct *fsp, off_t startpos, size_t nread);
 void sendfile_short_send(files_struct *fsp,
                                ssize_t nread,
                                size_t headersize,
@@ -945,7 +964,7 @@ void server_encryption_shutdown(struct smbd_server_connection *sconn);
 
 bool unix_token_equal(const struct security_unix_token *t1, const struct security_unix_token *t2);
 bool push_sec_ctx(void);
-void set_sec_ctx(uid_t uid, gid_t gid, int ngroups, gid_t *groups, struct security_token *token);
+void set_sec_ctx(uid_t uid, gid_t gid, int ngroups, gid_t *groups, const struct security_token *token);
 void set_root_sec_ctx(void);
 bool pop_sec_ctx(void);
 void init_sec_ctx(void);
@@ -975,11 +994,10 @@ struct smbd_smb2_tcon;
 connection_struct *make_connection_smb2(struct smbd_server_connection *sconn,
                                        struct smbd_smb2_tcon *tcon,
                                        user_struct *vuser,
-                                       DATA_BLOB password,
                                        const char *pdev,
                                        NTSTATUS *pstatus);
 connection_struct *make_connection(struct smbd_server_connection *sconn,
-                                  const char *service_in, DATA_BLOB password,
+                                  const char *service_in,
                                   const char *pdev, uint16 vuid,
                                   NTSTATUS *status);
 void close_cnum(connection_struct *conn, uint16 vuid);
@@ -1089,8 +1107,6 @@ void reply_transs2(struct smb_request *req);
 
 bool change_to_guest(void);
 bool change_to_user(connection_struct *conn, uint16 vuid);
-bool change_to_user_by_session(connection_struct *conn,
-                              const struct auth_session_info *session_info);
 bool change_to_root_user(void);
 bool smbd_change_to_root_user(void);
 bool become_authenticated_pipe_user(struct auth_session_info *session_info);
@@ -1133,13 +1149,14 @@ void *vfs_add_fsp_extension_notype(vfs_handle_struct *handle,
                                   files_struct *fsp, size_t ext_size,
                                   void (*destroy_fn)(void *p_data));
 void vfs_remove_fsp_extension(vfs_handle_struct *handle, files_struct *fsp);
+void vfs_remove_all_fsp_extensions(struct files_struct *fsp);
 void *vfs_memctx_fsp_extension(vfs_handle_struct *handle, files_struct *fsp);
 void *vfs_fetch_fsp_extension(vfs_handle_struct *handle, files_struct *fsp);
 bool smbd_vfs_init(connection_struct *conn);
 NTSTATUS vfs_file_exist(connection_struct *conn, struct smb_filename *smb_fname);
 ssize_t vfs_read_data(files_struct *fsp, char *buf, size_t byte_count);
 ssize_t vfs_pread_data(files_struct *fsp, char *buf,
-                size_t byte_count, SMB_OFF_T offset);
+                size_t byte_count, off_t offset);
 ssize_t vfs_write_data(struct smb_request *req,
                        files_struct *fsp,
                        const char *buffer,
@@ -1148,17 +1165,20 @@ ssize_t vfs_pwrite_data(struct smb_request *req,
                        files_struct *fsp,
                        const char *buffer,
                        size_t N,
-                       SMB_OFF_T offset);
+                       off_t offset);
 int vfs_allocate_file_space(files_struct *fsp, uint64_t len);
-int vfs_set_filelen(files_struct *fsp, SMB_OFF_T len);
-int vfs_slow_fallocate(files_struct *fsp, SMB_OFF_T offset, SMB_OFF_T len);
-int vfs_fill_sparse(files_struct *fsp, SMB_OFF_T len);
-SMB_OFF_T vfs_transfer_file(files_struct *in, files_struct *out, SMB_OFF_T n);
+int vfs_set_filelen(files_struct *fsp, off_t len);
+int vfs_slow_fallocate(files_struct *fsp, off_t offset, off_t len);
+int vfs_fill_sparse(files_struct *fsp, off_t len);
+off_t vfs_transfer_file(files_struct *in, files_struct *out, off_t n);
 const char *vfs_readdirname(connection_struct *conn, void *p,
                            SMB_STRUCT_STAT *sbuf, char **talloced);
 int vfs_ChDir(connection_struct *conn, const char *path);
 char *vfs_GetWd(TALLOC_CTX *ctx, connection_struct *conn);
 NTSTATUS check_reduced_name(connection_struct *conn, const char *fname);
+NTSTATUS check_reduced_name_with_privilege(connection_struct *conn,
+                       const char *fname,
+                       struct smb_request *smbreq);
 int vfs_stat_smb_fname(struct connection_struct *conn, const char *fname,
                       SMB_STRUCT_STAT *psbuf);
 int vfs_lstat_smb_fname(struct connection_struct *conn, const char *fname,