[SCM] Samba Shared Repository - branch master updated

Stefan Metzmacher metze at samba.org
Mon Oct 24 19:22:04 MDT 2011


The branch, master has been updated
       via  242292d s3:libsmb: make use of map_nt_error_from_unix_common() in async_smb.c
       via  6fb13f4 s3:libsmb: use HDR_* defines in cli_state_dispatch_smb1()
       via  648665a s3:libsmb: make use of smb_[set]len_nbt() in async_smb.c
       via  d670d06 s3:libsmb: use HDR_* defines in cli_pull_raw_error()
       via  1fa7300 libcli/smb: move smb_signing.[ch] to the toplevel
       via  aa2e5ce s3:libsmb/smb_signing: make use of HDR_* defines
       via  13a5f27 s3:libsmb/smb_signing: make use of smb_len_nbt()
       via  4db071c s3:libsmb/smb_signing: avoid usage of smb_ss_field
       via  ad3cabb s4:libcli: rename smb_signing.h to smb_raw_signing.h in the install directory
       via  d76758a libcli/smb: remove unused includes from read_smb.h
      from  4ba00ab Try and fix bug #8384 - Windows XP clients seem to crash smbd process every once in a while.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 242292d4deefadb14f96af46a1461fc694fad2f4
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Oct 25 00:49:08 2011 +0200

    s3:libsmb: make use of map_nt_error_from_unix_common() in async_smb.c
    
    metze
    
    Autobuild-User: Stefan Metzmacher <metze at samba.org>
    Autobuild-Date: Tue Oct 25 03:21:06 CEST 2011 on sn-devel-104

commit 6fb13f4c1932306e975eb91bcf4830f68139f1e2
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Oct 24 18:13:09 2011 +0200

    s3:libsmb: use HDR_* defines in cli_state_dispatch_smb1()
    
    metze

commit 648665a0087a46bce45be872730bf8bed4e1f1c2
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Oct 24 17:51:17 2011 +0200

    s3:libsmb: make use of smb_[set]len_nbt() in async_smb.c
    
    metze

commit d670d060fc43a77ac7d320ed9024c049c59d9963
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Oct 24 17:47:50 2011 +0200

    s3:libsmb: use HDR_* defines in cli_pull_raw_error()
    
    metze

commit 1fa7300037447c6e01438509343afd2e186f066c
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Oct 24 16:50:19 2011 +0200

    libcli/smb: move smb_signing.[ch] to the toplevel
    
    metze

commit aa2e5cea1c69c5417eec9734b70c0f63fb244d7e
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Oct 24 09:39:16 2011 +0200

    s3:libsmb/smb_signing: make use of HDR_* defines
    
    metze

commit 13a5f27db20f3bc17f7da516871b0011711dfd14
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Oct 24 09:39:16 2011 +0200

    s3:libsmb/smb_signing: make use of smb_len_nbt()
    
    metze

commit 4db071cca4c2e22ca33bd246b239986f7e9a4225
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Oct 24 09:30:47 2011 +0200

    s3:libsmb/smb_signing: avoid usage of smb_ss_field
    
    metze

commit ad3cabb6cb0542031d179bc7e0da2b007f07daf9
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Oct 24 17:12:51 2011 +0200

    s4:libcli: rename smb_signing.h to smb_raw_signing.h in the install directory
    
    metze

commit d76758ab9f3cb63d9f0710e09001f4c97c8690c9
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Oct 25 00:22:50 2011 +0200

    libcli/smb: remove unused includes from read_smb.h
    
    metze

-----------------------------------------------------------------------

Summary of changes:
 libcli/smb/read_smb.h                         |    4 +-
 {source3/libsmb => libcli/smb}/smb_signing.c  |   31 ++++++++++++-----------
 {source3/include => libcli/smb}/smb_signing.h |    0
 libcli/smb/wscript_build                      |   16 ++++++++----
 source3/Makefile.in                           |    2 +-
 source3/libsmb/async_smb.c                    |   32 +++++++++++++-----------
 source3/libsmb/clientgen.c                    |    2 +-
 source3/libsmb/clisigning.c                   |    2 +-
 source3/param/loadparm.c                      |    2 +-
 source3/smbd/signing.c                        |    2 +-
 source3/wscript_build                         |    1 -
 source4/libcli/wscript_build                  |    2 +-
 12 files changed, 52 insertions(+), 44 deletions(-)
 rename {source3/libsmb => libcli/smb}/smb_signing.c (93%)
 rename {source3/include => libcli/smb}/smb_signing.h (100%)


