connecting user if appropriate.
****************************************************************************/
-connection_struct *make_connection_snum(struct smbd_server_connection *sconn,
+static connection_struct *make_connection_snum(struct smbd_server_connection *sconn,
+ connection_struct *conn,
int snum, user_struct *vuser,
DATA_BLOB password,
const char *pdev,
NTSTATUS *pstatus)
{
- connection_struct *conn = NULL;
struct smb_filename *smb_fname_cpath = NULL;
fstring dev;
int ret;
goto err_root_exit;
}
- conn = conn_new(sconn);
- if (!conn) {
- DEBUG(0,("Couldn't find free connection.\n"));
- *pstatus = NT_STATUS_INSUFFICIENT_RESOURCES;
- goto err_root_exit;
- }
-
conn->params->service = snum;
status = create_connection_session_info(sconn,
status = set_conn_force_user_group(conn, snum);
if (!NT_STATUS_IS_OK(status)) {
- conn_free(conn);
*pstatus = status;
return NULL;
}
if (claimed_connection) {
yield_connection(conn, lp_servicename(snum));
}
- if (conn) {
+ return NULL;
+}
+
+/****************************************************************************
+ Make a connection to a service from SMB1. Internal interface.
+****************************************************************************/
+
+static connection_struct *make_connection_smb1(struct smbd_server_connection *sconn,
+ int snum, user_struct *vuser,
+ DATA_BLOB password,
+ const char *pdev,
+ NTSTATUS *pstatus)
+{
+ connection_struct *ret_conn = NULL;
+ connection_struct *conn = conn_new(sconn);
+ if (!conn) {
+ DEBUG(0,("make_connection_smb1: Couldn't find free connection.\n"));
+ *pstatus = NT_STATUS_INSUFFICIENT_RESOURCES;
+ return NULL;
+ }
+ ret_conn = make_connection_snum(sconn,
+ conn,
+ snum,
+ vuser,
+ password,
+ pdev,
+ pstatus);
+ if (ret_conn != conn) {
conn_free(conn);
+ return NULL;
}
- return NULL;
+ return conn;
+}
+
+/****************************************************************************
+ Make a connection to a service from SMB2. External SMB2 interface.
+ We must set cnum before claiming connection.
+****************************************************************************/
+
+connection_struct *make_connection_smb2(struct smbd_server_connection *sconn,
+ struct smbd_smb2_tcon *tcon,
+ user_struct *vuser,
+ DATA_BLOB password,
+ const char *pdev,
+ NTSTATUS *pstatus)
+{
+ connection_struct *ret_conn = NULL;
+ connection_struct *conn = conn_new(sconn);
+ if (!conn) {
+ DEBUG(0,("make_connection_smb2: Couldn't find free connection.\n"));
+ *pstatus = NT_STATUS_INSUFFICIENT_RESOURCES;
+ return NULL;
+ }
+ conn->cnum = tcon->tid;
+ ret_conn = make_connection_snum(sconn,
+ conn,
+ tcon->snum,
+ vuser,
+ password,
+ pdev,
+ pstatus);
+ if (ret_conn != conn) {
+ conn_free(conn);
+ return NULL;
+ }
+ return conn;
}
/****************************************************************************
- Make a connection to a service.
+ Make a connection to a service. External SMB1 interface.
*
* @param service
****************************************************************************/
}
DEBUG(5, ("making a connection to [homes] service "
"created at session setup time\n"));
- return make_connection_snum(sconn,
+ return make_connection_smb1(sconn,
vuser->homes_snum,
vuser, no_pw,
dev, status);
DEBUG(5, ("making a connection to 'homes' "
"service %s based on "
"security=share\n", service_in));
- return make_connection_snum(sconn,
+ return make_connection_smb1(sconn,
snum, NULL,
password,
dev, status);
DATA_BLOB no_pw = data_blob_null;
DEBUG(5, ("making a connection to 'homes' service [%s] "
"created at session setup time\n", service_in));
- return make_connection_snum(sconn,
+ return make_connection_smb1(sconn,
vuser->homes_snum,
vuser, no_pw,
dev, status);
DEBUG(5, ("making a connection to 'normal' service %s\n", service));
- return make_connection_snum(sconn, snum, vuser,
+ return make_connection_smb1(sconn, snum, vuser,
password,
dev, status);
}