lib: Move full_path_tos to util_str.c
[kai/samba-autobuild/.git] / source3 / smbd / proto.h
index 26d6432c15223cb7aa62e11e8d6c624c3b2edfa3..d9b86b6f539dd9707282428356ab8b59e81575b7 100644 (file)
@@ -64,8 +64,8 @@ void srv_set_signing(struct smbd_server_connection *conn,
 
 /* The following definitions come from smbd/aio.c  */
 
+struct aio_extra;
 bool aio_write_through_requested(struct aio_extra *aio_ex);
-bool initialize_async_io_handler(void);
 NTSTATUS schedule_aio_read_and_X(connection_struct *conn,
                             struct smb_request *req,
                             files_struct *fsp, off_t startpos,
@@ -89,13 +89,11 @@ NTSTATUS schedule_aio_smb2_write(connection_struct *conn,
                                DATA_BLOB in_data,
                                bool write_through);
 bool cancel_smb2_aio(struct smb_request *smbreq);
-int wait_for_aio_completion(files_struct *fsp);
-void smbd_aio_complete_aio_ex(struct aio_extra *aio_ex);
 
 /* The following definitions come from smbd/blocking.c  */
 
-void brl_timeout_fn(struct event_context *event_ctx,
-               struct timed_event *te,
+void brl_timeout_fn(struct tevent_context *event_ctx,
+               struct tevent_timer *te,
                struct timeval now,
                void *private_data);
 struct timeval timeval_brl_min(const struct timeval *tv1,
@@ -141,6 +139,9 @@ void msg_close_file(struct messaging_context *msg_ctx,
                    struct server_id server_id,
                    DATA_BLOB *data);
 NTSTATUS delete_all_streams(connection_struct *conn, const char *fname);
+bool recursive_rmdir(TALLOC_CTX *ctx,
+                    connection_struct *conn,
+                    struct smb_filename *smb_dname);
 
 /* The following definitions come from smbd/conn.c  */
 
@@ -159,10 +160,8 @@ void msg_force_tdis(struct messaging_context *msg,
 
 /* The following definitions come from smbd/connection.c  */
 
-bool yield_connection(connection_struct *conn, const char *name);
-int count_current_connections( const char *sharename, bool clear  );
+int count_current_connections(const char *sharename, bool verify);
 bool connections_snum_used(struct smbd_server_connection *unused, int snum);
-bool claim_connection(connection_struct *conn, const char *name);
 
 /* The following definitions come from smbd/dfree.c  */
 
@@ -212,7 +211,6 @@ char *dptr_ReadDirName(TALLOC_CTX *ctx,
                        long *poffset,
                        SMB_STRUCT_STAT *pst);
 bool dptr_SearchDir(struct dptr_struct *dptr, const char *name, long *poffset, SMB_STRUCT_STAT *pst);
-void dptr_DirCacheAdd(struct dptr_struct *dptr, const char *name, long offset);
 void dptr_init_search_op(struct dptr_struct *dptr);
 bool dptr_fill(struct smbd_server_connection *sconn,
               char *buf1,unsigned int key);
@@ -220,7 +218,6 @@ struct dptr_struct *dptr_fetch(struct smbd_server_connection *sconn,
                               char *buf,int *num);
 struct dptr_struct *dptr_fetch_lanman2(struct smbd_server_connection *sconn,
                                       int dptr_num);
-bool dir_check_ftype(connection_struct *conn, uint32 mode, uint32 dirtype);
 bool get_dir_entry(TALLOC_CTX *ctx,
                struct dptr_struct *dirptr,
                const char *mask,
@@ -239,7 +236,6 @@ const char *ReadDirName(struct smb_Dir *dirp, long *poffset,
 void RewindDir(struct smb_Dir *dirp, long *poffset);
 void SeekDir(struct smb_Dir *dirp, long offset);
 long TellDir(struct smb_Dir *dirp);
-void DirCacheAdd(struct smb_Dir *dirp, const char *name, long offset);
 bool SearchDir(struct smb_Dir *dirp, const char *name, long *poffset);
 NTSTATUS can_delete_directory(struct connection_struct *conn,
                                const char *dirname);
@@ -315,8 +311,8 @@ 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,off_t pos,size_t n);
-void update_write_time_handler(struct event_context *ctx,
-                                      struct timed_event *te,
+void update_write_time_handler(struct tevent_context *ctx,
+                                      struct tevent_timer *te,
                                       struct timeval now,
                                       void *private_data);
 void trigger_write_time_update(struct files_struct *fsp);
@@ -388,6 +384,9 @@ void file_sync_all(connection_struct *conn);
 void fsp_free(files_struct *fsp);
 void file_free(struct smb_request *req, files_struct *fsp);
 files_struct *file_fsp(struct smb_request *req, uint16 fid);
+struct files_struct *file_fsp_get(struct smbd_smb2_request *smb2req,
+                                 uint64_t persistent_id,
+                                 uint64_t volatile_id);
 struct files_struct *file_fsp_smb2(struct smbd_smb2_request *smb2req,
                                   uint64_t persistent_id,
                                   uint64_t volatile_id);
@@ -491,8 +490,15 @@ NTSTATUS create_conn_struct(TALLOC_CTX *ctx,
                            connection_struct **pconn,
                            int snum,
                            const char *path,
-                           const struct auth_session_info *session_info,
-                           char **poldcwd);
+                           const struct auth_session_info *session_info);
+NTSTATUS create_conn_struct_cwd(TALLOC_CTX *ctx,
+                               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  */
 
@@ -525,7 +531,7 @@ 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(TALLOC_CTX *mem_ctx,
-                                                    struct event_context *ev);
+                                                    struct tevent_context *ev);
 
 /* The following definitions come from smbd/notify_inotify.c  */
 
@@ -543,7 +549,7 @@ NTSTATUS inotify_watch(struct sys_notify_context *ctx,
 
 struct notify_context *notify_init(TALLOC_CTX *mem_ctx,
                                   struct messaging_context *messaging_ctx,
-                                  struct event_context *ev);
+                                  struct tevent_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 *),
@@ -579,7 +585,9 @@ void *init_quota_handle(TALLOC_CTX *mem_ctx);
 /* The following definitions come from smbd/nttrans.c  */
 
 void reply_ntcreate_and_X(struct smb_request *req);
-NTSTATUS set_sd(files_struct *fsp, uint8_t *data, uint32_t sd_len,
+NTSTATUS set_sd(files_struct *fsp, struct security_descriptor *psd,
+                       uint32_t security_info_sent);
+NTSTATUS set_sd_blob(files_struct *fsp, uint8_t *data, uint32_t sd_len,
                        uint32_t security_info_sent);
 struct ea_list *read_nttrans_ea_list(TALLOC_CTX *ctx, const char *pdata, size_t data_size);
 void reply_ntcancel(struct smb_request *req);
@@ -598,7 +606,10 @@ void reply_nttranss(struct smb_request *req);
 
 NTSTATUS smbd_check_access_rights(struct connection_struct *conn,
                                const struct smb_filename *smb_fname,
+                               bool use_privs,
                                uint32_t access_mask);
+NTSTATUS fd_open(struct connection_struct *conn, files_struct *fsp,
+                int flags, mode_t mode);
 NTSTATUS fd_close(files_struct *fsp);
 void change_file_owner_to_parent(connection_struct *conn,
                                 const char *inherit_from_dir,
@@ -608,16 +619,6 @@ NTSTATUS change_dir_owner_to_parent(connection_struct *conn,
                                    const char *fname,
                                    SMB_STRUCT_STAT *psbuf);
 bool is_stat_open(uint32 access_mask);
-bool request_timed_out(struct timeval request_time,
-                      struct timeval timeout);
-bool open_match_attributes(connection_struct *conn,
-                          uint32 old_dos_attr,
-                          uint32 new_dos_attr,
-                          mode_t existing_unx_mode,
-                          mode_t new_unx_mode,
-                          mode_t *returned_unx_mode);
-void remove_deferred_open_entry(struct file_id id, uint64_t mid,
-                               struct server_id pid);
 bool is_deferred_open_async(const void *ptr);
 NTSTATUS open_file_fchmod(connection_struct *conn,
                          struct smb_filename *smb_fname,
@@ -657,13 +658,9 @@ NTSTATUS get_relative_fid_filename(connection_struct *conn,
 /* The following definitions come from smbd/oplock.c  */
 
 void break_kernel_oplock(struct messaging_context *msg_ctx, files_struct *fsp);
-NTSTATUS set_file_oplock(files_struct *fsp, int oplock_type);
-void release_file_oplock(files_struct *fsp);
+NTSTATUS set_file_oplock(files_struct *fsp);
 bool remove_oplock(files_struct *fsp);
 bool downgrade_oplock(files_struct *fsp);
-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,
                                  enum level2_contention_type type);
 void contend_level2_oplocks_end(files_struct *fsp,
@@ -673,7 +670,7 @@ void smbd_contend_level2_oplocks_begin(files_struct *fsp,
 void smbd_contend_level2_oplocks_end(files_struct *fsp,
                                enum level2_contention_type type);
 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);
+void message_to_share_mode_entry(struct share_mode_entry *e, const char *msg);
 bool init_oplocks(struct smbd_server_connection *sconn);
 void init_kernel_oplocks(struct smbd_server_connection *sconn);
 
@@ -707,7 +704,6 @@ void reply_pipe_read_and_X(struct smb_request *req);
 /* The following definitions come from smbd/posix_acls.c  */
 
 void create_file_sids(const SMB_STRUCT_STAT *psbuf, struct dom_sid *powner_sid, struct dom_sid *pgroup_sid);
-bool nt4_compatible_acls(void);
 uint32_t map_canon_ace_perms(int snum,
                                 enum security_ace_type *pacl_type,
                                 mode_t perms,
@@ -716,13 +712,13 @@ NTSTATUS unpack_nt_owners(connection_struct *conn, uid_t *puser, gid_t *pgrp, ui
 bool current_user_in_group(connection_struct *conn, gid_t gid);
 SMB_ACL_T free_empty_sys_acl(connection_struct *conn, SMB_ACL_T the_acl);
 NTSTATUS posix_fget_nt_acl(struct files_struct *fsp, uint32_t security_info,
+                          TALLOC_CTX *mem_ctx,
                           struct security_descriptor **ppdesc);
 NTSTATUS posix_get_nt_acl(struct connection_struct *conn, const char *name,
-                         uint32_t security_info, struct security_descriptor **ppdesc);
+                         uint32_t security_info,
+                         TALLOC_CTX *mem_ctx,
+                         struct security_descriptor **ppdesc);
 NTSTATUS try_chown(files_struct *fsp, uid_t uid, gid_t gid);
-NTSTATUS append_parent_acl(files_struct *fsp,
-                               const struct security_descriptor *pcsd,
-                               struct security_descriptor **pp_new_sd);
 NTSTATUS set_nt_acl(files_struct *fsp, uint32 security_info_sent, const struct security_descriptor *psd);
 int get_acl_group_bits( connection_struct *conn, const char *fname, mode_t *mode );
 int chmod_acl(connection_struct *conn, const char *name, mode_t mode);
@@ -733,11 +729,23 @@ bool set_unix_posix_default_acl(connection_struct *conn, const char *fname,
                                const SMB_STRUCT_STAT *psbuf,
                                uint16 num_def_acls, const char *pdata);
 bool set_unix_posix_acl(connection_struct *conn, files_struct *fsp, const char *fname, uint16 num_acls, const char *pdata);
-struct security_descriptor *get_nt_acl_no_snum( TALLOC_CTX *ctx, const char *fname);
+NTSTATUS get_nt_acl_no_snum( TALLOC_CTX *ctx, const char *fname,
+                            uint32 security_info_wanted,
+                            struct security_descriptor **sd);
 NTSTATUS make_default_filesystem_acl(TALLOC_CTX *ctx,
                                        const char *name,
                                        SMB_STRUCT_STAT *psbuf,
                                        struct security_descriptor **ppdesc);
+int posix_sys_acl_blob_get_file(vfs_handle_struct *handle,
+                               const char *path_p,
+                               TALLOC_CTX *mem_ctx,
+                               char **blob_description,
+                               DATA_BLOB *blob);
+int posix_sys_acl_blob_get_fd(vfs_handle_struct *handle,
+                             files_struct *fsp,
+                             TALLOC_CTX *mem_ctx,
+                             char **blob_description,
+                             DATA_BLOB *blob);
 
 /* The following definitions come from smbd/process.c  */
 
@@ -784,7 +792,7 @@ 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);
+bool req_is_in_chain(const struct smb_request *req);
 void smbd_process(struct tevent_context *ev_ctx,
                  struct messaging_context *msg_ctx,
                  int sock_fd,
@@ -793,18 +801,8 @@ bool fork_echo_handler(struct smbd_server_connection *sconn);
 
 /* The following definitions come from smbd/quotas.c  */
 
-bool disk_quotas(const char *path, uint64_t *bsize, uint64_t *dfree, uint64_t *dsize);
-bool disk_quotas(const char *path, uint64_t *bsize, uint64_t *dfree, uint64_t *dsize);
-bool disk_quotas(const char *path,
-               uint64_t *bsize,
-               uint64_t *dfree,
-               uint64_t *dsize);
-bool disk_quotas(const char *path, uint64_t *bsize, uint64_t *dfree, uint64_t *dsize);
-bool disk_quotas(const char *path, uint64_t *bsize, uint64_t *dfree, uint64_t *dsize);
 bool disk_quotas(const char *path, uint64_t *bsize, uint64_t *dfree, uint64_t *dsize);
 bool disk_quotas_vxfs(const char *name, char *path, uint64_t *bsize, uint64_t *dfree, uint64_t *dsize);
-bool disk_quotas(const char *path,uint64_t *bsize,uint64_t *dfree,uint64_t *dsize);
-bool disk_quotas(const char *path,uint64_t *bsize,uint64_t *dfree,uint64_t *dsize);
 
 /* The following definitions come from smbd/reply.c  */
 
@@ -834,6 +832,8 @@ size_t srvstr_get_path_req_wcard(TALLOC_CTX *mem_ctx, struct smb_request *req,
 size_t srvstr_get_path_req(TALLOC_CTX *mem_ctx, struct smb_request *req,
                           char **pp_dest, const char *src, int flags,
                           NTSTATUS *err);
+size_t srvstr_pull_req_talloc(TALLOC_CTX *ctx, struct smb_request *req,
+                             char **dest, const uint8_t *src, int flags);
 bool check_fsp_open(connection_struct *conn, struct smb_request *req,
                    files_struct *fsp);
 bool check_fsp(connection_struct *conn, struct smb_request *req,
@@ -953,6 +953,7 @@ void set_sec_ctx(uid_t uid, gid_t gid, int ngroups, gid_t *groups, const struct
 void set_root_sec_ctx(void);
 bool pop_sec_ctx(void);
 void init_sec_ctx(void);
+const struct security_token *sec_ctx_active_token(void);
 
 /* The following definitions come from smbd/server.c  */
 
@@ -962,11 +963,14 @@ void delete_and_reload_printers(struct tevent_context *ev,
 bool reload_services(struct smbd_server_connection *sconn,
                     bool (*snumused) (struct smbd_server_connection *, int),
                     bool test);
-void exit_server(const char *const explanation);
-void exit_server_cleanly(const char *const explanation);
 NTSTATUS messaging_send_to_children(struct messaging_context *msg_ctx,
                                    uint32_t msg_type, DATA_BLOB* data);
 
+/* The following definitions come from smbd/server_exit.c  */
+
+void smbd_exit_server(const char *reason) _NORETURN_;
+void smbd_exit_server_cleanly(const char *const reason) _NORETURN_;
+
 /* The following definitions come from smbd/service.c  */
 
 bool set_conn_connectpath(connection_struct *conn, const char *connectpath);
@@ -982,6 +986,7 @@ connection_struct *make_connection_smb2(struct smbd_server_connection *sconn,
                                        const char *pdev,
                                        NTSTATUS *pstatus);
 connection_struct *make_connection(struct smbd_server_connection *sconn,
+                                  NTTIME now,
                                   const char *service_in,
                                   const char *pdev, uint64_t vuid,
                                   NTSTATUS *status);
@@ -989,10 +994,13 @@ void close_cnum(connection_struct *conn, uint64_t vuid);
 
 /* The following definitions come from smbd/session.c  */
 struct sessionid;
+struct smbXsrv_session;
 bool session_init(void);
-bool session_claim(struct smbd_server_connection *sconn, struct user_struct *vuser);
-void session_yield(struct user_struct *vuser);
+bool session_claim(struct smbXsrv_session *session);
+void session_yield(struct smbXsrv_session *session);
 int list_sessions(TALLOC_CTX *mem_ctx, struct sessionid **session_list);
+int find_sessions(TALLOC_CTX *mem_ctx, const char *username,
+                 const char *machine, struct sessionid **session_list);
 
 /* The following definitions come from smbd/sesssetup.c  */
 
@@ -1061,6 +1069,7 @@ NTSTATUS set_ea(connection_struct *conn, files_struct *fsp,
 struct ea_list *read_ea_list_entry(TALLOC_CTX *ctx, const char *pdata, size_t data_size, size_t *pbytes_used);
 void send_trans2_replies(connection_struct *conn,
                        struct smb_request *req,
+                       NTSTATUS status,
                         const char *params,
                         int paramsize,
                         const char *pdata,
@@ -1086,11 +1095,14 @@ void reply_transs2(struct smb_request *req);
 /* The following definitions come from smbd/uid.c  */
 
 bool change_to_guest(void);
+NTSTATUS check_user_share_access(connection_struct *conn,
+                               const struct auth_session_info *session_info,
+                               uint32_t *p_share_access,
+                               bool *p_readonly_share);
 bool change_to_user(connection_struct *conn, uint64_t vuid);
-bool change_to_root_user(void);
 bool smbd_change_to_root_user(void);
-bool become_authenticated_pipe_user(struct auth_session_info *session_info);
-bool unbecome_authenticated_pipe_user(void);
+bool smbd_become_authenticated_pipe_user(struct auth_session_info *session_info);
+bool smbd_unbecome_authenticated_pipe_user(void);
 void become_root(void);
 void unbecome_root(void);
 void smbd_become_root(void);
@@ -1108,17 +1120,9 @@ uint64_t get_current_vuid(connection_struct *conn);
 /* The following definitions come from smbd/utmp.c  */
 
 void sys_utmp_claim(const char *username, const char *hostname,
-                       const char *ip_addr_str,
-                       const char *id_str, int id_num);
-void sys_utmp_yield(const char *username, const char *hostname,
-                       const char *ip_addr_str,
-                       const char *id_str, int id_num);
+                   const char *id_str, int id_num);
 void sys_utmp_yield(const char *username, const char *hostname,
-                       const char *ip_addr_str,
-                       const char *id_str, int id_num);
-void sys_utmp_claim(const char *username, const char *hostname,
-                       const char *ip_addr_str,
-                       const char *id_str, int id_num);
+                   const char *id_str, int id_num);
 
 /* The following definitions come from smbd/vfs.c  */
 
@@ -1168,4 +1172,21 @@ NTSTATUS vfs_streaminfo(connection_struct *conn,
 void *avahi_start_register(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
                           uint16_t port);
 
+/* The following definitions come from smbd/smb2_create.c */
+
+NTSTATUS vfs_default_durable_cookie(struct files_struct *fsp,
+                                   TALLOC_CTX *mem_ctx,
+                                   DATA_BLOB *cookie_blob);
+NTSTATUS vfs_default_durable_disconnect(struct files_struct *fsp,
+                                       const DATA_BLOB old_cookie,
+                                       TALLOC_CTX *mem_ctx,
+                                       DATA_BLOB *new_cookie);
+NTSTATUS vfs_default_durable_reconnect(struct connection_struct *conn,
+                                      struct smb_request *smb1req,
+                                      struct smbXsrv_open *op,
+                                      const DATA_BLOB old_cookie,
+                                      TALLOC_CTX *mem_ctx,
+                                      files_struct **result,
+                                      DATA_BLOB *new_cookie);
+
 #endif /* _SMBD_PROTO_H_ */