From 910d61bcd1fbfc6fc406d4384f305f5210e92d56 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 18 Nov 2005 14:13:49 +0000 Subject: r11789: - add the start of a SMB2 server - it does Negprot and SessionSetup yet the rest returns NT_STATUS_NOT_IMPLEMENTED - it's off by default, enable with: smbsrv:enable smb2 = yes - negotition in the SMB Negprot isn't supported yet - it's only tested with smbtorture SMB2-CONNECT not with vista as client metze (This used to be commit 08b31d5f618d2e416cb9812ad3a49754cd7212b8) --- source4/smb_server/smb2/tcon.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 source4/smb_server/smb2/tcon.c (limited to 'source4/smb_server/smb2/tcon.c') diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c new file mode 100644 index 0000000000..af9632eadc --- /dev/null +++ b/source4/smb_server/smb2/tcon.c @@ -0,0 +1,34 @@ +/* + Unix SMB2 implementation. + + Copyright (C) Stefan Metzmacher 2005 + + 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 "libcli/smb2/smb2.h" +#include "libcli/smb2/smb2_calls.h" +#include "smb_server/smb2/smb2_server.h" + +void smb2srv_tcon_recv(struct smb2srv_request *req) +{ + smb2srv_send_error(req, NT_STATUS_NOT_IMPLEMENTED); +} + +void smb2srv_tdis_recv(struct smb2srv_request *req) +{ + smb2srv_send_error(req, NT_STATUS_NOT_IMPLEMENTED); +} -- cgit From 05bfa9ad863d6d7afc20ff3f76816750afcac64b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 6 Dec 2005 14:14:43 +0000 Subject: r12094: - implement dummy smb2srv_tcon() - implement smb2srv_tdis() metze (This used to be commit cb9ddf7997731a4ad21f274fcb2e713614b382ef) --- source4/smb_server/smb2/tcon.c | 124 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 122 insertions(+), 2 deletions(-) (limited to 'source4/smb_server/smb2/tcon.c') diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c index af9632eadc..fb84aa6fdc 100644 --- a/source4/smb_server/smb2/tcon.c +++ b/source4/smb_server/smb2/tcon.c @@ -21,14 +21,134 @@ #include "includes.h" #include "libcli/smb2/smb2.h" #include "libcli/smb2/smb2_calls.h" +#include "smb_server/smb_server.h" #include "smb_server/smb2/smb2_server.h" +static NTSTATUS smb2srv_tcon_backend(struct smb2srv_request *req, struct smb2_tree_connect *io) +{ + struct smbsrv_tcon *tcon; + + tcon = smbsrv_tcon_new(req->smb_conn); + NT_STATUS_HAVE_NO_MEMORY(tcon); + + /* TODO: do real tree connect */ + + io->out.unknown1 = 0; + io->out.unknown2 = 0; + io->out.unknown3 = 0; + io->out.access_mask = 0; + + io->out.tid = tcon->tid; + + req->tcon = tcon; + return NT_STATUS_OK; +} + +static void smb2srv_tcon_send(struct smb2srv_request *req, struct smb2_tree_connect *io) +{ + NTSTATUS status; + + if (NT_STATUS_IS_ERR(req->status)) { + smb2srv_send_error(req, req->status); + return; + } + + status = smb2srv_setup_reply(req, 0x10, 0); + if (!NT_STATUS_IS_OK(status)) { + smbsrv_terminate_connection(req->smb_conn, nt_errstr(status)); + talloc_free(req); + return; + } + + SBVAL(req->out.hdr, SMB2_HDR_TID, io->out.tid); + + SSVAL(req->out.body, 0x02, io->out.unknown1); + SIVAL(req->out.body, 0x04, io->out.unknown2); + SIVAL(req->out.body, 0x08, io->out.unknown3); + SIVAL(req->out.body, 0x0C, io->out.access_mask); + + smb2srv_send_reply(req); +} + void smb2srv_tcon_recv(struct smb2srv_request *req) { - smb2srv_send_error(req, NT_STATUS_NOT_IMPLEMENTED); + struct smb2_tree_connect *io; + NTSTATUS status; + + if (req->in.body_size < 0x08) { + smb2srv_send_error(req, NT_STATUS_FOOBAR); + return; + } + + io = talloc(req, struct smb2_tree_connect); + if (!io) { + smbsrv_terminate_connection(req->smb_conn, nt_errstr(NT_STATUS_NO_MEMORY)); + talloc_free(req); + return; + } + + io->in.unknown1 = SVAL(req->in.body, 0x02); + status = smb2_pull_o16s16_string(&req->in, io, req->in.body+0x04, &io->in.path); + if (!NT_STATUS_IS_OK(status)) { + smbsrv_terminate_connection(req->smb_conn, nt_errstr(status)); + talloc_free(req); + return; + } + + req->status = smb2srv_tcon_backend(req, io); + + if (req->control_flags & SMB2SRV_REQ_CTRL_FLAG_NOT_REPLY) { + talloc_free(req); + return; + } + smb2srv_tcon_send(req, io); +} + +static NTSTATUS smb2srv_tdis_backend(struct smb2srv_request *req) +{ + /* TODO: call ntvfs backends to close file of this tcon */ + talloc_free(req->tcon); + req->tcon = NULL; + return NT_STATUS_OK; +} + +static void smb2srv_tdis_send(struct smb2srv_request *req) +{ + NTSTATUS status; + + if (NT_STATUS_IS_ERR(req->status)) { + smb2srv_send_error(req, req->status); + return; + } + + status = smb2srv_setup_reply(req, 0x04, 0); + if (!NT_STATUS_IS_OK(status)) { + smbsrv_terminate_connection(req->smb_conn, nt_errstr(status)); + talloc_free(req); + return; + } + + SSVAL(req->out.body, 0x02, 0); + + smb2srv_send_reply(req); } void smb2srv_tdis_recv(struct smb2srv_request *req) { - smb2srv_send_error(req, NT_STATUS_NOT_IMPLEMENTED); + uint16_t _pad; + + if (req->in.body_size < 0x04) { + smb2srv_send_error(req, NT_STATUS_FOOBAR); + return; + } + + _pad = SVAL(req->in.body, 0x02); + + req->status = smb2srv_tdis_backend(req); + + if (req->control_flags & SMB2SRV_REQ_CTRL_FLAG_NOT_REPLY) { + talloc_free(req); + return; + } + smb2srv_tdis_send(req); } -- 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/smb2/tcon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/smb_server/smb2/tcon.c') diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c index fb84aa6fdc..9fb2a03ce3 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_tcon_new(req->smb_conn); + tcon = smbsrv_smb2_tcon_new(req->session); NT_STATUS_HAVE_NO_MEMORY(tcon); /* TODO: do real tree connect */ -- 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/smb2/tcon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/smb_server/smb2/tcon.c') diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c index 9fb2a03ce3..836c13a019 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 */ -- cgit From bc141c795767cc765731c607f1fb047811da6e03 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 28 Apr 2006 01:55:17 +0000 Subject: r15304: Fix smbd build, more updates on getting --enable-dso to build again (This used to be commit 3ef9326386ba1c210166302cbcf02d2ed3f19944) --- source4/smb_server/smb2/tcon.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/smb_server/smb2/tcon.c') diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c index 836c13a019..8d6c002d50 100644 --- a/source4/smb_server/smb2/tcon.c +++ b/source4/smb_server/smb2/tcon.c @@ -22,6 +22,7 @@ #include "libcli/smb2/smb2.h" #include "libcli/smb2/smb2_calls.h" #include "smb_server/smb_server.h" +#include "smb_server/service_smb_proto.h" #include "smb_server/smb2/smb2_server.h" static NTSTATUS smb2srv_tcon_backend(struct smb2srv_request *req, struct smb2_tree_connect *io) -- cgit From dc86ab3e454d7219608d01879145dec5609acaa3 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 11 May 2006 10:47:37 +0000 Subject: r15532: add a BOOL body_dynamic_present, because the body_dynamic_size can be 0 also if the dynamic flag should be set metze (This used to be commit 7829100e1ee79f4f5d24004af221288e19c09b3e) --- source4/smb_server/smb2/tcon.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/smb_server/smb2/tcon.c') diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c index 8d6c002d50..ba7758b362 100644 --- a/source4/smb_server/smb2/tcon.c +++ b/source4/smb_server/smb2/tcon.c @@ -54,7 +54,7 @@ static void smb2srv_tcon_send(struct smb2srv_request *req, struct smb2_tree_conn return; } - status = smb2srv_setup_reply(req, 0x10, 0); + status = smb2srv_setup_reply(req, 0x10, False, 0); if (!NT_STATUS_IS_OK(status)) { smbsrv_terminate_connection(req->smb_conn, nt_errstr(status)); talloc_free(req); @@ -122,7 +122,7 @@ static void smb2srv_tdis_send(struct smb2srv_request *req) return; } - status = smb2srv_setup_reply(req, 0x04, 0); + status = smb2srv_setup_reply(req, 0x04, False, 0); if (!NT_STATUS_IS_OK(status)) { smbsrv_terminate_connection(req->smb_conn, nt_errstr(status)); talloc_free(req); -- cgit From bd6dd99eb92be69fd90457f5976b9f597c2d52c3 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 11 May 2006 11:01:47 +0000 Subject: r15533: with this vista does a fine SMB2 TreeConnect against samba4 metze (This used to be commit 6c920d21a16e88040818cc8db6ebe918b5669a9b) --- source4/smb_server/smb2/tcon.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/smb_server/smb2/tcon.c') diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c index ba7758b362..b8daee8ff2 100644 --- a/source4/smb_server/smb2/tcon.c +++ b/source4/smb_server/smb2/tcon.c @@ -34,10 +34,10 @@ static NTSTATUS smb2srv_tcon_backend(struct smb2srv_request *req, struct smb2_tr /* TODO: do real tree connect */ - io->out.unknown1 = 0; - io->out.unknown2 = 0; - io->out.unknown3 = 0; - io->out.access_mask = 0; + io->out.unknown1 = 0x0001; /* 1 - DISK, 2 - Print, 3 - IPC */ + io->out.unknown2 = 0x00000000; + io->out.unknown3 = 0x00000000; + io->out.access_mask = SEC_RIGHTS_FILE_ALL; io->out.tid = tcon->tid; -- cgit From 5761c59ef7733d006ff8051ab3592a1596192800 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 11 May 2006 18:32:34 +0000 Subject: r15535: fix the build metze (This used to be commit 297868325f305c652b14023a698099d5b358d70a) --- source4/smb_server/smb2/tcon.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/smb_server/smb2/tcon.c') diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c index b8daee8ff2..da5b22f3bc 100644 --- a/source4/smb_server/smb2/tcon.c +++ b/source4/smb_server/smb2/tcon.c @@ -24,6 +24,7 @@ #include "smb_server/smb_server.h" #include "smb_server/service_smb_proto.h" #include "smb_server/smb2/smb2_server.h" +#include "librpc/gen_ndr/security.h" static NTSTATUS smb2srv_tcon_backend(struct smb2srv_request *req, struct smb2_tree_connect *io) { -- cgit From 44dc58fe168dc4315d7dadf1029de821f2bb0c09 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 20 May 2006 11:03:51 +0000 Subject: r15743: use union smb_tcon metze (This used to be commit 012a08cfb9d550a47bed49b18335a038ae19605c) --- source4/smb_server/smb2/tcon.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'source4/smb_server/smb2/tcon.c') diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c index da5b22f3bc..50c62109d9 100644 --- a/source4/smb_server/smb2/tcon.c +++ b/source4/smb_server/smb2/tcon.c @@ -26,7 +26,7 @@ #include "smb_server/smb2/smb2_server.h" #include "librpc/gen_ndr/security.h" -static NTSTATUS smb2srv_tcon_backend(struct smb2srv_request *req, struct smb2_tree_connect *io) +static NTSTATUS smb2srv_tcon_backend(struct smb2srv_request *req, union smb_tcon *io) { struct smbsrv_tcon *tcon; @@ -35,18 +35,18 @@ static NTSTATUS smb2srv_tcon_backend(struct smb2srv_request *req, struct smb2_tr /* TODO: do real tree connect */ - io->out.unknown1 = 0x0001; /* 1 - DISK, 2 - Print, 3 - IPC */ - io->out.unknown2 = 0x00000000; - io->out.unknown3 = 0x00000000; - io->out.access_mask = SEC_RIGHTS_FILE_ALL; + io->smb2.out.unknown1 = 0x0001; /* 1 - DISK, 2 - Print, 3 - IPC */ + io->smb2.out.unknown2 = 0x00000000; + io->smb2.out.unknown3 = 0x00000000; + io->smb2.out.access_mask= SEC_RIGHTS_FILE_ALL; - io->out.tid = tcon->tid; + io->smb2.out.tid = tcon->tid; req->tcon = tcon; return NT_STATUS_OK; } -static void smb2srv_tcon_send(struct smb2srv_request *req, struct smb2_tree_connect *io) +static void smb2srv_tcon_send(struct smb2srv_request *req, union smb_tcon *io) { NTSTATUS status; @@ -62,19 +62,19 @@ static void smb2srv_tcon_send(struct smb2srv_request *req, struct smb2_tree_conn return; } - SBVAL(req->out.hdr, SMB2_HDR_TID, io->out.tid); + SBVAL(req->out.hdr, SMB2_HDR_TID, io->smb2.out.tid); - SSVAL(req->out.body, 0x02, io->out.unknown1); - SIVAL(req->out.body, 0x04, io->out.unknown2); - SIVAL(req->out.body, 0x08, io->out.unknown3); - SIVAL(req->out.body, 0x0C, io->out.access_mask); + SSVAL(req->out.body, 0x02, io->smb2.out.unknown1); + SIVAL(req->out.body, 0x04, io->smb2.out.unknown2); + SIVAL(req->out.body, 0x08, io->smb2.out.unknown3); + SIVAL(req->out.body, 0x0C, io->smb2.out.access_mask); smb2srv_send_reply(req); } void smb2srv_tcon_recv(struct smb2srv_request *req) { - struct smb2_tree_connect *io; + union smb_tcon *io; NTSTATUS status; if (req->in.body_size < 0x08) { @@ -82,15 +82,16 @@ void smb2srv_tcon_recv(struct smb2srv_request *req) return; } - io = talloc(req, struct smb2_tree_connect); + io = talloc(req, union smb_tcon); if (!io) { smbsrv_terminate_connection(req->smb_conn, nt_errstr(NT_STATUS_NO_MEMORY)); talloc_free(req); return; } - io->in.unknown1 = SVAL(req->in.body, 0x02); - status = smb2_pull_o16s16_string(&req->in, io, req->in.body+0x04, &io->in.path); + io->smb2.level = RAW_TCON_SMB2; + io->smb2.in.unknown1 = SVAL(req->in.body, 0x02); + status = smb2_pull_o16s16_string(&req->in, io, req->in.body+0x04, &io->smb2.in.path); if (!NT_STATUS_IS_OK(status)) { smbsrv_terminate_connection(req->smb_conn, nt_errstr(status)); talloc_free(req); -- cgit From 7442613a53f5a226429a76e2f7bad6db5032418e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 20 May 2006 12:25:45 +0000 Subject: r15748: - implement SMB2 TreeConnect server code TODO: pass in oplock and handle callbacks, but as we don't do file access yet, it's no problem to skip them metze (This used to be commit 4ae4a742fc2e40b2937d9ce01f2e45f43f7ff1c3) --- source4/smb_server/smb2/tcon.c | 110 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 105 insertions(+), 5 deletions(-) (limited to 'source4/smb_server/smb2/tcon.c') diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c index 50c62109d9..85ebc33f5d 100644 --- a/source4/smb_server/smb2/tcon.c +++ b/source4/smb_server/smb2/tcon.c @@ -25,25 +25,125 @@ #include "smb_server/service_smb_proto.h" #include "smb_server/smb2/smb2_server.h" #include "librpc/gen_ndr/security.h" +#include "smbd/service_stream.h" +#include "ntvfs/ntvfs.h" static NTSTATUS smb2srv_tcon_backend(struct smb2srv_request *req, union smb_tcon *io) { struct smbsrv_tcon *tcon; + NTSTATUS status; + enum ntvfs_type type; + uint16_t type_smb2; + int snum; + const char *service = io->smb2.in.path; + + if (strncmp(service, "\\\\", 2) == 0) { + const char *p = strchr(service+2, '\\'); + if (p) { + service = p + 1; + } + } + + snum = smbsrv_find_service(service); + if (snum == -1) { + DEBUG(0,("smb2srv_tcon_backend: couldn't find service %s\n", service)); + return NT_STATUS_BAD_NETWORK_NAME; + } + + if (!socket_check_access(req->smb_conn->connection->socket, + lp_servicename(snum), + lp_hostsallow(snum), + lp_hostsdeny(snum))) { + return NT_STATUS_ACCESS_DENIED; + } + + /* work out what sort of connection this is */ + if (strcmp(lp_fstype(snum), "IPC") == 0) { + type = NTVFS_IPC; + type_smb2 = 0x0003; + } else if (lp_print_ok(snum)) { + type = NTVFS_PRINT; + type_smb2 = 0x0002; + } else { + type = NTVFS_DISK; + type_smb2 = 0x0001; + } + + tcon = smbsrv_smb2_tcon_new(req->session, lp_servicename(snum)); + if (!tcon) { + DEBUG(0,("smb2srv_tcon_backend: Couldn't find free connection.\n")); + return NT_STATUS_INSUFFICIENT_RESOURCES; + } + req->tcon = tcon; + + /* init ntvfs function pointers */ + 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, ("smb2srv_tcon_backend: ntvfs_init_connection failed for service %s\n", + lp_servicename(snum))); + goto failed; + } - tcon = smbsrv_smb2_tcon_new(req->session, "fake"); - NT_STATUS_HAVE_NO_MEMORY(tcon); +/* status = ntvfs_set_oplock_handler(tcon->ntvfs, smb2srv_send_oplock_break, tcon); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0,("smb2srv_tcon_backend: NTVFS failed to set the oplock handler!\n")); + 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,("smb2srv_tcon_backend: NTVFS failed to set the addr callbacks!\n")); + goto failed; + } - /* TODO: do real tree connect */ +/* status = ntvfs_set_handle_callbacks(tcon->ntvfs, + smb2srv_handle_create_new, + smb2srv_handle_make_valid, + smb2srv_handle_destroy, + smb2srv_handle_search_by_wire_key, + smb2srv_handle_get_wire_key, + tcon); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0,("smb2srv_tcon_backend: NTVFS failed to set the handle callbacks!\n")); + goto failed; + } +*/ + req->ntvfs = ntvfs_request_create(req->tcon->ntvfs, req, + req->session->session_info, + 0, /* TODO: fill in PID */ + 0, /* TODO: fill in 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->ntvfs, lp_servicename(snum)); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0,("smb2srv_tcon_backend: NTVFS ntvfs_connect() failed!\n")); + goto failed; + } - io->smb2.out.unknown1 = 0x0001; /* 1 - DISK, 2 - Print, 3 - IPC */ + io->smb2.out.unknown1 = type_smb2; /* 1 - DISK, 2 - Print, 3 - IPC */ io->smb2.out.unknown2 = 0x00000000; io->smb2.out.unknown3 = 0x00000000; io->smb2.out.access_mask= SEC_RIGHTS_FILE_ALL; io->smb2.out.tid = tcon->tid; - req->tcon = tcon; return NT_STATUS_OK; + +failed: + req->tcon = NULL; + talloc_free(tcon); + return status; } static void smb2srv_tcon_send(struct smb2srv_request *req, union smb_tcon *io) -- cgit From 476a6253a6cad266248461d0b483278ecc5bb584 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 20 May 2006 12:54:55 +0000 Subject: r15749: - pass in a dummy oplock callback - pass in SMB2 ntvfs_handle callbacks metze (This used to be commit 338aee88d4ba3b25b473a456e55dd7ff5c1a4c5d) --- source4/smb_server/smb2/tcon.c | 122 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 118 insertions(+), 4 deletions(-) (limited to 'source4/smb_server/smb2/tcon.c') diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c index 85ebc33f5d..2c135e0add 100644 --- a/source4/smb_server/smb2/tcon.c +++ b/source4/smb_server/smb2/tcon.c @@ -28,6 +28,120 @@ #include "smbd/service_stream.h" #include "ntvfs/ntvfs.h" +/* + send an oplock break request to a client +*/ +static NTSTATUS smb2srv_send_oplock_break(void *p, struct ntvfs_handle *ntvfs, uint8_t level) +{ + DEBUG(0,("TODO: we don't pass SMB2 oplock breaks to the Clients yet!\n")); + return NT_STATUS_OK; +} + +struct ntvfs_handle *smb2srv_pull_handle(struct smb2srv_request *req, const uint8_t *base, uint_t offset) +{ + struct smbsrv_tcon *tcon; + struct smbsrv_handle *handle; + uint64_t hid; + uint32_t tid; + uint32_t pad; + + hid = BVAL(base, offset); + tid = IVAL(base, offset + 8); + pad = IVAL(base, offset + 12); + + if (pad != 0xFFFFFFFF) { + return NULL; + } + +/* TODO: add comments */ + tcon = req->tcon; + if (tid != req->tcon->tid) { + tcon = smbsrv_smb2_tcon_find(req->session, tid, req->request_time); + } + + handle = smbsrv_smb_handle_find(tcon, hid, req->request_time); + if (!handle) { + return NULL; + } + + req->tcon = tcon; + return handle->ntvfs; +} + +void smb2srv_push_handle(uint8_t *base, uint_t offset, struct ntvfs_handle *ntvfs) +{ + struct smbsrv_handle *handle = talloc_get_type(ntvfs->frontend_data.private_data, + struct smbsrv_handle); + + /* + * the handle is 128 bit on the wire + */ + SBVAL(base, offset, handle->hid); + SIVAL(base, offset + 8, handle->tcon->tid); + SIVAL(base, offset + 12,0xFFFFFFFF); +} + +static NTSTATUS smb2srv_handle_create_new(void *private_data, struct ntvfs_request *ntvfs, struct ntvfs_handle **_h) +{ + struct smbsrv_request *req = talloc_get_type(ntvfs->frontend_data.private_data, + struct smbsrv_request); + struct smbsrv_handle *handle; + struct ntvfs_handle *h; + + handle = smbsrv_handle_new(req); + if (!handle) return NT_STATUS_INSUFFICIENT_RESOURCES; + + h = talloc_zero(handle, struct ntvfs_handle); + if (!h) goto nomem; + + /* + * note: we don't set handle->ntvfs yet, + * this will be done by smbsrv_handle_make_valid() + * this makes sure the handle is invalid for clients + * until the ntvfs subsystem has made it valid + */ + h->ctx = ntvfs->ctx; + h->session_info = ntvfs->session_info; + h->smbpid = ntvfs->smbpid; + + h->frontend_data.private_data = handle; + + *_h = h; + return NT_STATUS_OK; +nomem: + talloc_free(handle); + return NT_STATUS_NO_MEMORY; +} + +static NTSTATUS smb2srv_handle_make_valid(void *private_data, struct ntvfs_handle *h) +{ + struct smbsrv_tcon *tcon = talloc_get_type(private_data, struct smbsrv_tcon); + struct smbsrv_handle *handle = talloc_get_type(h->frontend_data.private_data, + struct smbsrv_handle); + /* this tells the frontend that the handle is valid */ + handle->ntvfs = h; + /* this moves the smbsrv_request to the smbsrv_tcon memory context */ + talloc_steal(tcon, handle); + return NT_STATUS_OK; +} + +static void smb2srv_handle_destroy(void *private_data, struct ntvfs_handle *h) +{ + struct smbsrv_handle *handle = talloc_get_type(h->frontend_data.private_data, + struct smbsrv_handle); + talloc_free(handle); +} + +static struct ntvfs_handle *smb2srv_handle_search_by_wire_key(void *private_data, struct ntvfs_request *ntvfs, const DATA_BLOB *key) +{ + return NULL; +} + +static DATA_BLOB smb2srv_handle_get_wire_key(void *private_data, struct ntvfs_handle *handle, TALLOC_CTX *mem_ctx) +{ + return data_blob(NULL, 0); +} + static NTSTATUS smb2srv_tcon_backend(struct smb2srv_request *req, union smb_tcon *io) { struct smbsrv_tcon *tcon; @@ -89,19 +203,19 @@ static NTSTATUS smb2srv_tcon_backend(struct smb2srv_request *req, union smb_tcon goto failed; } -/* status = ntvfs_set_oplock_handler(tcon->ntvfs, smb2srv_send_oplock_break, tcon); + status = ntvfs_set_oplock_handler(tcon->ntvfs, smb2srv_send_oplock_break, tcon); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("smb2srv_tcon_backend: NTVFS failed to set the oplock handler!\n")); 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,("smb2srv_tcon_backend: NTVFS failed to set the addr callbacks!\n")); goto failed; } -/* status = ntvfs_set_handle_callbacks(tcon->ntvfs, + status = ntvfs_set_handle_callbacks(tcon->ntvfs, smb2srv_handle_create_new, smb2srv_handle_make_valid, smb2srv_handle_destroy, @@ -112,7 +226,7 @@ static NTSTATUS smb2srv_tcon_backend(struct smb2srv_request *req, union smb_tcon DEBUG(0,("smb2srv_tcon_backend: NTVFS failed to set the handle callbacks!\n")); goto failed; } -*/ + req->ntvfs = ntvfs_request_create(req->tcon->ntvfs, req, req->session->session_info, 0, /* TODO: fill in PID */ -- cgit From 3cb64219e2cd492d25931f5442cbd484d6930950 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 20 May 2006 16:48:29 +0000 Subject: r15751: thanks to talloc_get_type() I noticed that I used smbsrv_request in the smb2srv code metze (This used to be commit 6c304a1a5f5dc6b2d3774682303874444a59b07d) --- source4/smb_server/smb2/tcon.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/smb_server/smb2/tcon.c') diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c index 2c135e0add..bfb3904d47 100644 --- a/source4/smb_server/smb2/tcon.c +++ b/source4/smb_server/smb2/tcon.c @@ -59,7 +59,7 @@ struct ntvfs_handle *smb2srv_pull_handle(struct smb2srv_request *req, const uint tcon = smbsrv_smb2_tcon_find(req->session, tid, req->request_time); } - handle = smbsrv_smb_handle_find(tcon, hid, req->request_time); + handle = smbsrv_smb2_handle_find(tcon, hid, req->request_time); if (!handle) { return NULL; } @@ -83,12 +83,12 @@ void smb2srv_push_handle(uint8_t *base, uint_t offset, struct ntvfs_handle *ntvf static NTSTATUS smb2srv_handle_create_new(void *private_data, struct ntvfs_request *ntvfs, struct ntvfs_handle **_h) { - struct smbsrv_request *req = talloc_get_type(ntvfs->frontend_data.private_data, - struct smbsrv_request); + struct smb2srv_request *req = talloc_get_type(ntvfs->frontend_data.private_data, + struct smb2srv_request); struct smbsrv_handle *handle; struct ntvfs_handle *h; - handle = smbsrv_handle_new(req); + handle = smbsrv_handle_new(req->session, req->tcon, req, req->request_time); if (!handle) return NT_STATUS_INSUFFICIENT_RESOURCES; h = talloc_zero(handle, struct ntvfs_handle); -- 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/smb2/tcon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/smb_server/smb2/tcon.c') diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c index bfb3904d47..b2270640c8 100644 --- a/source4/smb_server/smb2/tcon.c +++ b/source4/smb_server/smb2/tcon.c @@ -158,7 +158,7 @@ static NTSTATUS smb2srv_tcon_backend(struct smb2srv_request *req, union smb_tcon } } - snum = smbsrv_find_service(service); + snum = lp_find_valid_service(service); if (snum == -1) { DEBUG(0,("smb2srv_tcon_backend: couldn't find service %s\n", service)); return NT_STATUS_BAD_NETWORK_NAME; -- cgit From b20c00f718c09cc2c9077235488683e0ca98f5bc Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 1 Jul 2006 14:11:00 +0000 Subject: r16732: use the given macros metze (This used to be commit 6d5c74c38ca4d4a605b619cd7cbbd7e1dccd6b0c) --- source4/smb_server/smb2/tcon.c | 35 +++++------------------------------ 1 file changed, 5 insertions(+), 30 deletions(-) (limited to 'source4/smb_server/smb2/tcon.c') diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c index b2270640c8..28c505a1fd 100644 --- a/source4/smb_server/smb2/tcon.c +++ b/source4/smb_server/smb2/tcon.c @@ -262,19 +262,12 @@ failed: static void smb2srv_tcon_send(struct smb2srv_request *req, union smb_tcon *io) { - NTSTATUS status; - if (NT_STATUS_IS_ERR(req->status)) { smb2srv_send_error(req, req->status); return; } - status = smb2srv_setup_reply(req, 0x10, False, 0); - if (!NT_STATUS_IS_OK(status)) { - smbsrv_terminate_connection(req->smb_conn, nt_errstr(status)); - talloc_free(req); - return; - } + SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x10, False, 0)); SBVAL(req->out.hdr, SMB2_HDR_TID, io->smb2.out.tid); @@ -289,28 +282,13 @@ static void smb2srv_tcon_send(struct smb2srv_request *req, union smb_tcon *io) void smb2srv_tcon_recv(struct smb2srv_request *req) { union smb_tcon *io; - NTSTATUS status; - if (req->in.body_size < 0x08) { - smb2srv_send_error(req, NT_STATUS_FOOBAR); - return; - } - - io = talloc(req, union smb_tcon); - if (!io) { - smbsrv_terminate_connection(req->smb_conn, nt_errstr(NT_STATUS_NO_MEMORY)); - talloc_free(req); - return; - } + SMB2SRV_CHECK_BODY_SIZE(req, 0x08, True); + SMB2SRV_TALLOC_IO_PTR(io, union smb_tcon); io->smb2.level = RAW_TCON_SMB2; io->smb2.in.unknown1 = SVAL(req->in.body, 0x02); - status = smb2_pull_o16s16_string(&req->in, io, req->in.body+0x04, &io->smb2.in.path); - if (!NT_STATUS_IS_OK(status)) { - smbsrv_terminate_connection(req->smb_conn, nt_errstr(status)); - talloc_free(req); - return; - } + SMB2SRV_CHECK(smb2_pull_o16s16_string(&req->in, io, req->in.body+0x04, &io->smb2.in.path)); req->status = smb2srv_tcon_backend(req, io); @@ -354,10 +332,7 @@ void smb2srv_tdis_recv(struct smb2srv_request *req) { uint16_t _pad; - if (req->in.body_size < 0x04) { - smb2srv_send_error(req, NT_STATUS_FOOBAR); - return; - } + SMB2SRV_CHECK_BODY_SIZE(req, 0x04, False); _pad = SVAL(req->in.body, 0x02); -- cgit From 627f49d8c95400cc041a61b0a6526ba5a0eb8b4b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 10 Jul 2006 10:27:02 +0000 Subject: r16910: - don't search the wildcard handle (a handle with all bits set to 1 is justed for some SMB2 Ioctl calls...) - don't crash if we didn't find the tcon metze (This used to be commit 27087818c7e8cbaadbcd640fe3b0ffc1c3455b04) --- source4/smb_server/smb2/tcon.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source4/smb_server/smb2/tcon.c') diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c index 28c505a1fd..38bf4d7ef0 100644 --- a/source4/smb_server/smb2/tcon.c +++ b/source4/smb_server/smb2/tcon.c @@ -53,10 +53,18 @@ struct ntvfs_handle *smb2srv_pull_handle(struct smb2srv_request *req, const uint return NULL; } + /* if it's the wildcard handle, don't waste time to search it... */ + if (hid == UINT64_MAX && tid == UINT32_MAX) { + return NULL; + } + /* TODO: add comments */ tcon = req->tcon; if (tid != req->tcon->tid) { tcon = smbsrv_smb2_tcon_find(req->session, tid, req->request_time); + if (!tcon) { + return NULL; + } } handle = smbsrv_smb2_handle_find(tcon, hid, req->request_time); -- cgit From 29f3389fc065228d90ec85d7bde2babd10e6562e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 10 Jul 2006 10:31:11 +0000 Subject: r16911: the TID is only 32 bits...don't overwrite parts of the UID field metze (This used to be commit 7db393e5ea15dd363f83dcf5eb299f2806971f97) --- source4/smb_server/smb2/tcon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/smb_server/smb2/tcon.c') diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c index 38bf4d7ef0..38a54bb8f6 100644 --- a/source4/smb_server/smb2/tcon.c +++ b/source4/smb_server/smb2/tcon.c @@ -277,7 +277,7 @@ static void smb2srv_tcon_send(struct smb2srv_request *req, union smb_tcon *io) SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x10, False, 0)); - SBVAL(req->out.hdr, SMB2_HDR_TID, io->smb2.out.tid); + SIVAL(req->out.hdr, SMB2_HDR_TID, io->smb2.out.tid); SSVAL(req->out.body, 0x02, io->smb2.out.unknown1); SIVAL(req->out.body, 0x04, io->smb2.out.unknown2); -- cgit From ac857dcfed805ec0e45f06a86d8b2422c4cad1f5 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 10 Jul 2006 10:34:34 +0000 Subject: r16912: I messed up the numbers for ipc and print shares... This caused vista beta2 to not do any rpc calls against samba4 metze (This used to be commit b42d918d56387a4d5dd27cc4dfc187990195d9c3) --- source4/smb_server/smb2/tcon.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/smb_server/smb2/tcon.c') diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c index 38a54bb8f6..2ebfa883ef 100644 --- a/source4/smb_server/smb2/tcon.c +++ b/source4/smb_server/smb2/tcon.c @@ -182,10 +182,10 @@ static NTSTATUS smb2srv_tcon_backend(struct smb2srv_request *req, union smb_tcon /* work out what sort of connection this is */ if (strcmp(lp_fstype(snum), "IPC") == 0) { type = NTVFS_IPC; - type_smb2 = 0x0003; + type_smb2 = 0x0002; } else if (lp_print_ok(snum)) { type = NTVFS_PRINT; - type_smb2 = 0x0002; + type_smb2 = 0x0003; } else { type = NTVFS_DISK; type_smb2 = 0x0001; -- cgit From 41992489d2cb54b1a7158b49cc2c3a53cfd57b5a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 10 Jul 2006 10:57:30 +0000 Subject: r16913: better return the same values as vista beta2 metze (This used to be commit ae9c007324b04a81fd367e4e72f50275df137d46) --- source4/smb_server/smb2/tcon.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'source4/smb_server/smb2/tcon.c') diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c index 2ebfa883ef..cc0a911224 100644 --- a/source4/smb_server/smb2/tcon.c +++ b/source4/smb_server/smb2/tcon.c @@ -156,6 +156,7 @@ static NTSTATUS smb2srv_tcon_backend(struct smb2srv_request *req, union smb_tcon NTSTATUS status; enum ntvfs_type type; uint16_t type_smb2; + uint32_t unknown2; int snum; const char *service = io->smb2.in.path; @@ -183,12 +184,15 @@ static NTSTATUS smb2srv_tcon_backend(struct smb2srv_request *req, union smb_tcon if (strcmp(lp_fstype(snum), "IPC") == 0) { type = NTVFS_IPC; type_smb2 = 0x0002; + unknown2 = 0x00000030; } else if (lp_print_ok(snum)) { type = NTVFS_PRINT; type_smb2 = 0x0003; + unknown2 = 0x00000000; } else { type = NTVFS_DISK; type_smb2 = 0x0001; + unknown2 = 0x00000800; } tcon = smbsrv_smb2_tcon_new(req->session, lp_servicename(snum)); @@ -254,7 +258,7 @@ static NTSTATUS smb2srv_tcon_backend(struct smb2srv_request *req, union smb_tcon } io->smb2.out.unknown1 = type_smb2; /* 1 - DISK, 2 - Print, 3 - IPC */ - io->smb2.out.unknown2 = 0x00000000; + io->smb2.out.unknown2 = unknown2; io->smb2.out.unknown3 = 0x00000000; io->smb2.out.access_mask= SEC_RIGHTS_FILE_ALL; @@ -270,14 +274,24 @@ failed: static void smb2srv_tcon_send(struct smb2srv_request *req, union smb_tcon *io) { - if (NT_STATUS_IS_ERR(req->status)) { + uint16_t unknown1; + + if (!NT_STATUS_IS_OK(req->status)) { smb2srv_send_error(req, req->status); return; } + if (io->smb2.out.unknown1 == 0x0002) { + /* if it's an IPC share vista returns 0x0005 */ + unknown1 = 0x0005; + } else { + unknown1 = 0x0001; + } + SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x10, False, 0)); SIVAL(req->out.hdr, SMB2_HDR_TID, io->smb2.out.tid); + SSVAL(req->out.hdr, SMB2_HDR_UNKNOWN1,unknown1); SSVAL(req->out.body, 0x02, io->smb2.out.unknown1); SIVAL(req->out.body, 0x04, io->smb2.out.unknown2); -- 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/smb2/tcon.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/smb_server/smb2/tcon.c') diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c index cc0a911224..338fb5ed22 100644 --- a/source4/smb_server/smb2/tcon.c +++ b/source4/smb_server/smb2/tcon.c @@ -242,7 +242,6 @@ static NTSTATUS smb2srv_tcon_backend(struct smb2srv_request *req, union smb_tcon req->ntvfs = ntvfs_request_create(req->tcon->ntvfs, req, req->session->session_info, 0, /* TODO: fill in PID */ - 0, /* TODO: fill in 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/smb2/tcon.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'source4/smb_server/smb2/tcon.c') diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c index 338fb5ed22..d01b63d446 100644 --- a/source4/smb_server/smb2/tcon.c +++ b/source4/smb_server/smb2/tcon.c @@ -157,8 +157,9 @@ static NTSTATUS smb2srv_tcon_backend(struct smb2srv_request *req, union smb_tcon enum ntvfs_type type; uint16_t type_smb2; uint32_t unknown2; - int snum; const char *service = io->smb2.in.path; + struct share_config *scfg; + const char *sharetype; if (strncmp(service, "\\\\", 2) == 0) { const char *p = strchr(service+2, '\\'); @@ -167,25 +168,26 @@ static NTSTATUS smb2srv_tcon_backend(struct smb2srv_request *req, union smb_tcon } } - snum = lp_find_valid_service(service); - if (snum == -1) { + status = share_get_config(req, req->smb_conn->share_context, service, &scfg); + if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("smb2srv_tcon_backend: couldn't find service %s\n", service)); return NT_STATUS_BAD_NETWORK_NAME; } if (!socket_check_access(req->smb_conn->connection->socket, - lp_servicename(snum), - lp_hostsallow(snum), - lp_hostsdeny(snum))) { + 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, SHARE_TYPE, "DISK"); + if (sharetype && strcmp(sharetype, "IPC") == 0) { type = NTVFS_IPC; type_smb2 = 0x0002; unknown2 = 0x00000030; - } else if (lp_print_ok(snum)) { + } else if (sharetype && strcmp(sharetype, "PRINTER") == 0) { type = NTVFS_PRINT; type_smb2 = 0x0003; unknown2 = 0x00000000; @@ -195,7 +197,7 @@ static NTSTATUS smb2srv_tcon_backend(struct smb2srv_request *req, union smb_tcon unknown2 = 0x00000800; } - tcon = smbsrv_smb2_tcon_new(req->session, lp_servicename(snum)); + tcon = smbsrv_smb2_tcon_new(req->session, scfg->name); if (!tcon) { DEBUG(0,("smb2srv_tcon_backend: Couldn't find free connection.\n")); return NT_STATUS_INSUFFICIENT_RESOURCES; @@ -203,7 +205,7 @@ static NTSTATUS smb2srv_tcon_backend(struct smb2srv_request *req, union smb_tcon 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, @@ -211,7 +213,7 @@ static NTSTATUS smb2srv_tcon_backend(struct smb2srv_request *req, union smb_tcon &tcon->ntvfs); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("smb2srv_tcon_backend: ntvfs_init_connection failed for service %s\n", - lp_servicename(snum))); + scfg->name)); goto failed; } @@ -250,7 +252,7 @@ static NTSTATUS smb2srv_tcon_backend(struct smb2srv_request *req, union smb_tcon } /* 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,("smb2srv_tcon_backend: NTVFS ntvfs_connect() failed!\n")); goto failed; @@ -279,7 +281,6 @@ static void smb2srv_tcon_send(struct smb2srv_request *req, union smb_tcon *io) smb2srv_send_error(req, req->status); return; } - if (io->smb2.out.unknown1 == 0x0002) { /* if it's an IPC share vista returns 0x0005 */ unknown1 = 0x0005; -- cgit From c5148cd9cd7cbc6463308b9c65bbc68c2be3b16a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 1 Aug 2006 10:37:34 +0000 Subject: r17360: add some comments metze (This used to be commit 3d849f9d2565ebcba16653df3ce2060d3b606c50) --- source4/smb_server/smb2/tcon.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'source4/smb_server/smb2/tcon.c') diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c index d01b63d446..a98110ab85 100644 --- a/source4/smb_server/smb2/tcon.c +++ b/source4/smb_server/smb2/tcon.c @@ -49,7 +49,7 @@ struct ntvfs_handle *smb2srv_pull_handle(struct smb2srv_request *req, const uint tid = IVAL(base, offset + 8); pad = IVAL(base, offset + 12); - if (pad != 0xFFFFFFFF) { + if (pad != UINT32_MAX) { return NULL; } @@ -58,7 +58,15 @@ struct ntvfs_handle *smb2srv_pull_handle(struct smb2srv_request *req, const uint return NULL; } -/* TODO: add comments */ + /* + * the handle can belong to a different tcon + * as that TID in the SMB2 header says, but + * the request should succeed nevertheless! + * + * because if this we put the 32 bit TID into the + * 128 bit handle, so that we can extract the tcon from the + * handle + */ tcon = req->tcon; if (tid != req->tcon->tid) { tcon = smbsrv_smb2_tcon_find(req->session, tid, req->request_time); @@ -72,6 +80,18 @@ struct ntvfs_handle *smb2srv_pull_handle(struct smb2srv_request *req, const uint return NULL; } + /* + * as the smb2srv_tcon is a child object of the smb2srv_session + * the handle belongs to the correct session! + * + * Note: no check is needed here for SMB2 + */ + + /* + * as the handle may have overwritten the tcon + * we need to set it on the request so that the + * correct ntvfs context will be used for the ntvfs_*() request + */ req->tcon = tcon; return handle->ntvfs; } @@ -86,7 +106,7 @@ void smb2srv_push_handle(uint8_t *base, uint_t offset, struct ntvfs_handle *ntvf */ SBVAL(base, offset, handle->hid); SIVAL(base, offset + 8, handle->tcon->tid); - SIVAL(base, offset + 12,0xFFFFFFFF); + SIVAL(base, offset + 12,UINT32_MAX); } static NTSTATUS smb2srv_handle_create_new(void *private_data, struct ntvfs_request *ntvfs, struct ntvfs_handle **_h) -- cgit From bf62b6642c77e14142cdb724dc99dd3f8bfd89ac Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 14 May 2007 18:02:49 +0000 Subject: r22866: handle incoming chained smb2 requests in our server code to let the windows explorer in longhorn beta3 work. metze (This used to be commit 2390c9f24daccec917608cac0870890cdc73cb1c) --- source4/smb_server/smb2/tcon.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source4/smb_server/smb2/tcon.c') diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c index a98110ab85..023ca9b0a4 100644 --- a/source4/smb_server/smb2/tcon.c +++ b/source4/smb_server/smb2/tcon.c @@ -45,6 +45,17 @@ struct ntvfs_handle *smb2srv_pull_handle(struct smb2srv_request *req, const uint uint32_t tid; uint32_t pad; + /* + * if there're chained requests used the cached handle + * + * TODO: check if this also correct when the given handle + * isn't all 0xFF. + */ + if (req->chained_file_handle) { + base = req->chained_file_handle; + offset = 0; + } + hid = BVAL(base, offset); tid = IVAL(base, offset + 8); pad = IVAL(base, offset + 12); -- cgit From 10498e8a720d047ca3a013abbc9e406c630ab30a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 21 May 2007 17:23:56 +0000 Subject: r23044: - use uint32_t for handle id's - include the session vuid in the SMB2 128-Bit wire handles as SMB2 oplock breaks doesn't include a TID or VUID in the header we need to make sure the handle is unique for the whole TCP connection metze (This used to be commit 7c29b8a7e67c48478399788912b22c287fbd3b4e) --- source4/smb_server/smb2/tcon.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'source4/smb_server/smb2/tcon.c') diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c index 023ca9b0a4..9dd2461a0e 100644 --- a/source4/smb_server/smb2/tcon.c +++ b/source4/smb_server/smb2/tcon.c @@ -41,9 +41,9 @@ struct ntvfs_handle *smb2srv_pull_handle(struct smb2srv_request *req, const uint { struct smbsrv_tcon *tcon; struct smbsrv_handle *handle; - uint64_t hid; + uint32_t hid; uint32_t tid; - uint32_t pad; + uint64_t uid; /* * if there're chained requests used the cached handle @@ -56,16 +56,20 @@ struct ntvfs_handle *smb2srv_pull_handle(struct smb2srv_request *req, const uint offset = 0; } - hid = BVAL(base, offset); - tid = IVAL(base, offset + 8); - pad = IVAL(base, offset + 12); + hid = IVAL(base, offset); + tid = IVAL(base, offset + 4); + uid = BVAL(base, offset + 8); - if (pad != UINT32_MAX) { + /* if it's the wildcard handle, don't waste time to search it... */ + if (hid == UINT32_MAX && tid == UINT32_MAX && uid == UINT64_MAX) { return NULL; } - /* if it's the wildcard handle, don't waste time to search it... */ - if (hid == UINT64_MAX && tid == UINT32_MAX) { + /* + * if the (v)uid part doesn't match the given session the handle isn't + * valid + */ + if (uid != req->session->vuid) { return NULL; } @@ -74,7 +78,7 @@ struct ntvfs_handle *smb2srv_pull_handle(struct smb2srv_request *req, const uint * as that TID in the SMB2 header says, but * the request should succeed nevertheless! * - * because if this we put the 32 bit TID into the + * because of this we put the 32 bit TID into the * 128 bit handle, so that we can extract the tcon from the * handle */ @@ -102,6 +106,8 @@ struct ntvfs_handle *smb2srv_pull_handle(struct smb2srv_request *req, const uint * as the handle may have overwritten the tcon * we need to set it on the request so that the * correct ntvfs context will be used for the ntvfs_*() request + * + * TODO: check if that's correct for chained requests as well! */ req->tcon = tcon; return handle->ntvfs; @@ -115,9 +121,9 @@ void smb2srv_push_handle(uint8_t *base, uint_t offset, struct ntvfs_handle *ntvf /* * the handle is 128 bit on the wire */ - SBVAL(base, offset, handle->hid); - SIVAL(base, offset + 8, handle->tcon->tid); - SIVAL(base, offset + 12,UINT32_MAX); + SIVAL(base, offset, handle->hid); + SIVAL(base, offset + 4, handle->tcon->tid); + SBVAL(base, offset + 8, handle->session->vuid); } static NTSTATUS smb2srv_handle_create_new(void *private_data, struct ntvfs_request *ntvfs, struct ntvfs_handle **_h) -- cgit From 6eaf8ee84960c85b703403a8c5ca440e330b0b80 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 21 May 2007 17:39:05 +0000 Subject: r23045: forward SMB2 oplock breaks to the client metze (This used to be commit 577acc198b096a1e182568b6db93c2da132b647e) --- source4/smb_server/smb2/tcon.c | 51 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) (limited to 'source4/smb_server/smb2/tcon.c') diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c index 9dd2461a0e..600f6c39b7 100644 --- a/source4/smb_server/smb2/tcon.c +++ b/source4/smb_server/smb2/tcon.c @@ -31,9 +31,56 @@ /* send an oplock break request to a client */ -static NTSTATUS smb2srv_send_oplock_break(void *p, struct ntvfs_handle *ntvfs, uint8_t level) +static NTSTATUS smb2srv_send_oplock_break(void *p, struct ntvfs_handle *h, uint8_t level) { - DEBUG(0,("TODO: we don't pass SMB2 oplock breaks to the Clients yet!\n")); + struct smbsrv_handle *handle = talloc_get_type(h->frontend_data.private_data, + struct smbsrv_handle); + struct smb2srv_request *req; + NTSTATUS status; + + /* setup a dummy request structure */ + req = smb2srv_init_request(handle->tcon->smb_conn); + NT_STATUS_HAVE_NO_MEMORY(req); + + req->in.buffer = talloc_size(req, NBT_HDR_SIZE + SMB2_MIN_SIZE); + NT_STATUS_HAVE_NO_MEMORY(req->in.buffer); + req->in.size = NBT_HDR_SIZE + SMB2_MIN_SIZE; + req->in.allocated = req->in.size; + + req->in.hdr = req->in.buffer+ NBT_HDR_SIZE; + req->in.body = req->in.hdr + SMB2_HDR_BODY; + req->in.body_size = req->in.size - (SMB2_HDR_BODY+NBT_HDR_SIZE); + req->in.dynamic = NULL; + + req->seqnum = UINT64_MAX; + + SIVAL(req->in.hdr, 0, SMB2_MAGIC); + SSVAL(req->in.hdr, SMB2_HDR_LENGTH, SMB2_HDR_BODY); + SSVAL(req->in.hdr, SMB2_HDR_PAD1, 0); + SIVAL(req->in.hdr, SMB2_HDR_STATUS, 0); + SSVAL(req->in.hdr, SMB2_HDR_OPCODE, SMB2_OP_BREAK); + SSVAL(req->in.hdr, SMB2_HDR_UNKNOWN1, 0); + SIVAL(req->in.hdr, SMB2_HDR_FLAGS, 0); + SIVAL(req->in.hdr, SMB2_HDR_CHAIN_OFFSET, 0); + SBVAL(req->in.hdr, SMB2_HDR_SEQNUM, 0); + SIVAL(req->in.hdr, SMB2_HDR_PID, 0); + SIVAL(req->in.hdr, SMB2_HDR_TID, 0); + SBVAL(req->in.hdr, SMB2_HDR_UID, 0); + memset(req->in.hdr+SMB2_HDR_SIG, 0, 16); + + SSVAL(req->in.body, 0, 2); + + status = smb2srv_setup_reply(req, 0x18, False, 0); + NT_STATUS_NOT_OK_RETURN(status); + + SSVAL(req->out.hdr, SMB2_HDR_UNKNOWN1, 0x0000); + + SSVAL(req->out.body, 0x02, 0x0001); + SIVAL(req->out.body, 0x04, 0x00000000); + smb2srv_push_handle(req->out.body, 0x08, h); + + smb2srv_send_reply(req); + return NT_STATUS_OK; } -- 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/smb2/tcon.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/smb_server/smb2/tcon.c') diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c index 600f6c39b7..b476e97168 100644 --- a/source4/smb_server/smb2/tcon.c +++ b/source4/smb_server/smb2/tcon.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 98b57d5eb61094a9c88e2f7d90d3e21b7e74e9d8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 8 Sep 2007 16:46:30 +0000 Subject: r25035: Fix some more warnings, use service pointer rather than service number in more places. (This used to be commit df9cebcb97e20564359097148665bd519f31bc6f) --- source4/smb_server/smb2/tcon.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/smb_server/smb2/tcon.c') diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c index b476e97168..6d7e19e470 100644 --- a/source4/smb_server/smb2/tcon.c +++ b/source4/smb_server/smb2/tcon.c @@ -41,7 +41,8 @@ static NTSTATUS smb2srv_send_oplock_break(void *p, struct ntvfs_handle *h, uint8 req = smb2srv_init_request(handle->tcon->smb_conn); NT_STATUS_HAVE_NO_MEMORY(req); - req->in.buffer = talloc_size(req, NBT_HDR_SIZE + SMB2_MIN_SIZE); + req->in.buffer = talloc_array(req, uint8_t, + NBT_HDR_SIZE + SMB2_MIN_SIZE); NT_STATUS_HAVE_NO_MEMORY(req->in.buffer); req->in.size = NBT_HDR_SIZE + SMB2_MIN_SIZE; req->in.allocated = req->in.size; -- cgit From 0c56f8dac31c51a42dedf2a1da9fd76896855b19 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 6 Oct 2007 22:10:49 +0000 Subject: r25551: Convert to standard bool type. (This used to be commit c9651e2c5c078edee7b91085e936a93625c8d708) --- source4/smb_server/smb2/tcon.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source4/smb_server/smb2/tcon.c') diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c index 6d7e19e470..572d3b5bf5 100644 --- a/source4/smb_server/smb2/tcon.c +++ b/source4/smb_server/smb2/tcon.c @@ -70,7 +70,7 @@ static NTSTATUS smb2srv_send_oplock_break(void *p, struct ntvfs_handle *h, uint8 SSVAL(req->in.body, 0, 2); - status = smb2srv_setup_reply(req, 0x18, False, 0); + status = smb2srv_setup_reply(req, 0x18, false, 0); NT_STATUS_NOT_OK_RETURN(status); SSVAL(req->out.hdr, SMB2_HDR_UNKNOWN1, 0x0000); @@ -372,7 +372,7 @@ static void smb2srv_tcon_send(struct smb2srv_request *req, union smb_tcon *io) unknown1 = 0x0001; } - SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x10, False, 0)); + SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x10, false, 0)); SIVAL(req->out.hdr, SMB2_HDR_TID, io->smb2.out.tid); SSVAL(req->out.hdr, SMB2_HDR_UNKNOWN1,unknown1); @@ -389,7 +389,7 @@ void smb2srv_tcon_recv(struct smb2srv_request *req) { union smb_tcon *io; - SMB2SRV_CHECK_BODY_SIZE(req, 0x08, True); + SMB2SRV_CHECK_BODY_SIZE(req, 0x08, true); SMB2SRV_TALLOC_IO_PTR(io, union smb_tcon); io->smb2.level = RAW_TCON_SMB2; @@ -422,7 +422,7 @@ static void smb2srv_tdis_send(struct smb2srv_request *req) return; } - status = smb2srv_setup_reply(req, 0x04, False, 0); + status = smb2srv_setup_reply(req, 0x04, false, 0); if (!NT_STATUS_IS_OK(status)) { smbsrv_terminate_connection(req->smb_conn, nt_errstr(status)); talloc_free(req); @@ -438,7 +438,7 @@ void smb2srv_tdis_recv(struct smb2srv_request *req) { uint16_t _pad; - SMB2SRV_CHECK_BODY_SIZE(req, 0x04, False); + SMB2SRV_CHECK_BODY_SIZE(req, 0x04, false); _pad = SVAL(req->in.body, 0x02); -- 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/smb2/tcon.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/smb_server/smb2/tcon.c') diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c index 572d3b5bf5..4393d38c0d 100644 --- a/source4/smb_server/smb2/tcon.c +++ b/source4/smb_server/smb2/tcon.c @@ -26,6 +26,7 @@ #include "librpc/gen_ndr/security.h" #include "smbd/service_stream.h" #include "ntvfs/ntvfs.h" +#include "param/param.h" /* send an oplock break request to a client @@ -293,6 +294,7 @@ static NTSTATUS smb2srv_tcon_backend(struct smb2srv_request *req, union smb_tcon 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/smb2/tcon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/smb_server/smb2/tcon.c') diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c index 4393d38c0d..6d0d98554c 100644 --- a/source4/smb_server/smb2/tcon.c +++ b/source4/smb_server/smb2/tcon.c @@ -294,7 +294,7 @@ static NTSTATUS smb2srv_tcon_backend(struct smb2srv_request *req, union smb_tcon 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 a2505c5a2cc2b7b692ffbcdd8c6b86000a15d2c7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 12 Feb 2008 17:00:35 +1100 Subject: updated SMB2 header defines to match WSPP docs (This used to be commit d2c6ad55eca27f50a38fc6e2a85032eddb3f0aae) --- source4/smb_server/smb2/tcon.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'source4/smb_server/smb2/tcon.c') diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c index 6d0d98554c..824a57b4a1 100644 --- a/source4/smb_server/smb2/tcon.c +++ b/source4/smb_server/smb2/tcon.c @@ -57,24 +57,24 @@ static NTSTATUS smb2srv_send_oplock_break(void *p, struct ntvfs_handle *h, uint8 SIVAL(req->in.hdr, 0, SMB2_MAGIC); SSVAL(req->in.hdr, SMB2_HDR_LENGTH, SMB2_HDR_BODY); - SSVAL(req->in.hdr, SMB2_HDR_PAD1, 0); + SSVAL(req->in.hdr, SMB2_HDR_EPOCH, 0); SIVAL(req->in.hdr, SMB2_HDR_STATUS, 0); SSVAL(req->in.hdr, SMB2_HDR_OPCODE, SMB2_OP_BREAK); - SSVAL(req->in.hdr, SMB2_HDR_UNKNOWN1, 0); + SSVAL(req->in.hdr, SMB2_HDR_CREDIT, 0); SIVAL(req->in.hdr, SMB2_HDR_FLAGS, 0); - SIVAL(req->in.hdr, SMB2_HDR_CHAIN_OFFSET, 0); - SBVAL(req->in.hdr, SMB2_HDR_SEQNUM, 0); + SIVAL(req->in.hdr, SMB2_HDR_NEXT_COMMAND, 0); + SBVAL(req->in.hdr, SMB2_HDR_MESSAGE_ID, 0); SIVAL(req->in.hdr, SMB2_HDR_PID, 0); SIVAL(req->in.hdr, SMB2_HDR_TID, 0); - SBVAL(req->in.hdr, SMB2_HDR_UID, 0); - memset(req->in.hdr+SMB2_HDR_SIG, 0, 16); + SBVAL(req->in.hdr, SMB2_HDR_SESSION_ID, 0); + memset(req->in.hdr+SMB2_HDR_SIGNATURE, 0, 16); SSVAL(req->in.body, 0, 2); status = smb2srv_setup_reply(req, 0x18, false, 0); NT_STATUS_NOT_OK_RETURN(status); - SSVAL(req->out.hdr, SMB2_HDR_UNKNOWN1, 0x0000); + SSVAL(req->out.hdr, SMB2_HDR_CREDIT, 0x0000); SSVAL(req->out.body, 0x02, 0x0001); SIVAL(req->out.body, 0x04, 0x00000000); @@ -361,7 +361,7 @@ failed: static void smb2srv_tcon_send(struct smb2srv_request *req, union smb_tcon *io) { - uint16_t unknown1; + uint16_t credit; if (!NT_STATUS_IS_OK(req->status)) { smb2srv_send_error(req, req->status); @@ -369,15 +369,15 @@ static void smb2srv_tcon_send(struct smb2srv_request *req, union smb_tcon *io) } if (io->smb2.out.unknown1 == 0x0002) { /* if it's an IPC share vista returns 0x0005 */ - unknown1 = 0x0005; + credit = 0x0005; } else { - unknown1 = 0x0001; + credit = 0x0001; } SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x10, false, 0)); SIVAL(req->out.hdr, SMB2_HDR_TID, io->smb2.out.tid); - SSVAL(req->out.hdr, SMB2_HDR_UNKNOWN1,unknown1); + SSVAL(req->out.hdr, SMB2_HDR_CREDIT,credit); SSVAL(req->out.body, 0x02, io->smb2.out.unknown1); SIVAL(req->out.body, 0x04, io->smb2.out.unknown2); -- cgit From e94d710b0b959d8e69eb02ef0704ebcff56485fb Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 13 Feb 2008 10:13:28 +1100 Subject: updated SMB2 tcon as per WSPP docs (This used to be commit 5913e3e549e71affc66c28cacb6563331fb0c790) --- source4/smb_server/smb2/tcon.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) (limited to 'source4/smb_server/smb2/tcon.c') diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c index 824a57b4a1..b375ce6b4b 100644 --- a/source4/smb_server/smb2/tcon.c +++ b/source4/smb_server/smb2/tcon.c @@ -240,8 +240,6 @@ static NTSTATUS smb2srv_tcon_backend(struct smb2srv_request *req, union smb_tcon struct smbsrv_tcon *tcon; NTSTATUS status; enum ntvfs_type type; - uint16_t type_smb2; - uint32_t unknown2; const char *service = io->smb2.in.path; struct share_config *scfg; const char *sharetype; @@ -270,16 +268,10 @@ static NTSTATUS smb2srv_tcon_backend(struct smb2srv_request *req, union smb_tcon sharetype = share_string_option(scfg, SHARE_TYPE, "DISK"); if (sharetype && strcmp(sharetype, "IPC") == 0) { type = NTVFS_IPC; - type_smb2 = 0x0002; - unknown2 = 0x00000030; } else if (sharetype && strcmp(sharetype, "PRINTER") == 0) { type = NTVFS_PRINT; - type_smb2 = 0x0003; - unknown2 = 0x00000000; } else { type = NTVFS_DISK; - type_smb2 = 0x0001; - unknown2 = 0x00000800; } tcon = smbsrv_smb2_tcon_new(req->session, scfg->name); @@ -344,10 +336,11 @@ static NTSTATUS smb2srv_tcon_backend(struct smb2srv_request *req, union smb_tcon goto failed; } - io->smb2.out.unknown1 = type_smb2; /* 1 - DISK, 2 - Print, 3 - IPC */ - io->smb2.out.unknown2 = unknown2; - io->smb2.out.unknown3 = 0x00000000; - io->smb2.out.access_mask= SEC_RIGHTS_FILE_ALL; + io->smb2.out.share_type = (unsigned)type; /* 1 - DISK, 2 - Print, 3 - IPC */ + io->smb2.out.reserved = 0; + io->smb2.out.flags = 0x00000000; + io->smb2.out.capabilities = 0; + io->smb2.out.access_mask = SEC_RIGHTS_FILE_ALL; io->smb2.out.tid = tcon->tid; @@ -367,7 +360,7 @@ static void smb2srv_tcon_send(struct smb2srv_request *req, union smb_tcon *io) smb2srv_send_error(req, req->status); return; } - if (io->smb2.out.unknown1 == 0x0002) { + if (io->smb2.out.share_type == NTVFS_IPC) { /* if it's an IPC share vista returns 0x0005 */ credit = 0x0005; } else { @@ -379,9 +372,10 @@ static void smb2srv_tcon_send(struct smb2srv_request *req, union smb_tcon *io) SIVAL(req->out.hdr, SMB2_HDR_TID, io->smb2.out.tid); SSVAL(req->out.hdr, SMB2_HDR_CREDIT,credit); - SSVAL(req->out.body, 0x02, io->smb2.out.unknown1); - SIVAL(req->out.body, 0x04, io->smb2.out.unknown2); - SIVAL(req->out.body, 0x08, io->smb2.out.unknown3); + SCVAL(req->out.body, 0x02, io->smb2.out.share_type); + SCVAL(req->out.body, 0x03, io->smb2.out.reserved); + SIVAL(req->out.body, 0x04, io->smb2.out.flags); + SIVAL(req->out.body, 0x08, io->smb2.out.capabilities); SIVAL(req->out.body, 0x0C, io->smb2.out.access_mask); smb2srv_send_reply(req); @@ -395,7 +389,7 @@ void smb2srv_tcon_recv(struct smb2srv_request *req) SMB2SRV_TALLOC_IO_PTR(io, union smb_tcon); io->smb2.level = RAW_TCON_SMB2; - io->smb2.in.unknown1 = SVAL(req->in.body, 0x02); + io->smb2.in.reserved = SVAL(req->in.body, 0x02); SMB2SRV_CHECK(smb2_pull_o16s16_string(&req->in, io, req->in.body+0x04, &io->smb2.in.path)); req->status = smb2srv_tcon_backend(req, io); -- cgit From e870cfec9f3512b0f1bd3110d7b975652525e28a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 14 Feb 2008 10:12:33 +1100 Subject: Convert SMB and SMB2 code to use a common buffer handling structure This converts our SMB and SMB2 code to use a common structure "struct request_bufinfo" for information on the buffer bounds of a packet, alignment information and string handling. This allows us to use a common backend for SMB and SMB2 code, while still using all the same string and blob handling functions. Up to now we had been passing a NULL req handle into these common routines from the SMB2 side of the server, which meant that we failed any operation which did a bounds checked string extraction (such as a RenameInformation setinfo call, which is what Vista uses for renaming files) There is still some more work to be done on this - for example we can now remove many of the SMB2 specific buffer handling functions that we had, and use the SMB ones. (This used to be commit ca6d9be6cb6a403a81b18fa6e9a6a0518d7f0f68) --- source4/smb_server/smb2/tcon.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/smb_server/smb2/tcon.c') diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c index b375ce6b4b..50094b806d 100644 --- a/source4/smb_server/smb2/tcon.c +++ b/source4/smb_server/smb2/tcon.c @@ -55,6 +55,8 @@ static NTSTATUS smb2srv_send_oplock_break(void *p, struct ntvfs_handle *h, uint8 req->seqnum = UINT64_MAX; + smb2srv_setup_bufinfo(req); + SIVAL(req->in.hdr, 0, SMB2_MAGIC); SSVAL(req->in.hdr, SMB2_HDR_LENGTH, SMB2_HDR_BODY); SSVAL(req->in.hdr, SMB2_HDR_EPOCH, 0); -- cgit From 5fb241e5d33024dd7af1e7ec5cbdefbf144be6a1 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 18 Feb 2008 14:54:14 +1100 Subject: 3 places where the VFS backend doesn't handle NULL strings. (This used to be commit cf109460aff5a8437ab7eba05e4d7316a131080e) --- source4/smb_server/smb2/tcon.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source4/smb_server/smb2/tcon.c') diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c index 50094b806d..7f7d558b16 100644 --- a/source4/smb_server/smb2/tcon.c +++ b/source4/smb_server/smb2/tcon.c @@ -394,6 +394,11 @@ void smb2srv_tcon_recv(struct smb2srv_request *req) io->smb2.in.reserved = SVAL(req->in.body, 0x02); SMB2SRV_CHECK(smb2_pull_o16s16_string(&req->in, io, req->in.body+0x04, &io->smb2.in.path)); + /* the VFS backend does not yet handle NULL paths */ + if (io->smb2.in.path == NULL) { + io->smb2.in.path = ""; + } + req->status = smb2srv_tcon_backend(req, io); if (req->control_flags & SMB2SRV_REQ_CTRL_FLAG_NOT_REPLY) { -- 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/smb2/tcon.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/smb_server/smb2/tcon.c') diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c index 7f7d558b16..040947f84f 100644 --- a/source4/smb_server/smb2/tcon.c +++ b/source4/smb_server/smb2/tcon.c @@ -245,6 +245,7 @@ static NTSTATUS smb2srv_tcon_backend(struct smb2srv_request *req, union smb_tcon const char *service = io->smb2.in.path; struct share_config *scfg; const char *sharetype; + uint64_t ntvfs_caps = 0; if (strncmp(service, "\\\\", 2) == 0) { const char *p = strchr(service+2, '\\'); @@ -283,9 +284,12 @@ static NTSTATUS smb2srv_tcon_backend(struct smb2srv_request *req, union smb_tcon } req->tcon = tcon; + 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 From 405e64c437348bc9e3f7d4412a55e5cf05b3890d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 2 Jun 2008 11:05:06 +1000 Subject: more updates for new info levels (This used to be commit 85d1873ee92fcc7df3addc42ddb8189144901f8b) --- source4/smb_server/smb2/tcon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/smb_server/smb2/tcon.c') diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c index 040947f84f..be64013bb2 100644 --- a/source4/smb_server/smb2/tcon.c +++ b/source4/smb_server/smb2/tcon.c @@ -327,7 +327,7 @@ static NTSTATUS smb2srv_tcon_backend(struct smb2srv_request *req, union smb_tcon req->ntvfs = ntvfs_request_create(req->tcon->ntvfs, req, req->session->session_info, - 0, /* TODO: fill in PID */ + SVAL(req->in.hdr, SMB2_HDR_PID), req->request_time, req, NULL, 0); if (!req->ntvfs) { -- cgit