HACK ! Always assumes smb_setup field is zero.
****************************************************************************/
-int send_nt_replies(const char *inbuf,
- char *outbuf,
- int bufsize,
- NTSTATUS nt_error,
- char *params,
- int paramsize,
- char *pdata,
- int datasize)
+int send_nt_replies(char *outbuf, int bufsize, NTSTATUS nt_error,
+ char *params, int paramsize, char *pdata, int datasize)
{
int data_to_send = datasize;
int params_to_send = paramsize;
* transNT replies.
*/
- set_message(inbuf,outbuf,18,0,True);
+ set_message(outbuf,18,0,True);
if (NT_STATUS_V(nt_error)) {
ERROR_NT(nt_error);
total_sent_thistime = MIN(total_sent_thistime, useable_space);
- set_message(inbuf,outbuf, 18, total_sent_thistime, True);
+ set_message(outbuf, 18, total_sent_thistime, True);
/*
* Set total params and data to be sent.
return(ERROR_DOS(ERRSRV,ERRnofids));
}
- /* TODO: Add pipe to db */
+ /* Add pipe to db */
if ( !store_pipe_opendb( p ) ) {
DEBUG(3,("nt_open_pipe: failed to store %s pipe open.\n", fname));
* the wcnt to 42 ? It's definately
* what happens on the wire....
*/
- set_message(inbuf,outbuf,50,0,True);
+ set_message(outbuf,50,0,True);
SCVAL(outbuf,smb_wct,42);
} else {
- set_message(inbuf,outbuf,34,0,True);
+ set_message(outbuf,34,0,True);
}
p = outbuf + smb_vwv2;
return ERROR_NT(status);
}
- set_message(inbuf,outbuf,34,0,True);
+ set_message(outbuf,34,0,True);
p = outbuf + smb_vwv2;
*/
pstring rel_fname;
files_struct *dir_fsp = file_fsp(inbuf,smb_ntcreate_RootDirectoryFid);
- size_t dir_name_len;
if(!dir_fsp) {
END_PROFILE(SMBntcreateX);
*/
pstrcpy( fname, dir_fsp->fsp_name );
- dir_name_len = strlen(fname);
- /*
- * Ensure it ends in a '\'.
- */
+ if (ISDOT(fname)) {
+ fname[0] = '\0';
+ } else {
+ size_t dir_name_len = strlen(fname);
+ /*
+ * Ensure it ends in a '\'.
+ */
- if((fname[dir_name_len-1] != '\\') && (fname[dir_name_len-1] != '/')) {
- pstrcat(fname, "/");
- dir_name_len++;
+ if((fname[dir_name_len-1] != '\\') && (fname[dir_name_len-1] != '/')) {
+ pstrcat(fname, "/");
+ }
}
srvstr_get_path(inbuf, rel_fname, smb_buf(inbuf), sizeof(rel_fname), 0, STR_TERMINATE, &status);
create_options,
new_file_attributes,
&info, &fsp);
-
- restore_case_semantics(conn, file_attributes);
-
- if(!NT_STATUS_IS_OK(status)) {
- if (!use_nt_status() && NT_STATUS_EQUAL(
- status, NT_STATUS_OBJECT_NAME_COLLISION)) {
- status = NT_STATUS_DOS(ERRDOS, ERRfilexists);
- }
- END_PROFILE(SMBntcreateX);
- return ERROR_NT(status);
- }
-
} else {
/*
oplock_request,
&info, &fsp);
- if (!NT_STATUS_IS_OK(status)) {
+ if (!NT_STATUS_IS_OK(status)) {
/* We cheat here. There are two cases we
* care about. One is a directory rename,
* where the NT client will attempt to
END_PROFILE(SMBntcreateX);
return ERROR_FORCE_NT(NT_STATUS_FILE_IS_A_DIRECTORY);
}
-
+
oplock_request = 0;
status = open_directory(conn, fname, &sbuf,
access_mask,
new_file_attributes,
&info, &fsp);
- if(!NT_STATUS_IS_OK(status)) {
- restore_case_semantics(conn, file_attributes);
- if (!use_nt_status() && NT_STATUS_EQUAL(
- status, NT_STATUS_OBJECT_NAME_COLLISION)) {
- status = NT_STATUS_DOS(ERRDOS, ERRfilexists);
- }
- END_PROFILE(SMBntcreateX);
- return ERROR_NT(status);
- }
- } else {
- restore_case_semantics(conn, file_attributes);
- END_PROFILE(SMBntcreateX);
- if (open_was_deferred(SVAL(inbuf,smb_mid))) {
- /* We have re-scheduled this call. */
- return -1;
- }
- return ERROR_NT(status);
}
- }
+ }
}
-
+
restore_case_semantics(conn, file_attributes);
+ if(!NT_STATUS_IS_OK(status)) {
+ END_PROFILE(SMBntcreateX);
+
+ if (open_was_deferred(SVAL(inbuf,smb_mid))) {
+ /* We have re-scheduled this call. */
+ return -1;
+ }
+
+ return ERROR_OPEN(status);
+ }
+
file_len = sbuf.st_size;
fattr = dos_mode(conn,fname,&sbuf);
if(fattr == 0) {
* the wcnt to 42 ? It's definately
* what happens on the wire....
*/
- set_message(inbuf,outbuf,50,0,True);
+ set_message(outbuf,50,0,True);
SCVAL(outbuf,smb_wct,42);
} else {
- set_message(inbuf,outbuf,34,0,True);
+ set_message(outbuf,34,0,True);
}
p = outbuf + smb_vwv2;
DEBUG(5,("do_nt_transact_create_pipe: open name = %s\n", fname));
/* Send the required number of replies */
- send_nt_replies(inbuf, outbuf, bufsize, NT_STATUS_OK, params, param_len, *ppdata, 0);
+ send_nt_replies(outbuf, bufsize, NT_STATUS_OK, params, param_len, *ppdata, 0);
return -1;
}
* This filename is relative to a directory fid.
*/
files_struct *dir_fsp = file_fsp(params,4);
- size_t dir_name_len;
if(!dir_fsp) {
return ERROR_DOS(ERRDOS,ERRbadfid);
*/
pstrcpy( fname, dir_fsp->fsp_name );
- dir_name_len = strlen(fname);
- /*
- * Ensure it ends in a '\'.
- */
+ if (ISDOT(fname)) {
+ fname[0] = '\0';
+ } else {
+ size_t dir_name_len = strlen(fname);
+ /*
+ * Ensure it ends in a '\'.
+ */
- if((fname[dir_name_len-1] != '\\') && (fname[dir_name_len-1] != '/')) {
- pstrcat(fname, "/");
- dir_name_len++;
+ if((fname[dir_name_len-1] != '\\') && (fname[dir_name_len-1] != '/')) {
+ pstrcat(fname, "/");
+ }
}
{
create_options,
new_file_attributes,
&info, &fsp);
- if(!NT_STATUS_IS_OK(status)) {
- restore_case_semantics(conn, file_attributes);
- return ERROR_NT(status);
- }
-
} else {
/*
oplock_request,
&info, &fsp);
- if (!NT_STATUS_IS_OK(status)) {
+ if (!NT_STATUS_IS_OK(status)) {
if (NT_STATUS_EQUAL(status,
NT_STATUS_FILE_IS_A_DIRECTORY)) {
restore_case_semantics(conn, file_attributes);
return ERROR_FORCE_NT(NT_STATUS_FILE_IS_A_DIRECTORY);
}
-
+
oplock_request = 0;
status = open_directory(conn, fname, &sbuf,
access_mask,
create_options,
new_file_attributes,
&info, &fsp);
- if(!NT_STATUS_IS_OK(status)) {
- restore_case_semantics(conn, file_attributes);
- return ERROR_NT(status);
- }
- } else {
- restore_case_semantics(conn, file_attributes);
- if (open_was_deferred(SVAL(inbuf,smb_mid))) {
- /* We have re-scheduled this call. */
- return -1;
- }
- return ERROR_NT(status);
}
- }
+ }
+ }
+
+ restore_case_semantics(conn, file_attributes);
+ if(!NT_STATUS_IS_OK(status)) {
+
+ if (open_was_deferred(SVAL(inbuf,smb_mid))) {
+ /* We have re-scheduled this call. */
+ return -1;
+ }
+
+ return ERROR_OPEN(status);
}
/*
* According to the MS documentation, the only time the security
* descriptor is applied to the opened file is iff we *created* the
* file; an existing file stays the same.
- *
+ *
* Also, it seems (from observation) that you can open the file with
* any access mask but you can still write the sd. We need to override
* the granted access before we call set_sd
DEBUG(5,("call_nt_transact_create: open name = %s\n", fname));
/* Send the required number of replies */
- send_nt_replies(inbuf, outbuf, bufsize, NT_STATUS_OK, params, param_len, *ppdata, 0);
+ send_nt_replies(outbuf, bufsize, NT_STATUS_OK, params, param_len, *ppdata, 0);
return -1;
}
return ERROR_NT(status);
}
- outsize = set_message(inbuf,outbuf,0,0,False);
+ outsize = set_message(outbuf,0,0,False);
END_PROFILE(SMBntrename);
return(outsize);
* here.
*/
- change_notify_reply(inbuf, fsp->notify);
+ change_notify_reply(inbuf, max_param_count, fsp->notify);
/*
* change_notify_reply() above has independently sent its
* No changes pending, queue the request
*/
- status = change_notify_add_request(inbuf, filter, recursive, fsp);
+ status = change_notify_add_request(inbuf, max_param_count, filter,
+ recursive, fsp);
if (!NT_STATUS_IS_OK(status)) {
return ERROR_NT(status);
}
/*
* Rename was successful.
*/
- send_nt_replies(inbuf, outbuf, bufsize, NT_STATUS_OK, NULL, 0, NULL, 0);
+ send_nt_replies(outbuf, bufsize, NT_STATUS_OK, NULL, 0, NULL, 0);
DEBUG(3,("nt transact rename from = %s, to = %s succeeded.\n",
fsp->fsp_name, new_name));
if(max_data_count < sd_size) {
- send_nt_replies(inbuf, outbuf, bufsize, NT_STATUS_BUFFER_TOO_SMALL,
+ send_nt_replies(outbuf, bufsize, NT_STATUS_BUFFER_TOO_SMALL,
params, 4, *ppdata, 0);
talloc_destroy(mem_ctx);
return -1;
talloc_destroy(mem_ctx);
- send_nt_replies(inbuf, outbuf, bufsize, NT_STATUS_OK, params, 4, data,
+ send_nt_replies(outbuf, bufsize, NT_STATUS_OK, params, 4, data,
(int)sd_size);
return -1;
}
done:
- send_nt_replies(inbuf, outbuf, bufsize, NT_STATUS_OK, NULL, 0, NULL, 0);
+ send_nt_replies(outbuf, bufsize, NT_STATUS_OK, NULL, 0, NULL, 0);
return -1;
}
so we can know if we need to pre-allocate or not */
DEBUG(10,("FSCTL_SET_SPARSE: called on FID[0x%04X](but not implemented)\n", fidnum));
- send_nt_replies(inbuf, outbuf, bufsize, NT_STATUS_OK, NULL, 0, NULL,
+ send_nt_replies(outbuf, bufsize, NT_STATUS_OK, NULL, 0, NULL,
0);
return -1;
- case FSCTL_CREATE_OR_GET_OBJECT_ID:
- {
- unsigned char objid[16];
-
- /* This should return the object-id on this file.
- * I think I'll make this be the inode+dev. JRA.
+ case FSCTL_0x000900C0:
+ /* pretend this succeeded - don't know what this really is
+ but works ok like this --metze
*/
- DEBUG(10,("FSCTL_CREATE_OR_GET_OBJECT_ID: called on FID[0x%04X]\n",fidnum));
-
- data_count = 64;
- pdata = nttrans_realloc(ppdata, data_count);
- if (pdata == NULL) {
- return ERROR_NT(NT_STATUS_NO_MEMORY);
- }
- push_file_id_16(pdata, &fsp->file_id);
- memcpy(pdata+16,create_volume_objectid(conn,objid),16);
- push_file_id_16(pdata+32, &fsp->file_id);
- send_nt_replies(inbuf, outbuf, bufsize, NT_STATUS_OK, NULL, 0, pdata, data_count);
+ DEBUG(10,("FSCTL_0x000900C0: called on FID[0x%04X](but not implemented)\n",fidnum));
+ send_nt_replies(outbuf, bufsize, NT_STATUS_OK, NULL, 0, NULL,
+ 0);
return -1;
- }
case FSCTL_GET_REPARSE_POINT:
/* pretend this fail - my winXP does it like this
*/
DEBUG(10,("FSCTL_GET_REPARSE_POINT: called on FID[0x%04X](but not implemented)\n",fidnum));
- return ERROR_NT(NT_STATUS_NOT_A_REPARSE_POINT);
+ send_nt_replies(outbuf, bufsize, NT_STATUS_NOT_A_REPARSE_POINT,
+ NULL, 0, NULL, 0);
+ return -1;
case FSCTL_SET_REPARSE_POINT:
/* pretend this fail - I'm assuming this because of the FSCTL_GET_REPARSE_POINT case.
*/
DEBUG(10,("FSCTL_SET_REPARSE_POINT: called on FID[0x%04X](but not implemented)\n",fidnum));
- return ERROR_NT(NT_STATUS_NOT_A_REPARSE_POINT);
+ send_nt_replies(outbuf, bufsize, NT_STATUS_NOT_A_REPARSE_POINT,
+ NULL, 0, NULL, 0);
+ return -1;
case FSCTL_GET_SHADOW_COPY_DATA: /* don't know if this name is right...*/
{
talloc_destroy(shadow_data->mem_ctx);
- send_nt_replies(inbuf, outbuf, bufsize, NT_STATUS_OK, NULL, 0,
+ send_nt_replies(outbuf, bufsize, NT_STATUS_OK, NULL, 0,
pdata, data_count);
return -1;
*/
/* this works for now... */
- send_nt_replies(inbuf, outbuf, bufsize, NT_STATUS_OK, NULL, 0,
+ send_nt_replies(outbuf, bufsize, NT_STATUS_OK, NULL, 0,
NULL, 0);
return -1;
}
break;
}
- send_nt_replies(inbuf, outbuf, bufsize, nt_status, params, param_len,
+ send_nt_replies(outbuf, bufsize, nt_status, params, param_len,
pdata, data_len);
return -1;
return ERROR_DOS(ERRSRV,ERRerror);
}
- send_nt_replies(inbuf, outbuf, bufsize, NT_STATUS_OK, params, param_len,
+ send_nt_replies(outbuf, bufsize, NT_STATUS_OK, params, param_len,
pdata, data_len);
return -1;
}
memcpy( state->setup, &inbuf[smb_nt_SetupStart], state->setup_count);
- dump_data(10, (uint8 *)state->setup, state->setup_count);
+ dump_data(10, (char *)state->setup, state->setup_count);
}
if ((state->received_data == state->total_data) &&
/* We need to send an interim response then receive the rest
of the parameter/data bytes */
- outsize = set_message(inbuf,outbuf,0,0,False);
+ outsize = set_message(outbuf,0,0,False);
show_msg(outbuf);
END_PROFILE(SMBnttrans);
return outsize;