s3: smbd: Reformat users of can_write_to_file().
[samba.git] / source3 / smbd / proto.h
index fa64e611347a4f40a1e0b5e32321229dfe44d806..5303c477cf7b16ad5aaf35a4213ce019b41e7f17 100644 (file)
@@ -49,6 +49,7 @@
 /* The following definitions come from smbd/signing.c  */
 
 struct smbXsrv_connection;
+struct dcesrv_context;
 
 bool srv_check_sign_mac(struct smbXsrv_connection *conn,
                        const char *inbuf, uint32_t *seqnum, bool trusted_channel);
@@ -154,12 +155,22 @@ connection_struct *conn_new(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, uint64_t vuid);
 void conn_free(connection_struct *conn);
-void conn_force_tdis(struct smbd_server_connection *sconn, const char *sharename);
+void conn_force_tdis(
+       struct smbd_server_connection *sconn,
+       bool (*check_fn)(struct connection_struct *conn,
+                        void *private_data),
+       void *private_data);
 void msg_force_tdis(struct messaging_context *msg,
                    void *private_data,
                    uint32_t msg_type,
                    struct server_id server_id,
                    DATA_BLOB *data);
+void msg_force_tdis_denied(
+       struct messaging_context *msg,
+       void *private_data,
+       uint32_t msg_type,
+       struct server_id server_id,
+       DATA_BLOB *data);
 
 /* The following definitions come from smbd/connection.c  */
 
@@ -213,7 +224,12 @@ bool get_dir_entry(TALLOC_CTX *ctx,
                struct timespec *date,
                bool check_descend,
                bool ask_sharemode);
-bool is_visible_file(connection_struct *conn, const char *dir_path, const char *name, SMB_STRUCT_STAT *pst, bool use_veto);
+struct smb_Dir;
+bool is_visible_file(connection_struct *conn,
+               struct smb_Dir *dir_hnd,
+               const char *name,
+               SMB_STRUCT_STAT *pst,
+               bool use_veto);
 struct smb_Dir *OpenDir(TALLOC_CTX *mem_ctx,
                        connection_struct *conn,
                        const struct smb_filename *smb_fname,
@@ -248,7 +264,7 @@ bool smbd_setup_mdns_registration(struct tevent_context *ev,
 
 mode_t unix_mode(connection_struct *conn, int dosmode,
                 const struct smb_filename *smb_fname,
-                const char *inherit_from_dir);
+                struct smb_filename *smb_fname_parent);
 uint32_t dos_mode_msdfs(connection_struct *conn,
                      const struct smb_filename *smb_fname);
 uint32_t dos_mode(connection_struct *conn, struct smb_filename *smb_fname);
@@ -257,8 +273,11 @@ struct tevent_req *dos_mode_at_send(TALLOC_CTX *mem_ctx,
                                    files_struct *dir_fsp,
                                    struct smb_filename *smb_fname);
 NTSTATUS dos_mode_at_recv(struct tevent_req *req, uint32_t *dosmode);
-int file_set_dosmode(connection_struct *conn, struct smb_filename *smb_fname,
-                    uint32_t dosmode, const char *parent_dir, bool newfile);
+int file_set_dosmode(connection_struct *conn,
+                    struct smb_filename *smb_fname,
+                    uint32_t dosmode,
+                    struct smb_filename *parent_dir,
+                    bool newfile);
 NTSTATUS file_set_sparse(connection_struct *conn,
                         struct files_struct *fsp,
                         bool sparse);
@@ -312,10 +331,13 @@ void reply_openerror(struct smb_request *req, NTSTATUS status);
 /* The following definitions come from smbd/file_access.c  */
 
 bool can_delete_file_in_directory(connection_struct *conn,
-                                 const struct smb_filename *smb_fname);
+                       struct files_struct *dirfsp,
+                       const struct smb_filename *smb_fname);
 bool can_write_to_file(connection_struct *conn,
-                      const struct smb_filename *smb_fname);
-bool directory_has_default_acl(connection_struct *conn, const char *fname);
+                       const struct smb_filename *smb_fname);
+bool directory_has_default_acl(connection_struct *conn,
+                       struct files_struct *dirfsp,
+                       struct smb_filename *smb_fname);
 NTSTATUS can_set_delete_on_close(files_struct *fsp, uint32_t dosmode);
 
 /* The following definitions come from smbd/fileio.c  */
