summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/include/proto.h6
-rw-r--r--source3/include/smb.h1
-rw-r--r--source3/smbd/conn.c23
-rw-r--r--source3/smbd/ipc.c3
-rw-r--r--source3/smbd/reply.c5
-rw-r--r--source3/smbd/service.c33
-rw-r--r--source3/smbd/smb2_tcon.c2
7 files changed, 38 insertions, 35 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index ccd8746603..667e847485 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -6145,8 +6145,7 @@ bool conn_close_all(struct smbd_server_connection *sconn);
bool conn_idle_all(struct smbd_server_connection *sconn, time_t t);
void conn_clear_vuid_caches(struct smbd_server_connection *sconn, uint16 vuid);
void conn_free_internal(connection_struct *conn);
-void conn_free(struct smbd_server_connection *sconn,
- connection_struct *conn);
+void conn_free(connection_struct *conn);
void msg_force_tdis(struct messaging_context *msg,
void *private_data,
uint32_t msg_type,
@@ -6984,8 +6983,7 @@ connection_struct *make_connection(struct smbd_server_connection *sconn,
const char *service_in, DATA_BLOB password,
const char *pdev, uint16 vuid,
NTSTATUS *status);
-void close_cnum(struct smbd_server_connection *sconn,
- connection_struct *conn, uint16 vuid);
+void close_cnum(connection_struct *conn, uint16 vuid);
/* The following definitions come from smbd/session.c */
diff --git a/source3/include/smb.h b/source3/include/smb.h
index e2d670fa04..c33c5363f3 100644
--- a/source3/include/smb.h
+++ b/source3/include/smb.h
@@ -546,6 +546,7 @@ struct share_iterator {
typedef struct connection_struct {
struct connection_struct *next, *prev;
+ struct smbd_server_connection *sconn; /* can be NULL */
unsigned cnum; /* an index passed over the wire */
struct share_params *params;
bool force_user;
diff --git a/source3/smbd/conn.c b/source3/smbd/conn.c
index af6e0919a4..9d1bbee8c9 100644
--- a/source3/smbd/conn.c
+++ b/source3/smbd/conn.c
@@ -101,6 +101,7 @@ connection_struct *conn_new(struct smbd_server_connection *sconn)
TALLOC_FREE(conn);
return NULL;
}
+ conn->sconn = sconn;
return conn;
}
@@ -154,6 +155,7 @@ find_again:
TALLOC_FREE(conn);
return NULL;
}
+ conn->sconn = sconn;
conn->cnum = i;
conn->force_group_gid = (gid_t)-1;
@@ -181,7 +183,7 @@ bool conn_close_all(struct smbd_server_connection *sconn)
for (conn=sconn->smb1.tcons.Connections;conn;conn=next) {
next=conn->next;
set_current_service(conn, 0, True);
- close_cnum(sconn, conn, conn->vuid);
+ close_cnum(conn, conn->vuid);
ret = true;
}
return ret;
@@ -294,19 +296,24 @@ void conn_free_internal(connection_struct *conn)
Free a conn structure.
****************************************************************************/
-void conn_free(struct smbd_server_connection *sconn, connection_struct *conn)
+void conn_free(connection_struct *conn)
{
- if (sconn->allow_smb2) {
+ if (conn->sconn == NULL) {
+ conn_free_internal(conn);
+ return;
+ }
+
+ if (conn->sconn->allow_smb2) {
conn_free_internal(conn);
return;
}
- DLIST_REMOVE(sconn->smb1.tcons.Connections, conn);
+ DLIST_REMOVE(conn->sconn->smb1.tcons.Connections, conn);
- bitmap_clear(sconn->smb1.tcons.bmap, conn->cnum);
+ bitmap_clear(conn->sconn->smb1.tcons.bmap, conn->cnum);
- SMB_ASSERT(sconn->smb1.tcons.num_open > 0);
- sconn->smb1.tcons.num_open--;
+ SMB_ASSERT(conn->sconn->smb1.tcons.num_open > 0);
+ conn->sconn->smb1.tcons.num_open--;
conn_free_internal(conn);
}
@@ -340,7 +347,7 @@ void msg_force_tdis(struct messaging_context *msg,
if (strequal(lp_servicename(SNUM(conn)), sharename)) {
DEBUG(1,("Forcing close of share %s cnum=%d\n",
sharename, conn->cnum));
- close_cnum(sconn, conn, (uint16)-1);
+ close_cnum(conn, (uint16)-1);
}
}
}
diff --git a/source3/smbd/ipc.c b/source3/smbd/ipc.c
index 96a411dd70..12d4922844 100644
--- a/source3/smbd/ipc.c
+++ b/source3/smbd/ipc.c
@@ -534,7 +534,6 @@ static void named_pipe(connection_struct *conn, uint16 vuid,
static void handle_trans(connection_struct *conn, struct smb_request *req,
struct trans_state *state)
{
- struct smbd_server_connection *sconn = smbd_server_conn;
char *local_machine_name;
int name_offset = 0;
@@ -585,7 +584,7 @@ static void handle_trans(connection_struct *conn, struct smb_request *req,
state->max_param_return);
if (state->close_on_completion) {
- close_cnum(sconn, conn,state->vuid);
+ close_cnum(conn,state->vuid);
req->conn = NULL;
}
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 77e122a90c..750915b1cb 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -703,7 +703,7 @@ void reply_tcon_and_X(struct smb_request *req)
/* we might have to close an old one */
if ((tcon_flags & 0x1) && conn) {
- close_cnum(sconn, conn,req->vuid);
+ close_cnum(conn,req->vuid);
req->conn = NULL;
conn = NULL;
}
@@ -4868,7 +4868,6 @@ void reply_unlock(struct smb_request *req)
void reply_tdis(struct smb_request *req)
{
- struct smbd_server_connection *sconn = smbd_server_conn;
connection_struct *conn = req->conn;
START_PROFILE(SMBtdis);
@@ -4881,7 +4880,7 @@ void reply_tdis(struct smb_request *req)
conn->used = False;
- close_cnum(sconn, conn,req->vuid);
+ close_cnum(conn,req->vuid);
req->conn = NULL;
reply_outbuf(req, 0, 0);
diff --git a/source3/smbd/service.c b/source3/smbd/service.c
index a043288bc9..c24b2264c1 100644
--- a/source3/smbd/service.c
+++ b/source3/smbd/service.c
@@ -673,7 +673,7 @@ connection_struct *make_connection_snum(struct smbd_server_connection *sconn,
DEBUG(1, ("create_connection_server_info failed: %s\n",
nt_errstr(status)));
*pstatus = status;
- conn_free(sconn, conn);
+ conn_free(conn);
return NULL;
}
@@ -730,7 +730,7 @@ connection_struct *make_connection_snum(struct smbd_server_connection *sconn,
fuser = talloc_string_sub(conn, lp_force_user(snum), "%S",
lp_servicename(snum));
if (fuser == NULL) {
- conn_free(sconn, conn);
+ conn_free(conn);
*pstatus = NT_STATUS_NO_MEMORY;
return NULL;
}
@@ -739,7 +739,7 @@ connection_struct *make_connection_snum(struct smbd_server_connection *sconn,
conn, fuser, conn->server_info->guest,
&forced_serverinfo);
if (!NT_STATUS_IS_OK(status)) {
- conn_free(sconn, conn);
+ conn_free(conn);
*pstatus = status;
return NULL;
}
@@ -764,7 +764,7 @@ connection_struct *make_connection_snum(struct smbd_server_connection *sconn,
&conn->server_info->utok.gid);
if (!NT_STATUS_IS_OK(status)) {
- conn_free(sconn, conn);
+ conn_free(conn);
*pstatus = status;
return NULL;
}
@@ -790,14 +790,14 @@ connection_struct *make_connection_snum(struct smbd_server_connection *sconn,
pdb_get_domain(conn->server_info->sam_account),
lp_pathname(snum));
if (!s) {
- conn_free(sconn, conn);
+ conn_free(conn);
*pstatus = NT_STATUS_NO_MEMORY;
return NULL;
}
if (!set_conn_connectpath(conn,s)) {
TALLOC_FREE(s);
- conn_free(sconn, conn);
+ conn_free(conn);
*pstatus = NT_STATUS_NO_MEMORY;
return NULL;
}
@@ -829,7 +829,7 @@ connection_struct *make_connection_snum(struct smbd_server_connection *sconn,
"denied due to security "
"descriptor.\n",
lp_servicename(snum)));
- conn_free(sconn, conn);
+ conn_free(conn);
*pstatus = NT_STATUS_ACCESS_DENIED;
return NULL;
} else {
@@ -842,7 +842,7 @@ connection_struct *make_connection_snum(struct smbd_server_connection *sconn,
if (!smbd_vfs_init(conn)) {
DEBUG(0, ("vfs_init failed for service %s\n",
lp_servicename(snum)));
- conn_free(sconn, conn);
+ conn_free(conn);
*pstatus = NT_STATUS_BAD_NETWORK_NAME;
return NULL;
}
@@ -860,7 +860,7 @@ connection_struct *make_connection_snum(struct smbd_server_connection *sconn,
"for service %s, path %s\n",
lp_servicename(snum),
conn->connectpath));
- conn_free(sconn, conn);
+ conn_free(conn);
*pstatus = NT_STATUS_BAD_NETWORK_NAME;
return NULL;
}
@@ -884,7 +884,7 @@ connection_struct *make_connection_snum(struct smbd_server_connection *sconn,
DEBUG(1, ("Max connections (%d) exceeded for %s\n",
lp_max_connections(snum), lp_servicename(snum)));
- conn_free(sconn, conn);
+ conn_free(conn);
*pstatus = NT_STATUS_INSUFFICIENT_RESOURCES;
return NULL;
}
@@ -894,7 +894,7 @@ connection_struct *make_connection_snum(struct smbd_server_connection *sconn,
*/
if (!claim_connection(conn, lp_servicename(snum), 0)) {
DEBUG(1, ("Could not store connections entry\n"));
- conn_free(sconn, conn);
+ conn_free(conn);
*pstatus = NT_STATUS_INTERNAL_DB_ERROR;
return NULL;
}
@@ -918,7 +918,7 @@ connection_struct *make_connection_snum(struct smbd_server_connection *sconn,
DEBUG(1,("root preexec gave %d - failing "
"connection\n", ret));
yield_connection(conn, lp_servicename(snum));
- conn_free(sconn, conn);
+ conn_free(conn);
*pstatus = NT_STATUS_ACCESS_DENIED;
return NULL;
}
@@ -929,7 +929,7 @@ connection_struct *make_connection_snum(struct smbd_server_connection *sconn,
/* No point continuing if they fail the basic checks */
DEBUG(0,("Can't become connected user!\n"));
yield_connection(conn, lp_servicename(snum));
- conn_free(sconn, conn);
+ conn_free(conn);
*pstatus = NT_STATUS_LOGON_FAILURE;
return NULL;
}
@@ -1072,7 +1072,7 @@ connection_struct *make_connection_snum(struct smbd_server_connection *sconn,
SMB_VFS_DISCONNECT(conn);
}
yield_connection(conn, lp_servicename(snum));
- conn_free(sconn, conn);
+ conn_free(conn);
return NULL;
}
@@ -1219,8 +1219,7 @@ connection_struct *make_connection(struct smbd_server_connection *sconn,
Close a cnum.
****************************************************************************/
-void close_cnum(struct smbd_server_connection *sconn,
- connection_struct *conn, uint16 vuid)
+void close_cnum(connection_struct *conn, uint16 vuid)
{
file_close_conn(conn);
@@ -1274,5 +1273,5 @@ void close_cnum(struct smbd_server_connection *sconn,
TALLOC_FREE(cmd);
}
- conn_free(sconn, conn);
+ conn_free(conn);
}
diff --git a/source3/smbd/smb2_tcon.c b/source3/smbd/smb2_tcon.c
index 8c4b1f1b6f..090f9b7908 100644
--- a/source3/smbd/smb2_tcon.c
+++ b/source3/smbd/smb2_tcon.c
@@ -127,7 +127,7 @@ static int smbd_smb2_tcon_destructor(struct smbd_smb2_tcon *tcon)
idr_remove(tcon->session->tcons.idtree, tcon->tid);
DLIST_REMOVE(tcon->session->tcons.list, tcon);
- conn_free(tcon->session->conn, tcon->compat_conn);
+ conn_free(tcon->compat_conn);
tcon->compat_conn = NULL;
tcon->tid = 0;