#include "../source4/libcli/smb2/smb2_constants.h"
static NTSTATUS smbd_smb2_tree_connect(struct smbd_smb2_request *req,
- const char *share,
+ const char *in_path,
+ uint8_t *out_share_type,
+ uint32_t *out_share_flags,
+ uint32_t *out_capabilities,
+ uint32_t *out_maximal_access,
uint32_t *out_tree_id);
NTSTATUS smbd_smb2_request_process_tcon(struct smbd_smb2_request *req)
DATA_BLOB in_path_buffer;
char *in_path_string;
size_t in_path_string_size;
+ uint8_t out_share_type;
+ uint32_t out_share_flags;
+ uint32_t out_capabilities;
+ uint32_t out_maximal_access;
uint32_t out_tree_id;
NTSTATUS status;
bool ok;
return smbd_smb2_request_error(req, NT_STATUS_ILLEGAL_CHARACTER);
}
- status = smbd_smb2_tree_connect(req, in_path_string, &out_tree_id);
+ status = smbd_smb2_tree_connect(req, in_path_string,
+ &out_share_type,
+ &out_share_flags,
+ &out_capabilities,
+ &out_maximal_access,
+ &out_tree_id);
if (!NT_STATUS_IS_OK(status)) {
return smbd_smb2_request_error(req, status);
}
SIVAL(outhdr, SMB2_HDR_TID, out_tree_id);
SSVAL(outbody.data, 0x00, 0x10); /* struct size */
- SCVAL(outbody.data, 0x02, 0); /* share type */
+ SCVAL(outbody.data, 0x02,
+ out_share_type); /* share type */
SCVAL(outbody.data, 0x03, 0); /* reserved */
- SIVAL(outbody.data, 0x04, 0); /* share flags */
- SIVAL(outbody.data, 0x08, 0); /* capabilities */
- SIVAL(outbody.data, 0x0C, 0); /* maximal access */
+ SIVAL(outbody.data, 0x04,
+ out_share_flags); /* share flags */
+ SIVAL(outbody.data, 0x08,
+ out_capabilities); /* capabilities */
+ SIVAL(outbody.data, 0x0C,
+ out_maximal_access); /* maximal access */
return smbd_smb2_request_done(req, outbody, NULL);
}
idr_remove(tcon->session->tcons.idtree, tcon->tid);
DLIST_REMOVE(tcon->session->tcons.list, tcon);
+ conn_free(tcon->session->conn, tcon->compat_conn);
+
+ tcon->compat_conn = NULL;
tcon->tid = 0;
tcon->session = NULL;
static NTSTATUS smbd_smb2_tree_connect(struct smbd_smb2_request *req,
const char *in_path,
+ uint8_t *out_share_type,
+ uint32_t *out_share_flags,
+ uint32_t *out_capabilities,
+ uint32_t *out_maximal_access,
uint32_t *out_tree_id)
{
const char *share = in_path;
int snum = -1;
struct smbd_smb2_tcon *tcon;
int id;
+ NTSTATUS status;
if (strncmp(share, "\\\\", 2) == 0) {
const char *p = strchr(share+2, '\\');
tcon,
req->session->tcons.limit);
if (id == -1) {
+ TALLOC_FREE(tcon);
return NT_STATUS_INSUFFICIENT_RESOURCES;
}
tcon->tid = id;
tcon->session = req->session;
talloc_set_destructor(tcon, smbd_smb2_tcon_destructor);
+ tcon->compat_conn = make_connection_snum(req->conn,
+ snum, req->session->compat_vuser,
+ data_blob_null, "???",
+ &status);
+ if (tcon->compat_conn == NULL) {
+ TALLOC_FREE(tcon);
+ return status;
+ }
+ tcon->compat_conn->cnum = tcon->tid;
+
+ *out_share_type = 0x01;
+ *out_share_flags = SMB2_SHAREFLAG_ALL;
+ *out_capabilities = 0;
+ *out_maximal_access = FILE_GENERIC_ALL;
+
*out_tree_id = tcon->tid;
return NT_STATUS_OK;
}
}
tcon = talloc_get_type_abort(p, struct smbd_smb2_tcon);
+ if (!change_to_user(tcon->compat_conn,req->session->vuid)) {
+ return NT_STATUS_ACCESS_DENIED;
+ }
+
req->tcon = tcon;
return NT_STATUS_OK;
}