mirror of
https://github.com/samba-team/samba.git
synced 2025-12-04 08:23:50 +03:00
r4726: - use the name tcon and tid instead of conn and cnum
- make use of talloc destructors metze
This commit is contained in:
committed by
Gerald (Jerry) Carter
parent
5287ec0818
commit
8308da6ce4
@@ -177,7 +177,7 @@ union smb_tcon {
|
|||||||
} in;
|
} in;
|
||||||
struct {
|
struct {
|
||||||
uint16_t max_xmit;
|
uint16_t max_xmit;
|
||||||
uint16_t cnum;
|
uint16_t tid;
|
||||||
} out;
|
} out;
|
||||||
} tcon;
|
} tcon;
|
||||||
|
|
||||||
@@ -195,7 +195,7 @@ union smb_tcon {
|
|||||||
uint16_t options;
|
uint16_t options;
|
||||||
char *dev_type;
|
char *dev_type;
|
||||||
char *fs_type;
|
char *fs_type;
|
||||||
uint16_t cnum;
|
uint16_t tid;
|
||||||
} out;
|
} out;
|
||||||
} tconx;
|
} tconx;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ NTSTATUS smbcli_send_tconX(struct smbcli_state *cli, const char *sharename,
|
|||||||
|
|
||||||
status = smb_tree_connect(cli->tree, mem_ctx, &tcon);
|
status = smb_tree_connect(cli->tree, mem_ctx, &tcon);
|
||||||
|
|
||||||
cli->tree->tid = tcon.tconx.out.cnum;
|
cli->tree->tid = tcon.tconx.out.tid;
|
||||||
|
|
||||||
talloc_free(mem_ctx);
|
talloc_free(mem_ctx);
|
||||||
|
|
||||||
|
|||||||
@@ -96,12 +96,12 @@ NTSTATUS smb_tree_connect_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx,
|
|||||||
case RAW_TCON_TCON:
|
case RAW_TCON_TCON:
|
||||||
SMBCLI_CHECK_WCT(req, 2);
|
SMBCLI_CHECK_WCT(req, 2);
|
||||||
parms->tcon.out.max_xmit = SVAL(req->in.vwv, VWV(0));
|
parms->tcon.out.max_xmit = SVAL(req->in.vwv, VWV(0));
|
||||||
parms->tcon.out.cnum = SVAL(req->in.vwv, VWV(1));
|
parms->tcon.out.tid = SVAL(req->in.vwv, VWV(1));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RAW_TCON_TCONX:
|
case RAW_TCON_TCONX:
|
||||||
ZERO_STRUCT(parms->tconx.out);
|
ZERO_STRUCT(parms->tconx.out);
|
||||||
parms->tconx.out.cnum = SVAL(req->in.hdr, HDR_TID);
|
parms->tconx.out.tid = SVAL(req->in.hdr, HDR_TID);
|
||||||
if (req->in.wct >= 4) {
|
if (req->in.wct >= 4) {
|
||||||
parms->tconx.out.options = SVAL(req->in.vwv, VWV(3));
|
parms->tconx.out.options = SVAL(req->in.vwv, VWV(3));
|
||||||
}
|
}
|
||||||
@@ -274,7 +274,7 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx,
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
tree->tid = tcon.tconx.out.cnum;
|
tree->tid = tcon.tconx.out.tid;
|
||||||
if (tcon.tconx.out.dev_type) {
|
if (tcon.tconx.out.dev_type) {
|
||||||
tree->device = talloc_strdup(tree, tcon.tconx.out.dev_type);
|
tree->device = talloc_strdup(tree, tcon.tconx.out.dev_type);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ static NTSTATUS smblsa_connect(struct smbcli_state *cli)
|
|||||||
talloc_free(lsa);
|
talloc_free(lsa);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
lsa->ipc_tree->tid = tcon.tconx.out.cnum;
|
lsa->ipc_tree->tid = tcon.tconx.out.tid;
|
||||||
|
|
||||||
lsa->pipe = dcerpc_pipe_init(lsa);
|
lsa->pipe = dcerpc_pipe_init(lsa);
|
||||||
if (lsa->pipe == NULL) {
|
if (lsa->pipe == NULL) {
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ static void cifs_socket_handler(struct event_context *ev, struct fd_event *fde,
|
|||||||
|
|
||||||
if (!smbcli_transport_process(private->transport)) {
|
if (!smbcli_transport_process(private->transport)) {
|
||||||
/* the connection to our server is dead */
|
/* the connection to our server is dead */
|
||||||
close_cnum(tcon);
|
talloc_free(tcon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
init the tcon structures
|
init the tcon structures
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
void conn_init(struct smbsrv_connection *smb_conn)
|
void smbsrv_tcon_init(struct smbsrv_connection *smb_conn)
|
||||||
{
|
{
|
||||||
smb_conn->tree.idtree_tid = idr_init(smb_conn);
|
smb_conn->tree.idtree_tid = idr_init(smb_conn);
|
||||||
}
|
}
|
||||||
@@ -36,18 +36,27 @@ void conn_init(struct smbsrv_connection *smb_conn)
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
find a tcon given a cnum
|
find a tcon given a cnum
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
struct smbsrv_tcon *conn_find(struct smbsrv_connection *smb_conn, uint_t cnum)
|
struct smbsrv_tcon *smbsrv_tcon_find(struct smbsrv_connection *smb_conn, uint_t tid)
|
||||||
{
|
{
|
||||||
return idr_find(smb_conn->tree.idtree_tid, cnum);
|
return idr_find(smb_conn->tree.idtree_tid, tid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
destroy a connection structure
|
destroy a connection structure
|
||||||
*/
|
*/
|
||||||
static int conn_destructor(void *ptr)
|
static int smbsrv_tcon_destructor(void *ptr)
|
||||||
{
|
{
|
||||||
struct smbsrv_tcon *tcon = ptr;
|
struct smbsrv_tcon *tcon = ptr;
|
||||||
idr_remove(tcon->smb_conn->tree.idtree_tid, tcon->cnum);
|
|
||||||
|
|
||||||
|
DEBUG(3,("%s closed connection to service %s\n",
|
||||||
|
socket_get_peer_addr(tcon->smb_conn->connection->socket, tcon),
|
||||||
|
lp_servicename(SNUM(tcon))));
|
||||||
|
|
||||||
|
/* tell the ntvfs backend that we are disconnecting */
|
||||||
|
ntvfs_disconnect(tcon);
|
||||||
|
|
||||||
|
idr_remove(tcon->smb_conn->tree.idtree_tid, tcon->tid);
|
||||||
DLIST_REMOVE(tcon->smb_conn->tree.tcons, tcon);
|
DLIST_REMOVE(tcon->smb_conn->tree.tcons, tcon);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -55,7 +64,7 @@ static int conn_destructor(void *ptr)
|
|||||||
/*
|
/*
|
||||||
find first available connection slot
|
find first available connection slot
|
||||||
*/
|
*/
|
||||||
struct smbsrv_tcon *conn_new(struct smbsrv_connection *smb_conn)
|
struct smbsrv_tcon *smbsrv_tcon_new(struct smbsrv_connection *smb_conn)
|
||||||
{
|
{
|
||||||
struct smbsrv_tcon *tcon;
|
struct smbsrv_tcon *tcon;
|
||||||
int i;
|
int i;
|
||||||
@@ -69,34 +78,12 @@ struct smbsrv_tcon *conn_new(struct smbsrv_connection *smb_conn)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
tcon->cnum = i;
|
tcon->tid = i;
|
||||||
tcon->smb_conn = smb_conn;
|
tcon->smb_conn = smb_conn;
|
||||||
|
|
||||||
talloc_set_destructor(tcon, conn_destructor);
|
talloc_set_destructor(tcon, smbsrv_tcon_destructor);
|
||||||
|
|
||||||
DLIST_ADD(smb_conn->tree.tcons, tcon);
|
DLIST_ADD(smb_conn->tree.tcons, tcon);
|
||||||
|
|
||||||
return tcon;
|
return tcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
close all tcon structures
|
|
||||||
****************************************************************************/
|
|
||||||
void conn_close_all(struct smbsrv_connection *smb_conn)
|
|
||||||
{
|
|
||||||
struct smbsrv_tcon *tcon, *next;
|
|
||||||
for (tcon=smb_conn->tree.tcons;tcon;tcon=next) {
|
|
||||||
next=tcon->next;
|
|
||||||
close_cnum(tcon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
Free a tcon structure.
|
|
||||||
****************************************************************************/
|
|
||||||
void conn_free(struct smbsrv_connection *smb_conn, struct smbsrv_tcon *tcon)
|
|
||||||
{
|
|
||||||
talloc_free(tcon);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@@ -112,8 +112,8 @@ void reply_tcon(struct smbsrv_request *req)
|
|||||||
req_setup_reply(req, 2, 0);
|
req_setup_reply(req, 2, 0);
|
||||||
|
|
||||||
SSVAL(req->out.vwv, VWV(0), con.tcon.out.max_xmit);
|
SSVAL(req->out.vwv, VWV(0), con.tcon.out.max_xmit);
|
||||||
SSVAL(req->out.vwv, VWV(1), con.tcon.out.cnum);
|
SSVAL(req->out.vwv, VWV(1), con.tcon.out.tid);
|
||||||
SSVAL(req->out.hdr, HDR_TID, req->tcon->cnum);
|
SSVAL(req->out.hdr, HDR_TID, req->tcon->tid);
|
||||||
|
|
||||||
req_send_reply(req);
|
req_send_reply(req);
|
||||||
}
|
}
|
||||||
@@ -181,8 +181,8 @@ void reply_tcon_and_X(struct smbsrv_request *req)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* set the incoming and outgoing tid to the just created one */
|
/* set the incoming and outgoing tid to the just created one */
|
||||||
SSVAL(req->in.hdr, HDR_TID, con.tconx.out.cnum);
|
SSVAL(req->in.hdr, HDR_TID, con.tconx.out.tid);
|
||||||
SSVAL(req->out.hdr,HDR_TID, con.tconx.out.cnum);
|
SSVAL(req->out.hdr,HDR_TID, con.tconx.out.tid);
|
||||||
|
|
||||||
chain_reply(req);
|
chain_reply(req);
|
||||||
}
|
}
|
||||||
@@ -1360,7 +1360,7 @@ void reply_tdis(struct smbsrv_request *req)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
close_cnum(req->tcon);
|
talloc_free(req->tcon);
|
||||||
|
|
||||||
/* construct reply */
|
/* construct reply */
|
||||||
req_setup_reply(req, 0, 0);
|
req_setup_reply(req, 0, 0);
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ static NTSTATUS make_connection_snum(struct smbsrv_request *req,
|
|||||||
return NT_STATUS_ACCESS_DENIED;
|
return NT_STATUS_ACCESS_DENIED;
|
||||||
}
|
}
|
||||||
|
|
||||||
tcon = conn_new(req->smb_conn);
|
tcon = smbsrv_tcon_new(req->smb_conn);
|
||||||
if (!tcon) {
|
if (!tcon) {
|
||||||
DEBUG(0,("Couldn't find free connection.\n"));
|
DEBUG(0,("Couldn't find free connection.\n"));
|
||||||
return NT_STATUS_INSUFFICIENT_RESOURCES;
|
return NT_STATUS_INSUFFICIENT_RESOURCES;
|
||||||
@@ -165,18 +165,16 @@ static NTSTATUS make_connection_snum(struct smbsrv_request *req,
|
|||||||
status = ntvfs_init_connection(req, type);
|
status = ntvfs_init_connection(req, type);
|
||||||
if (!NT_STATUS_IS_OK(status)) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
DEBUG(0, ("ntvfs_init_connection failed for service %s\n", lp_servicename(SNUM(tcon))));
|
DEBUG(0, ("ntvfs_init_connection failed for service %s\n", lp_servicename(SNUM(tcon))));
|
||||||
conn_free(req->smb_conn, tcon);
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Invoke NTVFS connection hook */
|
/* Invoke NTVFS connection hook */
|
||||||
status = ntvfs_connect(req, lp_servicename(snum));
|
status = ntvfs_connect(req, lp_servicename(snum));
|
||||||
if (!NT_STATUS_IS_OK(status)) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
DEBUG(0,("make_connection: NTVFS make connection failed!\n"));
|
DEBUG(0,("make_connection: NTVFS make connection failed!\n"));
|
||||||
conn_free(req->smb_conn, tcon);
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NT_STATUS_OK;
|
return NT_STATUS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,23 +227,6 @@ static NTSTATUS make_connection(struct smbsrv_request *req,
|
|||||||
return make_connection_snum(req, snum, type, password, dev);
|
return make_connection_snum(req, snum, type, password, dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
close a cnum
|
|
||||||
****************************************************************************/
|
|
||||||
void close_cnum(struct smbsrv_tcon *tcon)
|
|
||||||
{
|
|
||||||
DEBUG(3,("%s closed connection to service %s\n",
|
|
||||||
socket_get_peer_addr(tcon->smb_conn->connection->socket, tcon),
|
|
||||||
lp_servicename(SNUM(tcon))));
|
|
||||||
|
|
||||||
/* tell the ntvfs backend that we are disconnecting */
|
|
||||||
ntvfs_disconnect(tcon);
|
|
||||||
|
|
||||||
conn_free(tcon->smb_conn, tcon);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
backend for tree connect call
|
backend for tree connect call
|
||||||
*/
|
*/
|
||||||
@@ -274,8 +255,8 @@ NTSTATUS tcon_backend(struct smbsrv_request *req, union smb_tcon *con)
|
|||||||
}
|
}
|
||||||
|
|
||||||
con->tcon.out.max_xmit = req->smb_conn->negotiate.max_recv;
|
con->tcon.out.max_xmit = req->smb_conn->negotiate.max_recv;
|
||||||
con->tcon.out.cnum = req->tcon->cnum;
|
con->tcon.out.tid = req->tcon->tid;
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -285,7 +266,7 @@ NTSTATUS tcon_backend(struct smbsrv_request *req, union smb_tcon *con)
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
con->tconx.out.cnum = req->tcon->cnum;
|
con->tconx.out.tid = req->tcon->tid;
|
||||||
con->tconx.out.dev_type = talloc_strdup(req, req->tcon->dev_type);
|
con->tconx.out.dev_type = talloc_strdup(req, req->tcon->dev_type);
|
||||||
con->tconx.out.fs_type = talloc_strdup(req, req->tcon->fs_type);
|
con->tconx.out.fs_type = talloc_strdup(req, req->tcon->fs_type);
|
||||||
con->tconx.out.options = SMB_SUPPORT_SEARCH_BITS | (lp_csc_policy(req->tcon->service) << 2);
|
con->tconx.out.options = SMB_SUPPORT_SEARCH_BITS | (lp_csc_policy(req->tcon->service) << 2);
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ BOOL req_send_oplock_break(struct smbsrv_tcon *tcon, uint16_t fnum, uint8_t leve
|
|||||||
req_setup_reply(req, 8, 0);
|
req_setup_reply(req, 8, 0);
|
||||||
|
|
||||||
SCVAL(req->out.hdr,HDR_COM,SMBlockingX);
|
SCVAL(req->out.hdr,HDR_COM,SMBlockingX);
|
||||||
SSVAL(req->out.hdr,HDR_TID,tcon->cnum);
|
SSVAL(req->out.hdr,HDR_TID,tcon->tid);
|
||||||
SSVAL(req->out.hdr,HDR_PID,0xFFFF);
|
SSVAL(req->out.hdr,HDR_PID,0xFFFF);
|
||||||
SSVAL(req->out.hdr,HDR_UID,0);
|
SSVAL(req->out.hdr,HDR_UID,0);
|
||||||
SSVAL(req->out.hdr,HDR_MID,0xFFFF);
|
SSVAL(req->out.hdr,HDR_MID,0xFFFF);
|
||||||
@@ -484,7 +484,7 @@ static void switch_message(int type, struct smbsrv_request *req)
|
|||||||
|
|
||||||
flags = smb_messages[type].flags;
|
flags = smb_messages[type].flags;
|
||||||
|
|
||||||
req->tcon = conn_find(smb_conn, SVAL(req->in.hdr,HDR_TID));
|
req->tcon = smbsrv_tcon_find(smb_conn, SVAL(req->in.hdr,HDR_TID));
|
||||||
|
|
||||||
if (req->session == NULL) {
|
if (req->session == NULL) {
|
||||||
/* setup the user context for this request if it
|
/* setup the user context for this request if it
|
||||||
@@ -792,8 +792,6 @@ static void smbsrv_close(struct server_connection *conn, const char *reason)
|
|||||||
|
|
||||||
DEBUG(5,("smbsrv_close: %s\n",reason));
|
DEBUG(5,("smbsrv_close: %s\n",reason));
|
||||||
|
|
||||||
conn_close_all(smb_conn);
|
|
||||||
|
|
||||||
talloc_free(smb_conn);
|
talloc_free(smb_conn);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -846,7 +844,7 @@ void smbsrv_accept(struct server_connection *conn)
|
|||||||
|
|
||||||
srv_init_signing(smb_conn);
|
srv_init_signing(smb_conn);
|
||||||
|
|
||||||
conn_init(smb_conn);
|
smbsrv_tcon_init(smb_conn);
|
||||||
|
|
||||||
smb_conn->connection = conn;
|
smb_conn->connection = conn;
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,8 @@ struct smbsrv_tcon {
|
|||||||
/* the server context that this was created on */
|
/* the server context that this was created on */
|
||||||
struct smbsrv_connection *smb_conn;
|
struct smbsrv_connection *smb_conn;
|
||||||
|
|
||||||
uint16_t cnum; /* an index passed over the wire (the TID) */
|
uint16_t tid; /* an index passed over the wire (the TID) */
|
||||||
|
|
||||||
int service;
|
int service;
|
||||||
BOOL read_only;
|
BOOL read_only;
|
||||||
BOOL admin_user;
|
BOOL admin_user;
|
||||||
|
|||||||
@@ -229,7 +229,7 @@ static BOOL test_tree(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
|
|||||||
status = smb_tree_connect(tree, mem_ctx, &tcon);
|
status = smb_tree_connect(tree, mem_ctx, &tcon);
|
||||||
CHECK_STATUS(status, NT_STATUS_OK);
|
CHECK_STATUS(status, NT_STATUS_OK);
|
||||||
|
|
||||||
tree->tid = tcon.tconx.out.cnum;
|
tree->tid = tcon.tconx.out.tid;
|
||||||
printf("tid1=%d tid2=%d\n", cli->tree->tid, tree->tid);
|
printf("tid1=%d tid2=%d\n", cli->tree->tid, tree->tid);
|
||||||
|
|
||||||
printf("try a tconx with a bad device type\n");
|
printf("try a tconx with a bad device type\n");
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ static NTSTATUS anon_ipc(struct smbcli_transport *transport,
|
|||||||
return NT_STATUS_UNSUCCESSFUL;
|
return NT_STATUS_UNSUCCESSFUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
tree->tid = tcon.tconx.out.cnum;
|
tree->tid = tcon.tconx.out.tid;
|
||||||
|
|
||||||
if (tcon.tconx.out.dev_type != NULL)
|
if (tcon.tconx.out.dev_type != NULL)
|
||||||
tree->device = talloc_strdup(tree, tcon.tconx.out.dev_type);
|
tree->device = talloc_strdup(tree, tcon.tconx.out.dev_type);
|
||||||
|
|||||||
Reference in New Issue
Block a user