Changeset truncated at 500 lines:

diff --git a/libcli/smb/read_smb.h b/libcli/smb/read_smb.h
index ae4dfdd..1df2dc2 100644
--- a/libcli/smb/read_smb.h
+++ b/libcli/smb/read_smb.h
@@ -20,8 +20,8 @@
 #ifndef __LIBSMB_READ_SMB_H
 #define __LIBSMB_READ_SMB_H
 
-#include "lib/talloc/talloc.h"
-#include "lib/tevent/tevent.h"
+struct tevent_context;
+struct tevent_req;
 
 struct tevent_req *read_smb_send(TALLOC_CTX *mem_ctx,
 				 struct tevent_context *ev,
diff --git a/source3/libsmb/smb_signing.c b/libcli/smb/smb_signing.c
similarity index 93%
rename from source3/libsmb/smb_signing.c
rename to libcli/smb/smb_signing.c
index ba20723..a72760b 100644
--- a/source3/libsmb/smb_signing.c
+++ b/libcli/smb/smb_signing.c
@@ -21,6 +21,7 @@
 
 #include "includes.h"
 #include "../lib/crypto/md5.h"
+#include "smb_common.h"
 #include "smb_signing.h"
 
 /* Used by the SMB signing functions. */
@@ -142,7 +143,7 @@ static void smb_signing_md5(const DATA_BLOB *mac_key,
 			    const uint8_t *buf, uint32_t seq_number,
 			    uint8_t calc_md5_mac[16])
 {
-	const size_t offset_end_of_sig = (smb_ss_field + 8);
+	const size_t offset_end_of_sig = (NBT_HDR_SIZE + HDR_SS_FIELD + 8);
 	uint8_t sequence_buf[8];
 	struct MD5Context md5_ctx;
 
@@ -169,14 +170,14 @@ static void smb_signing_md5(const DATA_BLOB *mac_key,
 	MD5Update(&md5_ctx, mac_key->data, mac_key->length);
 
 	/* copy in the first bit of the SMB header */
-	MD5Update(&md5_ctx, buf + 4, smb_ss_field - 4);
+	MD5Update(&md5_ctx, buf + NBT_HDR_SIZE, HDR_SS_FIELD);
 
 	/* copy in the sequence number, instead of the signature */
 	MD5Update(&md5_ctx, sequence_buf, sizeof(sequence_buf));
 
 	/* copy in the rest of the packet in, skipping the signature */
 	MD5Update(&md5_ctx, buf + offset_end_of_sig, 
-		  smb_len(buf) - (offset_end_of_sig - 4));
+		  smb_len_nbt(buf) - (offset_end_of_sig - 4));
 
 	/* calculate the MD5 sig */
 	MD5Final(calc_md5_mac, &md5_ctx);
@@ -227,18 +228,18 @@ void smb_signing_sign_pdu(struct smb_signing_state *si,
 	}
 
 	/* JRA Paranioa test - we should be able to get rid of this... */
-	if (smb_len(outbuf) < (smb_ss_field + 8 - 4)) {
+	if (smb_len_nbt(outbuf) < (HDR_SS_FIELD + 8)) {
 		DEBUG(1,("smb_signing_sign_pdu: Logic error. "
 			 "Can't check signature on short packet! smb_len = %u\n",
-			 smb_len(outbuf)));
+			 smb_len_nbt(outbuf)));
 		abort();
 	}
 
-	com = SVAL(outbuf,smb_com);
-	flags = SVAL(outbuf,smb_flg);
+	com = SVAL(outbuf,NBT_HDR_SIZE+HDR_COM);
+	flags = SVAL(outbuf,NBT_HDR_SIZE+HDR_FLG);
 
 	if (!(flags & FLAG_REPLY)) {
-		uint16_t flags2 = SVAL(outbuf,smb_flg2);
+		uint16_t flags2 = SVAL(outbuf,NBT_HDR_SIZE+HDR_FLG2);
 		/*
 		 * If this is a request, specify what is
 		 * supported or required by the client
@@ -249,7 +250,7 @@ void smb_signing_sign_pdu(struct smb_signing_state *si,
 		if (si->negotiated && si->mandatory) {
 			flags2 |= FLAGS2_SMB_SECURITY_SIGNATURES_REQUIRED;
 		}
-		SSVAL(outbuf, smb_flg2, flags2);
+		SSVAL(outbuf, NBT_HDR_SIZE+HDR_FLG2, flags2);
 	}
 
 	if (si->mac_key.length == 0) {
@@ -268,9 +269,9 @@ void smb_signing_sign_pdu(struct smb_signing_state *si,
 	DEBUG(10, ("smb_signing_sign_pdu: sent SMB signature of\n"));
 	dump_data(10, calc_md5_mac, 8);
 
-	memcpy(&outbuf[smb_ss_field], calc_md5_mac, 8);
+	memcpy(&outbuf[NBT_HDR_SIZE+HDR_SS_FIELD], calc_md5_mac, 8);
 
-/*	outbuf[smb_ss_field+2]=0;
+/*	outbuf[NBT_HDR_SIZE+HDR_SS_FIELD+2]=0;
 	Uncomment this to test if the remote server actually verifies signatures...*/
 }
 
@@ -285,17 +286,17 @@ bool smb_signing_check_pdu(struct smb_signing_state *si,
 		return true;
 	}
 
-	if (smb_len(inbuf) < (smb_ss_field + 8 - 4)) {
+	if (smb_len_nbt(inbuf) < (HDR_SS_FIELD + 8)) {
 		DEBUG(1,("smb_signing_check_pdu: Can't check signature "
 			 "on short packet! smb_len = %u\n",
-			 smb_len(inbuf)));
-		return False;
+			 smb_len_nbt(inbuf)));
+		return false;
 	}
 
 	smb_signing_md5(&si->mac_key, inbuf,
 			seqnum, calc_md5_mac);
 
