This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
#include "version.h"
+#include "auth/credentials/credentials.h"
+#include "auth/gensec/gensec.h"
#include "auth/auth.h"
#include "smb_server/smb_server.h"
#include "smbd/service_stream.h"
#include "librpc/gen_ndr/nbt.h"
+#include "param/param.h"
/*
setup the OS, Lanman and domain portions of a session setup reply
{
(*os) = talloc_asprintf(req, "Unix");
(*lanman) = talloc_asprintf(req, "Samba %s", SAMBA_VERSION_STRING);
- (*domain) = talloc_asprintf(req, "%s", lp_workgroup());
+ (*domain) = talloc_asprintf(req, "%s",
+ lp_workgroup(req->smb_conn->lp_ctx));
}
static void smbsrv_sesssetup_backend_send(struct smbsrv_request *req,
NTSTATUS status)
{
if (NT_STATUS_IS_OK(status)) {
- req->smb_conn->negotiate.done_sesssetup = True;
+ req->smb_conn->negotiate.done_sesssetup = true;
+ /* we need to keep the session long term */
+ req->session = talloc_steal(req->smb_conn, req->session);
}
smbsrv_reply_sesssetup_send(req, sess, status);
}
if (!NT_STATUS_IS_OK(status)) goto failed;
/* This references server_info into session_info */
- status = auth_generate_session_info(req, server_info, &session_info);
+ status = auth_generate_session_info(req, req->smb_conn->lp_ctx,
+ server_info, &session_info);
if (!NT_STATUS_IS_OK(status)) goto failed;
/* allocate a new session */
- smb_sess = smbsrv_session_new(req->smb_conn, NULL);
+ smb_sess = smbsrv_session_new(req->smb_conn, req, NULL);
if (!smb_sess) {
status = NT_STATUS_INSUFFICIENT_RESOURCES;
goto failed;
user_info = talloc(req, struct auth_usersupplied_info);
if (!user_info) goto nomem;
- user_info->mapped_state = False;
+ user_info->mapped_state = false;
user_info->logon_parameters = 0;
user_info->flags = 0;
user_info->client.account_name = sess->old.in.user;
if (!NT_STATUS_IS_OK(status)) goto failed;
/* This references server_info into session_info */
- status = auth_generate_session_info(req, server_info, &session_info);
+ status = auth_generate_session_info(req, req->smb_conn->lp_ctx,
+ server_info, &session_info);
if (!NT_STATUS_IS_OK(status)) goto failed;
/* allocate a new session */
- smb_sess = smbsrv_session_new(req->smb_conn, NULL);
+ smb_sess = smbsrv_session_new(req->smb_conn, req, NULL);
if (!smb_sess) {
status = NT_STATUS_INSUFFICIENT_RESOURCES;
goto failed;
}
/* TODO: should we use just "anonymous" here? */
- status = auth_context_create(req, lp_auth_methods(),
+ status = auth_context_create(req,
req->smb_conn->connection->event.ctx,
req->smb_conn->connection->msg_ctx,
+ req->smb_conn->lp_ctx,
&auth_context);
if (!NT_STATUS_IS_OK(status)) goto failed;
} else {
user_info = talloc(req, struct auth_usersupplied_info);
if (!user_info) goto nomem;
- user_info->mapped_state = False;
+ user_info->mapped_state = false;
user_info->logon_parameters = 0;
user_info->flags = 0;
user_info->client.account_name = sess->nt1.in.user;
failed:
status = auth_nt_status_squash(status);
smbsrv_sesssetup_backend_send(req, sess, status);
+ if (!NT_STATUS_IS_OK(status) &&
+ !NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
+ talloc_free(smb_sess);
+ }
}
/*
status = gensec_server_start(req,
req->smb_conn->connection->event.ctx,
+ req->smb_conn->lp_ctx,
req->smb_conn->connection->msg_ctx,
&gensec_ctx);
if (!NT_STATUS_IS_OK(status)) {
}
/* allocate a new session */
- smb_sess = smbsrv_session_new(req->smb_conn, gensec_ctx);
+ smb_sess = smbsrv_session_new(req->smb_conn, req->smb_conn, gensec_ctx);
if (!smb_sess) {
status = NT_STATUS_INSUFFICIENT_RESOURCES;
goto failed;