diff options
author | Stefan Metzmacher <metze@samba.org> | 2006-03-15 17:28:46 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:57:26 -0500 |
commit | 2e7df84576d26bc37eb87b7e3c79fcb3fb358d68 (patch) | |
tree | 2b30c038028b0a1530d0236fa196efaa3d63b0f5 /source4/smb_server | |
parent | 84aea6eca58b20f32fad0de0f43d9a5c7de247c9 (diff) | |
download | samba-2e7df84576d26bc37eb87b7e3c79fcb3fb358d68.tar.gz samba-2e7df84576d26bc37eb87b7e3c79fcb3fb358d68.tar.xz samba-2e7df84576d26bc37eb87b7e3c79fcb3fb358d68.zip |
r14456: don't access the smbsrv_tcon inside the ntvfs modules
metze
(This used to be commit 5709c1c4e1a561dd9af98cfefbbbdac9b18765b7)
Diffstat (limited to 'source4/smb_server')
-rw-r--r-- | source4/smb_server/management.c | 2 | ||||
-rw-r--r-- | source4/smb_server/smb/receive.c | 11 | ||||
-rw-r--r-- | source4/smb_server/smb/service.c | 43 | ||||
-rw-r--r-- | source4/smb_server/smb2/tcon.c | 2 | ||||
-rw-r--r-- | source4/smb_server/smb_server.h | 11 | ||||
-rw-r--r-- | source4/smb_server/tcon.c | 28 |
6 files changed, 56 insertions, 41 deletions
diff --git a/source4/smb_server/management.c b/source4/smb_server/management.c index bb153d3c5e4..b55a9f7d574 100644 --- a/source4/smb_server/management.c +++ b/source4/smb_server/management.c @@ -100,7 +100,7 @@ static NTSTATUS smbsrv_tcon_information(struct irpc_message *msg, } info->tid = tcon->tid; - info->share_name = lp_servicename(tcon->service); + info->share_name = tcon->share_name; info->connect_time = timeval_to_nttime(&tcon->statistics.connect_time); i++; } diff --git a/source4/smb_server/smb/receive.c b/source4/smb_server/smb/receive.c index 8430871c192..4eed107d974 100644 --- a/source4/smb_server/smb/receive.c +++ b/source4/smb_server/smb/receive.c @@ -30,17 +30,16 @@ /* send an oplock break request to a client */ -BOOL req_send_oplock_break(struct smbsrv_tcon *tcon, uint16_t fnum, uint8_t level) +NTSTATUS smbsrv_send_oplock_break(void *p, uint16_t fnum, uint8_t level) { + struct smbsrv_tcon *tcon = talloc_get_type(p, struct smbsrv_tcon); struct smbsrv_request *req; req = smbsrv_init_request(tcon->smb_conn); - if (!req) { - return False; - } + NT_STATUS_HAVE_NO_MEMORY(req); smbsrv_setup_reply(req, 8, 0); - + SCVAL(req->out.hdr,HDR_COM,SMBlockingX); SSVAL(req->out.hdr,HDR_TID,tcon->tid); SSVAL(req->out.hdr,HDR_PID,0xFFFF); @@ -59,7 +58,7 @@ BOOL req_send_oplock_break(struct smbsrv_tcon *tcon, uint16_t fnum, uint8_t leve SSVAL(req->out.vwv, VWV(7), 0); smbsrv_send_reply(req); - return True; + return NT_STATUS_OK; } static void switch_message(int type, struct smbsrv_request *req); diff --git a/source4/smb_server/smb/service.c b/source4/smb_server/smb/service.c index 49c2384e98c..c805d081df0 100644 --- a/source4/smb_server/smb/service.c +++ b/source4/smb_server/smb/service.c @@ -67,35 +67,45 @@ static NTSTATUS make_connection_snum(struct smbsrv_request *req, return NT_STATUS_ACCESS_DENIED; } - tcon = smbsrv_smb_tcon_new(req->smb_conn); + tcon = smbsrv_smb_tcon_new(req->smb_conn, lp_servicename(snum)); if (!tcon) { DEBUG(0,("Couldn't find free connection.\n")); return NT_STATUS_INSUFFICIENT_RESOURCES; } req->tcon = tcon; - tcon->service = snum; - /* init ntvfs function pointers */ - status = ntvfs_init_connection(req, type); + status = ntvfs_init_connection(tcon, snum, type, + req->smb_conn->negotiate.protocol, + req->smb_conn->connection->event.ctx, + req->smb_conn->connection->msg_ctx, + req->smb_conn->connection->server_id, + &tcon->ntvfs); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("ntvfs_init_connection failed for service %s\n", - lp_servicename(tcon->service))); - req->tcon = NULL; - talloc_free(tcon); - return status; + lp_servicename(snum))); + goto failed; + } + + status = ntvfs_set_oplock_handler(tcon->ntvfs, smbsrv_send_oplock_break, tcon); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0,("make_connection: NTVFS failed to set the oplock handler!\n")); + goto failed; } /* Invoke NTVFS connection hook */ status = ntvfs_connect(req, lp_servicename(snum)); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("make_connection: NTVFS make connection failed!\n")); - req->tcon = NULL; - talloc_free(tcon); - return status; + goto failed; } return NT_STATUS_OK; + +failed: + req->tcon = NULL; + talloc_free(tcon); + return status; } /**************************************************************************** @@ -155,6 +165,7 @@ static NTSTATUS make_connection(struct smbsrv_request *req, NTSTATUS smbsrv_tcon_backend(struct smbsrv_request *req, union smb_tcon *con) { NTSTATUS status; + int snum; /* can only do bare tcon in share level security */ if (!req->session && lp_security() != SEC_SHARE) { @@ -183,11 +194,13 @@ NTSTATUS smbsrv_tcon_backend(struct smbsrv_request *req, union smb_tcon *con) return status; } + snum = req->tcon->ntvfs->config.snum; + con->tconx.out.tid = req->tcon->tid; - con->tconx.out.dev_type = talloc_strdup(req, req->tcon->dev_type); - con->tconx.out.fs_type = talloc_strdup(req, req->tcon->fs_type); - con->tconx.out.options = SMB_SUPPORT_SEARCH_BITS | (lp_csc_policy(req->tcon->service) << 2); - if (lp_msdfs_root(req->tcon->service) && lp_host_msdfs()) { + con->tconx.out.dev_type = talloc_strdup(req, req->tcon->ntvfs->dev_type); + con->tconx.out.fs_type = talloc_strdup(req, req->tcon->ntvfs->fs_type); + con->tconx.out.options = SMB_SUPPORT_SEARCH_BITS | (lp_csc_policy(snum) << 2); + if (lp_msdfs_root(snum) && lp_host_msdfs()) { con->tconx.out.options |= SMB_SHARE_IN_DFS; } diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c index 9fb2a03ce33..836c13a019f 100644 --- a/source4/smb_server/smb2/tcon.c +++ b/source4/smb_server/smb2/tcon.c @@ -28,7 +28,7 @@ static NTSTATUS smb2srv_tcon_backend(struct smb2srv_request *req, struct smb2_tr { struct smbsrv_tcon *tcon; - tcon = smbsrv_smb2_tcon_new(req->session); + tcon = smbsrv_smb2_tcon_new(req->session, "fake"); NT_STATUS_HAVE_NO_MEMORY(tcon); /* TODO: do real tree connect */ diff --git a/source4/smb_server/smb_server.h b/source4/smb_server/smb_server.h index ab24381026f..2b06eb9d5b4 100644 --- a/source4/smb_server/smb_server.h +++ b/source4/smb_server/smb_server.h @@ -103,16 +103,11 @@ struct smbsrv_tcon { */ uint32_t tid; /* an index passed over the wire (the TID) */ - int service; + /* the share name */ + const char *share_name; /* the NTVFS context - see source/ntvfs/ for details */ - struct ntvfs_context *ntvfs_ctx; - - /* the reported filesystem type */ - char *fs_type; - - /* the reported device type */ - char *dev_type; + struct ntvfs_context *ntvfs; /* some stuff to support share level security */ struct { diff --git a/source4/smb_server/tcon.c b/source4/smb_server/tcon.c index 90fe20a4c8b..95e42d6537c 100644 --- a/source4/smb_server/tcon.c +++ b/source4/smb_server/tcon.c @@ -93,16 +93,16 @@ static int smbsrv_tcon_destructor(void *ptr) { struct smbsrv_tcon *tcon = talloc_get_type(ptr, struct smbsrv_tcon); struct smbsrv_tcons_context *tcons_ctx; - struct socket_address *client_addr; + client_addr = socket_get_peer_addr(tcon->smb_conn->connection->socket, ptr); DEBUG(3,("%s closed connection to service %s\n", client_addr ? client_addr->addr : "(unknown)", - lp_servicename(tcon->service))); + tcon->share_name)); /* tell the ntvfs backend that we are disconnecting */ - if (tcon->ntvfs_ctx) { - ntvfs_disconnect(tcon->ntvfs_ctx); + if (tcon->ntvfs) { + ntvfs_disconnect(tcon->ntvfs); } if (tcon->smb2.session) { @@ -119,7 +119,9 @@ static int smbsrv_tcon_destructor(void *ptr) /* find first available connection slot */ -static struct smbsrv_tcon *smbsrv_tcon_new(struct smbsrv_connection *smb_conn, struct smbsrv_session *smb_sess) +static struct smbsrv_tcon *smbsrv_tcon_new(struct smbsrv_connection *smb_conn, + struct smbsrv_session *smb_sess, + const char *share_name) { TALLOC_CTX *mem_ctx; struct smbsrv_tcons_context *tcons_ctx; @@ -138,11 +140,13 @@ static struct smbsrv_tcon *smbsrv_tcon_new(struct smbsrv_connection *smb_conn, s if (!tcon) return NULL; tcon->smb_conn = smb_conn; tcon->smb2.session = smb_sess; + tcon->share_name = talloc_strdup(tcon, share_name); + if (!tcon->share_name) goto failed; i = idr_get_new_random(tcons_ctx->idtree_tid, tcon, tcons_ctx->idtree_limit); if (i == -1) { DEBUG(1,("ERROR! Out of connection structures\n")); - return NULL; + goto failed; } tcon->tid = i; @@ -153,14 +157,18 @@ static struct smbsrv_tcon *smbsrv_tcon_new(struct smbsrv_connection *smb_conn, s tcon->statistics.connect_time = timeval_current(); return tcon; + +failed: + talloc_free(tcon); + return NULL; } -struct smbsrv_tcon *smbsrv_smb_tcon_new(struct smbsrv_connection *smb_conn) +struct smbsrv_tcon *smbsrv_smb_tcon_new(struct smbsrv_connection *smb_conn, const char *share_name) { - return smbsrv_tcon_new(smb_conn, NULL); + return smbsrv_tcon_new(smb_conn, NULL, share_name); } -struct smbsrv_tcon *smbsrv_smb2_tcon_new(struct smbsrv_session *smb_sess) +struct smbsrv_tcon *smbsrv_smb2_tcon_new(struct smbsrv_session *smb_sess, const char *share_name) { - return smbsrv_tcon_new(smb_sess->smb_conn, smb_sess); + return smbsrv_tcon_new(smb_sess->smb_conn, smb_sess, share_name); } |