/* 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);
/* The following definitions come from smbd/blocking.c */
-struct timeval timeval_brl_min(const struct timeval *tv1,
- const struct timeval *tv2);
NTSTATUS smbd_do_locks_try(
struct files_struct *fsp,
enum brl_flavour lock_flav,
struct tevent_req *smbd_smb1_do_locks_send(
TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
- struct messaging_context *msg_ctx,
struct smb_request **smbreq, /* talloc_move()d into our state */
struct files_struct *fsp,
- uint32_t timeout,
+ uint32_t lock_timeout,
bool large_offset,
enum brl_flavour lock_flav,
uint16_t num_locks,
connection_struct *conn,
struct smb_filename *smb_dname);
bool has_other_nonposix_opens(struct share_mode_lock *lck,
- struct files_struct *fsp,
- struct server_id self);
+ struct files_struct *fsp);
/* The following definitions come from smbd/conn.c */
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 */
/* The following definitions come from smbd/dfree.c */
-uint64_t sys_disk_free(connection_struct *conn, struct smb_filename *fname,
- uint64_t *bsize, uint64_t *dfree, uint64_t *dsize);
uint64_t get_dfree_info(connection_struct *conn, struct smb_filename *fname,
uint64_t *bsize, uint64_t *dfree, uint64_t *dsize);
void flush_dfree_cache(void);
const char *dptr_path(struct smbd_server_connection *sconn, int key);
const char *dptr_wcard(struct smbd_server_connection *sconn, int key);
uint16_t dptr_attr(struct smbd_server_connection *sconn, int key);
-void dptr_close(struct smbd_server_connection *sconn, int *key);
void dptr_closecnum(connection_struct *conn);
-void dptr_idlecnum(connection_struct *conn);
-void dptr_closepath(struct smbd_server_connection *sconn,
- char *path,uint16_t spid);
NTSTATUS dptr_create(connection_struct *conn,
struct smb_request *req,
files_struct *fsp,
- const struct smb_filename *smb_dname,
bool old_handle,
bool expect_close,
uint16_t spid,
bool dptr_SearchDir(struct dptr_struct *dptr, const char *name, long *poffset, SMB_STRUCT_STAT *pst);
bool dptr_fill(struct smbd_server_connection *sconn,
char *buf1,unsigned int key);
-struct dptr_struct *dptr_fetch(struct smbd_server_connection *sconn,
+files_struct *dptr_fetch_fsp(struct smbd_server_connection *sconn,
char *buf,int *num);
-struct dptr_struct *dptr_fetch_lanman2(struct smbd_server_connection *sconn,
+files_struct *dptr_fetch_lanman2_fsp(struct smbd_server_connection *sconn,
int dptr_num);
bool get_dir_entry(TALLOC_CTX *ctx,
struct dptr_struct *dirptr,
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,
const char *mask,
uint32_t attr);
-const char *ReadDirName(struct smb_Dir *dirp, long *poffset,
+const char *ReadDirName(struct smb_Dir *dir_hnd, long *poffset,
SMB_STRUCT_STAT *sbuf, char **talloced);
-void RewindDir(struct smb_Dir *dirp, long *poffset);
+void RewindDir(struct smb_Dir *dir_hnd, long *poffset);
void SeekDir(struct smb_Dir *dirp, long offset);
long TellDir(struct smb_Dir *dirp);
bool SearchDir(struct smb_Dir *dirp, const char *name, long *poffset);
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);
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);
/* 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 */
const char *data,
off_t pos,
size_t n);
-void delete_write_cache(files_struct *fsp);
-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);
/* The following definitions come from smbd/filename.c */
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,
NTSTATUS fsp_new(struct connection_struct *conn, TALLOC_CTX *mem_ctx,
files_struct **result);
+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);
struct files_struct *file_fsp_smb2(struct smbd_smb2_request *smb2req,
uint64_t persistent_id,
uint64_t volatile_id);
-NTSTATUS dup_file_fsp(struct smb_request *req, files_struct *from,
- uint32_t access_mask, uint32_t share_access,
- uint32_t create_options, files_struct *to);
+NTSTATUS dup_file_fsp(
+ struct smb_request *req,
+ files_struct *from,
+ uint32_t access_mask,
+ uint32_t create_options,
+ files_struct *to);
NTSTATUS file_name_hash(connection_struct *conn,
const char *name, uint32_t *p_name_hash);
NTSTATUS fsp_set_smb_fname(struct files_struct *fsp,
const struct smb_filename *smb_fname_in);
-const struct GUID *fsp_client_guid(const files_struct *fsp);
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);
/* 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;
NTSTATUS get_referred_path(TALLOC_CTX *ctx,
+ struct auth_session_info *session_info,
const char *dfs_path,
const struct tsocket_address *remote_address,
const struct tsocket_address *local_address,
const char *dfs_path,
bool allow_broken_path,
struct junction_map *jucn);
-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);
+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,
+ 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,
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,
uint16_t break_to);
struct deferred_open_record;
bool is_deferred_open_async(const struct deferred_open_record *rec);
+bool defer_smb1_sharing_violation(struct smb_request *req);
NTSTATUS create_directory(connection_struct *conn, struct smb_request *req,
struct smb_filename *smb_dname);
void msg_file_was_renamed(struct messaging_context *msg,
uint32_t create_options,
uint32_t file_attributes,
uint32_t oplock_request,
- struct smb2_lease *lease,
+ const struct smb2_lease *lease,
uint64_t allocation_size,
uint32_t private_flags,
struct security_descriptor *sd,
const struct smb2_create_blobs *in_context_blobs,
struct smb2_create_blobs *out_context_blobs);
-NTSTATUS get_relative_fid_filename(connection_struct *conn,
- struct smb_request *req,
- uint16_t root_dir_fid,
- const struct smb_filename *smb_fname,
- struct smb_filename **smb_fname_out);
-
/* The following definitions come from smbd/oplock.c */
-uint32_t get_lease_type(const struct share_mode_data *d,
- const struct share_mode_entry *e);
-bool update_num_read_oplocks(files_struct *fsp, struct share_mode_lock *lck);
+uint32_t get_lease_type(const struct share_mode_entry *e, struct file_id id);
void break_kernel_oplock(struct messaging_context *msg_ctx, files_struct *fsp);
NTSTATUS set_file_oplock(files_struct *fsp);
-bool remove_oplock_under_lock(files_struct *fsp, struct share_mode_lock *lck);
bool remove_oplock(files_struct *fsp);
bool downgrade_oplock(files_struct *fsp);
bool fsp_lease_update(struct files_struct *fsp);
/* 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);
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,
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,
struct timeval *p_request_time,
struct deferred_open_record **open_rec);
bool push_deferred_open_message_smb(struct smb_request *req,
- struct timeval request_time,
- struct timeval timeout,
- struct file_id id,
- struct deferred_open_record *open_rec);
+ struct timeval timeout,
+ struct file_id id,
+ struct deferred_open_record *open_rec);
NTSTATUS allow_new_trans(struct trans_state *list, uint64_t mid);
void reply_outbuf(struct smb_request *req, uint8_t num_words, uint32_t num_bytes);
void smb_request_done(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,
+ struct dcesrv_context *dce_ctx,
int sock_fd,
bool interactive);
bool fork_echo_handler(struct smbXsrv_connection *xconn);
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,
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,
/* 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);
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,
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);
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_user_by_fsp(struct files_struct *fsp);
+bool change_to_user_and_service(connection_struct *conn, uint64_t vuid);
+bool change_to_user_and_service_by_fsp(struct files_struct *fsp);
bool smbd_change_to_root_user(void);
bool smbd_become_authenticated_pipe_user(struct auth_session_info *session_info);
bool smbd_unbecome_authenticated_pipe_user(void);
void unbecome_root(void);
void smbd_become_root(void);
void smbd_unbecome_root(void);
-bool become_user(connection_struct *conn, uint64_t vuid);
-bool become_user_by_fsp(struct files_struct *fsp);
-bool become_user_by_session(connection_struct *conn,
+bool become_user_without_service(connection_struct *conn, uint64_t vuid);
+bool become_user_without_service_by_fsp(struct files_struct *fsp);
+bool become_user_without_service_by_session(connection_struct *conn,
const struct auth_session_info *session_info);
-bool unbecome_user(void);
+bool unbecome_user_without_service(void);
uid_t get_current_uid(connection_struct *conn);
gid_t get_current_gid(connection_struct *conn);
const struct security_unix_token *get_current_utok(connection_struct *conn);
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);
+int vfs_set_blocking(files_struct *fsp, bool set);
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);
const struct smb_filename *smb_fname_in,
SMB_STRUCT_STAT *psbuf);
NTSTATUS vfs_stat_fsp(files_struct *fsp);
-NTSTATUS vfs_chown_fsp(files_struct *fsp, uid_t uid, gid_t gid);
NTSTATUS vfs_streaminfo(connection_struct *conn,
struct files_struct *fsp,
const struct smb_filename *smb_fname,
TALLOC_CTX *mem_ctx,
unsigned int *num_streams,
struct stream_struct **streams);
+void init_smb_file_time(struct smb_file_time *ft);
/* The following definitions come from smbd/avahi_register.c */