From a2f463bb3a66393f3934b465e73caab191277c6d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 22 May 2006 17:33:39 +0000 Subject: r15815: add SMB2 Lock client code metze (This used to be commit 4a307d7185862675fee23f55d3f85950a76f551d) --- source4/libcli/smb2/lock.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 source4/libcli/smb2/lock.c (limited to 'source4/libcli/smb2/lock.c') diff --git a/source4/libcli/smb2/lock.c b/source4/libcli/smb2/lock.c new file mode 100644 index 0000000000..73cc30c162 --- /dev/null +++ b/source4/libcli/smb2/lock.c @@ -0,0 +1,77 @@ +/* + Unix SMB/CIFS implementation. + + SMB2 client lock handling + + Copyright (C) Stefan Metzmacher 2006 + + 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" + +/* + send a lock request +*/ +struct smb2_request *smb2_lock_send(struct smb2_tree *tree, struct smb2_lock *io) +{ + struct smb2_request *req; + + req = smb2_request_init_tree(tree, SMB2_OP_LOCK, 0x30, False, 0); + if (req == NULL) return NULL; + + SIVAL(req->out.hdr, SMB2_HDR_PID, io->in.unknown2); + + SSVAL(req->out.body, 0x02, io->in.unknown1); + SIVAL(req->out.body, 0x04, io->in.unknown2); + smb2_push_handle(req->out.body+0x08, &io->in.file.handle); + SBVAL(req->out.body, 0x18, io->in.offset); + SBVAL(req->out.body, 0x20, io->in.count); + SIVAL(req->out.body, 0x28, io->in.unknown5); + SIVAL(req->out.body, 0x28, io->in.flags); + + smb2_transport_send(req); + + return req; +} + + +/* + recv a lock reply +*/ +NTSTATUS smb2_lock_recv(struct smb2_request *req, struct smb2_lock *io) +{ + if (!smb2_request_receive(req) || + smb2_request_is_error(req)) { + return smb2_request_destroy(req); + } + + SMB2_CHECK_PACKET_RECV(req, 0x04, False); + + io->out.unknown1 = SVAL(req->in.body, 0x02); + + return smb2_request_destroy(req); +} + +/* + sync lock request +*/ +NTSTATUS smb2_lock(struct smb2_tree *tree, struct smb2_lock *io) +{ + struct smb2_request *req = smb2_lock_send(tree, io); + return smb2_lock_recv(req, io); +} -- cgit From e982523bc0581906741ad45dea4126ae8a11731c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 22 May 2006 19:13:57 +0000 Subject: r15820: this line was just for testing metze (This used to be commit 1a9bfa2ac96d09d34d3c974ec5d89dc23bf3e153) --- source4/libcli/smb2/lock.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source4/libcli/smb2/lock.c') diff --git a/source4/libcli/smb2/lock.c b/source4/libcli/smb2/lock.c index 73cc30c162..c06c10a806 100644 --- a/source4/libcli/smb2/lock.c +++ b/source4/libcli/smb2/lock.c @@ -34,8 +34,6 @@ struct smb2_request *smb2_lock_send(struct smb2_tree *tree, struct smb2_lock *io req = smb2_request_init_tree(tree, SMB2_OP_LOCK, 0x30, False, 0); if (req == NULL) return NULL; - SIVAL(req->out.hdr, SMB2_HDR_PID, io->in.unknown2); - SSVAL(req->out.body, 0x02, io->in.unknown1); SIVAL(req->out.body, 0x04, io->in.unknown2); smb2_push_handle(req->out.body+0x08, &io->in.file.handle); -- cgit From 7e330c7c0c2aecf2dd2d049b0a58e20309ad4223 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 11 May 2007 08:59:14 +0000 Subject: r22788: fix typo metze (This used to be commit 635a636e89e462825efaacd5563c40fec2ceefb1) --- source4/libcli/smb2/lock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/smb2/lock.c') diff --git a/source4/libcli/smb2/lock.c b/source4/libcli/smb2/lock.c index c06c10a806..23693a0757 100644 --- a/source4/libcli/smb2/lock.c +++ b/source4/libcli/smb2/lock.c @@ -39,7 +39,7 @@ struct smb2_request *smb2_lock_send(struct smb2_tree *tree, struct smb2_lock *io smb2_push_handle(req->out.body+0x08, &io->in.file.handle); SBVAL(req->out.body, 0x18, io->in.offset); SBVAL(req->out.body, 0x20, io->in.count); - SIVAL(req->out.body, 0x28, io->in.unknown5); + SIVAL(req->out.body, 0x24, io->in.unknown5); SIVAL(req->out.body, 0x28, io->in.flags); smb2_transport_send(req); -- 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/libcli/smb2/lock.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/libcli/smb2/lock.c') diff --git a/source4/libcli/smb2/lock.c b/source4/libcli/smb2/lock.c index 23693a0757..470648a34c 100644 --- a/source4/libcli/smb2/lock.c +++ b/source4/libcli/smb2/lock.c @@ -7,7 +7,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, @@ -16,8 +16,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 2151cde58014ea2e822c13d2f8a369b45dc19ca8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 6 Oct 2007 22:28:14 +0000 Subject: r25554: Convert last instances of BOOL, True and False to the standard types. (This used to be commit 566aa14139510788548a874e9213d91317f83ca9) --- source4/libcli/smb2/lock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/libcli/smb2/lock.c') diff --git a/source4/libcli/smb2/lock.c b/source4/libcli/smb2/lock.c index 470648a34c..d71a337d56 100644 --- a/source4/libcli/smb2/lock.c +++ b/source4/libcli/smb2/lock.c @@ -30,7 +30,7 @@ struct smb2_request *smb2_lock_send(struct smb2_tree *tree, struct smb2_lock *io { struct smb2_request *req; - req = smb2_request_init_tree(tree, SMB2_OP_LOCK, 0x30, False, 0); + req = smb2_request_init_tree(tree, SMB2_OP_LOCK, 0x30, false, 0); if (req == NULL) return NULL; SSVAL(req->out.body, 0x02, io->in.unknown1); @@ -57,7 +57,7 @@ NTSTATUS smb2_lock_recv(struct smb2_request *req, struct smb2_lock *io) return smb2_request_destroy(req); } - SMB2_CHECK_PACKET_RECV(req, 0x04, False); + SMB2_CHECK_PACKET_RECV(req, 0x04, false); io->out.unknown1 = SVAL(req->in.body, 0x02); -- cgit From 4d39976dddf2adf6a0d659050c3a21a6e0ff8ab2 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 21 May 2008 22:12:20 +1000 Subject: fixed SMB2 locking - SMB2 locking is different in several ways from SMB locking. To fix it properly we will need a new generic mapping structure for locking, but for now do a best effort mapping - added locking to gentest_smb2 (This used to be commit ea6d9cf602302adafe0f9d5f5f90a9b26d1ead6f) --- source4/libcli/smb2/lock.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'source4/libcli/smb2/lock.c') diff --git a/source4/libcli/smb2/lock.c b/source4/libcli/smb2/lock.c index d71a337d56..62c6e5dba7 100644 --- a/source4/libcli/smb2/lock.c +++ b/source4/libcli/smb2/lock.c @@ -29,17 +29,25 @@ struct smb2_request *smb2_lock_send(struct smb2_tree *tree, struct smb2_lock *io) { struct smb2_request *req; + int i; - req = smb2_request_init_tree(tree, SMB2_OP_LOCK, 0x30, false, 0); + req = smb2_request_init_tree(tree, SMB2_OP_LOCK, + 24 + io->in.lock_count*24, false, 0); if (req == NULL) return NULL; - SSVAL(req->out.body, 0x02, io->in.unknown1); - SIVAL(req->out.body, 0x04, io->in.unknown2); + /* this is quite bizarre - the spec says we must lie about the length! */ + SSVAL(req->out.body, 0, 0x30); + + SSVAL(req->out.body, 0x02, io->in.lock_count); + SIVAL(req->out.body, 0x04, io->in.reserved); smb2_push_handle(req->out.body+0x08, &io->in.file.handle); - SBVAL(req->out.body, 0x18, io->in.offset); - SBVAL(req->out.body, 0x20, io->in.count); - SIVAL(req->out.body, 0x24, io->in.unknown5); - SIVAL(req->out.body, 0x28, io->in.flags); + + for (i=0;iin.lock_count;i++) { + SBVAL(req->out.body, 0x18 + i*24, io->in.locks[i].offset); + SBVAL(req->out.body, 0x20 + i*24, io->in.locks[i].length); + SIVAL(req->out.body, 0x28 + i*24, io->in.locks[i].flags); + SIVAL(req->out.body, 0x2C + i*24, io->in.locks[i].reserved); + } smb2_transport_send(req); @@ -59,7 +67,7 @@ NTSTATUS smb2_lock_recv(struct smb2_request *req, struct smb2_lock *io) SMB2_CHECK_PACKET_RECV(req, 0x04, false); - io->out.unknown1 = SVAL(req->in.body, 0x02); + io->out.reserved = SVAL(req->in.body, 0x02); return smb2_request_destroy(req); } -- cgit