@@ -346,6 +368,10 @@ NTSTATUS check_name(connection_struct *conn,
 int get_real_filename(connection_struct *conn, const char *path,
                      const char *name, TALLOC_CTX *mem_ctx,
                      char **found_name);
+char *get_original_lcomp(TALLOC_CTX *ctx,
+                       connection_struct *conn,
+                       const char *filename_in,
+                       uint32_t ucf_flags);
 NTSTATUS filename_convert(TALLOC_CTX *mem_ctx,
                        connection_struct *conn,
                        const char *name_in,
@@ -369,8 +395,6 @@ void fsp_set_gen_id(files_struct *fsp);
 NTSTATUS file_new(struct smb_request *req, connection_struct *conn,
                  files_struct **result);
 void file_close_conn(connection_struct *conn);
-void file_close_pid(struct smbd_server_connection *sconn, uint16_t smbpid,
-                   uint64_t vuid);
 bool file_init_global(void);
 bool file_init(struct smbd_server_connection *sconn);
 void file_close_user(struct smbd_server_connection *sconn, uint64_t vuid);
@@ -410,6 +434,16 @@ NTSTATUS fsp_set_smb_fname(struct files_struct *fsp,
                           const struct smb_filename *smb_fname_in);
 size_t fsp_fullbasepath(struct files_struct *fsp, char *buf, size_t buflen);
 
+NTSTATUS create_internal_dirfsp_at(connection_struct *conn,
+                                  struct files_struct *dirfsp,
+                                  const struct smb_filename *smb_dname,
+                                  struct files_struct **_fsp);
+
+NTSTATUS open_internal_dirfsp_at(connection_struct *conn,
+                                struct files_struct *dirfsp,
+                                const struct smb_filename *smb_dname,
+                                struct files_struct **_fsp);
+
 /* The following definitions come from smbd/ipc.c  */
 
 NTSTATUS nt_status_np_pipe(NTSTATUS status);
@@ -467,6 +501,11 @@ void reply_sendend(struct smb_request *req);
 
 /* The following definitions come from smbd/msdfs.c  */
 
+bool parse_msdfs_symlink(TALLOC_CTX *ctx,
+                       bool shuffle_referrals,
+                       const char *target,
+                       struct referral **preflist,
+                       size_t *refcount);
 bool is_msdfs_link(connection_struct *conn,
                struct smb_filename *smb_fname);
 struct junction_map;
@@ -491,9 +530,14 @@ struct referral;
 char *msdfs_link_string(TALLOC_CTX *ctx,
                const struct referral *reflist,
                size_t referral_count);
-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);
+bool create_msdfs_link(const struct junction_map *jucn,
+                      struct auth_session_info *session_info);
+bool remove_msdfs_link(const struct junction_map *jucn,
+                      struct auth_session_info *session_info);
+
+struct junction_map *enum_msdfs_links(TALLOC_CTX *ctx,
+                                     struct auth_session_info *session_info,
+                                     size_t *p_num_jn);
 NTSTATUS resolve_dfspath_wcard(TALLOC_CTX *ctx,
                                connection_struct *conn,
                                const char *name_in,
@@ -668,9 +712,10 @@ 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,
+                                struct smb_filename *inherit_from_dir,
                                 files_struct *fsp);
-bool is_stat_open(uint32_t access_mask);
+bool is_oplock_stat_open(uint32_t access_mask);
+bool is_lease_stat_open(uint32_t access_mask);
 NTSTATUS send_break_message(struct messaging_context *msg_ctx,
                            const struct file_id *id,
                            const struct share_mode_entry *exclusive,
@@ -742,15 +787,12 @@ void init_kernel_oplocks(struct smbd_server_connection *sconn);
 
 /* The following definitions come from smbd/oplock_linux.c  */
 
-void linux_set_lease_capability(void);
 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/password.c  */
 
-struct user_struct *get_valid_user_struct(struct smbd_server_connection *sconn,
-                                         uint64_t vuid);
 void invalidate_vuid(struct smbd_server_connection *sconn, uint64_t vuid);
 int register_homes_share(const char *username);
 
@@ -788,7 +830,7 @@ int get_acl_group_bits( connection_struct *conn,
                        const struct smb_filename *smb_fname,
                        mode_t *mode);
 int inherit_access_posix_acl(connection_struct *conn,
-                       const char *inherit_from_dir,
+                       struct smb_filename *inherit_from_dir,
                        const struct smb_filename *smb_fname,
                        mode_t mode);
 NTSTATUS set_unix_posix_default_acl(connection_struct *conn,
@@ -797,9 +839,6 @@ NTSTATUS set_unix_posix_default_acl(connection_struct *conn,
 NTSTATUS set_unix_posix_acl(connection_struct *conn, files_struct *fsp,
                                uint16_t num_acls,
                                const char *pdata);
-NTSTATUS get_nt_acl_no_snum( TALLOC_CTX *ctx, const char *fname,
-                            uint32_t security_info_wanted,
-                            struct security_descriptor **sd);
 int posix_sys_acl_blob_get_file(vfs_handle_struct *handle,
                                const struct smb_filename *smb_fname,
                                TALLOC_CTX *mem_ctx,
@@ -866,6 +905,7 @@ bool smb1_parse_chain(TALLOC_CTX *mem_ctx, const uint8_t *buf,
 bool req_is_in_chain(const struct smb_request *req);
 void smbd_process(struct tevent_context *ev_ctx,
                  struct messaging_context *msg_ctx,
+                 struct dcesrv_context *dce_ctx,
                  int sock_fd,
                  bool interactive);
 bool fork_echo_handler(struct smbXsrv_connection *xconn);
@@ -985,6 +1025,7 @@ void reply_rmdir(struct smb_request *req);
 NTSTATUS rename_internals_fsp(connection_struct *conn,
                        files_struct *fsp,
                        const struct smb_filename *smb_fname_dst_in,
+                       const char *dst_original_lcomp,
                        uint32_t attrs,
                        bool replace_if_exists);
 NTSTATUS rename_internals(TALLOC_CTX *ctx,
@@ -992,6 +1033,7 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx,
                        struct smb_request *req,
                        struct smb_filename *smb_fname_src,
                        struct smb_filename *smb_fname_dst,
+                       const char *dst_original_lcomp,
                        uint32_t attrs,
                        bool replace_if_exists,
                        bool src_has_wild,
@@ -1062,6 +1104,7 @@ 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);
+bool canonicalize_connect_path(connection_struct *conn);
 NTSTATUS set_conn_force_user_group(connection_struct *conn, int snum);
 void set_current_case_sensitive(connection_struct *conn, uint16_t flags);
 bool chdir_current_service(connection_struct *conn);
@@ -1071,7 +1114,6 @@ int find_service(TALLOC_CTX *ctx, const char *service, char **p_service_out);
 connection_struct *make_connection_smb2(struct smbd_smb2_request *req,
                                        struct smbXsrv_tcon *tcon,
                                        int snum,
-                                       struct user_struct *vuser,
                                        const char *pdev,
                                        NTSTATUS *pstatus);
 connection_struct *make_connection(struct smb_request *req,
@@ -1184,6 +1226,19 @@ void reply_findnclose(struct smb_request *req);
 void reply_trans2(struct smb_request *req);
 void reply_transs2(struct smb_request *req);
 
+enum perm_type {
+       PERM_NEW_FILE,
+       PERM_NEW_DIR,
+       PERM_EXISTING_FILE,
+       PERM_EXISTING_DIR
+};
+
+NTSTATUS unix_perms_from_wire(connection_struct *conn,
+                             const SMB_STRUCT_STAT *psbuf,
+                             uint32_t perms,
+                             enum perm_type ptype,
+                             mode_t *ret_perms);
+
 /* The following definitions come from smbd/uid.c  */
 
 bool change_to_guest(void);