-	reply_sent_mac = &inbuf[smb_ss_field];
+	reply_sent_mac = &inbuf[NBT_HDR_SIZE+HDR_SS_FIELD];
 	good = (memcmp(reply_sent_mac, calc_md5_mac, 8) == 0);
 
 	if (!good) {
diff --git a/source3/include/smb_signing.h b/libcli/smb/smb_signing.h
similarity index 100%
rename from source3/include/smb_signing.h
rename to libcli/smb/smb_signing.h
diff --git a/libcli/smb/wscript_build b/libcli/smb/wscript_build
index 9339b96..8cb3e60 100644
--- a/libcli/smb/wscript_build
+++ b/libcli/smb/wscript_build
@@ -2,14 +2,20 @@
 
 
 bld.SAMBA_LIBRARY('cli_smb_common',
-	source='smb_seal.c smb2_create_blob.c smb2_signing.c util.c read_smb.c',
+	source='''
+		smb_signing.c smb_seal.c
+		smb2_create_blob.c smb2_signing.c
+		util.c read_smb.c
+	''',
 	autoproto='smb_common_proto.h',
 	deps='LIBCRYPTO errors gssapi gensec KRB5_WRAP LIBASYNC_REQ',
 	public_deps='talloc samba-util',
 	private_library=True,
-	public_headers='''smb_common.h smb2_constants.h smb_constants.h
-			smb_seal.h
-			smb2_create_blob.h smb2_signing.h smb_util.h smb_unix_ext.h
-			read_smb.h
+	public_headers='''
+		smb_common.h smb2_constants.h smb_constants.h
+		smb_signing.h smb_seal.h
+		smb2_create_blob.h smb2_signing.h
+		smb_util.h read_smb.h
+		smb_unix_ext.h
 	''',
 	)
diff --git a/source3/Makefile.in b/source3/Makefile.in
index 6f216c6..c303fe9 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -463,7 +463,7 @@ LIB_OBJ = $(LIBSAMBAUTIL_OBJ) $(UTIL_OBJ) $(CRYPTO_OBJ) $(LIBTSOCKET_OBJ) \
 	  lib/substitute.o lib/substitute_generic.o ../lib/util/substitute.o lib/dbwrap/dbwrap_util.o \
 	  lib/ms_fnmatch.o ../lib/util/ms_fnmatch.o lib/errmap_unix.o ../libcli/util/errmap_unix.o \
 	  lib/tallocmsg.o lib/dmallocmsg.o \
-	  libsmb/smb_signing.o \
+	  ../libcli/smb/smb_signing.o \
 	  ../lib/util/charset/iconv.o ../lib/util/charset/weird.o \
 	  ../lib/util/charset/charset_macosxfs.o intl/lang_tdb.o \
 	  lib/conn_tdb.o lib/adt_tree.o lib/gencache.o \
diff --git a/source3/libsmb/async_smb.c b/source3/libsmb/async_smb.c
index 283dec6..933b7e8 100644
--- a/source3/libsmb/async_smb.c
+++ b/source3/libsmb/async_smb.c
@@ -29,8 +29,9 @@
 
 static NTSTATUS cli_pull_raw_error(const uint8_t *buf)
 {
-	uint32_t flags2 = SVAL(buf, smb_flg2);
-	NTSTATUS status = NT_STATUS(IVAL(buf, smb_rcls));
+	const uint8_t *hdr = buf + NBT_HDR_SIZE;
+	uint32_t flags2 = SVAL(hdr, HDR_FLG2);
+	NTSTATUS status = NT_STATUS(IVAL(hdr, HDR_RCLS));
 
 	if (NT_STATUS_IS_OK(status)) {
 		return NT_STATUS_OK;
@@ -40,7 +41,7 @@ static NTSTATUS cli_pull_raw_error(const uint8_t *buf)
 		return status;
 	}
 
-	return NT_STATUS_DOS(CVAL(buf, smb_rcls), SVAL(buf,smb_err));
+	return NT_STATUS_DOS(CVAL(hdr, HDR_RCLS), SVAL(hdr, HDR_ERR));
 }
 
 /**
@@ -498,7 +499,7 @@ static NTSTATUS cli_smb_req_iov_send(struct tevent_req *req,
 		SSVAL(iov[0].iov_base, smb_mid, mid);
 	}
 
-	smb_setlen((char *)iov[0].iov_base, iov_len(iov, iov_count) - 4);
+	smb_setlen_nbt((char *)iov[0].iov_base, iov_len(iov, iov_count) - 4);
 
 	status = cli_signv(state->cli, iov, iov_count, &state->seqnum);
 
@@ -522,7 +523,7 @@ static NTSTATUS cli_smb_req_iov_send(struct tevent_req *req,
 			return status;
 		}
 		buf = (char *)talloc_memdup(state, enc_buf,
-					    smb_len(enc_buf)+4);
+					    smb_len_nbt(enc_buf)+4);
 		SAFE_FREE(enc_buf);
 		if (buf == NULL) {
 			return NT_STATUS_NO_MEMORY;
@@ -596,7 +597,7 @@ static void cli_smb_sent(struct tevent_req *subreq)
 	nwritten = writev_recv(subreq, &err);
 	TALLOC_FREE(subreq);
 	if (nwritten == -1) {
-		NTSTATUS status = map_nt_error_from_unix(err);
+		NTSTATUS status = map_nt_error_from_unix_common(err);
 		cli_state_notify_pending(state->cli, status);
 		return;
 	}
@@ -636,7 +637,7 @@ static void cli_smb_received(struct tevent_req *subreq)
 	TALLOC_FREE(subreq);
 	cli->conn.read_smb_req = NULL;
 	if (received == -1) {
-		status = map_nt_error_from_unix(err);
+		status = map_nt_error_from_unix_common(err);
 		cli_state_notify_pending(cli, status);
 		TALLOC_FREE(frame);
 		return;
@@ -679,9 +680,10 @@ static NTSTATUS cli_state_dispatch_smb1(struct cli_state *cli,
 	int i;
 	uint16_t mid;
 	bool oplock_break;
+	const uint8_t *inhdr = inbuf + NBT_HDR_SIZE;
 
-	if ((IVAL(inbuf, 4) != 0x424d53ff) /* 0xFF"SMB" */
-	    && (SVAL(inbuf, 4) != 0x45ff)) /* 0xFF"E" */ {
+	if ((IVAL(inhdr, 0) != SMB_MAGIC) /* 0xFF"SMB" */
+	    && (SVAL(inhdr, 0) != 0x45ff)) /* 0xFF"E" */ {
 		DEBUG(10, ("Got non-SMB PDU\n"));
 		return NT_STATUS_INVALID_NETWORK_RESPONSE;
 	}
@@ -712,7 +714,7 @@ static NTSTATUS cli_state_dispatch_smb1(struct cli_state *cli,
 		}
 	}
 
-	mid = SVAL(inbuf, smb_mid);
+	mid = SVAL(inhdr, HDR_MID);
 	num_pending = talloc_array_length(cli->conn.pending);
 
 	for (i=0; i<num_pending; i++) {
@@ -731,11 +733,11 @@ static NTSTATUS cli_state_dispatch_smb1(struct cli_state *cli,
 		/*
 		 * Paranoia checks that this is really an oplock break request.
 		 */
-		oplock_break = (smb_len(inbuf) == 51); /* hdr + 8 words */
-		oplock_break &= ((CVAL(inbuf, smb_flg) & FLAG_REPLY) == 0);
-		oplock_break &= (CVAL(inbuf, smb_com) == SMBlockingX);
-		oplock_break &= (SVAL(inbuf, smb_vwv6) == 0);
-		oplock_break &= (SVAL(inbuf, smb_vwv7) == 0);
+		oplock_break = (smb_len_nbt(inbuf) == 51); /* hdr + 8 words */
+		oplock_break &= ((CVAL(inhdr, HDR_FLG) & FLAG_REPLY) == 0);
+		oplock_break &= (CVAL(inhdr, HDR_COM) == SMBlockingX);
+		oplock_break &= (SVAL(inhdr, HDR_VWV+VWV(6)) == 0);
+		oplock_break &= (SVAL(inhdr, HDR_VWV+VWV(7)) == 0);
 
 		if (!oplock_break) {
 			/* Dump unexpected reply */
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index f5123ea..117fc99 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -21,7 +21,7 @@
 #include "includes.h"
 #include "libsmb/libsmb.h"
 #include "../lib/util/tevent_ntstatus.h"
-#include "smb_signing.h"
+#include "../libcli/smb/smb_signing.h"
 #include "../libcli/smb/smb_seal.h"
 #include "async_smb.h"
 
diff --git a/source3/libsmb/clisigning.c b/source3/libsmb/clisigning.c
index 4049aa0..2ce96c6 100644
--- a/source3/libsmb/clisigning.c
+++ b/source3/libsmb/clisigning.c
@@ -21,7 +21,7 @@
 
 #include "includes.h"
 #include "libsmb/libsmb.h"
-#include "smb_signing.h"
+#include "../libcli/smb/smb_signing.h"
 
 bool cli_simple_set_signing(struct cli_state *cli,
 			    const DATA_BLOB user_session_key,
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 3ea6f66..407ef68 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -64,7 +64,7 @@
 #include "ads.h"
 #include "../librpc/gen_ndr/svcctl.h"
 #include "intl.h"
-#include "smb_signing.h"
+#include "../libcli/smb/smb_signing.h"
 #include "dbwrap/dbwrap.h"
 #include "dbwrap/dbwrap_rbt.h"
 #include "smbldap.h"
diff --git a/source3/smbd/signing.c b/source3/smbd/signing.c
index bdf920c..8e08ae9 100644
--- a/source3/smbd/signing.c
+++ b/source3/smbd/signing.c
@@ -22,7 +22,7 @@
 #include "includes.h"
 #include "smbd/smbd.h"
 #include "smbd/globals.h"
-#include "smb_signing.h"
+#include "../libcli/smb/smb_signing.h"
 
 /***********************************************************
  Called to validate an incoming packet from the client.
diff --git a/source3/wscript_build b/source3/wscript_build
index 26a1ea2..f2c4148 100755
--- a/source3/wscript_build
+++ b/source3/wscript_build
@@ -66,7 +66,6 @@ LIB_SRC = '''
           lib/substitute.c lib/substitute_generic.c
           lib/ms_fnmatch.c
           lib/tallocmsg.c lib/dmallocmsg.c
-          libsmb/smb_signing.c
           intl/lang_tdb.c
           lib/conn_tdb.c lib/gencache.c
           lib/sessionid_tdb.c
diff --git a/source4/libcli/wscript_build b/source4/libcli/wscript_build
index 6c9454b..2e2a097 100644
--- a/source4/libcli/wscript_build
+++ b/source4/libcli/wscript_build
@@ -84,7 +84,7 @@ bld.SAMBA_LIBRARY('smbclient-raw',
 	autoproto='raw/raw_proto.h',
 	public_deps='samba_socket LIBPACKET LIBCRYPTO',
 	deps='cli_composite LIBCLI_RESOLVE security ndr samba-util errors charset talloc LIBCLI_SMB_COMPOSITE tevent NDR_NBT_BUF cli_smb_common',
-	public_headers='raw/request.h:smb_request.h raw/signing.h:smb_signing.h raw/libcliraw.h:smb_cliraw.h raw/interfaces.h:smb_raw_interfaces.h raw/smb.h:smb_raw.h raw/trans2.h:smb_raw_trans2.h',
+	public_headers='raw/request.h:smb_request.h raw/signing.h:smb_raw_signing.h raw/libcliraw.h:smb_cliraw.h raw/interfaces.h:smb_raw_interfaces.h raw/smb.h:smb_raw.h raw/trans2.h:smb_raw_trans2.h',
 	private_library=False,
 	pc_files='raw/smbclient-raw.pc',
 	vnum='0.0.1'


-- 
Samba Shared Repository


More information about the samba-cvs mailing list