summaryrefslogtreecommitdiff
path: root/source4/smb_server/smb_server.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-07-15 02:11:03 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:57:36 -0500
commita02809e28e0becb201350b7edc72418f49ea2a4e (patch)
treefe15c7547ccfca6d62e3ae91b430f82d03c77aa2 /source4/smb_server/smb_server.c
parent5779a7da9aecb7329eb47e93000dc8b9de96d9ae (diff)
downloadsamba-a02809e28e0becb201350b7edc72418f49ea2a4e.tar.gz
samba-a02809e28e0becb201350b7edc72418f49ea2a4e.tar.bz2
samba-a02809e28e0becb201350b7edc72418f49ea2a4e.zip
r1507: fixed the handling of SMB chaining with the new server structure. You
must think carefully about packet chaining when dealing with any authentication or SMB parsing issues. The particular problem here was that a chained tconX didn't get the req->session setup after an initial sesstion setup call, so the tconx used a bogus VUID. (This used to be commit 6f2a335cd623211071b01d982d4e7c69b49a5602)
Diffstat (limited to 'source4/smb_server/smb_server.c')
-rw-r--r--source4/smb_server/smb_server.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/source4/smb_server/smb_server.c b/source4/smb_server/smb_server.c
index 94bf6302c1..7d793bdf02 100644
--- a/source4/smb_server/smb_server.c
+++ b/source4/smb_server/smb_server.c
@@ -421,8 +421,8 @@ onto the message queue
static void switch_message(int type, struct smbsrv_request *req)
{
int flags;
- uint16_t session_tag;
struct smbsrv_connection *smb_conn = req->smb_conn;
+ uint16_t session_tag;
type &= 0xff;
@@ -436,22 +436,28 @@ static void switch_message(int type, struct smbsrv_request *req)
flags = smb_messages[type].flags;
- /* In share mode security we must ignore the vuid. */
- session_tag = (lp_security() == SEC_SHARE) ?
- UID_FIELD_INVALID :
- SVAL(req->in.hdr,HDR_UID);
-
req->tcon = conn_find(smb_conn, SVAL(req->in.hdr,HDR_TID));
- /* setup the user context for this request */
- req->session = smbsrv_session_find(req->smb_conn, session_tag);
+ if (req->session == NULL) {
+ /* setup the user context for this request if it
+ hasn't already been initialised (to cope with SMB
+ chaining) */
- /* Ensure this value is replaced in the incoming packet. */
- SSVAL(req->in.hdr,HDR_UID,session_tag);
+ /* In share mode security we must ignore the vuid. */
+ if (lp_security() == SEC_SHARE) {
+ session_tag = UID_FIELD_INVALID;
+ } else {
+ session_tag = SVAL(req->in.hdr,HDR_UID);
+ }
- if (req->session) {
- req->session->vuid = session_tag;
+ req->session = smbsrv_session_find(req->smb_conn, session_tag);
+ if (req->session) {
+ req->session->vuid = session_tag;
+ }
+ } else {
+ session_tag = req->session->vuid;
}
+
DEBUG(3,("switch message %s (task_id %d)\n",smb_fn_name(type), smb_conn->connection->service->model_ops->get_id(req)));
/* does this protocol need to be run as root? */