mirror of
https://github.com/samba-team/samba.git
synced 2025-03-24 10:50:22 +03:00
s3: smbd: Cleanup - Split out smbd_marshall_security_desc() from smbd_do_query_security_desc().
This is part two of a cleanup to split this up into a fetch()/marshal() pair. Allows easy modification of the sd before returning if we need to add the SMB2+unix mode information here on a SMB2 posix handle. Also makes the code much clearer. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: David Mulder <dmulder@suse.com>
This commit is contained in:
parent
62bd38f788
commit
65774b5176
@ -2214,6 +2214,37 @@ static NTSTATUS smbd_fetch_security_desc(connection_struct *conn,
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Write a securty descriptor into marshalled format.
|
||||
****************************************************************************/
|
||||
|
||||
static NTSTATUS smbd_marshall_security_desc(TALLOC_CTX *mem_ctx,
|
||||
files_struct *fsp,
|
||||
struct security_descriptor *psd,
|
||||
uint32_t max_data_count,
|
||||
uint8_t **ppmarshalled_sd,
|
||||
size_t *psd_size)
|
||||
{
|
||||
*psd_size = ndr_size_security_descriptor(psd, 0);
|
||||
|
||||
DBG_NOTICE("sd_size = %zu.\n", *psd_size);
|
||||
|
||||
if (DEBUGLEVEL >= 10) {
|
||||
DBG_DEBUG("security desc for file %s\n",
|
||||
fsp_str_dbg(fsp));
|
||||
NDR_PRINT_DEBUG(security_descriptor, psd);
|
||||
}
|
||||
|
||||
if (max_data_count < *psd_size) {
|
||||
return NT_STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
return marshall_sec_desc(mem_ctx,
|
||||
psd,
|
||||
ppmarshalled_sd,
|
||||
psd_size);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Reply to query a security descriptor.
|
||||
Callable from SMB1 and SMB2.
|
||||
@ -2247,32 +2278,14 @@ NTSTATUS smbd_do_query_security_desc(connection_struct *conn,
|
||||
return status;
|
||||
}
|
||||
|
||||
*psd_size = ndr_size_security_descriptor(psd, 0);
|
||||
|
||||
DEBUG(3,("smbd_do_query_security_desc: sd_size = %lu.\n",
|
||||
(unsigned long)*psd_size));
|
||||
|
||||
if (DEBUGLEVEL >= 10) {
|
||||
DEBUG(10,("smbd_do_query_security_desc for file %s\n",
|
||||
fsp_str_dbg(fsp)));
|
||||
NDR_PRINT_DEBUG(security_descriptor, psd);
|
||||
}
|
||||
|
||||
if (max_data_count < *psd_size) {
|
||||
TALLOC_FREE(frame);
|
||||
return NT_STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
status = marshall_sec_desc(mem_ctx, psd,
|
||||
ppmarshalled_sd, psd_size);
|
||||
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
TALLOC_FREE(frame);
|
||||
return status;
|
||||
}
|
||||
|
||||
status = smbd_marshall_security_desc(mem_ctx,
|
||||
fsp,
|
||||
psd,
|
||||
max_data_count,
|
||||
ppmarshalled_sd,
|
||||
psd_size);
|
||||
TALLOC_FREE(frame);
|
||||
return NT_STATUS_OK;
|
||||
return status;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
Loading…
x
Reference in New Issue
Block a user