WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p,
struct srvsvc_NetGetFileSecurity *r)
{
+ struct smb_filename *smb_fname = NULL;
+ char *fname = NULL;
SEC_DESC *psd = NULL;
size_t sd_size;
fstring servicename;
goto error_exit;
}
+ nt_status = unix_convert(talloc_tos(), conn, r->in.file, &smb_fname,
+ 0);
+ if (!NT_STATUS_IS_OK(nt_status)) {
+ werr = ntstatus_to_werror(nt_status);
+ goto error_exit;
+ }
+
+ nt_status = get_full_smb_filename(talloc_tos(), smb_fname, &fname);
+ if (!NT_STATUS_IS_OK(nt_status)) {
+ werr = ntstatus_to_werror(nt_status);
+ goto error_exit;
+ }
+
nt_status = SMB_VFS_CREATE_FILE(
conn, /* conn */
NULL, /* req */
0, /* root_dir_fid */
- r->in.file, /* fname */
- CFF_DOS_PATH, /* create_file_flags */
+ fname, /* fname */
+ 0, /* create_file_flags */
FILE_READ_ATTRIBUTES, /* access_mask */
FILE_SHARE_READ|FILE_SHARE_WRITE, /* share_access */
FILE_OPEN, /* create_disposition*/
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(3,("_srvsvc_NetGetFileSecurity: can't open %s\n",
- r->in.file));
+ fname));
werr = ntstatus_to_werror(nt_status);
goto error_exit;
}
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(3,("_srvsvc_NetGetFileSecurity: Unable to get NT ACL "
- "for file %s\n", r->in.file));
+ "for file %s\n", fname));
werr = ntstatus_to_werror(nt_status);
goto error_exit;
}
close_file(NULL, fsp, NORMAL_CLOSE);
vfs_ChDir(conn, oldcwd);
conn_free_internal(conn);
- return WERR_OK;
+ werr = WERR_OK;
+ goto done;
error_exit:
conn_free_internal(conn);
}
+ done:
+ TALLOC_FREE(smb_fname);
+
return werr;
}
WERROR _srvsvc_NetSetFileSecurity(pipes_struct *p,
struct srvsvc_NetSetFileSecurity *r)
{
+ struct smb_filename *smb_fname = NULL;
+ char *fname = NULL;
fstring servicename;
files_struct *fsp = NULL;
SMB_STRUCT_STAT st;
goto error_exit;
}
+ nt_status = unix_convert(talloc_tos(), conn, r->in.file, &smb_fname,
+ 0);
+ if (!NT_STATUS_IS_OK(nt_status)) {
+ werr = ntstatus_to_werror(nt_status);
+ goto error_exit;
+ }
+
+ nt_status = get_full_smb_filename(talloc_tos(), smb_fname, &fname);
+ if (!NT_STATUS_IS_OK(nt_status)) {
+ werr = ntstatus_to_werror(nt_status);
+ goto error_exit;
+ }
+
nt_status = SMB_VFS_CREATE_FILE(
conn, /* conn */
NULL, /* req */
0, /* root_dir_fid */
- r->in.file, /* fname */
- CFF_DOS_PATH, /* create_file_flags */
+ fname, /* fname */
+ 0, /* create_file_flags */
FILE_WRITE_ATTRIBUTES, /* access_mask */
FILE_SHARE_READ|FILE_SHARE_WRITE, /* share_access */
FILE_OPEN, /* create_disposition*/
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(3,("_srvsvc_NetSetFileSecurity: can't open %s\n",
- r->in.file));
+ fname));
werr = ntstatus_to_werror(nt_status);
goto error_exit;
}
close_file(NULL, fsp, NORMAL_CLOSE);
vfs_ChDir(conn, oldcwd);
conn_free_internal(conn);
- return WERR_OK;
+ werr = WERR_OK;
+ goto done;
error_exit:
conn_free_internal(conn);
}
+ done:
+ TALLOC_FREE(smb_fname);
+
return werr;
}
void reply_ntcreate_and_X(struct smb_request *req)
{
connection_struct *conn = req->conn;
+ struct smb_filename *smb_fname = NULL;
char *fname = NULL;
uint32 flags;
uint32 access_mask;
reply bits separately. */
uint32 fattr=0;
SMB_OFF_T file_len = 0;
- SMB_STRUCT_STAT sbuf;
int info = 0;
files_struct *fsp = NULL;
char *p = NULL;
START_PROFILE(SMBntcreateX);
- SET_STAT_INVALID(sbuf);
-
if (req->wct < 24) {
reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
return;
if (!NT_STATUS_IS_OK(status)) {
reply_nterror(req, status);
- END_PROFILE(SMBntcreateX);
- return;
+ goto out;
}
DEBUG(10,("reply_ntcreate_and_X: flags = 0x%x, access_mask = 0x%x "
if (IS_IPC(conn)) {
if (lp_nt_pipe_support()) {
do_ntcreate_pipe_open(conn, req);
- END_PROFILE(SMBntcreateX);
- return;
+ goto out;
}
reply_doserror(req, ERRDOS, ERRnoaccess);
- END_PROFILE(SMBntcreateX);
- return;
+ goto out;
}
oplock_request = (flags & REQUEST_OPLOCK) ? EXCLUSIVE_OPLOCK : 0;
? BATCH_OPLOCK : 0;
}
+ status = unix_convert(ctx, conn, fname, &smb_fname, 0);
+ if (!NT_STATUS_IS_OK(status)) {
+ reply_nterror(req, status);
+ goto out;
+ }
+
+ status = get_full_smb_filename(ctx, smb_fname, &fname);
+ if (!NT_STATUS_IS_OK(status)) {
+ reply_nterror(req, status);
+ goto out;
+ }
+
status = SMB_VFS_CREATE_FILE(
conn, /* conn */
req, /* req */
root_dir_fid, /* root_dir_fid */
fname, /* fname */
- CFF_DOS_PATH, /* create_file_flags */
+ 0, /* create_file_flags */
access_mask, /* access_mask */
share_access, /* share_access */
create_disposition, /* create_disposition*/
NULL, /* ea_list */
&fsp, /* result */
&info, /* pinfo */
- &sbuf); /* psbuf */
+ &smb_fname->st); /* psbuf */
if (!NT_STATUS_IS_OK(status)) {
if (open_was_deferred(req->mid)) {
/* We have re-scheduled this call, no error. */
- END_PROFILE(SMBntcreateX);
- return;
+ goto out;
}
if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) {
reply_botherror(req, status, ERRDOS, ERRfilexists);
else {
reply_nterror(req, status);
}
- END_PROFILE(SMBntcreateX);
- return;
+ goto out;
}
/*
oplock_granted = NO_OPLOCK_RETURN;
}
- file_len = sbuf.st_ex_size;
- fattr = dos_mode(conn,fsp->fsp_name,&sbuf);
+ file_len = smb_fname->st.st_ex_size;
+ fattr = dos_mode(conn,fsp->fsp_name,&smb_fname->st);
if (fattr == 0) {
fattr = FILE_ATTRIBUTE_NORMAL;
}
p += 4;
/* Create time. */
- c_timespec = sbuf.st_ex_btime;
- a_timespec = sbuf.st_ex_atime;
- m_timespec = sbuf.st_ex_mtime;
+ c_timespec = smb_fname->st.st_ex_btime;
+ a_timespec = smb_fname->st.st_ex_atime;
+ m_timespec = smb_fname->st.st_ex_mtime;
if (lp_dos_filetime_resolution(SNUM(conn))) {
dos_filetime_timespec(&c_timespec);
p += 8;
SIVAL(p,0,fattr); /* File Attributes. */
p += 4;
- SOFF_T(p, 0, SMB_VFS_GET_ALLOC_SIZE(conn,fsp,&sbuf));
+ SOFF_T(p, 0, SMB_VFS_GET_ALLOC_SIZE(conn,fsp,&smb_fname->st));
p += 8;
SOFF_T(p,0,file_len);
p += 8;
if (flags & EXTENDED_RESPONSE_REQUIRED) {
uint32 perms = 0;
p += 25;
- if (fsp->is_directory
- || can_write_to_file(conn, fsp->fsp_name, &sbuf)) {
+ if (fsp->is_directory ||
+ can_write_to_file(conn, fsp->fsp_name, &smb_fname->st)) {
perms = FILE_GENERIC_ALL;
} else {
perms = FILE_GENERIC_READ|FILE_EXECUTE;
fsp->fnum, fsp->fsp_name));
chain_reply(req);
+ out:
+ TALLOC_FREE(smb_fname);
END_PROFILE(SMBntcreateX);
return;
}
char **ppdata, uint32 data_count,
uint32 max_data_count)
{
+ struct smb_filename *smb_fname = NULL;
char *fname = NULL;
char *params = *ppparams;
char *data = *ppdata;
/* Breakout the oplock request bits so we can set the reply bits separately. */
uint32 fattr=0;
SMB_OFF_T file_len = 0;
- SMB_STRUCT_STAT sbuf;
int info = 0;
files_struct *fsp = NULL;
char *p = NULL;
uint8_t oplock_granted;
TALLOC_CTX *ctx = talloc_tos();
- SET_STAT_INVALID(sbuf);
-
DEBUG(5,("call_nt_transact_create\n"));
/*
ppsetup, setup_count,
ppparams, parameter_count,
ppdata, data_count);
- return;
+ goto out;
}
reply_doserror(req, ERRDOS, ERRnoaccess);
- return;
+ goto out;
}
/*
if(parameter_count < 54) {
DEBUG(0,("call_nt_transact_create - insufficient parameters (%u)\n", (unsigned int)parameter_count));
reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
- return;
+ goto out;
}
flags = IVAL(params,0);
"%u, data_count = %u\n", (unsigned int)ea_len,
(unsigned int)sd_len, (unsigned int)data_count));
reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
- return;
+ goto out;
}
if (sd_len) {
"unmarshall_sec_desc failed: %s\n",
nt_errstr(status)));
reply_nterror(req, status);
- return;
+ goto out;
}
}
"EA's not supported.\n",
(unsigned int)ea_len));
reply_nterror(req, NT_STATUS_EAS_NOT_SUPPORTED);
- return;
+ goto out;
}
if (ea_len < 10) {
"too small (should be more than 10)\n",
(unsigned int)ea_len ));
reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
- return;
+ goto out;
}
/* We have already checked that ea_len <= data_count here. */
ea_len);
if (ea_list == NULL) {
reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
- return;
+ goto out;
}
}
STR_TERMINATE, &status);
if (!NT_STATUS_IS_OK(status)) {
reply_nterror(req, status);
- return;
+ goto out;
}
oplock_request = (flags & REQUEST_OPLOCK) ? EXCLUSIVE_OPLOCK : 0;
? BATCH_OPLOCK : 0;
}
+ status = unix_convert(ctx, conn, fname, &smb_fname, 0);
+ if (!NT_STATUS_IS_OK(status)) {
+ reply_nterror(req, status);
+ goto out;
+ }
+
+ status = get_full_smb_filename(ctx, smb_fname, &fname);
+ if (!NT_STATUS_IS_OK(status)) {
+ reply_nterror(req, status);
+ goto out;
+ }
+
status = SMB_VFS_CREATE_FILE(
conn, /* conn */
req, /* req */
root_dir_fid, /* root_dir_fid */
fname, /* fname */
- CFF_DOS_PATH, /* create_file_flags */
+ 0, /* create_file_flags */
access_mask, /* access_mask */
share_access, /* share_access */
create_disposition, /* create_disposition*/
ea_list, /* ea_list */
&fsp, /* result */
&info, /* pinfo */
- &sbuf); /* psbuf */
+ &smb_fname->st); /* psbuf */
if(!NT_STATUS_IS_OK(status)) {
if (open_was_deferred(req->mid)) {
return;
}
reply_openerror(req, status);
- return;
+ goto out;
}
/*
oplock_granted = NO_OPLOCK_RETURN;
}
- file_len = sbuf.st_ex_size;
- fattr = dos_mode(conn,fsp->fsp_name,&sbuf);
+ file_len = smb_fname->st.st_ex_size;
+ fattr = dos_mode(conn, fsp->fsp_name, &smb_fname->st);
if (fattr == 0) {
fattr = FILE_ATTRIBUTE_NORMAL;
}
params = nttrans_realloc(ppparams, param_len);
if(params == NULL) {
reply_doserror(req, ERRDOS, ERRnomem);
- return;
+ goto out;
}
p = params;
p += 8;
/* Create time. */
- c_timespec = sbuf.st_ex_btime;
- a_timespec = sbuf.st_ex_atime;
- m_timespec = sbuf.st_ex_mtime;
+ c_timespec = smb_fname->st.st_ex_btime;
+ a_timespec = smb_fname->st.st_ex_atime;
+ m_timespec = smb_fname->st.st_ex_mtime;
if (lp_dos_filetime_resolution(SNUM(conn))) {
dos_filetime_timespec(&c_timespec);
p += 8;
SIVAL(p,0,fattr); /* File Attributes. */
p += 4;
- SOFF_T(p, 0, SMB_VFS_GET_ALLOC_SIZE(conn,fsp,&sbuf));
+ SOFF_T(p, 0, SMB_VFS_GET_ALLOC_SIZE(conn, fsp, &smb_fname->st));
p += 8;
SOFF_T(p,0,file_len);
p += 8;
if (flags & EXTENDED_RESPONSE_REQUIRED) {
uint32 perms = 0;
p += 25;
- if (fsp->is_directory
- || can_write_to_file(conn, fsp->fsp_name, &sbuf)) {
+ if (fsp->is_directory ||
+ can_write_to_file(conn, fsp->fsp_name, &smb_fname->st)) {
perms = FILE_GENERIC_ALL;
} else {
perms = FILE_GENERIC_READ|FILE_EXECUTE;
/* Send the required number of replies */
send_nt_replies(conn, req, NT_STATUS_OK, params, param_len, *ppdata, 0);
-
+ out:
+ TALLOC_FREE(smb_fname);
return;
}
void reply_open(struct smb_request *req)
{
connection_struct *conn = req->conn;
+ struct smb_filename *smb_fname = NULL;
char *fname = NULL;
uint32 fattr=0;
SMB_OFF_T size = 0;
time_t mtime=0;
int info;
- SMB_STRUCT_STAT sbuf;
files_struct *fsp;
int oplock_request;
int deny_mode;
START_PROFILE(SMBopen);
- SET_STAT_INVALID(sbuf);
-
if (req->wct < 2) {
reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
- END_PROFILE(SMBopen);
- return;
+ goto out;
}
oplock_request = CORE_OPLOCK_REQUEST(req->inbuf);
STR_TERMINATE, &status);
if (!NT_STATUS_IS_OK(status)) {
reply_nterror(req, status);
- END_PROFILE(SMBopen);
- return;
+ goto out;
}
if (!map_open_params_to_ntcreate(
return;
}
+ status = unix_convert(ctx, conn, fname, &smb_fname, 0);
+ if (!NT_STATUS_IS_OK(status)) {
+ reply_nterror(req, status);
+ goto out;
+ }
+
+ status = get_full_smb_filename(ctx, smb_fname, &fname);
+ if (!NT_STATUS_IS_OK(status)) {
+ reply_nterror(req, status);
+ goto out;
+ }
+
status = SMB_VFS_CREATE_FILE(
conn, /* conn */
req, /* req */
0, /* root_dir_fid */
fname, /* fname */
- CFF_DOS_PATH, /* create_file_flags */
+ 0, /* create_file_flags */
access_mask, /* access_mask */
share_mode, /* share_access */
create_disposition, /* create_disposition*/
NULL, /* ea_list */
&fsp, /* result */
&info, /* pinfo */
- &sbuf); /* psbuf */
+ &smb_fname->st); /* psbuf */
if (!NT_STATUS_IS_OK(status)) {
if (open_was_deferred(req->mid)) {
/* We have re-scheduled this call. */
- END_PROFILE(SMBopen);
- return;
+ goto out;
}
reply_openerror(req, status);
- END_PROFILE(SMBopen);
- return;
+ goto out;
}
- size = sbuf.st_ex_size;
- fattr = dos_mode(conn,fsp->fsp_name,&sbuf);
- mtime = convert_timespec_to_time_t(sbuf.st_ex_mtime);
+ size = smb_fname->st.st_ex_size;
+ fattr = dos_mode(conn,fsp->fsp_name,&smb_fname->st);
+ mtime = convert_timespec_to_time_t(smb_fname->st.st_ex_mtime);
if (fattr & aDIR) {
DEBUG(3,("attempt to open a directory %s\n",fsp->fsp_name));
close_file(req, fsp, ERROR_CLOSE);
reply_doserror(req, ERRDOS,ERRnoaccess);
- END_PROFILE(SMBopen);
- return;
+ goto out;
}
reply_outbuf(req, 7, 0);
SCVAL(req->outbuf,smb_flg,
CVAL(req->outbuf,smb_flg)|CORE_OPLOCK_GRANTED);
}
+ out:
+ TALLOC_FREE(smb_fname);
END_PROFILE(SMBopen);
return;
}
void reply_open_and_X(struct smb_request *req)
{
connection_struct *conn = req->conn;
+ struct smb_filename *smb_fname = NULL;
char *fname = NULL;
uint16 open_flags;
int deny_mode;
int smb_ofun;
uint32 fattr=0;
int mtime=0;
- SMB_STRUCT_STAT sbuf;
int smb_action = 0;
files_struct *fsp;
NTSTATUS status;
if (req->wct < 15) {
reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
- END_PROFILE(SMBopenX);
- return;
+ goto out;
}
- SET_STAT_INVALID(sbuf);
-
open_flags = SVAL(req->vwv+2, 0);
deny_mode = SVAL(req->vwv+3, 0);
smb_attr = SVAL(req->vwv+5, 0);
} else {
reply_doserror(req, ERRSRV, ERRaccess);
}
- END_PROFILE(SMBopenX);
- return;
+ goto out;
}
/* XXXX we need to handle passed times, sattr and flags */
STR_TERMINATE, &status);
if (!NT_STATUS_IS_OK(status)) {
reply_nterror(req, status);
- END_PROFILE(SMBopenX);
- return;
+ goto out;
}
if (!map_open_params_to_ntcreate(
fname, deny_mode, smb_ofun, &access_mask,
&share_mode, &create_disposition, &create_options)) {
reply_nterror(req, NT_STATUS_DOS(ERRDOS, ERRbadaccess));
- END_PROFILE(SMBopenX);
- return;
+ goto out;
+ }
+
+ status = unix_convert(ctx, conn, fname, &smb_fname, 0);
+ if (!NT_STATUS_IS_OK(status)) {
+ reply_nterror(req, status);
+ goto out;
+ }
+
+ status = get_full_smb_filename(ctx, smb_fname, &fname);
+ if (!NT_STATUS_IS_OK(status)) {
+ reply_nterror(req, status);
+ goto out;
}
status = SMB_VFS_CREATE_FILE(
req, /* req */
0, /* root_dir_fid */
fname, /* fname */
- CFF_DOS_PATH, /* create_file_flags */
+ 0, /* create_file_flags */
access_mask, /* access_mask */
share_mode, /* share_access */
create_disposition, /* create_disposition*/
NULL, /* ea_list */
&fsp, /* result */
&smb_action, /* pinfo */
- &sbuf); /* psbuf */
+ &smb_fname->st); /* psbuf */
if (!NT_STATUS_IS_OK(status)) {
- END_PROFILE(SMBopenX);
if (open_was_deferred(req->mid)) {
/* We have re-scheduled this call. */
- return;
+ goto out;
}
reply_openerror(req, status);
- return;
+ goto out;
}
/* Setting the "size" field in vwv9 and vwv10 causes the file to be set to this size,
if (vfs_allocate_file_space(fsp, fsp->initial_allocation_size) == -1) {
close_file(req, fsp, ERROR_CLOSE);
reply_nterror(req, NT_STATUS_DISK_FULL);
- END_PROFILE(SMBopenX);
- return;
+ goto out;
}
retval = vfs_set_filelen(fsp, (SMB_OFF_T)allocation_size);
if (retval < 0) {
close_file(req, fsp, ERROR_CLOSE);
reply_nterror(req, NT_STATUS_DISK_FULL);
- END_PROFILE(SMBopenX);
- return;
+ goto out;
}
- sbuf.st_ex_size = SMB_VFS_GET_ALLOC_SIZE(conn,fsp,&sbuf);
+ smb_fname->st.st_ex_size =
+ SMB_VFS_GET_ALLOC_SIZE(conn, fsp, &smb_fname->st);
}
- fattr = dos_mode(conn,fsp->fsp_name,&sbuf);
- mtime = convert_timespec_to_time_t(sbuf.st_ex_mtime);
+ fattr = dos_mode(conn,fsp->fsp_name,&smb_fname->st);
+ mtime = convert_timespec_to_time_t(smb_fname->st.st_ex_mtime);
if (fattr & aDIR) {
close_file(req, fsp, ERROR_CLOSE);
reply_doserror(req, ERRDOS, ERRnoaccess);
- END_PROFILE(SMBopenX);
- return;
+ goto out;
}
/* If the caller set the extended oplock request bit
} else {
srv_put_dos_date3((char *)req->outbuf,smb_vwv4,mtime);
}
- SIVAL(req->outbuf,smb_vwv6,(uint32)sbuf.st_ex_size);
+ SIVAL(req->outbuf,smb_vwv6,(uint32)smb_fname->st.st_ex_size);
SSVAL(req->outbuf,smb_vwv8,GET_OPENX_MODE(deny_mode));
SSVAL(req->outbuf,smb_vwv11,smb_action);
SIVAL(req->outbuf, smb_vwv15, STD_RIGHT_ALL_ACCESS);
}
- END_PROFILE(SMBopenX);
chain_reply(req);
+ out:
+ TALLOC_FREE(smb_fname);
+ END_PROFILE(SMBopenX);
return;
}
void reply_mknew(struct smb_request *req)
{
connection_struct *conn = req->conn;
+ struct smb_filename *smb_fname = NULL;
char *fname = NULL;
uint32 fattr = 0;
struct smb_file_time ft;
files_struct *fsp;
int oplock_request = 0;
- SMB_STRUCT_STAT sbuf;
NTSTATUS status;
uint32 access_mask = FILE_GENERIC_READ | FILE_GENERIC_WRITE;
uint32 share_mode = FILE_SHARE_READ|FILE_SHARE_WRITE;
START_PROFILE(SMBcreate);
ZERO_STRUCT(ft);
- SET_STAT_INVALID(sbuf);
if (req->wct < 3) {
reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
- END_PROFILE(SMBcreate);
- return;
+ goto out;
}
fattr = SVAL(req->vwv+0, 0);
STR_TERMINATE, &status);
if (!NT_STATUS_IS_OK(status)) {
reply_nterror(req, status);
- END_PROFILE(SMBcreate);
- return;
+ goto out;
}
if (fattr & aVOLID) {
create_disposition = FILE_OVERWRITE_IF;
}
+ status = unix_convert(ctx, conn, fname, &smb_fname, 0);
+ if (!NT_STATUS_IS_OK(status)) {
+ reply_nterror(req, status);
+ goto out;
+ }
+
+ status = get_full_smb_filename(ctx, smb_fname, &fname);
+ if (!NT_STATUS_IS_OK(status)) {
+ reply_nterror(req, status);
+ goto out;
+ }
+
status = SMB_VFS_CREATE_FILE(
conn, /* conn */
req, /* req */
0, /* root_dir_fid */
fname, /* fname */
- CFF_DOS_PATH, /* create_file_flags */
+ 0, /* create_file_flags */
access_mask, /* access_mask */
share_mode, /* share_access */
create_disposition, /* create_disposition*/
NULL, /* ea_list */
&fsp, /* result */
NULL, /* pinfo */
- &sbuf); /* psbuf */
+ &smb_fname->st); /* psbuf */
if (!NT_STATUS_IS_OK(status)) {
- END_PROFILE(SMBcreate);
if (open_was_deferred(req->mid)) {
/* We have re-scheduled this call. */
- return;
+ goto out;
}
reply_openerror(req, status);
- return;
+ goto out;
}
- ft.atime = sbuf.st_ex_atime; /* atime. */
- status = smb_set_file_time(conn, fsp, fsp->fsp_name, &sbuf, &ft, true);
+ ft.atime = smb_fname->st.st_ex_atime; /* atime. */
+ status = smb_set_file_time(conn, fsp, fsp->fsp_name, &smb_fname->st,
+ &ft, true);
if (!NT_STATUS_IS_OK(status)) {
END_PROFILE(SMBcreate);
- reply_openerror(req, status);
- return;
+ goto out;
}
reply_outbuf(req, 1, 0);
DEBUG( 3, ( "reply_mknew %s fd=%d dmode=0x%x\n",
fsp->fsp_name, fsp->fh->fd, (unsigned int)fattr ) );
+ out:
+ TALLOC_FREE(smb_fname);
END_PROFILE(SMBcreate);
return;
}
files_struct *result;
int info;
SMB_STRUCT_STAT sbuf;
+ struct smb_filename *smb_fname = NULL;
req = tevent_req_create(mem_ctx, &state,
struct smbd_smb2_create_state);
smbreq = smbd_smb2_fake_smb_request(smb2req);
if (tevent_req_nomem(smbreq, req)) {
- return tevent_req_post(req, ev);
+ goto out;
}
if (IS_IPC(smbreq->conn)) {
if (!lp_nt_pipe_support()) {
tevent_req_nterror(req, NT_STATUS_ACCESS_DENIED);
- return tevent_req_post(req, ev);
+ goto out;
}
/* Strip \\ off the name. */
status = open_np_file(smbreq, pipe_name, &result);
if (!NT_STATUS_IS_OK(status)) {
tevent_req_nterror(req, status);
- return tevent_req_post(req, ev);
+ goto out;
}
info = FILE_WAS_OPENED;
ZERO_STRUCT(sbuf);
status = file_new(smbreq, smbreq->conn, &result);
if(!NT_STATUS_IS_OK(status)) {
tevent_req_nterror(req, status);
- return tevent_req_post(req, ev);
+ goto out;
}
status = print_fsp_open(smbreq,
if (!NT_STATUS_IS_OK(status)) {
file_free(smbreq, result);
tevent_req_nterror(req, status);
- return tevent_req_post(req, ev);
+ goto out;
}
info = FILE_WAS_CREATED;
} else {
+ char *fname = NULL;
+
/* these are ignored for SMB2 */
in_create_options &= ~(0x10);/* NTCREATEX_OPTIONS_SYNC_ALERT */
in_create_options &= ~(0x20);/* NTCREATEX_OPTIONS_ASYNC_ALERT */
+ status = unix_convert(talloc_tos(), smbreq->conn, in_name,
+ &smb_fname, 0);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto out;
+ }
+
+ status = get_full_smb_filename(talloc_tos(), smb_fname, &fname);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto out;
+ }
+
status = SMB_VFS_CREATE_FILE(smbreq->conn,
smbreq,
0, /* root_dir_fid */
- in_name,
- CFF_DOS_PATH, /* create_file_flags */
+ fname,
+ 0, /* create_file_flags */
in_desired_access,
in_share_access,
in_create_disposition,
NULL, /* ea_list */
&result,
&info,
- &sbuf);
+ &smb_fname->st);
if (!NT_STATUS_IS_OK(status)) {
tevent_req_nterror(req, status);
- return tevent_req_post(req, ev);
+ goto out;
}
+ sbuf = smb_fname->st;
}
smb2req->compat_chain_fsp = smbreq->chain_fsp;
state->out_file_id_volatile = result->fnum;
tevent_req_done(req);
+ out:
+ TALLOC_FREE(smb_fname);
return tevent_req_post(req, ev);
}
char **ppdata, int total_data,
unsigned int max_data_bytes)
{
+ struct smb_filename *smb_fname = NULL;
char *params = *pparams;
char *pdata = *ppdata;
int deny_mode;
SMB_OFF_T size=0;
int fattr=0,mtime=0;
SMB_INO_T inode = 0;
- SMB_STRUCT_STAT sbuf;
int smb_action = 0;
files_struct *fsp;
struct ea_list *ea_list = NULL;
uint32 create_options = 0;
TALLOC_CTX *ctx = talloc_tos();
- SET_STAT_INVALID(sbuf);
-
/*
* Ensure we have enough parameters to perform the operation.
*/
if (total_params < 29) {
reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
- return;
+ goto out;
}
flags = SVAL(params, 0);
if (IS_IPC(conn)) {
reply_doserror(req, ERRSRV, ERRaccess);
- return;
+ goto out;
}
srvstr_get_path(ctx, params, req->flags2, &fname, pname,
&status);
if (!NT_STATUS_IS_OK(status)) {
reply_nterror(req, status);
- return;
+ goto out;
}
DEBUG(3,("call_trans2open %s deny_mode=0x%x attr=%d ofun=0x%x size=%d\n",
if (open_ofun == 0) {
reply_nterror(req, NT_STATUS_OBJECT_NAME_COLLISION);
- return;
+ goto out;
}
if (!map_open_params_to_ntcreate(fname, deny_mode, open_ofun,
&create_disposition,
&create_options)) {
reply_doserror(req, ERRDOS, ERRbadaccess);
- return;
+ goto out;
}
/* Any data in this call is an EA list. */
if (total_data && (total_data != 4) && !lp_ea_support(SNUM(conn))) {
reply_nterror(req, NT_STATUS_EAS_NOT_SUPPORTED);
- return;
+ goto out;
}
if (total_data != 4) {
if (total_data < 10) {
reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
- return;
+ goto out;
}
if (IVAL(pdata,0) > total_data) {
DEBUG(10,("call_trans2open: bad total data size (%u) > %u\n",
IVAL(pdata,0), (unsigned int)total_data));
reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
- return;
+ goto out;
}
ea_list = read_ea_list(talloc_tos(), pdata + 4,
total_data - 4);
if (!ea_list) {
reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
- return;
+ goto out;
}
} else if (IVAL(pdata,0) != 4) {
reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
- return;
+ goto out;
+ }
+
+ status = unix_convert(ctx, conn, fname, &smb_fname, 0);
+ if (!NT_STATUS_IS_OK(status)) {
+ reply_nterror(req, status);
+ goto out;
+ }
+
+ status = get_full_smb_filename(ctx, smb_fname, &fname);
+ if (!NT_STATUS_IS_OK(status)) {
+ reply_nterror(req, status);
+ goto out;
}
status = SMB_VFS_CREATE_FILE(
req, /* req */
0, /* root_dir_fid */
fname, /* fname */
- CFF_DOS_PATH, /* create_file_flags */
+ 0, /* create_file_flags */
access_mask, /* access_mask */
share_mode, /* share_access */
create_disposition, /* create_disposition*/
ea_list, /* ea_list */
&fsp, /* result */
&smb_action, /* pinfo */
- &sbuf); /* psbuf */
+ &smb_fname->st); /* psbuf */
if (!NT_STATUS_IS_OK(status)) {
if (open_was_deferred(req->mid)) {
/* We have re-scheduled this call. */
- return;
+ goto out;
}
reply_openerror(req, status);
- return;
+ goto out;
}
- size = get_file_size_stat(&sbuf);
- fattr = dos_mode(conn,fsp->fsp_name,&sbuf);
- mtime = convert_timespec_to_time_t(sbuf.st_ex_mtime);
- inode = sbuf.st_ex_ino;
+ size = get_file_size_stat(&smb_fname->st);
+ fattr = dos_mode(conn, fsp->fsp_name, &smb_fname->st);
+ mtime = convert_timespec_to_time_t(smb_fname->st.st_ex_mtime);
+ inode = smb_fname->st.st_ex_ino;
if (fattr & aDIR) {
close_file(req, fsp, ERROR_CLOSE);
reply_doserror(req, ERRDOS,ERRnoaccess);
- return;
+ goto out;
}
/* Realloc the size of parameters and data we will return */
*pparams = (char *)SMB_REALLOC(*pparams, 30);
if(*pparams == NULL ) {
reply_nterror(req, NT_STATUS_NO_MEMORY);
- return;
+ goto out;
}
params = *pparams;
/* Send the required number of replies */
send_trans2_replies(conn, req, params, 30, *ppdata, 0, max_data_bytes);
+ out:
+ TALLOC_FREE(smb_fname);
}
/*********************************************************