[SCM] Samba Shared Repository - branch master updated
Stefan Metzmacher
metze at samba.org
Tue Apr 30 08:03:04 MDT 2013
The branch, master has been updated
via 5f82641 libsmb: Use sizeof instead of explicit numbers
via b8c1e30 libsmb: Use smb2_lease_push in smb2_create_send
via a8edad3 libcli: Add smb2_lease marshalling
via 96a8f6e libsmb: Move "struct smb2_lease" to common
from 7e80793 check_parent_exists() can change errno. Ensure we preserve it across calls.
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 5f82641553e33bc236b6c8a4f5cfc1cf3b722eea
Author: Volker Lendecke <vl at samba.org>
Date: Thu Apr 25 14:24:08 2013 +0200
libsmb: Use sizeof instead of explicit numbers
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
Autobuild-User(master): Stefan Metzmacher <metze at samba.org>
Autobuild-Date(master): Tue Apr 30 16:02:19 CEST 2013 on sn-devel-104
commit b8c1e30a6f2213c0dbb43a55bd5e1f498a610cab
Author: Volker Lendecke <vl at samba.org>
Date: Thu Apr 25 14:19:36 2013 +0200
libsmb: Use smb2_lease_push in smb2_create_send
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
commit a8edad3743a60b9521b2cd759e22e6350c41cc06
Author: Volker Lendecke <vl at samba.org>
Date: Wed Apr 17 17:04:38 2013 +0200
libcli: Add smb2_lease marshalling
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
commit 96a8f6e0fb9042fe125c9552dfb4c3f6d19cb225
Author: Volker Lendecke <vl at samba.org>
Date: Wed Apr 17 16:48:21 2013 +0200
libsmb: Move "struct smb2_lease" to common
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
-----------------------------------------------------------------------
Summary of changes:
libcli/smb/smb2_lease.c | 86 +++++++++++++++++++++++++++++++++++++++
libcli/smb/smb2_lease.h | 50 ++++++++++++++++++++++
libcli/smb/smb_common.h | 1 +
libcli/smb/wscript | 2 +
source4/libcli/raw/interfaces.h | 17 --------
source4/libcli/smb2/create.c | 34 +++++++--------
6 files changed, 155 insertions(+), 35 deletions(-)
create mode 100644 libcli/smb/smb2_lease.c
create mode 100644 libcli/smb/smb2_lease.h
Changeset truncated at 500 lines:
diff --git a/libcli/smb/smb2_lease.c b/libcli/smb/smb2_lease.c
new file mode 100644
index 0000000..10beaca
--- /dev/null
+++ b/libcli/smb/smb2_lease.c
@@ -0,0 +1,86 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ SMB2 Lease context handling
+
+ Copyright (C) Stefan Metzmacher 2012
+ Copyright (C) Volker Lendecke 2013
+
+ 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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "../libcli/smb/smb_common.h"
+
+ssize_t smb2_lease_pull(uint8_t *buf, size_t len, struct smb2_lease *lease)
+{
+ int version;
+
+ switch (len) {
+ case 32:
+ version = 1;
+ break;
+ case 52:
+ version = 2;
+ break;
+ default:
+ return -1;
+ }
+
+ memcpy(&lease->lease_key, buf, 16);
+ lease->lease_state = IVAL(buf, 16);
+ lease->lease_flags = IVAL(buf, 20);
+ lease->lease_duration = BVAL(buf, 24);
+
+ switch (version) {
+ case 1:
+ memcpy(&lease->parent_lease_key, buf+32, 16);
+ lease->lease_epoch = SVAL(buf, 48);
+ break;
+ case 2:
+ ZERO_STRUCT(lease->parent_lease_key);
+ lease->lease_epoch = 0;
+ break;
+ }
+
+ return len;
+}
+
+bool smb2_lease_push(const struct smb2_lease *lease, uint8_t *buf, size_t len)
+{
+ int version;
+
+ switch (len) {
+ case 32:
+ version = 1;
+ break;
+ case 52:
+ version = 2;
+ break;
+ default:
+ return false;
+ }
+
+ memcpy(&buf[0], &lease->lease_key, 16);
+ SIVAL(buf, 16, lease->lease_state);
+ SIVAL(buf, 20, lease->lease_flags);
+ SBVAL(buf, 24, lease->lease_duration);
+
+ if (version == 2) {
+ memcpy(&buf[32], &lease->parent_lease_key, 16);
+ SIVAL(buf, 48, lease->lease_epoch);
+ }
+
+ return true;
+}
diff --git a/libcli/smb/smb2_lease.h b/libcli/smb/smb2_lease.h
new file mode 100644
index 0000000..fa8e7af
--- /dev/null
+++ b/libcli/smb/smb2_lease.h
@@ -0,0 +1,50 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ SMB2 Lease context handling
+
+ Copyright (C) Stefan Metzmacher 2012
+ Copyright (C) Volker Lendecke 2013
+
+ 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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _LIBCLI_SMB_SMB2_LEASE_H_
+#define _LIBCLI_SMB_SMB2_LEASE_H_
+
+/*
+ SMB2 lease structure (per MS-SMB2 2.2.13)
+*/
+struct smb2_lease_key {
+ uint64_t data[2];
+};
+
+struct smb2_lease {
+ struct smb2_lease_key lease_key;
+ uint32_t lease_state;
+ uint32_t lease_flags;
+ uint64_t lease_duration; /* should be 0 */
+ /* only for v2 */
+ struct smb2_lease_key parent_lease_key;
+ uint16_t lease_epoch;
+};
+
+/*
+ * Parse a smb2 lease create context. Return -1 on error, buffer.length on
+ * success. V1 and V2 differ only by length of buffer.length
+ */
+ssize_t smb2_lease_pull(uint8_t *buf, size_t len, struct smb2_lease *lease);
+bool smb2_lease_push(const struct smb2_lease *lease, uint8_t *buf, size_t len);
+
+#endif /* _LIBCLI_SMB_SMB2_LEASE_H_ */
diff --git a/libcli/smb/smb_common.h b/libcli/smb/smb_common.h
index 47a336a..2f66b0a 100644
--- a/libcli/smb/smb_common.h
+++ b/libcli/smb/smb_common.h
@@ -25,6 +25,7 @@
#include "libcli/smb/smb_constants.h"
#include "libcli/smb/smb2_constants.h"
#include "libcli/smb/smb2_create_blob.h"
+#include "libcli/smb/smb2_lease.h"
#include "libcli/smb/smb2_signing.h"
#include "libcli/smb/smb_util.h"
#include "libcli/smb/smb_unix_ext.h"
diff --git a/libcli/smb/wscript b/libcli/smb/wscript
index 3616ad1..544c43e 100755
--- a/libcli/smb/wscript
+++ b/libcli/smb/wscript
@@ -18,6 +18,7 @@ def build(bld):
source='''
smb_signing.c smb_seal.c
smb2_create_blob.c smb2_signing.c
+ smb2_lease.c
util.c
smbXcli_base.c
smb1cli_trans.c
@@ -41,6 +42,7 @@ def build(bld):
smb_common.h smb2_constants.h smb_constants.h
smb_signing.h smb_seal.h
smb2_create_blob.h smb2_signing.h
+ smb2_lease.h
smb_util.h
smb_unix_ext.h
''',
diff --git a/source4/libcli/raw/interfaces.h b/source4/libcli/raw/interfaces.h
index fb73f26..7bc79ca 100644
--- a/source4/libcli/raw/interfaces.h
+++ b/source4/libcli/raw/interfaces.h
@@ -54,23 +54,6 @@ struct smb2_handle {
uint64_t data[2];
};
-/*
- SMB2 lease structure (per MS-SMB2 2.2.13)
-*/
-struct smb2_lease_key {
- uint64_t data[2];
-};
-
-struct smb2_lease {
- struct smb2_lease_key lease_key;
- uint32_t lease_state;
- uint32_t lease_flags;
- uint64_t lease_duration; /* should be 0 */
- /* only for v2 */
- struct smb2_lease_key parent_lease_key;
- uint16_t lease_epoch;
-};
-
struct smb2_lease_break {
struct smb2_lease current_lease;
uint32_t break_flags;
diff --git a/source4/libcli/smb2/create.c b/source4/libcli/smb2/create.c
index 7267f92..1a7f02b 100644
--- a/source4/libcli/smb2/create.c
+++ b/source4/libcli/smb2/create.c
@@ -212,14 +212,15 @@ struct smb2_request *smb2_create_send(struct smb2_tree *tree, struct smb2_create
if (io->in.lease_request) {
uint8_t data[32];
- memcpy(&data[0], &io->in.lease_request->lease_key, 16);
- SIVAL(data, 16, io->in.lease_request->lease_state);
- SIVAL(data, 20, io->in.lease_request->lease_flags);
- SBVAL(data, 24, io->in.lease_request->lease_duration);
+ if (!smb2_lease_push(io->in.lease_request, data,
+ sizeof(data))) {
+ TALLOC_FREE(req);
+ return NULL;
+ }
- status = smb2_create_blob_add(req, &blobs,
- SMB2_CREATE_TAG_RQLS,
- data_blob_const(data, 32));
+ status = smb2_create_blob_add(
+ req, &blobs, SMB2_CREATE_TAG_RQLS,
+ data_blob_const(data, sizeof(data)));
if (!NT_STATUS_IS_OK(status)) {
talloc_free(req);
return NULL;
@@ -227,20 +228,17 @@ struct smb2_request *smb2_create_send(struct smb2_tree *tree, struct smb2_create
}
if (io->in.lease_request_v2) {
- struct smb2_lease *ls = io->in.lease_request_v2;
uint8_t data[52];
- memcpy(&data[0], &ls->lease_key, 16);
- SIVAL(data, 16, ls->lease_state);
- SIVAL(data, 20, ls->lease_flags);
- SBVAL(data, 24, ls->lease_duration);
- memcpy(&data[32], &ls->parent_lease_key, 16);
- SSVAL(data, 48, ls->lease_epoch);
- SSVAL(data, 50, 0); /* reserved */
+ if (!smb2_lease_push(io->in.lease_request_v2, data,
+ sizeof(data))) {
+ TALLOC_FREE(req);
+ return NULL;
+ }
- status = smb2_create_blob_add(req, &blobs,
- SMB2_CREATE_TAG_RQLS,
- data_blob_const(data, 52));
+ status = smb2_create_blob_add(
+ req, &blobs, SMB2_CREATE_TAG_RQLS,
+ data_blob_const(data, sizeof(data)));
if (!NT_STATUS_IS_OK(status)) {
talloc_free(req);
return NULL;
--
Samba Shared Repository
More information about the samba-cvs
mailing list