From 6d34ab056f70d85c3207696fac4fbb9e7f437b14 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 18 Nov 2005 13:30:18 +0000 Subject: r11786: move all SMB protocol specific stuff to smb_server/smb/ metze (This used to be commit 5fea278cb65076cea71bb6c921e51c4feffc37d7) --- source4/smb_server/smb/service.c | 194 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 194 insertions(+) create mode 100644 source4/smb_server/smb/service.c (limited to 'source4/smb_server/smb/service.c') diff --git a/source4/smb_server/smb/service.c b/source4/smb_server/smb/service.c new file mode 100644 index 0000000000..213cf6726b --- /dev/null +++ b/source4/smb_server/smb/service.c @@ -0,0 +1,194 @@ +/* + Unix SMB/CIFS implementation. + service (connection) handling + Copyright (C) Andrew Tridgell 1992-2003 + + 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 + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + 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. +*/ + +#include "includes.h" +#include "smb_server/smb_server.h" +#include "smbd/service_stream.h" + + +/** + * Find a service entry. service is always in dos codepage. + * + * @param service is modified (to canonical form??) + **/ +static int find_service(const char *service) +{ + int iService; + + iService = lp_servicenumber(service); + + if (iService >= 0 && !lp_snum_ok(iService)) { + DEBUG(0,("Invalid snum %d for %s\n",iService, service)); + iService = -1; + } + + if (iService == -1) { + DEBUG(3,("find_service() failed to find service %s\n", service)); + } + + return iService; +} + + +/**************************************************************************** + Make a connection, given the snum to connect to, and the vuser of the + connecting user if appropriate. +****************************************************************************/ +static NTSTATUS make_connection_snum(struct smbsrv_request *req, + int snum, enum ntvfs_type type, + DATA_BLOB password, + const char *dev) +{ + struct smbsrv_tcon *tcon; + NTSTATUS status; + + if (!socket_check_access(req->smb_conn->connection->socket, + lp_servicename(snum), + lp_hostsallow(snum), + lp_hostsdeny(snum))) { + return NT_STATUS_ACCESS_DENIED; + } + + tcon = smbsrv_tcon_new(req->smb_conn); + 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); + 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; + } + + /* 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; + } + + return NT_STATUS_OK; +} + +/**************************************************************************** + Make a connection to a service. + * + * @param service +****************************************************************************/ +static NTSTATUS make_connection(struct smbsrv_request *req, + const char *service, DATA_BLOB password, + const char *dev) +{ + int snum; + enum ntvfs_type type; + const char *type_str; + + /* TODO: check the password, when it's share level security! */ + + /* the service might be of the form \\SERVER\SHARE. Should we put + the server name we get from this somewhere? */ + if (strncmp(service, "\\\\", 2) == 0) { + char *p = strchr(service+2, '\\'); + if (p) { + service = p + 1; + } + } + + snum = find_service(service); + + if (snum == -1) { + DEBUG(0,("couldn't find service %s\n", service)); + return NT_STATUS_BAD_NETWORK_NAME; + } + + /* work out what sort of connection this is */ + if (strcmp(lp_fstype(snum), "IPC") == 0) { + type = NTVFS_IPC; + type_str = "IPC"; + } else if (lp_print_ok(snum)) { + type = NTVFS_PRINT; + type_str = "LPT:"; + } else { + type = NTVFS_DISK; + type_str = "A:"; + } + + if (strcmp(dev, "?????") != 0 && strcasecmp(type_str, dev) != 0) { + /* the client gave us the wrong device type */ + return NT_STATUS_BAD_DEVICE_TYPE; + } + + return make_connection_snum(req, snum, type, password, dev); +} + +/* + backend for tree connect call +*/ +NTSTATUS tcon_backend(struct smbsrv_request *req, union smb_tcon *con) +{ + NTSTATUS status; + + /* can only do bare tcon in share level security */ + if (!req->session && lp_security() != SEC_SHARE) { + return NT_STATUS_ACCESS_DENIED; + } + + if (con->generic.level == RAW_TCON_TCON) { + DATA_BLOB password; + password = data_blob(con->tcon.in.password, strlen(con->tcon.in.password) + 1); + + status = make_connection(req, con->tcon.in.service, password, con->tcon.in.dev); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + con->tcon.out.max_xmit = req->smb_conn->negotiate.max_recv; + con->tcon.out.tid = req->tcon->tid; + + return status; + } + + status = make_connection(req, con->tconx.in.path, con->tconx.in.password, + con->tconx.in.device); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + 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.options |= SMB_SHARE_IN_DFS; + } + + return status; +} -- cgit From 273f340376452bd072b68d0601dde3f7b43b62db Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 6 Dec 2005 17:59:20 +0000 Subject: r12102: for SMB2 we need to allocate tcons per session metze (This used to be commit 4d527ac005086c2db954578b4126ca128e436e01) --- source4/smb_server/smb/service.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/smb_server/smb/service.c') diff --git a/source4/smb_server/smb/service.c b/source4/smb_server/smb/service.c index 213cf6726b..6032e5a20d 100644 --- a/source4/smb_server/smb/service.c +++ b/source4/smb_server/smb/service.c @@ -66,7 +66,7 @@ static NTSTATUS make_connection_snum(struct smbsrv_request *req, return NT_STATUS_ACCESS_DENIED; } - tcon = smbsrv_tcon_new(req->smb_conn); + tcon = smbsrv_smb_tcon_new(req->smb_conn); if (!tcon) { DEBUG(0,("Couldn't find free connection.\n")); return NT_STATUS_INSUFFICIENT_RESOURCES; -- cgit From 0a3c167f6bcf08b2204ca49831ca49eef73dcbf4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 27 Dec 2005 22:51:30 +0000 Subject: r12528: Add seperate proto headers for ntvfs, tdr, smb_server and nbt_server. (This used to be commit 87f665a1d5ba74289974bf9d8f9441c162e6f1b1) --- source4/smb_server/smb/service.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/smb_server/smb/service.c') diff --git a/source4/smb_server/smb/service.c b/source4/smb_server/smb/service.c index 6032e5a20d..f5ba1254d8 100644 --- a/source4/smb_server/smb/service.c +++ b/source4/smb_server/smb/service.c @@ -21,6 +21,7 @@ #include "includes.h" #include "smb_server/smb_server.h" #include "smbd/service_stream.h" +#include "ntvfs/ntvfs.h" /** -- cgit From 354a61fc915da99a16732337b62920909a591b58 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 6 Mar 2006 15:33:25 +0000 Subject: r13866: prefix more functions with smbsrv_ metze (This used to be commit bb083f17c961964dd99185ae4194596ccaafd4a8) --- source4/smb_server/smb/service.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/smb_server/smb/service.c') diff --git a/source4/smb_server/smb/service.c b/source4/smb_server/smb/service.c index f5ba1254d8..49c2384e98 100644 --- a/source4/smb_server/smb/service.c +++ b/source4/smb_server/smb/service.c @@ -152,7 +152,7 @@ static NTSTATUS make_connection(struct smbsrv_request *req, /* backend for tree connect call */ -NTSTATUS tcon_backend(struct smbsrv_request *req, union smb_tcon *con) +NTSTATUS smbsrv_tcon_backend(struct smbsrv_request *req, union smb_tcon *con) { NTSTATUS status; -- cgit From 2e7df84576d26bc37eb87b7e3c79fcb3fb358d68 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 15 Mar 2006 17:28:46 +0000 Subject: r14456: don't access the smbsrv_tcon inside the ntvfs modules metze (This used to be commit 5709c1c4e1a561dd9af98cfefbbbdac9b18765b7) --- source4/smb_server/smb/service.c | 43 ++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 15 deletions(-) (limited to 'source4/smb_server/smb/service.c') diff --git a/source4/smb_server/smb/service.c b/source4/smb_server/smb/service.c index 49c2384e98..c805d081df 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; } -- cgit From 3948fcac493ed131bc40358138e8dc17a58853f7 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 16 Mar 2006 18:26:14 +0000 Subject: r14485: mark smb commands as need session and need tcon explicit, so we only need to check in one global place and can't forget in other places... metze (This used to be commit 742be8e075651c3b7e502ec6da01286fd7a2d4ca) --- source4/smb_server/smb/service.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'source4/smb_server/smb/service.c') diff --git a/source4/smb_server/smb/service.c b/source4/smb_server/smb/service.c index c805d081df..dcd91f1917 100644 --- a/source4/smb_server/smb/service.c +++ b/source4/smb_server/smb/service.c @@ -167,11 +167,6 @@ 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) { - return NT_STATUS_ACCESS_DENIED; - } - if (con->generic.level == RAW_TCON_TCON) { DATA_BLOB password; password = data_blob(con->tcon.in.password, strlen(con->tcon.in.password) + 1); -- cgit From d3087451c4ec25171ba956fe2cd4e1d0f64f7edc Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 16 Mar 2006 18:54:19 +0000 Subject: r14487: split smbsrv_request into two parts, one will be moved to ntvfs_request but I don't to get the commit to large, to I'll do this tomorrow... metze (This used to be commit 10e627032d7d04f1ebf6efed248c426614f5aa6f) --- source4/smb_server/smb/service.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'source4/smb_server/smb/service.c') diff --git a/source4/smb_server/smb/service.c b/source4/smb_server/smb/service.c index dcd91f1917..76607a0e0f 100644 --- a/source4/smb_server/smb/service.c +++ b/source4/smb_server/smb/service.c @@ -47,6 +47,21 @@ static int find_service(const char *service) return iService; } +static struct socket_address *smbsrv_get_my_addr(void *p, TALLOC_CTX *mem_ctx) +{ + struct smbsrv_connection *smb_conn = talloc_get_type(p, + struct smbsrv_connection); + + return socket_get_my_addr(smb_conn->connection->socket, mem_ctx); +} + +static struct socket_address *smbsrv_get_peer_addr(void *p, TALLOC_CTX *mem_ctx) +{ + struct smbsrv_connection *smb_conn = talloc_get_type(p, + struct smbsrv_connection); + + return socket_get_peer_addr(smb_conn->connection->socket, mem_ctx); +} /**************************************************************************** Make a connection, given the snum to connect to, and the vuser of the @@ -93,6 +108,14 @@ static NTSTATUS make_connection_snum(struct smbsrv_request *req, goto failed; } + status = ntvfs_set_addr_callbacks(tcon->ntvfs, smbsrv_get_my_addr, smbsrv_get_peer_addr, req->smb_conn); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0,("make_connection: NTVFS failed to set the oplock handler!\n")); + goto failed; + } + + req->ctx = tcon->ntvfs; + /* Invoke NTVFS connection hook */ status = ntvfs_connect(req, lp_servicename(snum)); if (!NT_STATUS_IS_OK(status)) { -- cgit From 61fa658ebcaf2856d543d376b120932ad5a082f0 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 18 Mar 2006 11:10:21 +0000 Subject: r14541: separate smbsrv_request and ntvfs_request, with this it's now possible to write a ntvfs_test programm like the vfstest in samba3 also smb2 support will be possible later metze (This used to be commit 7253153691e35cd206346fbd4e9b9f95c042f602) --- source4/smb_server/smb/service.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'source4/smb_server/smb/service.c') diff --git a/source4/smb_server/smb/service.c b/source4/smb_server/smb/service.c index 76607a0e0f..13ef268a98 100644 --- a/source4/smb_server/smb/service.c +++ b/source4/smb_server/smb/service.c @@ -114,10 +114,19 @@ static NTSTATUS make_connection_snum(struct smbsrv_request *req, goto failed; } - req->ctx = tcon->ntvfs; + req->ntvfs = ntvfs_request_create(req->tcon->ntvfs, req, + req->session->session_info, + SVAL(req->in.hdr,HDR_PID), + SVAL(req->in.hdr,HDR_MID), + req->request_time, + req, NULL, 0); + if (!req->ntvfs) { + status = NT_STATUS_NO_MEMORY; + goto failed; + } /* Invoke NTVFS connection hook */ - status = ntvfs_connect(req, lp_servicename(snum)); + status = ntvfs_connect(req->ntvfs, lp_servicename(snum)); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("make_connection: NTVFS make connection failed!\n")); goto failed; -- cgit From 9ef33f5f5c786b83311ca088357fb2f0aa72fc9e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 20 May 2006 08:15:22 +0000 Subject: r15734: This is a major change to the NTVFS subsystem: - to use a struct ntvfs_handle instead of a uint16_t fnum. (to make it independend from the frontend protocol) - the allocation of handles now is provided by the frontend (smbsrv_*) via callbacks and not by each backend module - this also makes sure that file handles are only passed to the ntvfs subsystem when the tcon and session matches, so modules can rely on this and need to check this. - this allows multiple modules in the ntvfs module chain to allocate file handles. This can be used for virtual files like "\\$Extend\\$Quota:$Q:$INDEX_ALLOCATION"... - also this will make SMB2 with 128 bit file handles possible metze (This used to be commit 287fc1c22d670f6e568014b420f7f4cb31dc7958) --- source4/smb_server/smb/service.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'source4/smb_server/smb/service.c') diff --git a/source4/smb_server/smb/service.c b/source4/smb_server/smb/service.c index 13ef268a98..7c703c8920 100644 --- a/source4/smb_server/smb/service.c +++ b/source4/smb_server/smb/service.c @@ -110,7 +110,19 @@ static NTSTATUS make_connection_snum(struct smbsrv_request *req, status = ntvfs_set_addr_callbacks(tcon->ntvfs, smbsrv_get_my_addr, smbsrv_get_peer_addr, req->smb_conn); if (!NT_STATUS_IS_OK(status)) { - DEBUG(0,("make_connection: NTVFS failed to set the oplock handler!\n")); + DEBUG(0,("make_connection: NTVFS failed to set the addr callbacks!\n")); + goto failed; + } + + status = ntvfs_set_handle_callbacks(tcon->ntvfs, + smbsrv_handle_create_new, + smbsrv_handle_make_valid, + smbsrv_handle_destroy, + smbsrv_handle_search_by_wire_key, + smbsrv_handle_get_wire_key, + tcon); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0,("make_connection: NTVFS failed to set the handle callbacks!\n")); goto failed; } -- cgit From 7930ae6a70dd80e93d593383eca028722ab90251 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 20 May 2006 12:15:05 +0000 Subject: r15747: move some functions to the protocol independend part of the smb server metze (This used to be commit 79af05551fe5f7b364c9f515ba4db54dd72907f8) --- source4/smb_server/smb/service.c | 43 +--------------------------------------- 1 file changed, 1 insertion(+), 42 deletions(-) (limited to 'source4/smb_server/smb/service.c') diff --git a/source4/smb_server/smb/service.c b/source4/smb_server/smb/service.c index 7c703c8920..176b954ac6 100644 --- a/source4/smb_server/smb/service.c +++ b/source4/smb_server/smb/service.c @@ -23,46 +23,6 @@ #include "smbd/service_stream.h" #include "ntvfs/ntvfs.h" - -/** - * Find a service entry. service is always in dos codepage. - * - * @param service is modified (to canonical form??) - **/ -static int find_service(const char *service) -{ - int iService; - - iService = lp_servicenumber(service); - - if (iService >= 0 && !lp_snum_ok(iService)) { - DEBUG(0,("Invalid snum %d for %s\n",iService, service)); - iService = -1; - } - - if (iService == -1) { - DEBUG(3,("find_service() failed to find service %s\n", service)); - } - - return iService; -} - -static struct socket_address *smbsrv_get_my_addr(void *p, TALLOC_CTX *mem_ctx) -{ - struct smbsrv_connection *smb_conn = talloc_get_type(p, - struct smbsrv_connection); - - return socket_get_my_addr(smb_conn->connection->socket, mem_ctx); -} - -static struct socket_address *smbsrv_get_peer_addr(void *p, TALLOC_CTX *mem_ctx) -{ - struct smbsrv_connection *smb_conn = talloc_get_type(p, - struct smbsrv_connection); - - return socket_get_peer_addr(smb_conn->connection->socket, mem_ctx); -} - /**************************************************************************** Make a connection, given the snum to connect to, and the vuser of the connecting user if appropriate. @@ -176,8 +136,7 @@ static NTSTATUS make_connection(struct smbsrv_request *req, } } - snum = find_service(service); - + snum = smbsrv_find_service(service); if (snum == -1) { DEBUG(0,("couldn't find service %s\n", service)); return NT_STATUS_BAD_NETWORK_NAME; -- cgit From e0dcbe8dd1d89670a2b4df0415b41b66b70fe487 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 21 May 2006 10:06:15 +0000 Subject: r15769: this functions belong to params/ so move it. metze (This used to be commit 9c4c40772bfd8a8324cd086c2234451d164be5d0) --- source4/smb_server/smb/service.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/smb_server/smb/service.c') diff --git a/source4/smb_server/smb/service.c b/source4/smb_server/smb/service.c index 176b954ac6..676f417619 100644 --- a/source4/smb_server/smb/service.c +++ b/source4/smb_server/smb/service.c @@ -136,7 +136,7 @@ static NTSTATUS make_connection(struct smbsrv_request *req, } } - snum = smbsrv_find_service(service); + snum = lp_find_valid_service(service); if (snum == -1) { DEBUG(0,("couldn't find service %s\n", service)); return NT_STATUS_BAD_NETWORK_NAME; -- cgit From 3b36a857980b1f9fa5a6be0253e85c975f35c13f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 11 Jul 2006 18:15:42 +0000 Subject: r16950: remove the smb mid from the ntvfs layer and keep a list of pending requests on the smbsrv_connection, to be able to match then on ntcancel metze (This used to be commit 04f0d3d03179b6060fd013b867d13caa92ec6460) --- source4/smb_server/smb/service.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/smb_server/smb/service.c') diff --git a/source4/smb_server/smb/service.c b/source4/smb_server/smb/service.c index 676f417619..92967d858c 100644 --- a/source4/smb_server/smb/service.c +++ b/source4/smb_server/smb/service.c @@ -89,7 +89,6 @@ static NTSTATUS make_connection_snum(struct smbsrv_request *req, req->ntvfs = ntvfs_request_create(req->tcon->ntvfs, req, req->session->session_info, SVAL(req->in.hdr,HDR_PID), - SVAL(req->in.hdr,HDR_MID), req->request_time, req, NULL, 0); if (!req->ntvfs) { -- cgit From 9c66f601f1520a99b9236c32bc9f03a33bd4b2aa Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 23 Jul 2006 18:43:07 +0000 Subject: r17206: Add a modular API for share configuration. Commit the classic backwards compatible module which is the default one (This used to be commit a89cc346b9296cb49929898d257a064a6c2bae86) --- source4/smb_server/smb/service.c | 57 ++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 28 deletions(-) (limited to 'source4/smb_server/smb/service.c') diff --git a/source4/smb_server/smb/service.c b/source4/smb_server/smb/service.c index 92967d858c..b396d2b605 100644 --- a/source4/smb_server/smb/service.c +++ b/source4/smb_server/smb/service.c @@ -27,22 +27,16 @@ Make a connection, given the snum to connect to, and the vuser of the connecting user if appropriate. ****************************************************************************/ -static NTSTATUS make_connection_snum(struct smbsrv_request *req, - int snum, enum ntvfs_type type, +static NTSTATUS make_connection_scfg(struct smbsrv_request *req, + struct share_config *scfg, + enum ntvfs_type type, DATA_BLOB password, const char *dev) { struct smbsrv_tcon *tcon; NTSTATUS status; - if (!socket_check_access(req->smb_conn->connection->socket, - lp_servicename(snum), - lp_hostsallow(snum), - lp_hostsdeny(snum))) { - return NT_STATUS_ACCESS_DENIED; - } - - tcon = smbsrv_smb_tcon_new(req->smb_conn, lp_servicename(snum)); + tcon = smbsrv_smb_tcon_new(req->smb_conn, scfg->name); if (!tcon) { DEBUG(0,("Couldn't find free connection.\n")); return NT_STATUS_INSUFFICIENT_RESOURCES; @@ -50,15 +44,15 @@ static NTSTATUS make_connection_snum(struct smbsrv_request *req, req->tcon = tcon; /* init ntvfs function pointers */ - status = ntvfs_init_connection(tcon, snum, type, + status = ntvfs_init_connection(tcon, scfg, 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(snum))); + DEBUG(0, ("make_connection_scfg: connection failed for service %s\n", + scfg->name)); goto failed; } @@ -97,7 +91,7 @@ static NTSTATUS make_connection_snum(struct smbsrv_request *req, } /* Invoke NTVFS connection hook */ - status = ntvfs_connect(req->ntvfs, lp_servicename(snum)); + status = ntvfs_connect(req->ntvfs, scfg->name); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("make_connection: NTVFS make connection failed!\n")); goto failed; @@ -120,11 +114,11 @@ static NTSTATUS make_connection(struct smbsrv_request *req, const char *service, DATA_BLOB password, const char *dev) { - int snum; + NTSTATUS status; enum ntvfs_type type; const char *type_str; - - /* TODO: check the password, when it's share level security! */ + struct share_config *scfg; + const char *sharetype; /* the service might be of the form \\SERVER\SHARE. Should we put the server name we get from this somewhere? */ @@ -135,17 +129,27 @@ static NTSTATUS make_connection(struct smbsrv_request *req, } } - snum = lp_find_valid_service(service); - if (snum == -1) { - DEBUG(0,("couldn't find service %s\n", service)); + status = share_get_config(req, req->smb_conn->share_context, service, &scfg); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0,("make_connection: couldn't find service %s\n", service)); return NT_STATUS_BAD_NETWORK_NAME; } + /* TODO: check the password, when it's share level security! */ + + if (!socket_check_access(req->smb_conn->connection->socket, + scfg->name, + share_string_list_option(req, scfg, SHARE_HOSTS_ALLOW), + share_string_list_option(req, scfg, SHARE_HOSTS_DENY))) { + return NT_STATUS_ACCESS_DENIED; + } + /* work out what sort of connection this is */ - if (strcmp(lp_fstype(snum), "IPC") == 0) { + sharetype = share_string_option(scfg, "type", "DISK"); + if (sharetype && strcmp(sharetype, "IPC") == 0) { type = NTVFS_IPC; type_str = "IPC"; - } else if (lp_print_ok(snum)) { + } else if (sharetype && strcmp(sharetype, "PRINTER") == 0) { type = NTVFS_PRINT; type_str = "LPT:"; } else { @@ -158,7 +162,7 @@ static NTSTATUS make_connection(struct smbsrv_request *req, return NT_STATUS_BAD_DEVICE_TYPE; } - return make_connection_snum(req, snum, type, password, dev); + return make_connection_scfg(req, scfg, type, password, dev); } /* @@ -167,7 +171,6 @@ static NTSTATUS make_connection(struct smbsrv_request *req, NTSTATUS smbsrv_tcon_backend(struct smbsrv_request *req, union smb_tcon *con) { NTSTATUS status; - int snum; if (con->generic.level == RAW_TCON_TCON) { DATA_BLOB password; @@ -191,13 +194,11 @@ 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->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_SUPPORT_SEARCH_BITS | (share_int_option(req->tcon->ntvfs->config, SHARE_CSC_POLICY, SHARE_CSC_POLICY_DEFAULT) << 2); + if (share_bool_option(req->tcon->ntvfs->config, SHARE_MSDFS_ROOT, SHARE_MSDFS_ROOT_DEFAULT) && lp_host_msdfs()) { con->tconx.out.options |= SMB_SHARE_IN_DFS; } -- cgit From c13a4084f217cdda8d24851acdbd86dce9a76fea Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 19 Apr 2007 16:50:16 +0000 Subject: r22381: fix memory leak metze (This used to be commit 4bfe900d1b4bd037ce0115cf34761066f667beb6) --- source4/smb_server/smb/service.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/smb_server/smb/service.c') diff --git a/source4/smb_server/smb/service.c b/source4/smb_server/smb/service.c index b396d2b605..39caf3789c 100644 --- a/source4/smb_server/smb/service.c +++ b/source4/smb_server/smb/service.c @@ -174,7 +174,7 @@ NTSTATUS smbsrv_tcon_backend(struct smbsrv_request *req, union smb_tcon *con) if (con->generic.level == RAW_TCON_TCON) { DATA_BLOB password; - password = data_blob(con->tcon.in.password, strlen(con->tcon.in.password) + 1); + password = data_blob_string_const(con->tcon.in.password); status = make_connection(req, con->tcon.in.service, password, con->tcon.in.dev); -- cgit From 0479a2f1cbae51fcd8dbdc3c148c808421fb4d25 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:07:03 +0000 Subject: r23792: convert Samba4 to GPLv3 There are still a few tidyups of old FSF addresses to come (in both s3 and s4). More commits soon. (This used to be commit fcf38a38ac691abd0fa51b89dc951a08e89fdafa) --- source4/smb_server/smb/service.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/smb_server/smb/service.c') diff --git a/source4/smb_server/smb/service.c b/source4/smb_server/smb/service.c index 39caf3789c..c646df20b8 100644 --- a/source4/smb_server/smb/service.c +++ b/source4/smb_server/smb/service.c @@ -5,7 +5,7 @@ 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, @@ -14,8 +14,7 @@ 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 . */ #include "includes.h" -- cgit From 113587b823fba2f48b22da03e036771f6ecf6611 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 16 Aug 2007 14:45:46 +0000 Subject: r24494: add comment to remind me to look at the flags on a tconx metze (This used to be commit deefefeadfc4c5c3448ac378e1910fb75df0dc77) --- source4/smb_server/smb/service.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/smb_server/smb/service.c') diff --git a/source4/smb_server/smb/service.c b/source4/smb_server/smb/service.c index c646df20b8..c159eb3b88 100644 --- a/source4/smb_server/smb/service.c +++ b/source4/smb_server/smb/service.c @@ -187,6 +187,8 @@ NTSTATUS smbsrv_tcon_backend(struct smbsrv_request *req, union smb_tcon *con) return status; } + /* TODO: take a look at tconx.in.flags! */ + status = make_connection(req, con->tconx.in.path, con->tconx.in.password, con->tconx.in.device); if (!NT_STATUS_IS_OK(status)) { -- cgit From ffeee68e4b72dd94fee57366bd8d38b8c284c3d4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 8 Sep 2007 12:42:09 +0000 Subject: r25026: Move param/param.h out of includes.h (This used to be commit abe8349f9b4387961ff3665d8c589d61cd2edf31) --- source4/smb_server/smb/service.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/smb_server/smb/service.c') diff --git a/source4/smb_server/smb/service.c b/source4/smb_server/smb/service.c index c159eb3b88..8a99223d8b 100644 --- a/source4/smb_server/smb/service.c +++ b/source4/smb_server/smb/service.c @@ -21,6 +21,8 @@ #include "smb_server/smb_server.h" #include "smbd/service_stream.h" #include "ntvfs/ntvfs.h" +#include "param/share.h" +#include "param/param.h" /**************************************************************************** Make a connection, given the snum to connect to, and the vuser of the -- cgit From 37d53832a4623653f706e77985a79d84bd7c6694 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 28 Sep 2007 01:17:46 +0000 Subject: r25398: Parse loadparm context to all lp_*() functions. (This used to be commit 3fcc960839c6e5ca4de2c3c042f12f369ac5f238) --- source4/smb_server/smb/service.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/smb_server/smb/service.c') diff --git a/source4/smb_server/smb/service.c b/source4/smb_server/smb/service.c index 8a99223d8b..558f30307b 100644 --- a/source4/smb_server/smb/service.c +++ b/source4/smb_server/smb/service.c @@ -201,7 +201,7 @@ NTSTATUS smbsrv_tcon_backend(struct smbsrv_request *req, union smb_tcon *con) 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 | (share_int_option(req->tcon->ntvfs->config, SHARE_CSC_POLICY, SHARE_CSC_POLICY_DEFAULT) << 2); - if (share_bool_option(req->tcon->ntvfs->config, SHARE_MSDFS_ROOT, SHARE_MSDFS_ROOT_DEFAULT) && lp_host_msdfs()) { + if (share_bool_option(req->tcon->ntvfs->config, SHARE_MSDFS_ROOT, SHARE_MSDFS_ROOT_DEFAULT) && lp_host_msdfs(global_loadparm)) { con->tconx.out.options |= SMB_SHARE_IN_DFS; } -- cgit From b83a7a135f3247f553cb04173646b2d871b97235 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 3 Dec 2007 21:25:17 +0100 Subject: r26268: Avoid more use of global_loadparm - put lp_ctx in smb_server and wbsrv_connection. (This used to be commit 7c008664238ed966cb82adf5b25b22157bb50730) --- source4/smb_server/smb/service.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/smb_server/smb/service.c') diff --git a/source4/smb_server/smb/service.c b/source4/smb_server/smb/service.c index 558f30307b..0e602f6a8b 100644 --- a/source4/smb_server/smb/service.c +++ b/source4/smb_server/smb/service.c @@ -201,7 +201,7 @@ NTSTATUS smbsrv_tcon_backend(struct smbsrv_request *req, union smb_tcon *con) 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 | (share_int_option(req->tcon->ntvfs->config, SHARE_CSC_POLICY, SHARE_CSC_POLICY_DEFAULT) << 2); - if (share_bool_option(req->tcon->ntvfs->config, SHARE_MSDFS_ROOT, SHARE_MSDFS_ROOT_DEFAULT) && lp_host_msdfs(global_loadparm)) { + if (share_bool_option(req->tcon->ntvfs->config, SHARE_MSDFS_ROOT, SHARE_MSDFS_ROOT_DEFAULT) && lp_host_msdfs(req->smb_conn->lp_ctx)) { con->tconx.out.options |= SMB_SHARE_IN_DFS; } -- cgit From a72c5053c587f0ed6113ef514fe3739cb81e7abf Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 8 Dec 2007 23:32:43 +0100 Subject: r26353: Remove use of global_loadparm. (This used to be commit 17637e4490e42db6cdef619286c4d5a0982e9d1a) --- source4/smb_server/smb/service.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/smb_server/smb/service.c') diff --git a/source4/smb_server/smb/service.c b/source4/smb_server/smb/service.c index 0e602f6a8b..467cbca418 100644 --- a/source4/smb_server/smb/service.c +++ b/source4/smb_server/smb/service.c @@ -49,6 +49,7 @@ static NTSTATUS make_connection_scfg(struct smbsrv_request *req, req->smb_conn->negotiate.protocol, req->smb_conn->connection->event.ctx, req->smb_conn->connection->msg_ctx, + global_loadparm, req->smb_conn->connection->server_id, &tcon->ntvfs); if (!NT_STATUS_IS_OK(status)) { -- cgit From b65dba2245bf382c47d65c95ac9b1efa43918fc0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 10 Dec 2007 04:33:16 +0100 Subject: r26355: Eliminate global_loadparm in more places. (This used to be commit 5d589a0d94bd76a9b4c9fc748854e8098ea43c4d) --- source4/smb_server/smb/service.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/smb_server/smb/service.c') diff --git a/source4/smb_server/smb/service.c b/source4/smb_server/smb/service.c index 467cbca418..35b3653026 100644 --- a/source4/smb_server/smb/service.c +++ b/source4/smb_server/smb/service.c @@ -49,7 +49,7 @@ static NTSTATUS make_connection_scfg(struct smbsrv_request *req, req->smb_conn->negotiate.protocol, req->smb_conn->connection->event.ctx, req->smb_conn->connection->msg_ctx, - global_loadparm, + req->smb_conn->lp_ctx, req->smb_conn->connection->server_id, &tcon->ntvfs); if (!NT_STATUS_IS_OK(status)) { -- cgit From 87f2925252b910f2f403bdbb3f9158202cb7a2c5 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 6 Mar 2008 15:14:08 +0100 Subject: ntvfs: pass down the client capabilities into the ntvfs layer Note that we don't use any protocol specific values here. For now only NTVFS_CLIENT_CAP_LEVEL_II_OPLOCKS is defined others should be defined, when we find out that the ntvfs layer needs to know about it. metze (This used to be commit cc42cd5f6753ca582677fa6f403f0419eec5ab10) --- source4/smb_server/smb/service.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source4/smb_server/smb/service.c') diff --git a/source4/smb_server/smb/service.c b/source4/smb_server/smb/service.c index 35b3653026..52471c09c9 100644 --- a/source4/smb_server/smb/service.c +++ b/source4/smb_server/smb/service.c @@ -36,6 +36,7 @@ static NTSTATUS make_connection_scfg(struct smbsrv_request *req, { struct smbsrv_tcon *tcon; NTSTATUS status; + uint64_t ntvfs_caps = 0; tcon = smbsrv_smb_tcon_new(req->smb_conn, scfg->name); if (!tcon) { @@ -44,9 +45,14 @@ static NTSTATUS make_connection_scfg(struct smbsrv_request *req, } req->tcon = tcon; + if (req->smb_conn->negotiate.client_caps & CAP_LEVEL_II_OPLOCKS) { + ntvfs_caps |= NTVFS_CLIENT_CAP_LEVEL_II_OPLOCKS; + } + /* init ntvfs function pointers */ status = ntvfs_init_connection(tcon, scfg, type, req->smb_conn->negotiate.protocol, + ntvfs_caps, req->smb_conn->connection->event.ctx, req->smb_conn->connection->msg_ctx, req->smb_conn->lp_ctx, -- cgit