2011-05-31 02:12:27 +04:00
/*
* Unix SMB / CIFS implementation .
* Main SMB server routines
*
* Copyright ( C ) Andrew Tridgell 1992 - 2002 , 2006
* Copyright ( C ) Jeremy Allison 1992 - 2010
* Copyright ( C ) Volker Lendecke 1993 - 2009
* Copyright ( C ) John H Terpstra 1995 - 1998
* Copyright ( C ) Luke Kenneth Casson Leighton 1996 - 1998
* Copyright ( C ) Paul Ashton 1997 - 1998
* Copyright ( C ) Tim Potter 1999 - 2000
* Copyright ( C ) T . D . Lee @ durham . ac . uk 1999
* Copyright ( C ) Ying Chen 2000
* Copyright ( C ) Shirish Kalele 2000
* Copyright ( C ) Andrew Bartlett 2001 - 2003
* Copyright ( C ) Alexander Bokovoy 2002 , 2005
* Copyright ( C ) Simo Sorce 2001 - 2002 , 2009
* Copyright ( C ) Andreas Gruenbacher 2002
* Copyright ( C ) Jim McDonough < jmcd @ us . ibm . com > 2002
* Copyright ( C ) Martin Pool 2002
* Copyright ( C ) Luke Howard 2003
* Copyright ( C ) Stefan ( metze ) Metzmacher 2003 , 2009
* Copyright ( C ) Steve French 2005
* Copyright ( C ) Gerald ( Jerry ) Carter 2006
* Copyright ( C ) James Peach 2006 - 2007
* Copyright ( C ) Jelmer Vernooij 2002 - 2003
* Copyright ( C ) Michael Adam 2007
* Copyright ( C ) Rishi Srivatsavai 2007
* Copyright ( C ) Tim Prouty 2009
* Copyright ( C ) Gregor Beck 2011
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program . If not , see < http : //www.gnu.org/licenses/>.
*/
2011-03-19 02:47:12 +03:00
2011-05-31 02:13:15 +04:00
# ifndef _SMBD_PROTO_H_
# define _SMBD_PROTO_H_
2020-06-02 17:33:23 +03:00
struct smbXsrv_client ;
2014-05-21 16:44:01 +04:00
struct smbXsrv_connection ;
2019-02-26 15:58:43 +03:00
struct dcesrv_context ;
2014-05-21 16:44:01 +04:00
2022-03-17 22:55:25 +03:00
/* The following definitions come from smbd/smb2_signing.c */
2022-03-17 23:28:10 +03:00
bool srv_init_signing ( struct smbXsrv_connection * conn ) ;
2022-03-17 22:55:25 +03:00
2011-03-19 02:47:12 +03:00
/* The following definitions come from smbd/aio.c */
2012-07-13 12:22:05 +04:00
struct aio_extra ;
2012-07-12 21:57:47 +04:00
bool aio_write_through_requested ( struct aio_extra * aio_ex ) ;
2011-03-19 02:47:12 +03:00
NTSTATUS schedule_smb2_aio_read ( connection_struct * conn ,
struct smb_request * smbreq ,
files_struct * fsp ,
TALLOC_CTX * ctx ,
DATA_BLOB * preadbuf ,
2012-04-05 08:53:08 +04:00
off_t startpos ,
2011-03-19 02:47:12 +03:00
size_t smb_maxcnt ) ;
NTSTATUS schedule_aio_smb2_write ( connection_struct * conn ,
struct smb_request * smbreq ,
files_struct * fsp ,
uint64_t in_offset ,
DATA_BLOB in_data ,
bool write_through ) ;
2011-11-14 12:52:47 +04:00
bool cancel_smb2_aio ( struct smb_request * smbreq ) ;
2014-12-05 08:13:33 +03:00
bool aio_add_req_to_fsp ( files_struct * fsp , struct tevent_req * req ) ;
2022-03-11 19:17:59 +03:00
struct aio_extra * create_aio_extra ( TALLOC_CTX * mem_ctx ,
files_struct * fsp ,
size_t buflen ) ;
2022-03-11 19:21:35 +03:00
struct tevent_req * pwrite_fsync_send ( TALLOC_CTX * mem_ctx ,
struct tevent_context * ev ,
struct files_struct * fsp ,
const void * data ,
size_t n , off_t offset ,
bool write_through ) ;
ssize_t pwrite_fsync_recv ( struct tevent_req * req , int * perr ) ;
2011-03-19 02:47:12 +03:00
/* The following definitions come from smbd/blocking.c */
2019-06-13 13:38:57 +03:00
NTSTATUS smbd_do_locks_try (
struct files_struct * fsp ,
uint16_t num_locks ,
struct smbd_lock_element * locks ,
uint16_t * blocker_idx ,
struct server_id * blocking_pid ,
uint64_t * blocking_smblctx ) ;
struct tevent_req * smbd_smb1_do_locks_send (
TALLOC_CTX * mem_ctx ,
struct tevent_context * ev ,
struct smb_request * * smbreq , /* talloc_move()d into our state */
struct files_struct * fsp ,
2019-08-13 19:34:36 +03:00
uint32_t lock_timeout ,
2019-06-13 13:38:57 +03:00
bool large_offset ,
uint16_t num_locks ,
struct smbd_lock_element * locks ) ;
NTSTATUS smbd_smb1_do_locks_recv ( struct tevent_req * req ) ;
bool smbd_smb1_do_locks_extract_smbreq (
struct tevent_req * req ,
TALLOC_CTX * mem_ctx ,
struct smb_request * * psmbreq ) ;
void smbd_smb1_brl_finish_by_req ( struct tevent_req * req , NTSTATUS status ) ;
bool smbd_smb1_brl_finish_by_lock (
struct files_struct * fsp ,
bool large_offset ,
struct smbd_lock_element lock ,
NTSTATUS finish_status ) ;
bool smbd_smb1_brl_finish_by_mid (
struct smbd_server_connection * sconn , uint64_t mid ) ;
2011-03-19 02:47:12 +03:00
/* The following definitions come from smbd/close.c */
void set_close_write_time ( struct files_struct * fsp , struct timespec ts ) ;
2022-02-09 20:03:33 +03:00
NTSTATUS close_file_smb ( struct smb_request * req ,
struct files_struct * fsp ,
enum file_close_type close_type ) ;
2022-02-01 19:47:29 +03:00
NTSTATUS close_file_free ( struct smb_request * req ,
struct files_struct * * _fsp ,
enum file_close_type close_type ) ;
2011-03-19 02:47:12 +03:00
void msg_close_file ( struct messaging_context * msg_ctx ,
void * private_data ,
uint32_t msg_type ,
struct server_id server_id ,
DATA_BLOB * data ) ;
2016-03-05 01:07:04 +03:00
NTSTATUS delete_all_streams ( connection_struct * conn ,
const struct smb_filename * smb_fname ) ;
2022-03-03 20:34:45 +03:00
NTSTATUS recursive_rmdir ( TALLOC_CTX * ctx ,
2012-10-01 11:55:28 +04:00
connection_struct * conn ,
struct smb_filename * smb_dname ) ;
2018-09-08 17:58:36 +03:00
bool has_other_nonposix_opens ( struct share_mode_lock * lck ,
2019-08-14 22:27:53 +03:00
struct files_struct * fsp ) ;
2024-10-16 08:37:25 +03:00
bool has_nonposix_opens ( struct share_mode_lock * lck ) ;
2011-03-19 02:47:12 +03:00
/* The following definitions come from smbd/conn.c */
int conn_num_open ( struct smbd_server_connection * sconn ) ;
2011-05-25 07:00:22 +04:00
bool conn_snum_used ( struct smbd_server_connection * sconn , int snum ) ;
2024-02-13 14:26:22 +03:00
enum protocol_types conn_protocol ( struct smbd_server_connection * sconn ) ;
2024-02-13 14:28:06 +03:00
bool conn_using_smb2 ( struct smbd_server_connection * sconn ) ;
2011-03-19 02:47:12 +03:00
connection_struct * conn_new ( struct smbd_server_connection * sconn ) ;
bool conn_idle_all ( struct smbd_server_connection * sconn , time_t t ) ;
2012-06-05 17:50:21 +04:00
void conn_clear_vuid_caches ( struct smbd_server_connection * sconn , uint64_t vuid ) ;
2011-03-19 02:47:12 +03:00
void conn_free ( connection_struct * conn ) ;
2021-01-12 22:39:51 +03:00
void conn_setup_case_options ( connection_struct * conn ) ;
2020-01-13 17:37:25 +03:00
void conn_force_tdis (
struct smbd_server_connection * sconn ,
bool ( * check_fn ) ( struct connection_struct * conn ,
void * private_data ) ,
void * private_data ) ;
2011-03-19 02:47:12 +03:00
void msg_force_tdis ( struct messaging_context * msg ,
void * private_data ,
uint32_t msg_type ,
struct server_id server_id ,
DATA_BLOB * data ) ;
2020-01-13 17:19:58 +03:00
void msg_force_tdis_denied (
struct messaging_context * msg ,
void * private_data ,
uint32_t msg_type ,
struct server_id server_id ,
DATA_BLOB * data ) ;
2011-03-19 02:47:12 +03:00
/* The following definitions come from smbd/connection.c */
2012-08-27 17:12:36 +04:00
int count_current_connections ( const char * sharename , bool verify ) ;
2011-12-13 15:18:01 +04:00
bool connections_snum_used ( struct smbd_server_connection * unused , int snum ) ;
2011-03-19 02:47:12 +03:00
/* The following definitions come from smbd/dfree.c */
2016-01-14 01:09:36 +03:00
uint64_t get_dfree_info ( connection_struct * conn , struct smb_filename * fname ,
uint64_t * bsize , uint64_t * dfree , uint64_t * dsize ) ;
2018-05-19 06:51:58 +03:00
void flush_dfree_cache ( void ) ;
2011-03-19 02:47:12 +03:00
/* The following definitions come from smbd/dmapi.c */
const void * dmapi_get_current_session ( void ) ;
bool dmapi_have_session ( void ) ;
bool dmapi_new_session ( void ) ;
bool dmapi_destroy_session ( void ) ;
2015-05-03 07:01:14 +03:00
uint32_t dmapi_file_flags ( const char * const path ) ;
2011-03-19 02:47:12 +03:00
/* The following definitions come from smbd/dnsregister.c */
bool smbd_setup_mdns_registration ( struct tevent_context * ev ,
TALLOC_CTX * mem_ctx ,
uint16_t port ) ;
/* The following definitions come from smbd/dosmode.c */
2024-09-20 22:33:33 +03:00
mode_t apply_conf_file_mask ( struct connection_struct * conn , mode_t mode ) ;
mode_t apply_conf_dir_mask ( struct connection_struct * conn , mode_t mode ) ;
2011-03-19 02:47:12 +03:00
mode_t unix_mode ( connection_struct * conn , int dosmode ,
const struct smb_filename * smb_fname ,
2022-03-03 13:52:12 +03:00
struct files_struct * parent_dirfsp ) ;
2015-05-03 07:01:14 +03:00
uint32_t dos_mode_msdfs ( connection_struct * conn ,
2023-06-20 17:28:19 +03:00
const char * name ,
const struct stat_ex * st ) ;
2020-10-19 16:44:29 +03:00
uint32_t fdos_mode ( struct files_struct * fsp ) ;
2018-03-15 17:21:53 +03:00
struct tevent_req * dos_mode_at_send ( TALLOC_CTX * mem_ctx ,
2018-12-28 14:16:27 +03:00
struct tevent_context * ev ,
2018-03-15 17:21:53 +03:00
files_struct * dir_fsp ,
struct smb_filename * smb_fname ) ;
NTSTATUS dos_mode_at_recv ( struct tevent_req * req , uint32_t * dosmode ) ;
2020-04-28 19:06:21 +03:00
int file_set_dosmode ( connection_struct * conn ,
struct smb_filename * smb_fname ,
uint32_t dosmode ,
2020-04-28 19:09:18 +03:00
struct smb_filename * parent_dir ,
2020-04-28 19:06:21 +03:00
bool newfile ) ;
2011-03-19 02:47:12 +03:00
NTSTATUS file_set_sparse ( connection_struct * conn ,
struct files_struct * fsp ,
bool sparse ) ;
2021-04-13 18:05:57 +03:00
int file_ntimes ( connection_struct * conn ,
files_struct * fsp ,
2011-03-19 02:47:12 +03:00
struct smb_file_time * ft ) ;
bool set_sticky_write_time_fsp ( struct files_struct * fsp ,
struct timespec mtime ) ;
2020-11-03 09:57:03 +03:00
NTSTATUS fget_ea_dos_attribute ( struct files_struct * fsp ,
uint32_t * pattr ) ;
2016-03-20 22:51:32 +03:00
NTSTATUS set_ea_dos_attribute ( connection_struct * conn ,
2022-08-21 14:38:16 +03:00
struct smb_filename * smb_fname ,
2016-03-20 22:51:32 +03:00
uint32_t dosmode ) ;
2021-05-20 19:28:29 +03:00
NTSTATUS set_create_timespec_ea ( struct files_struct * fsp ,
2011-03-19 02:47:12 +03:00
struct timespec create_time ) ;
struct timespec get_create_timespec ( connection_struct * conn ,
struct files_struct * fsp ,
const struct smb_filename * smb_fname ) ;
struct timespec get_change_timespec ( connection_struct * conn ,
struct files_struct * fsp ,
const struct smb_filename * smb_fname ) ;
2018-03-15 12:56:28 +03:00
NTSTATUS parse_dos_attribute_blob ( struct smb_filename * smb_fname ,
DATA_BLOB blob ,
uint32_t * pattr ) ;
2011-03-19 02:47:12 +03:00
/* The following definitions come from smbd/error.c */
bool use_nt_status ( void ) ;
2015-05-03 07:01:14 +03:00
void error_packet_set ( char * outbuf , uint8_t eclass , uint32_t ecode , NTSTATUS ntstatus , int line , const char * file ) ;
2018-05-16 18:05:38 +03:00
size_t error_packet ( char * outbuf ,
uint8_t eclass ,
uint32_t ecode ,
NTSTATUS ntstatus ,
int line ,
const char * file ) ;
2011-03-19 02:47:12 +03:00
void reply_nt_error ( struct smb_request * req , NTSTATUS ntstatus ,
int line , const char * file ) ;
2015-05-03 07:01:14 +03:00
void reply_force_dos_error ( struct smb_request * req , uint8_t eclass , uint32_t ecode ,
2011-03-19 02:47:12 +03:00
int line , const char * file ) ;
2015-05-03 07:01:14 +03:00
void reply_both_error ( struct smb_request * req , uint8_t eclass , uint32_t ecode ,
2011-03-19 02:47:12 +03:00
NTSTATUS status , int line , const char * file ) ;
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 ,
2020-05-01 01:28:32 +03:00
struct files_struct * dirfsp ,
2020-05-01 01:20:34 +03:00
const struct smb_filename * smb_fname ) ;
2021-06-02 21:36:59 +03:00
bool can_write_to_fsp ( struct files_struct * fsp ) ;
2021-05-25 02:58:12 +03:00
bool directory_has_default_acl_fsp ( struct files_struct * fsp ) ;
2015-05-03 07:01:14 +03:00
NTSTATUS can_set_delete_on_close ( files_struct * fsp , uint32_t dosmode ) ;
2011-03-19 02:47:12 +03:00
/* The following definitions come from smbd/fileio.c */
2012-04-05 08:53:08 +04:00
ssize_t read_file ( files_struct * fsp , char * data , off_t pos , size_t n ) ;
2018-05-23 10:41:29 +03:00
void fsp_flush_write_time_update ( struct files_struct * fsp ) ;
2011-03-19 02:47:12 +03:00
void trigger_write_time_update ( struct files_struct * fsp ) ;
void trigger_write_time_update_immediate ( struct files_struct * fsp ) ;
2012-07-12 18:28:11 +04:00
void mark_file_modified ( files_struct * fsp ) ;
2011-03-19 02:47:12 +03:00
ssize_t write_file ( struct smb_request * req ,
files_struct * fsp ,
const char * data ,
2012-04-05 08:53:08 +04:00
off_t pos ,
2011-03-19 02:47:12 +03:00
size_t n ) ;
NTSTATUS sync_file ( connection_struct * conn , files_struct * fsp , bool write_through ) ;
/* The following definitions come from smbd/filename.c */
2017-05-18 21:56:39 +03:00
uint32_t ucf_flags_from_smb_request ( struct smb_request * req ) ;
2024-02-02 23:16:46 +03:00
uint32_t filename_create_ucf_flags ( struct smb_request * req ,
uint32_t create_disposition ,
uint32_t create_options ) ;
2020-05-02 13:55:33 +03:00
NTSTATUS canonicalize_snapshot_path ( struct smb_filename * smb_fname ,
2020-05-04 14:51:37 +03:00
uint32_t ucf_flags ,
2020-05-02 13:55:33 +03:00
NTTIME twrp ) ;
2022-03-13 17:55:25 +03:00
NTSTATUS get_real_filename_full_scan_at ( struct files_struct * dirfsp ,
const char * name ,
bool mangled ,
TALLOC_CTX * mem_ctx ,
char * * found_name ) ;
2020-03-25 20:00:57 +03:00
char * get_original_lcomp ( TALLOC_CTX * ctx ,
connection_struct * conn ,
const char * filename_in ,
uint32_t ucf_flags ) ;
2022-07-14 20:37:30 +03:00
NTSTATUS get_real_filename_at ( struct files_struct * dirfsp ,
const char * name ,
TALLOC_CTX * mem_ctx ,
char * * found_name ) ;
2011-03-19 02:47:12 +03:00
/* The following definitions come from smbd/files.c */
2012-06-07 18:13:36 +04:00
NTSTATUS fsp_new ( struct connection_struct * conn , TALLOC_CTX * mem_ctx ,
files_struct * * result ) ;
2019-09-16 13:54:32 +03:00
void fsp_set_gen_id ( files_struct * fsp ) ;
2011-03-19 02:47:12 +03:00
NTSTATUS file_new ( struct smb_request * req , connection_struct * conn ,
files_struct * * result ) ;
2020-06-19 08:31:51 +03:00
NTSTATUS fsp_bind_smb ( struct files_struct * fsp , struct smb_request * req ) ;
2022-08-17 21:39:36 +03:00
void file_close_conn ( connection_struct * conn , enum file_close_type close_type ) ;
2012-05-24 14:20:30 +04:00
bool file_init_global ( void ) ;
2011-03-19 02:47:12 +03:00
bool file_init ( struct smbd_server_connection * sconn ) ;
2012-06-05 20:23:14 +04:00
void file_close_user ( struct smbd_server_connection * sconn , uint64_t vuid ) ;
2011-03-19 02:47:12 +03:00
struct files_struct * files_forall (
struct smbd_server_connection * sconn ,
struct files_struct * ( * fn ) ( struct files_struct * fsp ,
void * private_data ) ,
void * private_data ) ;
files_struct * file_find_fd ( struct smbd_server_connection * sconn , int fd ) ;
files_struct * file_find_dif ( struct smbd_server_connection * sconn ,
struct file_id id , unsigned long gen_id ) ;
files_struct * file_find_di_first ( struct smbd_server_connection * sconn ,
2020-11-19 13:35:23 +03:00
struct file_id id ,
bool need_fsa ) ;
files_struct * file_find_di_next ( files_struct * start_fsp ,
bool need_fsa ) ;
2014-10-29 01:31:46 +03:00
struct files_struct * file_find_one_fsp_from_lease_key (
struct smbd_server_connection * sconn ,
const struct smb2_lease_key * lease_key ) ;
2011-03-19 02:47:12 +03:00
bool file_find_subpath ( files_struct * dir_fsp ) ;
2022-02-09 19:23:03 +03:00
void fsp_unbind_smb ( struct smb_request * req , files_struct * fsp ) ;
2011-03-19 02:47:12 +03:00
void file_free ( struct smb_request * req , files_struct * fsp ) ;
2015-05-03 07:01:14 +03:00
files_struct * file_fsp ( struct smb_request * req , uint16_t fid ) ;
2013-01-15 20:23:04 +04:00
struct files_struct * file_fsp_get ( struct smbd_smb2_request * smb2req ,
uint64_t persistent_id ,
uint64_t volatile_id ) ;
2012-06-08 12:11:57 +04:00
struct files_struct * file_fsp_smb2 ( struct smbd_smb2_request * smb2req ,
uint64_t persistent_id ,
uint64_t volatile_id ) ;
2011-03-19 02:47:12 +03:00
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 ) ;
2016-06-13 17:12:54 +03:00
size_t fsp_fullbasepath ( struct files_struct * fsp , char * buf , size_t buflen ) ;
2020-12-21 17:44:22 +03:00
void fsp_set_base_fsp ( struct files_struct * fsp , struct files_struct * base_fsp ) ;
2022-02-11 11:37:35 +03:00
bool fsp_is_alternate_stream ( const struct files_struct * fsp ) ;
2022-02-11 11:45:30 +03:00
struct files_struct * metadata_fsp ( struct files_struct * fsp ) ;
2022-05-11 19:09:10 +03:00
bool fsp_search_ask_sharemode ( struct files_struct * fsp ) ;
bool fsp_getinfo_ask_sharemode ( struct files_struct * fsp ) ;
2011-03-19 02:47:12 +03:00
2020-12-23 13:50:34 +03:00
NTSTATUS create_internal_fsp ( connection_struct * conn ,
const struct smb_filename * smb_fname ,
struct files_struct * * _fsp ) ;
2020-05-15 16:14:26 +03:00
NTSTATUS create_internal_dirfsp ( connection_struct * conn ,
const struct smb_filename * smb_dname ,
struct files_struct * * _fsp ) ;
2020-03-23 13:36:42 +03:00
2020-05-15 16:14:26 +03:00
NTSTATUS open_internal_dirfsp ( connection_struct * conn ,
const struct smb_filename * smb_dname ,
int open_flags ,
struct files_struct * * _fsp ) ;
2020-03-23 13:36:42 +03:00
2024-10-11 15:56:21 +03:00
NTSTATUS open_rootdir_pathref_fsp ( connection_struct * conn ,
struct files_struct * * _fsp ) ;
2020-09-29 11:14:47 +03:00
NTSTATUS openat_pathref_fsp ( const struct files_struct * dirfsp ,
struct smb_filename * smb_fname ) ;
2021-12-08 09:08:10 +03:00
NTSTATUS open_stream_pathref_fsp (
struct files_struct * * _base_fsp ,
struct smb_filename * smb_fname ) ;
2022-12-12 16:04:00 +03:00
2024-02-04 20:07:19 +03:00
struct reparse_data_buffer ;
NTSTATUS openat_pathref_fsp_nosymlink (
TALLOC_CTX * mem_ctx ,
struct connection_struct * conn ,
struct files_struct * dirfsp ,
const char * path_in ,
NTTIME twrp ,
bool posix ,
struct smb_filename * * _smb_fname ,
struct reparse_data_buffer * * _symlink_err ) ;
2023-10-18 12:50:20 +03:00
NTSTATUS openat_pathref_fsp_lcomp ( struct files_struct * dirfsp ,
struct smb_filename * smb_fname_rel ,
uint32_t ucf_flags ) ;
2022-09-07 11:43:23 +03:00
NTSTATUS readlink_talloc (
TALLOC_CTX * mem_ctx ,
struct files_struct * dirfsp ,
struct smb_filename * smb_relname ,
char * * _substitute ) ;
2020-09-29 11:14:47 +03:00
2024-02-04 18:07:22 +03:00
NTSTATUS read_symlink_reparse ( TALLOC_CTX * mem_ctx ,
struct files_struct * dirfsp ,
struct smb_filename * smb_relname ,
struct reparse_data_buffer * * _reparse ) ;
2022-12-05 14:15:21 +03:00
2020-11-23 07:59:02 +03:00
void smb_fname_fsp_unlink ( struct smb_filename * smb_fname ) ;
2020-11-23 08:00:40 +03:00
NTSTATUS move_smb_fname_fsp_link ( struct smb_filename * smb_fname_dst ,
struct smb_filename * smb_fname_src ) ;
2022-04-08 12:44:28 +03:00
NTSTATUS reference_smb_fname_fsp_link ( struct smb_filename * smb_fname_dst ,
const struct smb_filename * smb_fname_src ) ;
2021-01-21 17:04:57 +03:00
NTSTATUS synthetic_pathref ( TALLOC_CTX * mem_ctx ,
struct files_struct * dirfsp ,
const char * base_name ,
const char * stream_name ,
const SMB_STRUCT_STAT * psbuf ,
NTTIME twrp ,
uint32_t flags ,
struct smb_filename * * _smb_fname ) ;
2021-01-21 19:05:17 +03:00
NTSTATUS parent_pathref ( TALLOC_CTX * mem_ctx ,
struct files_struct * dirfsp ,
const struct smb_filename * smb_fname ,
struct smb_filename * * _parent ,
struct smb_filename * * _atname ) ;
2022-03-11 19:53:04 +03:00
/* The following definitions come from smbd/smb2_ipc.c */
NTSTATUS nt_status_np_pipe ( NTSTATUS status ) ;
2011-03-19 02:47:12 +03:00
/* The following definitions come from smbd/mangle.c */
void mangle_reset_cache ( void ) ;
void mangle_change_to_posix ( void ) ;
bool mangle_is_mangled ( const char * s , const struct share_params * p ) ;
bool mangle_is_8_3 ( const char * fname , bool check_case ,
const struct share_params * p ) ;
bool mangle_is_8_3_wildcards ( const char * fname , bool check_case ,
const struct share_params * p ) ;
bool mangle_must_mangle ( const char * fname ,
const struct share_params * p ) ;
bool mangle_lookup_name_from_8_3 ( TALLOC_CTX * ctx ,
const char * in ,
char * * out , /* talloced on the given context. */
const struct share_params * p ) ;
bool name_to_8_3 ( const char * in ,
char out [ 13 ] ,
bool cache83 ,
const struct share_params * p ) ;
/* The following definitions come from smbd/mangle_hash.c */
const struct mangle_fns * mangle_hash_init ( void ) ;
/* The following definitions come from smbd/mangle_hash2.c */
const struct mangle_fns * mangle_hash2_init ( void ) ;
const struct mangle_fns * posix_mangle_init ( void ) ;
/* The following definitions come from smbd/msdfs.c */
2020-01-28 03:35:25 +03:00
bool parse_msdfs_symlink ( TALLOC_CTX * ctx ,
bool shuffle_referrals ,
const char * target ,
struct referral * * preflist ,
size_t * refcount ) ;
2021-07-13 03:44:10 +03:00
bool is_msdfs_link ( struct files_struct * dirfsp ,
struct smb_filename * smb_fname ) ;
2011-03-19 02:47:12 +03:00
struct junction_map ;
NTSTATUS get_referred_path ( TALLOC_CTX * ctx ,
2019-12-13 18:19:03 +03:00
struct auth_session_info * session_info ,
2017-03-21 17:32:37 +03:00
const char * dfs_path ,
const struct tsocket_address * remote_address ,
const struct tsocket_address * local_address ,
struct junction_map * jucn ,
2022-08-04 23:23:28 +03:00
size_t * consumedcntp ,
2017-03-21 17:32:37 +03:00
bool * self_referralp ) ;
2011-03-19 02:47:12 +03:00
int setup_dfs_referral ( connection_struct * orig_conn ,
const char * dfs_path ,
int max_referral_level ,
char * * ppdata , NTSTATUS * pstatus ) ;
bool create_junction ( TALLOC_CTX * ctx ,
const char * dfs_path ,
struct junction_map * jucn ) ;
2019-12-13 22:48:05 +03:00
struct referral ;
char * msdfs_link_string ( TALLOC_CTX * ctx ,
const struct referral * reflist ,
size_t referral_count ) ;
2019-12-13 18:23:38 +03:00
bool create_msdfs_link ( const struct junction_map * jucn ,
struct auth_session_info * session_info ) ;
2019-12-13 18:25:44 +03:00
bool remove_msdfs_link ( const struct junction_map * jucn ,
struct auth_session_info * session_info ) ;
2019-12-13 18:31:04 +03:00
struct junction_map * enum_msdfs_links ( TALLOC_CTX * ctx ,
struct auth_session_info * session_info ,
size_t * p_num_jn ) ;
2018-05-24 16:59:43 +03:00
struct connection_struct ;
struct smb_filename ;
2021-05-28 10:25:22 +03:00
NTSTATUS create_conn_struct_cwd ( TALLOC_CTX * mem_ctx ,
struct tevent_context * ev ,
struct messaging_context * msg ,
const struct auth_session_info * session_info ,
int snum ,
const char * path ,
struct connection_struct * * c ) ;
2018-05-24 16:59:43 +03:00
struct conn_struct_tos {
struct connection_struct * conn ;
struct smb_filename * oldcwd_fname ;
} ;
NTSTATUS create_conn_struct_tos ( struct messaging_context * msg ,
int snum ,
const char * path ,
const struct auth_session_info * session_info ,
struct conn_struct_tos * * _c ) ;
NTSTATUS create_conn_struct_tos_cwd ( struct messaging_context * msg ,
int snum ,
const char * path ,
const struct auth_session_info * session_info ,
struct conn_struct_tos * * _c ) ;
2011-03-19 02:47:12 +03:00
/* The following definitions come from smbd/notify.c */
2012-06-05 11:36:36 +04:00
bool change_notify_fsp_has_changes ( struct files_struct * fsp ) ;
2011-03-19 02:47:12 +03:00
void change_notify_reply ( struct smb_request * req ,
NTSTATUS error_code ,
uint32_t max_param ,
struct notify_change_buf * notify_buf ,
void ( * reply_fn ) ( struct smb_request * req ,
NTSTATUS error_code ,
uint8_t * buf , size_t len ) ) ;
2016-06-14 15:54:32 +03:00
void notify_callback ( struct smbd_server_connection * sconn ,
void * private_data , struct timespec when ,
2016-06-14 07:54:11 +03:00
const struct notify_event * e ) ;
2019-01-16 23:29:51 +03:00
NTSTATUS change_notify_create ( struct files_struct * fsp ,
uint32_t max_buffer_size ,
uint32_t filter ,
2011-03-19 02:47:12 +03:00
bool recursive ) ;
NTSTATUS change_notify_add_request ( struct smb_request * req ,
2015-05-03 07:01:14 +03:00
uint32_t max_param ,
uint32_t filter , bool recursive ,
2011-03-19 02:47:12 +03:00
struct files_struct * fsp ,
void ( * reply_fn ) ( struct smb_request * req ,
NTSTATUS error_code ,
uint8_t * buf , size_t len ) ) ;
2015-04-21 11:16:16 +03:00
void smbd_notify_cancel_deleted ( struct messaging_context * msg ,
void * private_data , uint32_t msg_type ,
struct server_id server_id , DATA_BLOB * data ) ;
2016-06-21 17:23:19 +03:00
void smbd_notifyd_restarted ( struct messaging_context * msg ,
void * private_data , uint32_t msg_type ,
struct server_id server_id , DATA_BLOB * data ) ;
2019-06-19 22:15:38 +03:00
bool remove_pending_change_notify_requests_by_mid (
2011-03-19 02:47:12 +03:00
struct smbd_server_connection * sconn , uint64_t mid ) ;
void remove_pending_change_notify_requests_by_fid ( files_struct * fsp ,
NTSTATUS status ) ;
2024-11-04 20:48:14 +03:00
void notify_fname ( struct connection_struct * conn ,
uint32_t action ,
uint32_t filter ,
const struct smb_filename * smb_fname ,
const struct smb2_lease * lease ) ;
2015-05-03 07:01:14 +03:00
char * notify_filter_string ( TALLOC_CTX * mem_ctx , uint32_t filter ) ;
2012-03-21 14:55:55 +04:00
struct sys_notify_context * sys_notify_context_create ( TALLOC_CTX * mem_ctx ,
2013-02-18 12:56:41 +04:00
struct tevent_context * ev ) ;
2011-03-19 02:47:12 +03:00
/* The following definitions come from smbd/notify_inotify.c */
2014-11-05 15:18:31 +03:00
int inotify_watch ( TALLOC_CTX * mem_ctx ,
struct sys_notify_context * ctx ,
2014-10-27 16:26:35 +03:00
const char * path ,
uint32_t * filter ,
uint32_t * subdir_filter ,
void ( * callback ) ( struct sys_notify_context * ctx ,
void * private_data ,
2016-07-15 01:44:46 +03:00
struct notify_event * ev ,
uint32_t filter ) ,
2014-10-27 16:26:35 +03:00
void * private_data ,
void * handle_p ) ;
2011-03-19 02:47:12 +03:00
2016-02-12 19:20:59 +03:00
int fam_watch ( TALLOC_CTX * mem_ctx ,
2014-11-20 18:30:51 +03:00
struct sys_notify_context * ctx ,
const char * path ,
uint32_t * filter ,
uint32_t * subdir_filter ,
void ( * callback ) ( struct sys_notify_context * ctx ,
void * private_data ,
2016-07-15 01:44:46 +03:00
struct notify_event * ev ,
uint32_t filter ) ,
2014-11-20 18:30:51 +03:00
void * private_data ,
void * handle_p ) ;
2011-03-19 02:47:12 +03:00
/* The following definitions come from smbd/notify_internal.c */
2016-06-14 12:55:13 +03:00
struct notify_context * notify_init (
TALLOC_CTX * mem_ctx , struct messaging_context * msg ,
2016-06-14 15:54:32 +03:00
struct smbd_server_connection * sconn ,
void ( * callback ) ( struct smbd_server_connection * sconn ,
void * , struct timespec ,
2016-06-14 12:55:13 +03:00
const struct notify_event * ) ) ;
NTSTATUS notify_add ( struct notify_context * ctx ,
2012-04-04 16:51:43 +04:00
const char * path , uint32_t filter , uint32_t subdir_filter ,
2011-03-19 02:47:12 +03:00
void * private_data ) ;
2016-06-13 19:06:08 +03:00
NTSTATUS notify_remove ( struct notify_context * ctx , void * private_data ,
char * path ) ;
2011-03-19 02:47:12 +03:00
void notify_trigger ( struct notify_context * notify ,
2014-01-02 20:54:53 +04:00
uint32_t action , uint32_t filter ,
const char * dir , const char * path ) ;
2015-01-09 15:48:56 +03:00
2011-03-19 02:47:12 +03:00
/* The following definitions come from smbd/ntquotas.c */
2016-03-29 23:30:23 +03:00
NTSTATUS vfs_get_ntquota ( files_struct * fsp , enum SMB_QUOTA_TYPE qtype ,
struct dom_sid * psid , SMB_NTQUOTA_STRUCT * qt ) ;
2011-03-19 02:47:12 +03:00
int vfs_set_ntquota ( files_struct * fsp , enum SMB_QUOTA_TYPE qtype , struct dom_sid * psid , SMB_NTQUOTA_STRUCT * qt ) ;
int vfs_get_user_ntquota_list ( files_struct * fsp , SMB_NTQUOTA_LIST * * qt_list ) ;
void * init_quota_handle ( TALLOC_CTX * mem_ctx ) ;
2022-03-11 21:16:18 +03:00
/* The following definitions come from smbd/smb2_nttrans.c */
NTSTATUS set_sd ( files_struct * fsp , struct security_descriptor * psd ,
uint32_t security_info_sent ) ;
2022-03-11 21:21:40 +03:00
NTSTATUS set_sd_blob ( files_struct * fsp , uint8_t * data , uint32_t sd_len ,
uint32_t security_info_sent ) ;
2022-03-11 22:06:38 +03:00
NTSTATUS copy_internals ( TALLOC_CTX * ctx ,
connection_struct * conn ,
struct smb_request * req ,
2022-07-28 21:49:35 +03:00
struct files_struct * src_dirfsp ,
2022-03-11 22:06:38 +03:00
struct smb_filename * smb_fname_src ,
2022-07-28 21:49:35 +03:00
struct files_struct * dst_dirfsp ,
2022-03-11 22:06:38 +03:00
struct smb_filename * smb_fname_dst ,
uint32_t attrs ) ;
2022-03-11 22:10:56 +03:00
NTSTATUS smbd_do_query_security_desc ( connection_struct * conn ,
TALLOC_CTX * mem_ctx ,
files_struct * fsp ,
uint32_t security_info_wanted ,
uint32_t max_data_count ,
uint8_t * * ppmarshalled_sd ,
size_t * psd_size ) ;
2022-03-11 22:16:49 +03:00
# ifdef HAVE_SYS_QUOTAS
struct smb2_query_quota_info ;
NTSTATUS smbd_do_query_getinfo_quota ( TALLOC_CTX * mem_ctx ,
files_struct * fsp ,
bool restart_scan ,
bool return_single ,
uint32_t sid_list_length ,
DATA_BLOB * sidbuffer ,
uint32_t max_data_count ,
uint8_t * * p_data ,
uint32_t * p_data_size ) ;
# endif
2022-03-11 21:16:18 +03:00
2011-03-19 02:47:12 +03:00
/* The following definitions come from smbd/open.c */
2021-06-08 22:24:17 +03:00
NTSTATUS smbd_check_access_rights_fsp ( struct files_struct * dirfsp ,
struct files_struct * fsp ,
2020-10-27 13:24:03 +03:00
bool use_privs ,
uint32_t access_mask ) ;
2021-05-21 01:17:09 +03:00
NTSTATUS check_parent_access_fsp ( struct files_struct * fsp ,
uint32_t access_mask ) ;
s3:smbd: let mkdir_internal() work more atomically using a temporary name
Currently we do this in mkdir_internal():
mkdirat(client_name);
if (EEXIST) {
return EEXIST;
}
prepare_acls(client_name);
Note 'prepare_acls()' is a placeholder for the complex steps
it is doing to prepare the directory. During these steps
we have the problem that other clients already see
the directory and are able to create files or subdirectories
in it and these may not inherit the correct acls as
the their parent directory is not created completely.
I think I found a good strategie even without relying on
renameat2(RENAME_NOREPLACE).
We would do this instead:
tmp_name = ".::TMPNAME:D:$PID:client_name"
mkdirat(tmp_name, mode=client_mode);
prepare_acls(tmp_name);
mkdirat(client_name, mode=0);
if (EEXIST) {
unlinkat(tmp_name);
return EEXIST;
}
renameat(tmp_name, client_name);
So instead of having a long windows during prepare_acls,
we just have a short window between mkdirat(client_name, mode=0)
and renameat(tmp_name, client_name);
And in that short window the directory with the client_name
has a mode of 0, so it's not possible for other clients
to create files or subdirs in it.
As the mkdirat(client_name, mode=0) still catches
EEXIST the race where two clients try to create
the same client_name is closed as before,
so we don't need any other protection.
Following patches will make use of renameat2(RENAME_NOREPLACE),
but this already a very good improvement.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15693
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2024-08-01 15:37:55 +03:00
bool smbd_is_tmpname ( const char * n , int * _unlink_flags ) ;
2020-10-13 15:38:28 +03:00
NTSTATUS fd_openat ( const struct files_struct * dirfsp ,
struct smb_filename * smb_fname ,
files_struct * fsp ,
2022-06-17 11:39:20 +03:00
const struct vfs_open_how * how ) ;
2011-03-19 02:47:12 +03:00
NTSTATUS fd_close ( files_struct * fsp ) ;
2024-10-09 08:32:55 +03:00
NTSTATUS reopen_from_fsp ( struct files_struct * dirfsp ,
struct smb_filename * smb_fname ,
struct files_struct * fsp ,
const struct vfs_open_how * how ,
bool * p_file_created ) ;
2020-03-05 17:12:20 +03:00
bool is_oplock_stat_open ( uint32_t access_mask ) ;
2020-03-05 17:14:21 +03:00
bool is_lease_stat_open ( uint32_t access_mask ) ;
2014-12-05 08:15:24 +03:00
NTSTATUS send_break_message ( struct messaging_context * msg_ctx ,
2018-02-07 14:24:35 +03:00
const struct file_id * id ,
const struct share_mode_entry * exclusive ,
uint16_t break_to ) ;
2014-06-20 18:12:14 +04:00
struct deferred_open_record ;
bool is_deferred_open_async ( const struct deferred_open_record * rec ) ;
2019-07-30 15:54:18 +03:00
bool defer_smb1_sharing_violation ( struct smb_request * req ) ;
2022-07-28 22:01:21 +03:00
NTSTATUS create_directory ( connection_struct * conn ,
struct smb_request * req ,
struct files_struct * dirfsp ,
2011-03-19 02:47:12 +03:00
struct smb_filename * smb_dname ) ;
void msg_file_was_renamed ( struct messaging_context * msg ,
void * private_data ,
uint32_t msg_type ,
struct server_id server_id ,
DATA_BLOB * data ) ;
2018-09-18 10:55:51 +03:00
struct fsp_lease * find_fsp_lease ( struct files_struct * new_fsp ,
2014-10-29 01:31:46 +03:00
const struct smb2_lease_key * key ,
2018-09-18 10:55:51 +03:00
uint32_t current_state ,
uint16_t lease_version ,
uint16_t lease_epoch ) ;
2011-03-19 02:47:12 +03:00
NTSTATUS create_file_default ( connection_struct * conn ,
struct smb_request * req ,
2021-11-23 14:29:17 +03:00
struct files_struct * dirfsp ,
2011-03-19 02:47:12 +03:00
struct smb_filename * smb_fname ,
uint32_t access_mask ,
uint32_t share_access ,
uint32_t create_disposition ,
uint32_t create_options ,
uint32_t file_attributes ,
uint32_t oplock_request ,
2019-08-07 22:41:22 +03:00
const struct smb2_lease * lease ,
2011-03-19 02:47:12 +03:00
uint64_t allocation_size ,
uint32_t private_flags ,
struct security_descriptor * sd ,
struct ea_list * ea_list ,
files_struct * * result ,
2014-11-26 16:12:51 +03:00
int * pinfo ,
const struct smb2_create_blobs * in_context_blobs ,
struct smb2_create_blobs * out_context_blobs ) ;
2011-03-19 02:47:12 +03:00
/* The following definitions come from smbd/oplock.c */
2020-07-02 15:45:59 +03:00
uint32_t get_lease_type ( struct share_mode_entry * e , struct file_id id ) ;
2014-10-29 01:27:09 +03:00
2011-03-19 02:47:12 +03:00
void break_kernel_oplock ( struct messaging_context * msg_ctx , files_struct * fsp ) ;
2013-09-03 17:57:11 +04:00
NTSTATUS set_file_oplock ( files_struct * fsp ) ;
2022-08-30 10:48:40 +03:00
void release_file_oplock ( files_struct * fsp ) ;
2011-03-19 02:47:12 +03:00
bool remove_oplock ( files_struct * fsp ) ;
bool downgrade_oplock ( files_struct * fsp ) ;
2019-05-24 16:58:09 +03:00
bool fsp_lease_update ( struct files_struct * fsp ) ;
2021-05-19 17:58:21 +03:00
const struct smb2_lease * fsp_get_smb2_lease ( const struct files_struct * fsp ) ;
2020-06-02 17:33:23 +03:00
NTSTATUS downgrade_lease ( struct smbXsrv_client * client ,
2014-10-29 01:31:46 +03:00
uint32_t num_file_ids ,
const struct file_id * ids ,
const struct smb2_lease_key * key ,
uint32_t lease_state ) ;
2011-03-19 02:47:12 +03:00
void contend_level2_oplocks_begin ( files_struct * fsp ,
enum level2_contention_type type ) ;
void contend_level2_oplocks_end ( files_struct * fsp ,
enum level2_contention_type type ) ;
2011-05-31 07:18:37 +04:00
void smbd_contend_level2_oplocks_begin ( files_struct * fsp ,
enum level2_contention_type type ) ;
void smbd_contend_level2_oplocks_end ( files_struct * fsp ,
enum level2_contention_type type ) ;
2024-09-04 18:58:45 +03:00
void contend_dirleases ( struct connection_struct * conn ,
const struct smb_filename * smb_fname ,
const struct smb2_lease * lease ) ;
2011-12-13 16:13:53 +04:00
bool init_oplocks ( struct smbd_server_connection * sconn ) ;
2012-03-30 17:51:25 +04:00
void init_kernel_oplocks ( struct smbd_server_connection * sconn ) ;
2011-03-19 02:47:12 +03:00
/* The following definitions come from smbd/oplock_linux.c */
int linux_set_lease_sighandler ( int fd ) ;
int linux_setlease ( int fd , int leasetype ) ;
2011-12-13 16:38:41 +04:00
struct kernel_oplocks * linux_init_kernel_oplocks ( struct smbd_server_connection * sconn ) ;
2011-03-19 02:47:12 +03:00
/* The following definitions come from smbd/password.c */
2012-06-05 20:17:15 +04:00
void invalidate_vuid ( struct smbd_server_connection * sconn , uint64_t vuid ) ;
2011-03-19 02:47:12 +03:00
int register_homes_share ( const char * username ) ;
/* The following definitions come from smbd/pipes.c */
NTSTATUS open_np_file ( struct smb_request * smb_req , const char * name ,
struct files_struct * * pfsp ) ;
/* The following definitions come from smbd/posix_acls.c */
2018-05-18 21:49:09 +03:00
mode_t unix_perms_to_acl_perms ( mode_t mode , int r_mask , int w_mask , int x_mask ) ;
2018-05-18 21:50:44 +03:00
int map_acl_perms_to_permset ( mode_t mode , SMB_ACL_PERMSET_T * p_permset ) ;
2011-03-19 02:47:12 +03:00
uint32_t map_canon_ace_perms ( int snum ,
enum security_ace_type * pacl_type ,
mode_t perms ,
bool directory_ace ) ;
2011-03-31 05:00:09 +04:00
bool current_user_in_group ( connection_struct * conn , gid_t gid ) ;
2011-03-19 02:47:12 +03:00
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 ,
2012-10-10 04:50:27 +04:00
TALLOC_CTX * mem_ctx ,
2011-03-19 02:47:12 +03:00
struct security_descriptor * * ppdesc ) ;
2022-11-30 02:46:24 +03:00
NTSTATUS chown_if_needed ( files_struct * fsp , uint32_t security_info_sent ,
const struct security_descriptor * psd ,
bool * did_chown ) ;
2015-05-03 07:01:14 +03:00
NTSTATUS set_nt_acl ( files_struct * fsp , uint32_t security_info_sent , const struct security_descriptor * psd ) ;
2022-03-10 21:30:28 +03:00
int get_acl_group_bits ( connection_struct * conn ,
struct files_struct * fsp ,
mode_t * mode ) ;
2017-05-24 03:11:18 +03:00
int inherit_access_posix_acl ( connection_struct * conn ,
2022-03-03 13:32:20 +03:00
struct files_struct * inherit_from_dirfsp ,
const struct smb_filename * smb_fname ,
mode_t mode ) ;
2019-06-19 01:14:53 +03:00
NTSTATUS set_unix_posix_default_acl ( connection_struct * conn ,
2019-06-19 01:36:58 +03:00
files_struct * fsp ,
2015-05-03 07:01:14 +03:00
uint16_t num_def_acls , const char * pdata ) ;
2019-06-19 01:03:28 +03:00
NTSTATUS set_unix_posix_acl ( connection_struct * conn , files_struct * fsp ,
2017-05-24 03:11:18 +03:00
uint16_t num_acls ,
const char * pdata ) ;
2012-10-10 09:49:59 +04:00
int posix_sys_acl_blob_get_file ( vfs_handle_struct * handle ,
2017-05-24 03:35:59 +03:00
const struct smb_filename * smb_fname ,
2012-10-10 09:49:59 +04:00
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 ) ;
2011-03-19 02:47:12 +03:00
2017-10-17 16:18:52 +03:00
enum default_acl_style { DEFAULT_ACL_POSIX , DEFAULT_ACL_WINDOWS , DEFAULT_ACL_EVERYONE } ;
2017-09-28 08:53:48 +03:00
const struct enum_list * get_default_acl_style_list ( void ) ;
NTSTATUS make_default_filesystem_acl (
TALLOC_CTX * ctx ,
enum default_acl_style acl_style ,
const char * name ,
2018-05-18 14:14:57 +03:00
const SMB_STRUCT_STAT * psbuf ,
2017-09-28 08:53:48 +03:00
struct security_descriptor * * ppdesc ) ;
2022-03-18 17:22:31 +03:00
/* The following definitions come from smbd/smb2_process.c */
2022-03-31 22:09:13 +03:00
# if !defined(WITH_SMB1SERVER)
2023-06-05 16:45:35 +03:00
bool smb1_srv_send ( struct smbXsrv_connection * xconn ,
char * buffer ,
bool do_signing ,
uint32_t seqnum ,
bool do_encrypt ) ;
2022-03-31 22:09:13 +03:00
# endif
2022-04-05 04:40:11 +03:00
size_t srv_smb1_set_message ( char * buf ,
2022-03-18 00:23:33 +03:00
size_t num_words ,
size_t num_bytes ,
bool zero ) ;
2022-03-18 00:29:18 +03:00
NTSTATUS read_packet_remainder ( int fd , char * buffer ,
unsigned int timeout , ssize_t len ) ;
2022-03-18 18:41:02 +03:00
NTSTATUS receive_smb_talloc ( TALLOC_CTX * mem_ctx ,
struct smbXsrv_connection * xconn ,
int sock ,
char * * buffer , unsigned int timeout ,
size_t * p_unread , bool * p_encrypted ,
size_t * p_len ,
uint32_t * seqnum ,
bool trusted_channel ) ;
2022-03-18 21:28:19 +03:00
void remove_deferred_open_message_smb ( struct smbXsrv_connection * xconn ,
uint64_t mid ) ;
2022-03-18 22:35:41 +03:00
bool schedule_deferred_open_message_smb ( struct smbXsrv_connection * xconn ,
uint64_t mid ) ;
2022-03-18 23:08:12 +03:00
bool open_was_deferred ( struct smbXsrv_connection * xconn , uint64_t mid ) ;
2022-03-18 23:15:30 +03:00
bool get_deferred_open_message_state ( struct smb_request * smbreq ,
struct timeval * p_request_time ,
struct deferred_open_record * * open_rec ) ;
2022-03-18 23:28:08 +03:00
bool push_deferred_open_message_smb ( struct smb_request * req ,
struct timeval timeout ,
struct file_id id ,
struct deferred_open_record * open_rec ) ;
2022-04-05 04:45:44 +03:00
bool create_smb1_outbuf ( TALLOC_CTX * mem_ctx , struct smb_request * req ,
2022-03-18 23:45:09 +03:00
const uint8_t * inbuf , char * * outbuf ,
uint8_t num_words , uint32_t num_bytes ) ;
2022-04-05 04:43:54 +03:00
void construct_smb1_reply_common_req ( struct smb_request * req , char * outbuf ) ;
2022-04-05 05:53:20 +03:00
void reply_smb1_outbuf ( struct smb_request * req , uint8_t num_words , uint32_t num_bytes ) ;
2022-03-18 23:53:19 +03:00
void process_smb ( struct smbXsrv_connection * xconn ,
2023-06-05 17:02:29 +03:00
uint8_t * inbuf ,
size_t nread ,
size_t unread_bytes ,
uint32_t seqnum ,
bool encrypted ) ;
2022-03-21 17:05:15 +03:00
void smbd_process ( struct tevent_context * ev_ctx ,
struct messaging_context * msg_ctx ,
int sock_fd ,
bool interactive ) ;
2022-04-05 04:35:16 +03:00
bool valid_smb1_header ( const uint8_t * inbuf ) ;
2022-04-05 05:55:39 +03:00
bool init_smb1_request ( struct smb_request * req ,
2022-03-25 23:08:18 +03:00
struct smbd_server_connection * sconn ,
struct smbXsrv_connection * xconn ,
const uint8_t * inbuf ,
size_t unread_bytes , bool encrypted ,
uint32_t seqnum ) ;
2022-03-18 17:22:31 +03:00
2011-03-19 02:47:12 +03:00
/* The following definitions come from smbd/quotas.c */
2016-01-14 01:09:36 +03:00
bool disk_quotas ( connection_struct * conn , struct smb_filename * fname ,
uint64_t * bsize , uint64_t * dfree , uint64_t * dsize ) ;
2011-03-19 02:47:12 +03:00
2022-03-16 01:29:59 +03:00
/* The following definitions come from smbd/smb2_reply.c */
2023-03-31 12:44:00 +03:00
NTSTATUS check_path_syntax ( char * path , bool posix ) ;
2023-03-30 16:55:53 +03:00
NTSTATUS smb1_strip_dfs_path ( TALLOC_CTX * mem_ctx ,
uint32_t * ucf_flags ,
char * * in_path ) ;
2023-03-27 20:06:03 +03:00
NTSTATUS smb2_strip_dfs_path ( const char * in_path , const char * * out_path ) ;
2022-03-16 01:32:34 +03:00
size_t srvstr_get_path ( TALLOC_CTX * ctx ,
const char * inbuf ,
uint16_t smb_flags2 ,
char * * pp_dest ,
const char * src ,
size_t src_len ,
int flags ,
NTSTATUS * err ) ;
size_t srvstr_get_path_posix ( TALLOC_CTX * ctx ,
const char * inbuf ,
uint16_t smb_flags2 ,
char * * pp_dest ,
const char * src ,
size_t src_len ,
int flags ,
NTSTATUS * err ) ;
size_t srvstr_get_path_req ( TALLOC_CTX * mem_ctx , struct smb_request * req ,
char * * pp_dest , const char * src , int flags ,
NTSTATUS * err ) ;
2022-03-17 19:45:00 +03:00
size_t srvstr_pull_req_talloc ( TALLOC_CTX * ctx , struct smb_request * req ,
char * * dest , const uint8_t * src , int flags ) ;
2022-03-17 19:51:59 +03:00
bool check_fsp_open ( connection_struct * conn , struct smb_request * req ,
files_struct * fsp ) ;
2022-03-17 19:53:35 +03:00
bool check_fsp ( connection_struct * conn , struct smb_request * req ,
files_struct * fsp ) ;
2022-03-17 19:57:04 +03:00
bool check_fsp_ntquota_handle ( connection_struct * conn , struct smb_request * req ,
files_struct * fsp ) ;
2022-03-17 20:04:28 +03:00
void reply_special ( struct smbXsrv_connection * xconn , char * inbuf , size_t inbuf_size ) ;
2022-03-17 20:10:51 +03:00
NTSTATUS unlink_internals ( connection_struct * conn ,
struct smb_request * req ,
uint32_t dirtype ,
2022-07-28 21:17:47 +03:00
struct files_struct * dirfsp ,
2022-03-17 20:10:51 +03:00
struct smb_filename * smb_fname ) ;
2022-03-17 20:15:23 +03:00
ssize_t fake_sendfile ( struct smbXsrv_connection * xconn , files_struct * fsp ,
off_t startpos , size_t nread ) ;
2022-03-17 20:18:26 +03:00
ssize_t sendfile_short_send ( struct smbXsrv_connection * xconn ,
files_struct * fsp ,
ssize_t nread ,
size_t headersize ,
size_t smb_maxcnt ) ;
2022-03-17 20:25:05 +03:00
NTSTATUS rename_internals_fsp ( connection_struct * conn ,
files_struct * fsp ,
2024-09-30 21:03:43 +03:00
struct share_mode_lock * * lck ,
2022-03-17 20:25:05 +03:00
struct smb_filename * smb_fname_dst_in ,
const char * dst_original_lcomp ,
uint32_t attrs ,
bool replace_if_exists ) ;
2022-03-17 20:30:25 +03:00
NTSTATUS rename_internals ( TALLOC_CTX * ctx ,
connection_struct * conn ,
struct smb_request * req ,
2022-07-28 21:08:17 +03:00
struct files_struct * src_dirfsp ,
2022-03-17 20:30:25 +03:00
struct smb_filename * smb_fname_src ,
struct smb_filename * smb_fname_dst ,
const char * dst_original_lcomp ,
uint32_t attrs ,
bool replace_if_exists ,
uint32_t access_mask ) ;
2022-03-17 20:34:46 +03:00
NTSTATUS copy_file ( TALLOC_CTX * ctx ,
connection_struct * conn ,
struct smb_filename * smb_fname_src ,
struct smb_filename * smb_fname_dst ,
2022-05-20 09:06:28 +03:00
uint32_t new_create_disposition ) ;
2022-03-17 21:20:30 +03:00
uint64_t get_lock_offset ( const uint8_t * data , int data_offset ,
bool large_file_format ) ;
2022-03-16 01:29:59 +03:00
2011-03-19 02:47:12 +03:00
/* The following definitions come from smbd/seal.c */
2014-06-11 16:28:13 +04:00
bool is_encrypted_packet ( const uint8_t * inbuf ) ;
2014-06-12 10:43:26 +04:00
void srv_free_enc_buffer ( struct smbXsrv_connection * xconn , char * buf ) ;
NTSTATUS srv_decrypt_buffer ( struct smbXsrv_connection * xconn , char * buf ) ;
NTSTATUS srv_encrypt_buffer ( struct smbXsrv_connection * xconn , char * buf ,
2011-08-05 19:00:42 +04:00
char * * buf_out ) ;
2011-03-19 02:47:12 +03:00
NTSTATUS srv_request_encryption_setup ( connection_struct * conn ,
unsigned char * * ppdata ,
size_t * p_data_size ,
unsigned char * * pparam ,
size_t * p_param_size ) ;
NTSTATUS srv_encryption_start ( connection_struct * conn ) ;
2014-06-12 10:43:26 +04:00
void server_encryption_shutdown ( struct smbXsrv_connection * xconn ) ;
2011-03-19 02:47:12 +03:00
/* The following definitions come from smbd/sec_ctx.c */
bool unix_token_equal ( const struct security_unix_token * t1 , const struct security_unix_token * t2 ) ;
bool push_sec_ctx ( void ) ;
2012-04-05 01:53:10 +04:00
void set_sec_ctx ( uid_t uid , gid_t gid , int ngroups , gid_t * groups , const struct security_token * token ) ;
2011-03-19 02:47:12 +03:00
void set_root_sec_ctx ( void ) ;
bool pop_sec_ctx ( void ) ;
void init_sec_ctx ( void ) ;
2012-10-26 04:07:29 +04:00
const struct security_token * sec_ctx_active_token ( void ) ;
2011-03-19 02:47:12 +03:00
/* The following definitions come from smbd/server.c */
struct memcache * smbd_memcache ( void ) ;
2014-08-05 20:45:24 +04:00
bool snum_is_shared_printer ( int snum ) ;
2018-05-23 17:35:20 +03:00
void delete_and_reload_printers ( void ) ;
2011-12-14 16:25:20 +04:00
bool reload_services ( struct smbd_server_connection * sconn ,
bool ( * snumused ) ( struct smbd_server_connection * , int ) ,
2011-03-19 02:47:12 +03:00
bool test ) ;
2012-10-09 16:35:04 +04:00
/* 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_ ;
2022-03-17 22:35:44 +03:00
/* The following definitions come from smbd/smb2_service.c */
2011-03-19 02:47:12 +03:00
bool set_conn_connectpath ( connection_struct * conn , const char * connectpath ) ;
2020-03-19 13:19:34 +03:00
bool canonicalize_connect_path ( connection_struct * conn ) ;
2011-03-19 02:47:12 +03:00
NTSTATUS set_conn_force_user_group ( connection_struct * conn , int snum ) ;
2018-06-13 12:03:01 +03:00
bool chdir_current_service ( connection_struct * conn ) ;
2011-03-19 02:47:12 +03:00
void load_registry_shares ( void ) ;
int add_home_service ( const char * service , const char * username , const char * homedir ) ;
int find_service ( TALLOC_CTX * ctx , const char * service , char * * p_service_out ) ;
2014-09-15 05:47:41 +04:00
connection_struct * make_connection_smb2 ( struct smbd_smb2_request * req ,
2012-07-02 15:37:07 +04:00
struct smbXsrv_tcon * tcon ,
2012-03-27 13:09:05 +04:00
int snum ,
2011-03-19 02:47:12 +03:00
const char * pdev ,
NTSTATUS * pstatus ) ;
2022-03-17 22:32:30 +03:00
NTSTATUS make_connection_snum ( struct smbXsrv_connection * xconn ,
connection_struct * conn ,
int snum ,
struct smbXsrv_session * session ,
const char * pdev ) ;
2022-08-17 21:35:29 +03:00
void close_cnum ( connection_struct * conn ,
uint64_t vuid ,
enum file_close_type close_type ) ;
2011-03-19 02:47:12 +03:00
/* The following definitions come from smbd/session.c */
struct sessionid ;
2012-08-23 16:47:33 +04:00
struct smbXsrv_session ;
2011-03-19 02:47:12 +03:00
bool session_init ( void ) ;
2012-08-27 11:21:58 +04:00
bool session_claim ( struct smbXsrv_session * session ) ;
2012-08-23 16:47:33 +04:00
void session_yield ( struct smbXsrv_session * session ) ;
2011-03-19 02:47:12 +03:00
int list_sessions ( TALLOC_CTX * mem_ctx , struct sessionid * * session_list ) ;
2013-09-10 10:28:07 +04:00
int find_sessions ( TALLOC_CTX * mem_ctx , const char * username ,
const char * machine , struct sessionid * * session_list ) ;
2011-03-19 02:47:12 +03:00
/* The following definitions come from smbd/share_access.c */
bool token_contains_name_in_list ( const char * username ,
const char * domain ,
const char * sharename ,
const struct security_token * token ,
smbd: return errors from token_contains_name()
Invalid names in "valid users", "invalid users", "read list", "write list",
"veto files" and "hide files" are logged and ignored, but a failure to contact
winbind or a DC from winbind, or a memory allocation failure, now all trigger a
failure of the tree connect.
Manually tested with smbclient with the following hack in winbindd:
---8<---
$ git di
source3/winbindd/winbindd_cache.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/source3/winbindd/winbindd_cache.c b/source3/winbindd/winbindd_cache.c
index c889489dbbbc..8ccf0a28e11a 100644
--- a/source3/winbindd/winbindd_cache.c
+++ b/source3/winbindd/winbindd_cache.c
@@ -1821,6 +1821,13 @@ NTSTATUS wb_cache_name_to_sid(struct winbindd_domain *domain,
ZERO_STRUCTP(sid);
*type = SID_NAME_UNKNOWN;
+ if (strequal(name, "unknown")) {
+ return NT_STATUS_OK;
+ }
+ if (strequal(name, "iotimeout")) {
+ return NT_STATUS_IO_TIMEOUT;
+ }
+
status = wcache_name_to_sid(domain, domain_name, name, sid, type);
if (!NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) {
return status;
---8<---
veto files = ../unknown/file1/../slow/file2
$ bin/smbclient -U slow%x //localhost/test -c quit
$
In the log:
[2024/03/04 15:21:33.659356, 1, pid=977167, effective(0, 0), real(0, 0)] ../../source3/lib/util_namearray.c:128(token_contains_name)
token_contains_name: lookup_name 'unknown' failed
veto files = ../iotimeout/file1/../slow/file2
$ bin/smbclient -U slow%x //localhost/test -c quit
tree connect failed: NT_STATUS_LOGON_FAILURE
$
[2024/03/04 15:22:15.655811, 0, pid=977177, effective(0, 0), real(0, 0)] ../../source3/lib/util_namearray.c:131(token_contains_name)
token_contains_name: lookup_name 'iotimeout' failed NT_STATUS_NO_SUCH_DOMAIN
[2024/03/04 15:22:15.655846, 1, pid=977177, effective(0, 0), real(0, 0)] ../../source3/smbd/uid.c:381(change_to_user_impersonate)
change_to_user_impersonate: SMB user slow (unix user slow) not permitted access to share test.
[2024/03/04 15:22:15.655855, 0, pid=977177, effective(0, 0), real(0, 0)] ../../source3/smbd/smb2_service.c:689(make_connection_snum)
make_connection_snum: Can't become connected user!
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2024-02-02 10:10:54 +03:00
const char * * list ,
bool * match ) ;
2011-03-19 02:47:12 +03:00
bool user_ok_token ( const char * username , const char * domain ,
const struct security_token * token , int snum ) ;
bool is_share_read_only_for_token ( const char * username ,
const char * domain ,
const struct security_token * token ,
smbd: return errors from token_contains_name()
Invalid names in "valid users", "invalid users", "read list", "write list",
"veto files" and "hide files" are logged and ignored, but a failure to contact
winbind or a DC from winbind, or a memory allocation failure, now all trigger a
failure of the tree connect.
Manually tested with smbclient with the following hack in winbindd:
---8<---
$ git di
source3/winbindd/winbindd_cache.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/source3/winbindd/winbindd_cache.c b/source3/winbindd/winbindd_cache.c
index c889489dbbbc..8ccf0a28e11a 100644
--- a/source3/winbindd/winbindd_cache.c
+++ b/source3/winbindd/winbindd_cache.c
@@ -1821,6 +1821,13 @@ NTSTATUS wb_cache_name_to_sid(struct winbindd_domain *domain,
ZERO_STRUCTP(sid);
*type = SID_NAME_UNKNOWN;
+ if (strequal(name, "unknown")) {
+ return NT_STATUS_OK;
+ }
+ if (strequal(name, "iotimeout")) {
+ return NT_STATUS_IO_TIMEOUT;
+ }
+
status = wcache_name_to_sid(domain, domain_name, name, sid, type);
if (!NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) {
return status;
---8<---
veto files = ../unknown/file1/../slow/file2
$ bin/smbclient -U slow%x //localhost/test -c quit
$
In the log:
[2024/03/04 15:21:33.659356, 1, pid=977167, effective(0, 0), real(0, 0)] ../../source3/lib/util_namearray.c:128(token_contains_name)
token_contains_name: lookup_name 'unknown' failed
veto files = ../iotimeout/file1/../slow/file2
$ bin/smbclient -U slow%x //localhost/test -c quit
tree connect failed: NT_STATUS_LOGON_FAILURE
$
[2024/03/04 15:22:15.655811, 0, pid=977177, effective(0, 0), real(0, 0)] ../../source3/lib/util_namearray.c:131(token_contains_name)
token_contains_name: lookup_name 'iotimeout' failed NT_STATUS_NO_SUCH_DOMAIN
[2024/03/04 15:22:15.655846, 1, pid=977177, effective(0, 0), real(0, 0)] ../../source3/smbd/uid.c:381(change_to_user_impersonate)
change_to_user_impersonate: SMB user slow (unix user slow) not permitted access to share test.
[2024/03/04 15:22:15.655855, 0, pid=977177, effective(0, 0), real(0, 0)] ../../source3/smbd/smb2_service.c:689(make_connection_snum)
make_connection_snum: Can't become connected user!
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2024-02-02 10:10:54 +03:00
connection_struct * conn ,
bool * _read_only ) ;
2011-03-19 02:47:12 +03:00
/* The following definitions come from smbd/srvstr.c */
2015-05-03 07:01:14 +03:00
NTSTATUS srvstr_push_fn ( const char * base_ptr , uint16_t smb_flags2 , void * dest ,
2014-08-26 04:11:58 +04:00
const char * src , int dest_len , int flags , size_t * ret_len ) ;
2011-03-19 02:47:12 +03:00
/* The following definitions come from smbd/statvfs.c */
2022-06-03 15:47:30 +03:00
int sys_statvfs ( const char * path , struct vfs_statvfs_struct * statbuf ) ;
2011-03-19 02:47:12 +03:00
/* The following definitions come from smbd/trans2.c */
2022-12-29 01:47:42 +03:00
char * store_file_unix_basic ( connection_struct * conn ,
char * pdata ,
files_struct * fsp ,
const SMB_STRUCT_STAT * psbuf ) ;
char * store_file_unix_basic_info2 ( connection_struct * conn ,
char * pdata ,
files_struct * fsp ,
const SMB_STRUCT_STAT * psbuf ) ;
2024-10-11 16:30:46 +03:00
NTSTATUS smb_check_file_disposition_info ( struct files_struct * fsp ,
const char * data ,
int total_data ,
bool * _delete_on_close ) ;
2022-12-29 02:06:58 +03:00
NTSTATUS smb_set_file_disposition_info ( connection_struct * conn ,
const char * pdata ,
int total_data ,
files_struct * fsp ,
struct smb_filename * smb_fname ) ;
2024-10-09 11:50:15 +03:00
bool refuse_symlink_fsp ( const struct files_struct * fsp ) ;
2023-12-21 12:58:09 +03:00
NTSTATUS check_any_access_fsp ( struct files_struct * fsp ,
2023-12-21 12:58:09 +03:00
uint32_t access_requested ) ;
2011-03-19 02:47:12 +03:00
uint64_t smb_roundup ( connection_struct * conn , uint64_t val ) ;
2014-05-21 13:52:27 +04:00
bool samba_private_attr_name ( const char * unix_ea_name ) ;
2024-10-09 12:07:11 +03:00
int get_ea_value_fsp ( TALLOC_CTX * mem_ctx ,
files_struct * fsp ,
const char * ea_name ,
struct ea_struct * pea ) ;
2021-06-23 22:12:30 +03:00
NTSTATUS get_ea_names_from_fsp ( TALLOC_CTX * mem_ctx ,
2016-03-12 02:34:58 +03:00
files_struct * fsp ,
char * * * pnames ,
size_t * pnum_names ) ;
2011-03-19 02:47:12 +03:00
NTSTATUS set_ea ( connection_struct * conn , files_struct * fsp ,
2020-12-14 23:15:48 +03:00
struct ea_list * ea_list ) ;
2011-03-19 02:47:12 +03:00
unsigned char * create_volume_objectid ( connection_struct * conn , unsigned char objid [ 16 ] ) ;
NTSTATUS hardlink_internals ( TALLOC_CTX * ctx ,
connection_struct * conn ,
struct smb_request * req ,
bool overwrite_if_exists ,
const struct smb_filename * smb_fname_old ,
struct smb_filename * smb_fname_new ) ;
NTSTATUS smb_set_file_time ( connection_struct * conn ,
files_struct * fsp ,
2020-11-12 18:28:41 +03:00
struct smb_filename * smb_fname ,
2011-03-19 02:47:12 +03:00
struct smb_file_time * ft ,
bool setting_write_time ) ;
2022-12-30 18:23:27 +03:00
NTSTATUS smb_set_file_size ( connection_struct * conn ,
struct smb_request * req ,
files_struct * fsp ,
struct smb_filename * smb_fname ,
const SMB_STRUCT_STAT * psbuf ,
off_t size ,
bool fail_after_createfile ) ;
2011-03-19 02:47:12 +03:00
2022-12-30 18:23:52 +03:00
bool map_info2_flags_to_sbuf ( const SMB_STRUCT_STAT * psbuf ,
const uint32_t smb_fflags ,
const uint32_t smb_fmask ,
int * stat_fflags ) ;
2020-02-04 16:28:16 +03:00
NTSTATUS unix_perms_from_wire ( connection_struct * conn ,
const SMB_STRUCT_STAT * psbuf ,
uint32_t perms ,
mode_t * ret_perms ) ;
2022-03-21 21:29:26 +03:00
struct ea_list * read_ea_list ( TALLOC_CTX * ctx , const char * pdata ,
size_t data_size ) ;
unsigned int estimate_ea_size ( files_struct * fsp ) ;
NTSTATUS smb_set_fsquota ( connection_struct * conn ,
struct smb_request * req ,
files_struct * fsp ,
const DATA_BLOB * qdata ) ;
2020-02-04 16:28:16 +03:00
2024-09-20 06:14:12 +03:00
NTSTATUS smb2_parse_file_rename_information ( TALLOC_CTX * ctx ,
struct connection_struct * conn ,
struct smb_request * req ,
const char * pdata ,
int total_data ,
files_struct * fsp ,
struct smb_filename * smb_fname_src ,
bool * overwrite ,
struct files_struct * * _dst_dirfsp ,
struct smb_filename * * _smb_fname_dst ,
char * * _dst_original_lcomp ) ;
2011-03-19 02:47:12 +03:00
/* The following definitions come from smbd/uid.c */
bool change_to_guest ( void ) ;
2013-01-05 02:27:18 +04:00
NTSTATUS check_user_share_access ( connection_struct * conn ,
const struct auth_session_info * session_info ,
uint32_t * p_share_access ,
bool * p_readonly_share ) ;
2019-07-13 17:17:17 +03:00
bool change_to_user_and_service ( connection_struct * conn , uint64_t vuid ) ;
2019-07-13 17:20:11 +03:00
bool change_to_user_and_service_by_fsp ( struct files_struct * fsp ) ;
2011-05-31 07:18:37 +04:00
bool smbd_change_to_root_user ( void ) ;
2013-10-23 13:02:39 +04:00
bool smbd_become_authenticated_pipe_user ( struct auth_session_info * session_info ) ;
bool smbd_unbecome_authenticated_pipe_user ( void ) ;
2011-03-19 02:47:12 +03:00
void become_root ( void ) ;
void unbecome_root ( void ) ;
2011-05-31 07:18:37 +04:00
void smbd_become_root ( void ) ;
void smbd_unbecome_root ( void ) ;
2019-07-19 12:14:13 +03:00
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 ,
2011-07-18 07:06:47 +04:00
const struct auth_session_info * session_info ) ;
2019-07-19 12:14:13 +03:00
bool unbecome_user_without_service ( void ) ;
2011-03-19 02:47:12 +03:00
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 ) ;
const struct security_token * get_current_nttok ( connection_struct * conn ) ;
/* The following definitions come from smbd/utmp.c */
void sys_utmp_claim ( const char * username , const char * hostname ,
2012-10-09 11:38:36 +04:00
const char * id_str , int id_num ) ;
2011-03-19 02:47:12 +03:00
void sys_utmp_yield ( const char * username , const char * hostname ,
2012-10-09 11:38:36 +04:00
const char * id_str , int id_num ) ;
2011-03-19 02:47:12 +03:00
/* The following definitions come from smbd/vfs.c */
bool vfs_init_custom ( connection_struct * conn , const char * vfs_object ) ;
bool smbd_vfs_init ( connection_struct * conn ) ;
NTSTATUS vfs_file_exist ( connection_struct * conn , struct smb_filename * smb_fname ) ;
2020-05-11 23:00:37 +03:00
bool vfs_valid_pread_range ( off_t offset , size_t length ) ;
bool vfs_valid_pwrite_range ( off_t offset , size_t length ) ;
2011-03-19 02:47:12 +03:00
ssize_t vfs_pwrite_data ( struct smb_request * req ,
files_struct * fsp ,
const char * buffer ,
size_t N ,
2012-04-05 08:53:08 +04:00
off_t offset ) ;
2011-03-19 02:47:12 +03:00
int vfs_allocate_file_space ( files_struct * fsp , uint64_t len ) ;
2012-04-05 08:53:08 +04:00
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 ) ;
2019-09-27 09:37:40 +03:00
int vfs_set_blocking ( files_struct * fsp , bool set ) ;
2012-04-05 08:53:08 +04:00
off_t vfs_transfer_file ( files_struct * in , files_struct * out , off_t n ) ;
2020-11-22 15:57:27 +03:00
const char * vfs_readdirname ( connection_struct * conn ,
struct files_struct * dirfsp ,
2023-11-16 22:39:50 +03:00
DIR * d ,
2020-11-22 15:57:27 +03:00
char * * talloced ) ;
2017-06-29 21:29:33 +03:00
int vfs_ChDir ( connection_struct * conn ,
const struct smb_filename * smb_fname ) ;
2017-06-30 00:32:47 +03:00
struct smb_filename * vfs_GetWd ( TALLOC_CTX * ctx , connection_struct * conn ) ;
2020-10-16 15:35:10 +03:00
int vfs_stat ( struct connection_struct * conn ,
struct smb_filename * smb_fname ) ;
2016-03-19 08:17:30 +03:00
int vfs_stat_smb_basename ( struct connection_struct * conn ,
const struct smb_filename * smb_fname_in ,
2015-05-01 22:50:51 +03:00
SMB_STRUCT_STAT * psbuf ) ;
2011-03-19 02:47:12 +03:00
NTSTATUS vfs_stat_fsp ( files_struct * fsp ) ;
2021-04-28 11:51:05 +03:00
NTSTATUS vfs_fstreaminfo ( struct files_struct * fsp ,
TALLOC_CTX * mem_ctx ,
unsigned int * num_streams ,
struct stream_struct * * streams ) ;
2019-12-02 18:21:42 +03:00
void init_smb_file_time ( struct smb_file_time * ft ) ;
2020-07-23 08:32:11 +03:00
int vfs_fake_fd ( void ) ;
2020-12-18 16:03:09 +03:00
int vfs_fake_fd_close ( int fd ) ;
2024-09-24 08:36:58 +03:00
uint32_t vfs_get_fs_capabilities ( struct connection_struct * conn ,
enum timestamp_set_resolution * ts_res ) ;
2011-03-19 02:47:12 +03:00
/* The following definitions come from smbd/avahi_register.c */
void * avahi_start_register ( TALLOC_CTX * mem_ctx , struct tevent_context * ev ,
uint16_t port ) ;
2012-06-08 19:54:19 +04:00
/* 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 ) ;
2023-09-27 11:44:30 +03:00
struct smb3_file_posix_information ;
2024-11-27 17:27:14 +03:00
NTSTATUS smb3_file_posix_information_init (
2023-09-27 11:44:30 +03:00
connection_struct * conn ,
2024-11-27 17:27:14 +03:00
const struct smb_filename * smb_fname ,
2023-09-27 11:44:30 +03:00
uint32_t dos_attributes ,
struct smb3_file_posix_information * dst ) ;
2024-09-16 03:36:00 +03:00
struct tevent_req * delay_for_handle_lease_break_send (
TALLOC_CTX * mem_ctx ,
struct tevent_context * ev ,
struct timeval timeout ,
struct files_struct * fsp ,
2024-10-17 20:18:57 +03:00
bool recursive ,
2024-09-16 03:36:00 +03:00
struct share_mode_lock * * lck ) ;
NTSTATUS delay_for_handle_lease_break_recv ( struct tevent_req * req ,
TALLOC_CTX * mem_ctx ,
struct share_mode_lock * * lck ) ;
2011-05-31 02:13:15 +04:00
# endif /* _SMBD_PROTO_H_ */