mirror of
https://github.com/samba-team/samba.git
synced 2025-09-23 01:44:20 +03:00
s3: Plumb smb_filename through open_fake_file
This commit is contained in:
@@ -6266,11 +6266,11 @@ void reply_openerror(struct smb_request *req, NTSTATUS status);
|
|||||||
|
|
||||||
/* The following definitions come from smbd/fake_file.c */
|
/* The following definitions come from smbd/fake_file.c */
|
||||||
|
|
||||||
enum FAKE_FILE_TYPE is_fake_file(const char *fname);
|
enum FAKE_FILE_TYPE is_fake_file(const struct smb_filename *smb_fname);
|
||||||
NTSTATUS open_fake_file(struct smb_request *req, connection_struct *conn,
|
NTSTATUS open_fake_file(struct smb_request *req, connection_struct *conn,
|
||||||
uint16_t current_vuid,
|
uint16_t current_vuid,
|
||||||
enum FAKE_FILE_TYPE fake_file_type,
|
enum FAKE_FILE_TYPE fake_file_type,
|
||||||
const char *fname,
|
const struct smb_filename *smb_fname,
|
||||||
uint32 access_mask,
|
uint32 access_mask,
|
||||||
files_struct **result);
|
files_struct **result);
|
||||||
NTSTATUS close_fake_file(struct smb_request *req, files_struct *fsp);
|
NTSTATUS close_fake_file(struct smb_request *req, files_struct *fsp);
|
||||||
|
@@ -71,23 +71,32 @@ static struct fake_file_handle *init_fake_file_handle(enum FAKE_FILE_TYPE type)
|
|||||||
Does this name match a fake filename ?
|
Does this name match a fake filename ?
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
enum FAKE_FILE_TYPE is_fake_file(const char *fname)
|
enum FAKE_FILE_TYPE is_fake_file(const struct smb_filename *smb_fname)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SYS_QUOTAS
|
#ifdef HAVE_SYS_QUOTAS
|
||||||
int i;
|
int i;
|
||||||
|
char *fname = NULL;
|
||||||
|
NTSTATUS status;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!fname) {
|
if (!smb_fname) {
|
||||||
return FAKE_FILE_TYPE_NONE;
|
return FAKE_FILE_TYPE_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_SYS_QUOTAS
|
#ifdef HAVE_SYS_QUOTAS
|
||||||
|
status = get_full_smb_filename(talloc_tos(), smb_fname, &fname);
|
||||||
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
|
return FAKE_FILE_TYPE_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
for (i=0;fake_files[i].name!=NULL;i++) {
|
for (i=0;fake_files[i].name!=NULL;i++) {
|
||||||
if (strncmp(fname,fake_files[i].name,strlen(fake_files[i].name))==0) {
|
if (strncmp(fname,fake_files[i].name,strlen(fake_files[i].name))==0) {
|
||||||
DEBUG(5,("is_fake_file: [%s] is a fake file\n",fname));
|
DEBUG(5,("is_fake_file: [%s] is a fake file\n",fname));
|
||||||
|
TALLOC_FREE(fname);
|
||||||
return fake_files[i].type;
|
return fake_files[i].type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
TALLOC_FREE(fname);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return FAKE_FILE_TYPE_NONE;
|
return FAKE_FILE_TYPE_NONE;
|
||||||
@@ -101,7 +110,7 @@ enum FAKE_FILE_TYPE is_fake_file(const char *fname)
|
|||||||
NTSTATUS open_fake_file(struct smb_request *req, connection_struct *conn,
|
NTSTATUS open_fake_file(struct smb_request *req, connection_struct *conn,
|
||||||
uint16_t current_vuid,
|
uint16_t current_vuid,
|
||||||
enum FAKE_FILE_TYPE fake_file_type,
|
enum FAKE_FILE_TYPE fake_file_type,
|
||||||
const char *fname,
|
const struct smb_filename *smb_fname,
|
||||||
uint32 access_mask,
|
uint32 access_mask,
|
||||||
files_struct **result)
|
files_struct **result)
|
||||||
{
|
{
|
||||||
@@ -112,7 +121,8 @@ NTSTATUS open_fake_file(struct smb_request *req, connection_struct *conn,
|
|||||||
if (conn->server_info->utok.uid != 0) {
|
if (conn->server_info->utok.uid != 0) {
|
||||||
DEBUG(3, ("open_fake_file_shared: access_denied to "
|
DEBUG(3, ("open_fake_file_shared: access_denied to "
|
||||||
"service[%s] file[%s] user[%s]\n",
|
"service[%s] file[%s] user[%s]\n",
|
||||||
lp_servicename(SNUM(conn)), fname,
|
lp_servicename(SNUM(conn)),
|
||||||
|
smb_fname_str_dbg(smb_fname),
|
||||||
conn->server_info->unix_name));
|
conn->server_info->unix_name));
|
||||||
return NT_STATUS_ACCESS_DENIED;
|
return NT_STATUS_ACCESS_DENIED;
|
||||||
|
|
||||||
@@ -124,7 +134,8 @@ NTSTATUS open_fake_file(struct smb_request *req, connection_struct *conn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
DEBUG(5,("open_fake_file_shared: fname = %s, FID = %d, access_mask = 0x%x\n",
|
DEBUG(5,("open_fake_file_shared: fname = %s, FID = %d, access_mask = 0x%x\n",
|
||||||
fname, fsp->fnum, (unsigned int)access_mask));
|
smb_fname_str_dbg(smb_fname), fsp->fnum,
|
||||||
|
(unsigned int)access_mask));
|
||||||
|
|
||||||
fsp->conn = conn;
|
fsp->conn = conn;
|
||||||
fsp->fh->fd = -1;
|
fsp->fh->fd = -1;
|
||||||
@@ -132,7 +143,11 @@ NTSTATUS open_fake_file(struct smb_request *req, connection_struct *conn,
|
|||||||
fsp->fh->pos = -1;
|
fsp->fh->pos = -1;
|
||||||
fsp->can_lock = False; /* Should this be true ? - No, JRA */
|
fsp->can_lock = False; /* Should this be true ? - No, JRA */
|
||||||
fsp->access_mask = access_mask;
|
fsp->access_mask = access_mask;
|
||||||
string_set(&fsp->fsp_name,fname);
|
status = fsp_set_smb_fname(fsp, smb_fname);
|
||||||
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
|
file_free(req, fsp);
|
||||||
|
return NT_STATUS_NO_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
fsp->fake_file_handle = init_fake_file_handle(fake_file_type);
|
fsp->fake_file_handle = init_fake_file_handle(fake_file_type);
|
||||||
|
|
||||||
|
@@ -3462,16 +3462,9 @@ NTSTATUS create_file_default(connection_struct *conn,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if (is_ntfs_stream_smb_fname(smb_fname)) {
|
if (is_ntfs_stream_smb_fname(smb_fname)) {
|
||||||
char *fname = NULL;
|
|
||||||
enum FAKE_FILE_TYPE fake_file_type;
|
enum FAKE_FILE_TYPE fake_file_type;
|
||||||
|
|
||||||
status = get_full_smb_filename(talloc_tos(), smb_fname,
|
fake_file_type = is_fake_file(smb_fname);
|
||||||
&fname);
|
|
||||||
if (!NT_STATUS_IS_OK(status)) {
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
fake_file_type = is_fake_file(fname);
|
|
||||||
|
|
||||||
if (fake_file_type != FAKE_FILE_TYPE_NONE) {
|
if (fake_file_type != FAKE_FILE_TYPE_NONE) {
|
||||||
|
|
||||||
@@ -3487,9 +3480,8 @@ NTSTATUS create_file_default(connection_struct *conn,
|
|||||||
* close it
|
* close it
|
||||||
*/
|
*/
|
||||||
status = open_fake_file(req, conn, req->vuid,
|
status = open_fake_file(req, conn, req->vuid,
|
||||||
fake_file_type, fname,
|
fake_file_type, smb_fname,
|
||||||
access_mask, &fsp);
|
access_mask, &fsp);
|
||||||
TALLOC_FREE(fname);
|
|
||||||
if (!NT_STATUS_IS_OK(status)) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
@@ -3497,7 +3489,6 @@ NTSTATUS create_file_default(connection_struct *conn,
|
|||||||
ZERO_STRUCT(smb_fname->st);
|
ZERO_STRUCT(smb_fname->st);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
TALLOC_FREE(fname);
|
|
||||||
|
|
||||||
if (!(conn->fs_capabilities & FILE_NAMED_STREAMS)) {
|
if (!(conn->fs_capabilities & FILE_NAMED_STREAMS)) {
|
||||||
status = NT_STATUS_OBJECT_NAME_NOT_FOUND;
|
status = NT_STATUS_OBJECT_NAME_NOT_FOUND;
|
||||||
|
Reference in New Issue
Block a user