2009-07-02 12:17:30 +04:00
/*
Unix SMB / CIFS implementation .
Core SMB2 server
Copyright ( C ) Stefan Metzmacher 2009
2010-04-29 01:56:12 +04:00
Copyright ( C ) Jeremy Allison 2010
2009-07-02 12:17:30 +04:00
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/>.
*/
# include "includes.h"
2011-03-22 18:57:01 +03:00
# include "smbd/smbd.h"
2009-07-02 12:17:30 +04:00
# include "smbd/globals.h"
2009-08-12 19:52:55 +04:00
# include "../libcli/smb/smb_common.h"
2011-02-25 02:03:01 +03:00
# include "trans2.h"
2011-04-28 19:38:09 +04:00
# include "../lib/util/tevent_ntstatus.h"
2009-07-02 12:17:30 +04:00
2018-03-21 22:01:05 +03:00
# undef DBGC_CLASS
# define DBGC_CLASS DBGC_SMB2
2009-07-02 12:17:30 +04:00
static struct tevent_req * smbd_smb2_getinfo_send ( TALLOC_CTX * mem_ctx ,
struct tevent_context * ev ,
struct smbd_smb2_request * smb2req ,
2012-06-08 12:46:13 +04:00
struct files_struct * in_fsp ,
2009-07-02 12:17:30 +04:00
uint8_t in_info_type ,
uint8_t in_file_info_class ,
uint32_t in_output_buffer_length ,
DATA_BLOB in_input_buffer ,
uint32_t in_additional_information ,
2012-06-08 12:46:13 +04:00
uint32_t in_flags ) ;
2009-07-02 12:17:30 +04:00
static NTSTATUS smbd_smb2_getinfo_recv ( struct tevent_req * req ,
TALLOC_CTX * mem_ctx ,
2010-04-27 07:11:59 +04:00
DATA_BLOB * out_output_buffer ,
NTSTATUS * p_call_status ) ;
2009-07-02 12:17:30 +04:00
static void smbd_smb2_request_getinfo_done ( struct tevent_req * subreq ) ;
NTSTATUS smbd_smb2_request_process_getinfo ( struct smbd_smb2_request * req )
{
2014-06-12 10:38:48 +04:00
struct smbXsrv_connection * xconn = req - > xconn ;
2011-09-06 16:01:43 +04:00
NTSTATUS status ;
2009-07-02 12:17:30 +04:00
const uint8_t * inbody ;
uint8_t in_info_type ;
uint8_t in_file_info_class ;
uint32_t in_output_buffer_length ;
uint16_t in_input_buffer_offset ;
uint32_t in_input_buffer_length ;
DATA_BLOB in_input_buffer ;
uint32_t in_additional_information ;
uint32_t in_flags ;
uint64_t in_file_id_persistent ;
uint64_t in_file_id_volatile ;
2012-06-08 12:46:13 +04:00
struct files_struct * in_fsp ;
2009-07-02 12:17:30 +04:00
struct tevent_req * subreq ;
2011-09-06 16:01:43 +04:00
status = smbd_smb2_request_verify_sizes ( req , 0x29 ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
return smbd_smb2_request_error ( req , status ) ;
2009-07-02 12:17:30 +04:00
}
2012-08-05 17:00:23 +04:00
inbody = SMBD_SMB2_IN_BODY_PTR ( req ) ;
2009-07-02 12:17:30 +04:00
in_info_type = CVAL ( inbody , 0x02 ) ;
in_file_info_class = CVAL ( inbody , 0x03 ) ;
in_output_buffer_length = IVAL ( inbody , 0x04 ) ;
in_input_buffer_offset = SVAL ( inbody , 0x08 ) ;
/* 0x0A 2 bytes reserved */
in_input_buffer_length = IVAL ( inbody , 0x0C ) ;
in_additional_information = IVAL ( inbody , 0x10 ) ;
in_flags = IVAL ( inbody , 0x14 ) ;
in_file_id_persistent = BVAL ( inbody , 0x18 ) ;
in_file_id_volatile = BVAL ( inbody , 0x20 ) ;
if ( in_input_buffer_offset = = 0 & & in_input_buffer_length = = 0 ) {
/* This is ok */
} else if ( in_input_buffer_offset ! =
2012-08-05 17:00:23 +04:00
( SMB2_HDR_BODY + SMBD_SMB2_IN_BODY_LEN ( req ) ) ) {
2009-07-02 12:17:30 +04:00
return smbd_smb2_request_error ( req , NT_STATUS_INVALID_PARAMETER ) ;
}
2012-08-05 17:00:23 +04:00
if ( in_input_buffer_length > SMBD_SMB2_IN_DYN_LEN ( req ) ) {
2009-07-02 12:17:30 +04:00
return smbd_smb2_request_error ( req , NT_STATUS_INVALID_PARAMETER ) ;
}
2012-08-05 17:00:23 +04:00
in_input_buffer . data = SMBD_SMB2_IN_DYN_PTR ( req ) ;
2009-07-02 12:17:30 +04:00
in_input_buffer . length = in_input_buffer_length ;
2014-05-23 12:22:34 +04:00
if ( in_input_buffer . length > xconn - > smb2 . server . max_trans ) {
2012-05-11 21:03:32 +04:00
DEBUG ( 2 , ( " smbd_smb2_request_process_getinfo: "
" client ignored max trans: %s: 0x%08X: 0x%08X \n " ,
2012-05-30 11:08:49 +04:00
__location__ , ( unsigned ) in_input_buffer . length ,
2014-05-23 12:22:34 +04:00
( unsigned ) xconn - > smb2 . server . max_trans ) ) ;
2011-10-12 19:46:50 +04:00
return smbd_smb2_request_error ( req , NT_STATUS_INVALID_PARAMETER ) ;
}
2014-05-23 12:22:34 +04:00
if ( in_output_buffer_length > xconn - > smb2 . server . max_trans ) {
2012-05-11 21:03:32 +04:00
DEBUG ( 2 , ( " smbd_smb2_request_process_getinfo: "
" client ignored max trans: %s: 0x%08X: 0x%08X \n " ,
__location__ , in_output_buffer_length ,
2014-05-23 12:22:34 +04:00
xconn - > smb2 . server . max_trans ) ) ;
2011-10-12 19:46:50 +04:00
return smbd_smb2_request_error ( req , NT_STATUS_INVALID_PARAMETER ) ;
}
2012-02-28 05:51:40 +04:00
status = smbd_smb2_request_verify_creditcharge ( req ,
MAX ( in_input_buffer . length , in_output_buffer_length ) ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
return smbd_smb2_request_error ( req , status ) ;
}
2012-06-08 12:46:13 +04:00
in_fsp = file_fsp_smb2 ( req , in_file_id_persistent , in_file_id_volatile ) ;
if ( in_fsp = = NULL ) {
2009-07-02 12:17:30 +04:00
return smbd_smb2_request_error ( req , NT_STATUS_FILE_CLOSED ) ;
}
2018-03-22 12:54:41 +03:00
subreq = smbd_smb2_getinfo_send ( req , req - > ev_ctx ,
2012-06-08 12:46:13 +04:00
req , in_fsp ,
2009-07-02 12:17:30 +04:00
in_info_type ,
in_file_info_class ,
in_output_buffer_length ,
in_input_buffer ,
in_additional_information ,
2012-06-08 12:46:13 +04:00
in_flags ) ;
2009-07-02 12:17:30 +04:00
if ( subreq = = NULL ) {
return smbd_smb2_request_error ( req , NT_STATUS_NO_MEMORY ) ;
}
tevent_req_set_callback ( subreq , smbd_smb2_request_getinfo_done , req ) ;
2011-11-14 18:42:55 +04:00
return smbd_smb2_request_pending_queue ( req , subreq , 500 ) ;
2009-07-02 12:17:30 +04:00
}
static void smbd_smb2_request_getinfo_done ( struct tevent_req * subreq )
{
struct smbd_smb2_request * req = tevent_req_callback_data ( subreq ,
struct smbd_smb2_request ) ;
DATA_BLOB outbody ;
DATA_BLOB outdyn ;
uint16_t out_output_buffer_offset ;
2009-07-24 18:21:07 +04:00
DATA_BLOB out_output_buffer = data_blob_null ;
2009-07-02 12:17:30 +04:00
NTSTATUS status ;
2010-07-04 19:49:30 +04:00
NTSTATUS call_status = NT_STATUS_OK ;
2009-07-02 12:17:30 +04:00
NTSTATUS error ; /* transport error */
status = smbd_smb2_getinfo_recv ( subreq ,
req ,
2010-04-27 07:11:59 +04:00
& out_output_buffer ,
& call_status ) ;
2009-07-02 12:17:30 +04:00
TALLOC_FREE ( subreq ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
error = smbd_smb2_request_error ( req , status ) ;
if ( ! NT_STATUS_IS_OK ( error ) ) {
2014-06-11 14:15:48 +04:00
smbd_server_connection_terminate ( req - > xconn ,
2009-07-02 12:17:30 +04:00
nt_errstr ( error ) ) ;
return ;
}
return ;
}
2013-07-05 13:03:16 +04:00
/* some GetInfo responses set STATUS_BUFFER_OVERFLOW and return partial,
but valid data */
if ( ! ( NT_STATUS_IS_OK ( call_status ) | |
NT_STATUS_EQUAL ( call_status , STATUS_BUFFER_OVERFLOW ) ) ) {
2010-04-27 07:11:59 +04:00
/* Return a specific error with data. */
error = smbd_smb2_request_error_ex ( req ,
call_status ,
& out_output_buffer ,
__location__ ) ;
if ( ! NT_STATUS_IS_OK ( error ) ) {
2014-06-11 14:15:48 +04:00
smbd_server_connection_terminate ( req - > xconn ,
2010-04-27 07:11:59 +04:00
nt_errstr ( error ) ) ;
return ;
}
return ;
}
2009-07-02 12:17:30 +04:00
out_output_buffer_offset = SMB2_HDR_BODY + 0x08 ;
2013-12-04 17:59:07 +04:00
outbody = smbd_smb2_generate_outbody ( req , 0x08 ) ;
2009-07-02 12:17:30 +04:00
if ( outbody . data = = NULL ) {
error = smbd_smb2_request_error ( req , NT_STATUS_NO_MEMORY ) ;
if ( ! NT_STATUS_IS_OK ( error ) ) {
2014-06-11 14:15:48 +04:00
smbd_server_connection_terminate ( req - > xconn ,
2009-07-02 12:17:30 +04:00
nt_errstr ( error ) ) ;
return ;
}
return ;
}
SSVAL ( outbody . data , 0x00 , 0x08 + 1 ) ; /* struct size */
SSVAL ( outbody . data , 0x02 ,
out_output_buffer_offset ) ; /* output buffer offset */
SIVAL ( outbody . data , 0x04 ,
out_output_buffer . length ) ; /* output buffer length */
outdyn = out_output_buffer ;
2013-07-05 13:03:16 +04:00
error = smbd_smb2_request_done_ex ( req , call_status , outbody , & outdyn , __location__ ) ;
2009-07-02 12:17:30 +04:00
if ( ! NT_STATUS_IS_OK ( error ) ) {
2014-06-11 14:15:48 +04:00
smbd_server_connection_terminate ( req - > xconn ,
2009-07-02 12:17:30 +04:00
nt_errstr ( error ) ) ;
return ;
}
}
struct smbd_smb2_getinfo_state {
struct smbd_smb2_request * smb2req ;
NTSTATUS status ;
DATA_BLOB out_output_buffer ;
} ;
2011-01-29 00:07:08 +03:00
static void smb2_ipc_getinfo ( struct tevent_req * req ,
struct smbd_smb2_getinfo_state * state ,
struct tevent_context * ev ,
uint8_t in_info_type ,
uint8_t in_file_info_class )
{
/* We want to reply to SMB2_GETINFO_FILE
with a class of SMB2_FILE_STANDARD_INFO as
otherwise a Win7 client issues this request
twice ( 2 xroundtrips ) if we return NOT_SUPPORTED .
NB . We do the same for SMB1 in call_trans2qpipeinfo ( ) */
if ( in_info_type = = 0x01 & & /* SMB2_GETINFO_FILE */
in_file_info_class = = 0x05 ) { /* SMB2_FILE_STANDARD_INFO */
state - > out_output_buffer = data_blob_talloc ( state ,
NULL , 24 ) ;
if ( tevent_req_nomem ( state - > out_output_buffer . data , req ) ) {
return ;
}
memset ( state - > out_output_buffer . data , 0 , 24 ) ;
SOFF_T ( state - > out_output_buffer . data , 0 , 4096LL ) ;
SIVAL ( state - > out_output_buffer . data , 16 , 1 ) ;
SIVAL ( state - > out_output_buffer . data , 20 , 1 ) ;
tevent_req_done ( req ) ;
} else {
tevent_req_nterror ( req , NT_STATUS_NOT_SUPPORTED ) ;
}
}
2009-07-02 12:17:30 +04:00
static struct tevent_req * smbd_smb2_getinfo_send ( TALLOC_CTX * mem_ctx ,
struct tevent_context * ev ,
struct smbd_smb2_request * smb2req ,
2012-06-08 12:46:13 +04:00
struct files_struct * fsp ,
2009-07-02 12:17:30 +04:00
uint8_t in_info_type ,
uint8_t in_file_info_class ,
uint32_t in_output_buffer_length ,
DATA_BLOB in_input_buffer ,
uint32_t in_additional_information ,
2012-06-08 12:46:13 +04:00
uint32_t in_flags )
2009-07-02 12:17:30 +04:00
{
struct tevent_req * req ;
struct smbd_smb2_getinfo_state * state ;
struct smb_request * smbreq ;
2012-03-27 13:09:05 +04:00
connection_struct * conn = smb2req - > tcon - > compat ;
2010-04-27 07:11:59 +04:00
NTSTATUS status ;
2009-07-02 12:17:30 +04:00
req = tevent_req_create ( mem_ctx , & state ,
struct smbd_smb2_getinfo_state ) ;
if ( req = = NULL ) {
return NULL ;
}
state - > smb2req = smb2req ;
2010-04-27 07:11:59 +04:00
state - > status = NT_STATUS_OK ;
2009-07-02 12:17:30 +04:00
state - > out_output_buffer = data_blob_null ;
2012-06-14 15:18:55 +04:00
DEBUG ( 10 , ( " smbd_smb2_getinfo_send: %s - %s \n " ,
fsp_str_dbg ( fsp ) , fsp_fnum_dbg ( fsp ) ) ) ;
2009-07-02 12:17:30 +04:00
smbreq = smbd_smb2_fake_smb_request ( smb2req ) ;
if ( tevent_req_nomem ( smbreq , req ) ) {
return tevent_req_post ( req , ev ) ;
}
2009-07-10 22:39:08 +04:00
if ( IS_IPC ( conn ) ) {
2011-01-29 00:07:08 +03:00
smb2_ipc_getinfo ( req , state , ev ,
in_info_type , in_file_info_class ) ;
2009-07-10 22:39:08 +04:00
return tevent_req_post ( req , ev ) ;
}
switch ( in_info_type ) {
2013-08-26 12:36:14 +04:00
case SMB2_GETINFO_FILE :
2009-07-10 22:39:08 +04:00
{
uint16_t file_info_level ;
char * data = NULL ;
unsigned int data_size = 0 ;
bool delete_pending = false ;
struct timespec write_time_ts ;
struct file_id fileid ;
struct ea_list * ea_list = NULL ;
int lock_data_count = 0 ;
char * lock_data = NULL ;
2013-08-27 13:06:27 +04:00
size_t fixed_portion ;
2009-07-10 22:39:08 +04:00
ZERO_STRUCT ( write_time_ts ) ;
switch ( in_file_info_class ) {
case 0x0F : /* RAW_FILEINFO_SMB2_ALL_EAS */
file_info_level = 0xFF00 | in_file_info_class ;
break ;
case 0x12 : /* RAW_FILEINFO_SMB2_ALL_INFORMATION */
file_info_level = 0xFF00 | in_file_info_class ;
break ;
default :
/* the levels directly map to the passthru levels */
file_info_level = in_file_info_class + 1000 ;
break ;
}
if ( fsp - > fake_file_handle ) {
/*
* This is actually for the QUOTA_FAKE_FILE - - metze
*/
/* We know this name is ok, it's already passed the checks. */
2012-06-11 12:35:38 +04:00
} else if ( fsp - > fh - > fd = = - 1 ) {
2009-07-10 22:39:08 +04:00
/*
* This is actually a QFILEINFO on a directory
* handle ( returned from an NT SMB ) . NT5 .0 seems
* to do this call . JRA .
*/
if ( INFO_LEVEL_IS_UNIX ( file_info_level ) ) {
/* Always do lstat for UNIX calls. */
2009-07-11 01:50:37 +04:00
if ( SMB_VFS_LSTAT ( conn , fsp - > fsp_name ) ) {
2009-07-13 11:23:36 +04:00
DEBUG ( 3 , ( " smbd_smb2_getinfo_send: "
2009-07-10 22:39:08 +04:00
" SMB_VFS_LSTAT of %s failed "
2009-07-11 01:50:37 +04:00
" (%s) \n " , fsp_str_dbg ( fsp ) ,
2009-07-10 22:39:08 +04:00
strerror ( errno ) ) ) ;
status = map_nt_error_from_unix ( errno ) ;
tevent_req_nterror ( req , status ) ;
return tevent_req_post ( req , ev ) ;
}
2009-07-11 01:50:37 +04:00
} else if ( SMB_VFS_STAT ( conn , fsp - > fsp_name ) ) {
2009-07-13 11:23:36 +04:00
DEBUG ( 3 , ( " smbd_smb2_getinfo_send: "
2009-07-10 22:39:08 +04:00
" SMB_VFS_STAT of %s failed (%s) \n " ,
2009-07-11 01:50:37 +04:00
fsp_str_dbg ( fsp ) ,
2009-07-10 22:39:08 +04:00
strerror ( errno ) ) ) ;
status = map_nt_error_from_unix ( errno ) ;
tevent_req_nterror ( req , status ) ;
return tevent_req_post ( req , ev ) ;
}
2009-07-11 01:50:37 +04:00
fileid = vfs_file_id_from_sbuf ( conn ,
& fsp - > fsp_name - > st ) ;
2011-01-26 01:23:19 +03:00
get_file_infos ( fileid , fsp - > name_hash ,
& delete_pending , & write_time_ts ) ;
2009-07-10 22:39:08 +04:00
} else {
/*
* Original code - this is an open file .
*/
2009-07-11 01:50:37 +04:00
if ( SMB_VFS_FSTAT ( fsp , & fsp - > fsp_name - > st ) ! = 0 ) {
2009-07-13 11:23:36 +04:00
DEBUG ( 3 , ( " smbd_smb2_getinfo_send: "
2012-06-14 15:18:55 +04:00
" fstat of %s failed (%s) \n " ,
fsp_fnum_dbg ( fsp ) , strerror ( errno ) ) ) ;
2009-07-10 22:39:08 +04:00
status = map_nt_error_from_unix ( errno ) ;
tevent_req_nterror ( req , status ) ;
return tevent_req_post ( req , ev ) ;
}
2009-07-11 01:50:37 +04:00
fileid = vfs_file_id_from_sbuf ( conn ,
& fsp - > fsp_name - > st ) ;
2011-01-26 01:23:19 +03:00
get_file_infos ( fileid , fsp - > name_hash ,
& delete_pending , & write_time_ts ) ;
2009-07-10 22:39:08 +04:00
}
status = smbd_do_qfilepathinfo ( conn , state ,
file_info_level ,
fsp ,
2009-07-11 01:50:37 +04:00
fsp - > fsp_name ,
2009-07-10 22:39:08 +04:00
delete_pending ,
write_time_ts ,
ea_list ,
lock_data_count ,
lock_data ,
STR_UNICODE ,
in_output_buffer_length ,
2013-08-27 13:06:27 +04:00
& fixed_portion ,
2009-07-10 22:39:08 +04:00
& data ,
& data_size ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
SAFE_FREE ( data ) ;
2009-07-13 11:23:36 +04:00
if ( NT_STATUS_EQUAL ( status , NT_STATUS_INVALID_LEVEL ) ) {
status = NT_STATUS_INVALID_INFO_CLASS ;
}
2009-07-13 14:08:20 +04:00
tevent_req_nterror ( req , status ) ;
return tevent_req_post ( req , ev ) ;
}
2013-08-27 13:36:03 +04:00
if ( in_output_buffer_length < fixed_portion ) {
SAFE_FREE ( data ) ;
tevent_req_nterror (
req , NT_STATUS_INFO_LENGTH_MISMATCH ) ;
return tevent_req_post ( req , ev ) ;
}
2009-07-13 14:08:20 +04:00
if ( data_size > 0 ) {
state - > out_output_buffer = data_blob_talloc ( state ,
data ,
data_size ) ;
SAFE_FREE ( data ) ;
if ( tevent_req_nomem ( state - > out_output_buffer . data , req ) ) {
return tevent_req_post ( req , ev ) ;
}
2013-08-27 13:37:34 +04:00
if ( data_size > in_output_buffer_length ) {
state - > out_output_buffer . length =
in_output_buffer_length ;
status = STATUS_BUFFER_OVERFLOW ;
}
2009-07-13 14:08:20 +04:00
}
SAFE_FREE ( data ) ;
break ;
}
2013-08-26 12:36:14 +04:00
case SMB2_GETINFO_FS :
2009-07-13 14:08:20 +04:00
{
uint16_t file_info_level ;
char * data = NULL ;
int data_size = 0 ;
2013-08-27 13:06:27 +04:00
size_t fixed_portion ;
2009-07-13 14:08:20 +04:00
/* the levels directly map to the passthru levels */
file_info_level = in_file_info_class + 1000 ;
2014-06-11 15:36:34 +04:00
status = smbd_do_qfsinfo ( smb2req - > xconn , conn , state ,
2009-07-13 14:08:20 +04:00
file_info_level ,
STR_UNICODE ,
in_output_buffer_length ,
2013-08-27 13:06:27 +04:00
& fixed_portion ,
2013-02-06 17:35:25 +04:00
fsp - > fsp_name ,
2009-07-13 14:08:20 +04:00
& data ,
& data_size ) ;
2013-07-05 13:03:16 +04:00
/* some responses set STATUS_BUFFER_OVERFLOW and return
partial , but valid data */
if ( ! ( NT_STATUS_IS_OK ( status ) | |
NT_STATUS_EQUAL ( status , STATUS_BUFFER_OVERFLOW ) ) ) {
2009-07-13 14:08:20 +04:00
SAFE_FREE ( data ) ;
if ( NT_STATUS_EQUAL ( status , NT_STATUS_INVALID_LEVEL ) ) {
status = NT_STATUS_INVALID_INFO_CLASS ;
}
2009-07-10 22:39:08 +04:00
tevent_req_nterror ( req , status ) ;
return tevent_req_post ( req , ev ) ;
}
2013-08-27 13:36:03 +04:00
if ( in_output_buffer_length < fixed_portion ) {
SAFE_FREE ( data ) ;
tevent_req_nterror (
req , NT_STATUS_INFO_LENGTH_MISMATCH ) ;
return tevent_req_post ( req , ev ) ;
}
2009-07-10 22:39:08 +04:00
if ( data_size > 0 ) {
state - > out_output_buffer = data_blob_talloc ( state ,
data ,
data_size ) ;
SAFE_FREE ( data ) ;
if ( tevent_req_nomem ( state - > out_output_buffer . data , req ) ) {
return tevent_req_post ( req , ev ) ;
}
2013-08-27 13:37:34 +04:00
if ( data_size > in_output_buffer_length ) {
state - > out_output_buffer . length =
in_output_buffer_length ;
status = STATUS_BUFFER_OVERFLOW ;
}
2009-07-10 22:39:08 +04:00
}
SAFE_FREE ( data ) ;
break ;
}
2013-08-26 12:36:14 +04:00
case SMB2_GETINFO_SECURITY :
2010-04-27 07:11:59 +04:00
{
uint8_t * p_marshalled_sd = NULL ;
size_t sd_size = 0 ;
status = smbd_do_query_security_desc ( conn ,
state ,
fsp ,
/* Security info wanted. */
2014-08-20 15:58:38 +04:00
in_additional_information &
SMB_SUPPORTED_SECINFO_FLAGS ,
2010-04-27 07:11:59 +04:00
in_output_buffer_length ,
& p_marshalled_sd ,
& sd_size ) ;
if ( NT_STATUS_EQUAL ( status , NT_STATUS_BUFFER_TOO_SMALL ) ) {
/* Return needed size. */
state - > out_output_buffer = data_blob_talloc ( state ,
NULL ,
4 ) ;
if ( tevent_req_nomem ( state - > out_output_buffer . data , req ) ) {
return tevent_req_post ( req , ev ) ;
}
SIVAL ( state - > out_output_buffer . data , 0 , ( uint32_t ) sd_size ) ;
state - > status = NT_STATUS_BUFFER_TOO_SMALL ;
break ;
}
if ( ! NT_STATUS_IS_OK ( status ) ) {
DEBUG ( 10 , ( " smbd_smb2_getinfo_send: "
" smbd_do_query_security_desc of %s failed "
" (%s) \n " , fsp_str_dbg ( fsp ) ,
nt_errstr ( status ) ) ) ;
tevent_req_nterror ( req , status ) ;
return tevent_req_post ( req , ev ) ;
}
if ( sd_size > 0 ) {
state - > out_output_buffer = data_blob_talloc ( state ,
p_marshalled_sd ,
sd_size ) ;
if ( tevent_req_nomem ( state - > out_output_buffer . data , req ) ) {
return tevent_req_post ( req , ev ) ;
}
}
break ;
}
2013-08-26 12:36:14 +04:00
case SMB2_GETINFO_QUOTA :
2012-09-28 09:09:23 +04:00
tevent_req_nterror ( req , NT_STATUS_NOT_SUPPORTED ) ;
return tevent_req_post ( req , ev ) ;
2009-07-10 22:39:08 +04:00
default :
2010-04-27 07:11:59 +04:00
DEBUG ( 10 , ( " smbd_smb2_getinfo_send: "
" unknown in_info_type of %u "
" for file %s \n " ,
( unsigned int ) in_info_type ,
fsp_str_dbg ( fsp ) ) ) ;
2009-07-10 22:39:08 +04:00
tevent_req_nterror ( req , NT_STATUS_INVALID_PARAMETER ) ;
return tevent_req_post ( req , ev ) ;
}
2013-07-05 13:03:16 +04:00
state - > status = status ;
2009-07-10 22:39:08 +04:00
tevent_req_done ( req ) ;
2009-07-02 12:17:30 +04:00
return tevent_req_post ( req , ev ) ;
}
static NTSTATUS smbd_smb2_getinfo_recv ( struct tevent_req * req ,
TALLOC_CTX * mem_ctx ,
2010-04-27 07:11:59 +04:00
DATA_BLOB * out_output_buffer ,
NTSTATUS * pstatus )
2009-07-02 12:17:30 +04:00
{
NTSTATUS status ;
struct smbd_smb2_getinfo_state * state = tevent_req_data ( req ,
struct smbd_smb2_getinfo_state ) ;
if ( tevent_req_is_nterror ( req , & status ) ) {
tevent_req_received ( req ) ;
return status ;
}
* out_output_buffer = state - > out_output_buffer ;
talloc_steal ( mem_ctx , out_output_buffer - > data ) ;
2010-04-27 07:11:59 +04:00
* pstatus = state - > status ;
2009-07-02 12:17:30 +04:00
tevent_req_received ( req ) ;
return NT_STATUS_OK ;
}