int find_service(fstring service)
{
int iService;
+ struct smbd_server_connection *sconn = smbd_server_conn;
all_string_sub(service,"\\","/",0);
* Try mapping the servicename, it may
* be a Windows to unix mapped user name.
*/
- if(map_username(service))
+ if(map_username(sconn, service))
phome_dir = get_user_home_dir(
talloc_tos(), service);
}
Create an auth_serversupplied_info structure for a connection_struct
****************************************************************************/
-static NTSTATUS create_connection_server_info(TALLOC_CTX *mem_ctx, int snum,
+static NTSTATUS create_connection_server_info(struct smbd_server_connection *sconn,
+ TALLOC_CTX *mem_ctx, int snum,
struct auth_serversupplied_info *vuid_serverinfo,
DATA_BLOB password,
struct auth_serversupplied_info **presult)
/* add the sharename as a possible user name if we
are in share mode security */
- add_session_user(lp_servicename(snum));
+ add_session_user(sconn, lp_servicename(snum));
/* shall we let them in? */
- if (!authorise_login(snum,user,password,&guest)) {
+ if (!authorise_login(sconn, snum,user,password,&guest)) {
DEBUG( 2, ( "Invalid username/password for [%s]\n",
lp_servicename(snum)) );
return NT_STATUS_WRONG_PASSWORD;
connecting user if appropriate.
****************************************************************************/
-static connection_struct *make_connection_snum(int snum, user_struct *vuser,
- DATA_BLOB password,
- const char *pdev,
- NTSTATUS *pstatus)
+connection_struct *make_connection_snum(struct smbd_server_connection *sconn,
+ int snum, user_struct *vuser,
+ DATA_BLOB password,
+ const char *pdev,
+ NTSTATUS *pstatus)
{
connection_struct *conn;
SMB_STRUCT_STAT st;
return NULL;
}
- conn = conn_new();
+ conn = conn_new(sconn);
if (!conn) {
DEBUG(0,("Couldn't find free connection.\n"));
*pstatus = NT_STATUS_INSUFFICIENT_RESOURCES;
conn->params->service = snum;
- status = create_connection_server_info(
+ status = create_connection_server_info(sconn,
conn, snum, vuser ? vuser->server_info : NULL, password,
&conn->server_info);
DEBUG(1, ("create_connection_server_info failed: %s\n",
nt_errstr(status)));
*pstatus = status;
- conn_free(conn);
+ conn_free(sconn, conn);
return NULL;
}
conn->force_user = true;
}
- add_session_user(conn->server_info->unix_name);
+ add_session_user(sconn, conn->server_info->unix_name);
safe_strcpy(conn->client_address,
client_addr(get_client_fd(),addr,sizeof(addr)),
fuser = talloc_string_sub(conn, lp_force_user(snum), "%S",
lp_servicename(snum));
if (fuser == NULL) {
- conn_free(conn);
+ conn_free(sconn, conn);
*pstatus = NT_STATUS_NO_MEMORY;
return NULL;
}
conn, fuser, conn->server_info->guest,
&forced_serverinfo);
if (!NT_STATUS_IS_OK(status)) {
- conn_free(conn);
+ conn_free(sconn, conn);
*pstatus = status;
return NULL;
}
&conn->server_info->utok.gid);
if (!NT_STATUS_IS_OK(status)) {
- conn_free(conn);
+ conn_free(sconn, conn);
*pstatus = status;
return NULL;
}
pdb_get_domain(conn->server_info->sam_account),
lp_pathname(snum));
if (!s) {
- conn_free(conn);
+ conn_free(sconn, conn);
*pstatus = NT_STATUS_NO_MEMORY;
return NULL;
}
if (!set_conn_connectpath(conn,s)) {
TALLOC_FREE(s);
- conn_free(conn);
+ conn_free(sconn, conn);
*pstatus = NT_STATUS_NO_MEMORY;
return NULL;
}
"denied due to security "
"descriptor.\n",
lp_servicename(snum)));
- conn_free(conn);
+ conn_free(sconn, conn);
*pstatus = NT_STATUS_ACCESS_DENIED;
return NULL;
} else {
if (!smbd_vfs_init(conn)) {
DEBUG(0, ("vfs_init failed for service %s\n",
lp_servicename(snum)));
- conn_free(conn);
+ conn_free(sconn, conn);
*pstatus = NT_STATUS_BAD_NETWORK_NAME;
return NULL;
}
"for service %s, path %s\n",
lp_servicename(snum),
conn->connectpath));
- conn_free(conn);
+ conn_free(sconn, conn);
*pstatus = NT_STATUS_BAD_NETWORK_NAME;
return NULL;
}
DEBUG(1, ("Max connections (%d) exceeded for %s\n",
lp_max_connections(snum), lp_servicename(snum)));
- conn_free(conn);
+ conn_free(sconn, conn);
*pstatus = NT_STATUS_INSUFFICIENT_RESOURCES;
return NULL;
}
*/
if (!claim_connection(conn, lp_servicename(snum), 0)) {
DEBUG(1, ("Could not store connections entry\n"));
- conn_free(conn);
+ conn_free(sconn, conn);
*pstatus = NT_STATUS_INTERNAL_DB_ERROR;
return NULL;
}
DEBUG(1,("root preexec gave %d - failing "
"connection\n", ret));
yield_connection(conn, lp_servicename(snum));
- conn_free(conn);
+ conn_free(sconn, conn);
*pstatus = NT_STATUS_ACCESS_DENIED;
return NULL;
}
/* 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(conn);
+ conn_free(sconn, conn);
*pstatus = NT_STATUS_LOGON_FAILURE;
return NULL;
}
SMB_VFS_DISCONNECT(conn);
}
yield_connection(conn, lp_servicename(snum));
- conn_free(conn);
+ conn_free(sconn, conn);
return NULL;
}
* @param service
****************************************************************************/
-connection_struct *make_connection(const char *service_in, DATA_BLOB password,
+connection_struct *make_connection(struct smbd_server_connection *sconn,
+ const char *service_in, DATA_BLOB password,
const char *pdev, uint16 vuid,
NTSTATUS *status)
{
smb_panic("make_connection: PANIC ERROR. Called as nonroot\n");
}
- if (conn_num_open() > 2047) {
+ if (conn_num_open(sconn) > 2047) {
*status = NT_STATUS_INSUFF_SERVER_RESOURCES;
return NULL;
}
if(lp_security() != SEC_SHARE) {
- vuser = get_valid_user_struct(vuid);
+ vuser = get_valid_user_struct(sconn, vuid);
if (!vuser) {
DEBUG(1,("make_connection: refusing to connect with "
"no session setup\n"));
}
DEBUG(5, ("making a connection to [homes] service "
"created at session setup time\n"));
- return make_connection_snum(vuser->homes_snum,
+ return make_connection_snum(sconn,
+ vuser->homes_snum,
vuser, no_pw,
dev, status);
} else {
fstring unix_username;
fstrcpy(unix_username,
current_user_info.smb_name);
- map_username(unix_username);
+ map_username(sconn, unix_username);
snum = find_service(unix_username);
}
if (snum != -1) {
DEBUG(5, ("making a connection to 'homes' "
"service %s based on "
"security=share\n", service_in));
- return make_connection_snum(snum, NULL,
+ return make_connection_snum(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(vuser->homes_snum,
+ return make_connection_snum(sconn,
+ vuser->homes_snum,
vuser, no_pw,
dev, status);
}
DEBUG(5, ("making a connection to 'normal' service %s\n", service));
- return make_connection_snum(snum, vuser,
+ return make_connection_snum(sconn, snum, vuser,
password,
dev, status);
}
Close a cnum.
****************************************************************************/
-void close_cnum(connection_struct *conn, uint16 vuid)
+void close_cnum(struct smbd_server_connection *sconn,
+ connection_struct *conn, uint16 vuid)
{
file_close_conn(conn);
TALLOC_FREE(cmd);
}
- conn_free(conn);
+ conn_free(sconn, conn);
}