mirror of
https://github.com/samba-team/samba.git
synced 2025-03-01 04:58:35 +03:00
smbd: Move get_posix_fsp() to smb1_trans2.c
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
This commit is contained in:
parent
6fc64f53a8
commit
f48e2489ad
@ -1156,12 +1156,6 @@ bool map_info2_flags_to_sbuf(const SMB_STRUCT_STAT *psbuf,
|
||||
const uint32_t smb_fmask,
|
||||
int *stat_fflags);
|
||||
|
||||
NTSTATUS get_posix_fsp(connection_struct *conn,
|
||||
struct smb_request *req,
|
||||
struct smb_filename *smb_fname,
|
||||
uint32_t access_mask,
|
||||
files_struct **ret_fsp);
|
||||
|
||||
enum perm_type {
|
||||
PERM_NEW_FILE,
|
||||
PERM_NEW_DIR,
|
||||
|
@ -2144,6 +2144,83 @@ static NTSTATUS smb_q_unix_info2(
|
||||
}
|
||||
|
||||
#if defined(HAVE_POSIX_ACLS)
|
||||
/****************************************************************************
|
||||
Utility function to open a fsp for a POSIX handle operation.
|
||||
****************************************************************************/
|
||||
|
||||
static NTSTATUS get_posix_fsp(connection_struct *conn,
|
||||
struct smb_request *req,
|
||||
struct smb_filename *smb_fname,
|
||||
uint32_t access_mask,
|
||||
files_struct **ret_fsp)
|
||||
{
|
||||
NTSTATUS status;
|
||||
uint32_t create_disposition = FILE_OPEN;
|
||||
uint32_t share_access = FILE_SHARE_READ|
|
||||
FILE_SHARE_WRITE|
|
||||
FILE_SHARE_DELETE;
|
||||
struct smb2_create_blobs *posx = NULL;
|
||||
|
||||
/*
|
||||
* Only FILE_FLAG_POSIX_SEMANTICS matters on existing files,
|
||||
* but set reasonable defaults.
|
||||
*/
|
||||
uint32_t file_attributes = 0664;
|
||||
uint32_t oplock = NO_OPLOCK;
|
||||
uint32_t create_options = FILE_NON_DIRECTORY_FILE;
|
||||
|
||||
/* File or directory must exist. */
|
||||
if (!VALID_STAT(smb_fname->st)) {
|
||||
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
|
||||
}
|
||||
/* Cannot be a symlink. */
|
||||
if (S_ISLNK(smb_fname->st.st_ex_mode)) {
|
||||
return NT_STATUS_ACCESS_DENIED;
|
||||
}
|
||||
/* Set options correctly for directory open. */
|
||||
if (S_ISDIR(smb_fname->st.st_ex_mode)) {
|
||||
/*
|
||||
* Only FILE_FLAG_POSIX_SEMANTICS matters on existing
|
||||
* directories, but set reasonable defaults.
|
||||
*/
|
||||
file_attributes = 0775;
|
||||
create_options = FILE_DIRECTORY_FILE;
|
||||
}
|
||||
|
||||
status = make_smb2_posix_create_ctx(
|
||||
talloc_tos(), &posx, file_attributes);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
DBG_WARNING("make_smb2_posix_create_ctx failed: %s\n",
|
||||
nt_errstr(status));
|
||||
goto done;
|
||||
}
|
||||
|
||||
status = SMB_VFS_CREATE_FILE(
|
||||
conn, /* conn */
|
||||
req, /* req */
|
||||
NULL, /* dirfsp */
|
||||
smb_fname, /* fname */
|
||||
access_mask, /* access_mask */
|
||||
share_access, /* share_access */
|
||||
create_disposition,/* create_disposition*/
|
||||
create_options, /* create_options */
|
||||
file_attributes,/* file_attributes */
|
||||
oplock, /* oplock_request */
|
||||
NULL, /* lease */
|
||||
0, /* allocation_size */
|
||||
0, /* private_flags */
|
||||
NULL, /* sd */
|
||||
NULL, /* ea_list */
|
||||
ret_fsp, /* result */
|
||||
NULL, /* pinfo */
|
||||
posx, /* in_context */
|
||||
NULL); /* out_context */
|
||||
|
||||
done:
|
||||
TALLOC_FREE(posx);
|
||||
return status;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Utility function to count the number of entries in a POSIX acl.
|
||||
****************************************************************************/
|
||||
|
@ -87,85 +87,6 @@ NTSTATUS check_access_fsp(struct files_struct *fsp,
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
#if defined(HAVE_POSIX_ACLS)
|
||||
/****************************************************************************
|
||||
Utility function to open a fsp for a POSIX handle operation.
|
||||
****************************************************************************/
|
||||
|
||||
NTSTATUS get_posix_fsp(connection_struct *conn,
|
||||
struct smb_request *req,
|
||||
struct smb_filename *smb_fname,
|
||||
uint32_t access_mask,
|
||||
files_struct **ret_fsp)
|
||||
{
|
||||
NTSTATUS status;
|
||||
uint32_t create_disposition = FILE_OPEN;
|
||||
uint32_t share_access = FILE_SHARE_READ|
|
||||
FILE_SHARE_WRITE|
|
||||
FILE_SHARE_DELETE;
|
||||
struct smb2_create_blobs *posx = NULL;
|
||||
|
||||
/*
|
||||
* Only FILE_FLAG_POSIX_SEMANTICS matters on existing files,
|
||||
* but set reasonable defaults.
|
||||
*/
|
||||
uint32_t file_attributes = 0664;
|
||||
uint32_t oplock = NO_OPLOCK;
|
||||
uint32_t create_options = FILE_NON_DIRECTORY_FILE;
|
||||
|
||||
/* File or directory must exist. */
|
||||
if (!VALID_STAT(smb_fname->st)) {
|
||||
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
|
||||
}
|
||||
/* Cannot be a symlink. */
|
||||
if (S_ISLNK(smb_fname->st.st_ex_mode)) {
|
||||
return NT_STATUS_ACCESS_DENIED;
|
||||
}
|
||||
/* Set options correctly for directory open. */
|
||||
if (S_ISDIR(smb_fname->st.st_ex_mode)) {
|
||||
/*
|
||||
* Only FILE_FLAG_POSIX_SEMANTICS matters on existing
|
||||
* directories, but set reasonable defaults.
|
||||
*/
|
||||
file_attributes = 0775;
|
||||
create_options = FILE_DIRECTORY_FILE;
|
||||
}
|
||||
|
||||
status = make_smb2_posix_create_ctx(
|
||||
talloc_tos(), &posx, file_attributes);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
DBG_WARNING("make_smb2_posix_create_ctx failed: %s\n",
|
||||
nt_errstr(status));
|
||||
goto done;
|
||||
}
|
||||
|
||||
status = SMB_VFS_CREATE_FILE(
|
||||
conn, /* conn */
|
||||
req, /* req */
|
||||
NULL, /* dirfsp */
|
||||
smb_fname, /* fname */
|
||||
access_mask, /* access_mask */
|
||||
share_access, /* share_access */
|
||||
create_disposition,/* create_disposition*/
|
||||
create_options, /* create_options */
|
||||
file_attributes,/* file_attributes */
|
||||
oplock, /* oplock_request */
|
||||
NULL, /* lease */
|
||||
0, /* allocation_size */
|
||||
0, /* private_flags */
|
||||
NULL, /* sd */
|
||||
NULL, /* ea_list */
|
||||
ret_fsp, /* result */
|
||||
NULL, /* pinfo */
|
||||
posx, /* in_context */
|
||||
NULL); /* out_context */
|
||||
|
||||
done:
|
||||
TALLOC_FREE(posx);
|
||||
return status;
|
||||
}
|
||||
#endif
|
||||
|
||||
/********************************************************************
|
||||
Roundup a value to the nearest allocation roundup size boundary.
|
||||
Only do this for Windows clients.
|
||||
|
Loading…
x
Reference in New Issue
Block a user