*/
#include "includes.h"
+#include "printing.h"
+#include "smbd/smbd.h"
#include "smbd/globals.h"
#include "../libcli/smb/smb_common.h"
+#include "../librpc/gen_ndr/ndr_security.h"
+#include "../lib/util/tevent_ntstatus.h"
int map_smb2_oplock_levels_to_samba(uint8_t in_oplock_level)
{
uint64_t *out_allocation_size,
uint64_t *out_end_of_file,
uint32_t *out_file_attributes,
+ uint64_t *out_file_id_persistent,
uint64_t *out_file_id_volatile,
struct smb2_create_blobs *out_context_blobs);
in_name_buffer.data,
in_name_buffer.length,
&in_name_string,
- &in_name_string_size, false);
+ &in_name_string_size);
if (!ok) {
return smbd_smb2_request_error(smb2req, NT_STATUS_ILLEGAL_CHARACTER);
}
uint64_t out_allocation_size = 0;
uint64_t out_end_of_file = 0;
uint32_t out_file_attributes = 0;
+ uint64_t out_file_id_persistent = 0;
uint64_t out_file_id_volatile = 0;
struct smb2_create_blobs out_context_blobs;
DATA_BLOB out_context_buffer;
&out_allocation_size,
&out_end_of_file,
&out_file_attributes,
+ &out_file_id_persistent,
&out_file_id_volatile,
&out_context_blobs);
if (!NT_STATUS_IS_OK(status)) {
SIVAL(outbody.data, 0x38,
out_file_attributes); /* file attributes */
SIVAL(outbody.data, 0x3C, 0); /* reserved */
- SBVAL(outbody.data, 0x40, 0); /* file id (persistent) */
+ SBVAL(outbody.data, 0x40,
+ out_file_id_persistent); /* file id (persistent) */
SBVAL(outbody.data, 0x48,
out_file_id_volatile); /* file id (volatile) */
SIVAL(outbody.data, 0x50,
uint64_t out_allocation_size;
uint64_t out_end_of_file;
uint32_t out_file_attributes;
+ uint64_t out_file_id_persistent;
uint64_t out_file_id_volatile;
struct smb2_create_blobs out_context_blobs;
};
int info;
struct timespec write_time_ts;
struct smb2_create_blobs out_context_blobs;
+ int requested_oplock_level;
ZERO_STRUCT(out_context_blobs);
+ if(lp_fake_oplocks(SNUM(smb2req->tcon->compat_conn))) {
+ requested_oplock_level = SMB2_OPLOCK_LEVEL_NONE;
+ } else {
+ requested_oplock_level = in_oplock_level;
+ }
+
+
if (!smb2req->async) {
/* New create call. */
req = tevent_req_create(mem_ctx, &state,
return tevent_req_post(req, ev);
}
- status = print_fsp_open(smb1req,
- smb1req->conn,
- in_name,
- smb1req->vuid,
- result);
+ status = print_spool_open(result, in_name,
+ smb1req->vuid);
if (!NT_STATUS_IS_OK(status)) {
file_free(smb1req, result);
tevent_req_nterror(req, status);
}
ndr_err = ndr_pull_struct_blob(&secd->data,
- sec_desc, NULL, sec_desc,
+ sec_desc, sec_desc,
(ndr_pull_flags_fn_t)ndr_pull_security_descriptor);
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
DEBUG(2,("ndr_pull_security_descriptor failed: %s\n",
in_create_options &= ~(0x10);/* NTCREATEX_OPTIONS_SYNC_ALERT */
in_create_options &= ~(0x20);/* NTCREATEX_OPTIONS_ASYNC_ALERT */
- /* convert '\\' into '/' */
- status = check_path_syntax(fname);
- if (!NT_STATUS_IS_OK(status)) {
- tevent_req_nterror(req, status);
- return tevent_req_post(req, ev);
+ /*
+ * For a DFS path the function parse_dfs_path()
+ * will do the path processing.
+ */
+
+ if (!(smb1req->flags2 & FLAGS2_DFS_PATHNAMES)) {
+ /* convert '\\' into '/' */
+ status = check_path_syntax(fname);
+ if (!NT_STATUS_IS_OK(status)) {
+ tevent_req_nterror(req, status);
+ return tevent_req_post(req, ev);
+ }
}
status = filename_convert(req,
in_create_disposition,
in_create_options,
in_file_attributes,
- map_smb2_oplock_levels_to_samba(in_oplock_level),
+ map_smb2_oplock_levels_to_samba(requested_oplock_level),
allocation_size,
0, /* private_flags */
sec_desc,
if (qfid) {
uint8_t p[32];
+ uint64_t file_index = get_FileIndex(result->conn,
+ &result->fsp_name->st);
DATA_BLOB blob = data_blob_const(p, sizeof(p));
ZERO_STRUCT(p);
- /* TODO: maybe use result->file_id */
- SIVAL(p, 0, result->fsp_name->st.st_ex_ino);/* FileIndexLow */
- SIVAL(p, 4, result->fsp_name->st.st_ex_dev);/* FileIndexHigh */
+ /* From conversations with Microsoft engineers at
+ the MS plugfest. The first 8 bytes are the "volume index"
+ == inode, the second 8 bytes are the "volume id",
+ == dev. This will be updated in the SMB2 doc. */
+ SBVAL(p, 0, file_index);
+ SIVAL(p, 8, result->fsp_name->st.st_ex_dev);/* FileIndexHigh */
status = smb2_create_blob_add(state, &out_context_blobs,
SMB2_CREATE_TAG_QFID,
smb2req->compat_chain_fsp = smb1req->chain_fsp;
- state->out_oplock_level = map_samba_oplock_levels_to_smb2(result->oplock_type);
+ if(lp_fake_oplocks(SNUM(smb2req->tcon->compat_conn))) {
+ state->out_oplock_level = in_oplock_level;
+ } else {
+ state->out_oplock_level = map_samba_oplock_levels_to_smb2(result->oplock_type);
+ }
if ((in_create_disposition == FILE_SUPERSEDE)
&& (info == FILE_WAS_OVERWRITTEN)) {
/* Deal with other possible opens having a modified
write time. JRA. */
ZERO_STRUCT(write_time_ts);
- get_file_infos(result->file_id, NULL, &write_time_ts);
+ get_file_infos(result->file_id, 0, NULL, &write_time_ts);
if (!null_timespec(write_time_ts)) {
update_stat_ex_mtime(&result->fsp_name->st, write_time_ts);
}
if (state->out_file_attributes == 0) {
state->out_file_attributes = FILE_ATTRIBUTE_NORMAL;
}
+ state->out_file_id_persistent = result->fnum;
state->out_file_id_volatile = result->fnum;
state->out_context_blobs = out_context_blobs;
uint64_t *out_allocation_size,
uint64_t *out_end_of_file,
uint32_t *out_file_attributes,
+ uint64_t *out_file_id_persistent,
uint64_t *out_file_id_volatile,
struct smb2_create_blobs *out_context_blobs)
{
*out_allocation_size = state->out_allocation_size;
*out_end_of_file = state->out_end_of_file;
*out_file_attributes = state->out_file_attributes;
+ *out_file_id_persistent = state->out_file_id_persistent;
*out_file_id_volatile = state->out_file_id_volatile;
*out_context_blobs = state->out_context_blobs;
close.
*********************************************************/
-static struct smbd_smb2_request *find_open_smb2req(uint64_t mid)
+static struct smbd_smb2_request *find_open_smb2req(
+ struct smbd_server_connection *sconn, uint64_t mid)
{
- struct smbd_server_connection *sconn = smbd_server_conn;
struct smbd_smb2_request *smb2req;
for (smb2req = sconn->smb2.requests; smb2req; smb2req = smb2req->next) {
return NULL;
}
-bool open_was_deferred_smb2(uint64_t mid)
+bool open_was_deferred_smb2(struct smbd_server_connection *sconn, uint64_t mid)
{
struct smbd_smb2_create_state *state = NULL;
- struct smbd_smb2_request *smb2req = find_open_smb2req(mid);
+ struct smbd_smb2_request *smb2req;
+
+ smb2req = find_open_smb2req(sconn, mid);
if (!smb2req) {
DEBUG(10,("open_was_deferred_smb2: mid %llu smb2req == NULL\n",
TALLOC_FREE(state->im);
}
-void remove_deferred_open_message_smb2(uint64_t mid)
+void remove_deferred_open_message_smb2(
+ struct smbd_server_connection *sconn, uint64_t mid)
{
- struct smbd_smb2_request *smb2req = find_open_smb2req(mid);
+ struct smbd_smb2_request *smb2req;
+
+ smb2req = find_open_smb2req(sconn, mid);
if (!smb2req) {
DEBUG(10,("remove_deferred_open_message_smb2: "
}
}
-void schedule_deferred_open_message_smb2(uint64_t mid)
+void schedule_deferred_open_message_smb2(
+ struct smbd_server_connection *sconn, uint64_t mid)
{
struct smbd_smb2_create_state *state = NULL;
- struct smbd_smb2_request *smb2req = find_open_smb2req(mid);
+ struct smbd_smb2_request *smb2req;
+
+ smb2req = find_open_smb2req(sconn, mid);
if (!smb2req) {
DEBUG(10,("schedule_deferred_open_message_smb2: "
smb2req = state->smb2req;
mid = get_mid_from_smb2req(smb2req);
- remove_deferred_open_entry(state->id, mid);
+ remove_deferred_open_entry(state->id, mid,
+ sconn_server_id(smb2req->sconn));
remove_deferred_open_message_smb2_internal(smb2req, mid);
smb2req->cancelled = true;
if (!state->private_data.data) {
return false;
}
-#if 0
+
+#if 1
/* Boo - turns out this isn't what W2K8R2
does. It actually sends the STATUS_PENDING
message followed by the STATUS_SHARING_VIOLATION
calls (even on directories) will potentially
fail in a chain.... ? And I've seen directory
opens as the start of a chain. JRA.
+
+ Update: 19th May 2010. Talking with Microsoft
+ engineers at the plugfest this is a bug in
+ Windows. Re-enable this code.
*/
/*
* More subtlety. To match W2K8R2 don't