summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rw-r--r--source4/lib/crypto/config.mk3
-rw-r--r--source4/lib/crypto/crypto.h2
-rw-r--r--source4/lib/crypto/hmacsha256.c92
-rw-r--r--source4/lib/crypto/hmacsha256.h38
-rw-r--r--source4/lib/torture/torture.h2
-rw-r--r--source4/libcli/raw/interfaces.h17
-rw-r--r--source4/libcli/raw/rawsetfileinfo.c29
-rw-r--r--source4/libcli/raw/trans2.h27
-rw-r--r--source4/libcli/smb2/signing.c21
-rw-r--r--source4/ntvfs/common/brlock.c2
-rw-r--r--source4/ntvfs/common/brlock_tdb.c8
-rw-r--r--source4/ntvfs/ntvfs.h2
-rw-r--r--source4/ntvfs/ntvfs_generic.c45
-rw-r--r--source4/ntvfs/posix/pvfs_lock.c2
-rw-r--r--source4/ntvfs/posix/pvfs_oplock.c2
-rwxr-xr-x[-rw-r--r--]source4/setup/setpassword0
-rw-r--r--source4/smb_server/smb/trans2.c15
-rw-r--r--source4/smb_server/smb2/fileinfo.c5
-rw-r--r--source4/smb_server/smb2/tcon.c2
-rw-r--r--source4/torture/basic/delaywrite.c12
-rw-r--r--source4/torture/gentest.c15
-rw-r--r--source4/torture/nbench/nbench.c3
-rw-r--r--source4/torture/smb2/getinfo.c35
-rw-r--r--source4/torture/smb2/scan.c17
24 files changed, 293 insertions, 103 deletions
diff --git a/source4/lib/crypto/config.mk b/source4/lib/crypto/config.mk
index f771a0e306..c35280abda 100644
--- a/source4/lib/crypto/config.mk
+++ b/source4/lib/crypto/config.mk
@@ -6,8 +6,7 @@
LIBCRYPTO_OBJ_FILES = $(addprefix $(libcryptosrcdir)/, \
crc32.o md5.o hmacmd5.o md4.o \
- arcfour.o)
-
+ arcfour.o hmacsha256.o)
[MODULE::TORTURE_LIBCRYPTO]
SUBSYSTEM = smbtorture
diff --git a/source4/lib/crypto/crypto.h b/source4/lib/crypto/crypto.h
index 513ae788de..54a4482325 100644
--- a/source4/lib/crypto/crypto.h
+++ b/source4/lib/crypto/crypto.h
@@ -21,6 +21,8 @@
#include "lib/crypto/md4.h"
#include "lib/crypto/md5.h"
#include "lib/crypto/hmacmd5.h"
+#include "heimdal/lib/hcrypto/sha.h"
+#include "lib/crypto/hmacsha256.h"
struct arcfour_state {
uint8_t sbox[256];
diff --git a/source4/lib/crypto/hmacsha256.c b/source4/lib/crypto/hmacsha256.c
new file mode 100644
index 0000000000..5503bdd59b
--- /dev/null
+++ b/source4/lib/crypto/hmacsha256.c
@@ -0,0 +1,92 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ Interface header: HMAC SHA-256 code
+
+ Copyright (C) Andrew Tridgell 2008
+
+ based in hmacsha1.c which is:
+ Copyright (C) Stefan Metzmacher
+
+ 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/>.
+*/
+
+/*
+ taken direct from rfc2202 implementation and modified for suitable use
+ */
+
+#include "includes.h"
+#include "lib/crypto/crypto.h"
+#include "heimdal/lib/hcrypto/sha.h"
+
+/***********************************************************************
+ the rfc 2104/2202 version of hmac_sha256 initialisation.
+***********************************************************************/
+_PUBLIC_ void hmac_sha256_init(const uint8_t *key, size_t key_len, struct HMACSHA256Context *ctx)
+{
+ int i;
+ uint8_t tk[SHA256_DIGEST_LENGTH];
+
+ /* if key is longer than 64 bytes reset it to key=HASH(key) */
+ if (key_len > 64)
+ {
+ SHA256_CTX tctx;
+
+ SHA256_Init(&tctx);
+ SHA256_Update(&tctx, key, key_len);
+ SHA256_Final(tk, &tctx);
+
+ key = tk;
+ key_len = SHA256_DIGEST_LENGTH;
+ }
+
+ /* start out by storing key in pads */
+ ZERO_STRUCT(ctx->k_ipad);
+ ZERO_STRUCT(ctx->k_opad);
+ memcpy( ctx->k_ipad, key, key_len);
+ memcpy( ctx->k_opad, key, key_len);
+
+ /* XOR key with ipad and opad values */
+ for (i=0; i<64; i++)
+ {
+ ctx->k_ipad[i] ^= 0x36;
+ ctx->k_opad[i] ^= 0x5c;
+ }
+
+ SHA256_Init(&ctx->ctx);
+ SHA256_Update(&ctx->ctx, ctx->k_ipad, 64);
+}
+
+/***********************************************************************
+ update hmac_sha256 "inner" buffer
+***********************************************************************/
+_PUBLIC_ void hmac_sha256_update(const uint8_t *data, size_t data_len, struct HMACSHA256Context *ctx)
+{
+ SHA256_Update(&ctx->ctx, data, data_len); /* then text of datagram */
+}
+
+/***********************************************************************
+ finish off hmac_sha256 "inner" buffer and generate outer one.
+***********************************************************************/
+_PUBLIC_ void hmac_sha256_final(uint8_t digest[SHA256_DIGEST_LENGTH], struct HMACSHA256Context *ctx)
+{
+ SHA256_CTX ctx_o;
+
+ SHA256_Final(digest, &ctx->ctx);
+
+ SHA256_Init(&ctx_o);
+ SHA256_Update(&ctx_o, ctx->k_opad, 64);
+ SHA256_Update(&ctx_o, digest, SHA256_DIGEST_LENGTH);
+ SHA256_Final(digest, &ctx_o);
+}
diff --git a/source4/lib/crypto/hmacsha256.h b/source4/lib/crypto/hmacsha256.h
new file mode 100644
index 0000000000..8960c636c1
--- /dev/null
+++ b/source4/lib/crypto/hmacsha256.h
@@ -0,0 +1,38 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ Interface header: HMAC SHA256 code
+
+ Copyright (C) Andrew Tridgell 2008
+
+ based on hmacsha1.h which is:
+
+ 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 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 _HMAC_SHA256_H
+
+struct HMACSHA256Context {
+ SHA256_CTX ctx;
+ uint8_t k_ipad[65];
+ uint8_t k_opad[65];
+};
+
+void hmac_sha256_init(const uint8_t *key, size_t key_len, struct HMACSHA256Context *ctx);
+void hmac_sha256_update(const uint8_t *data, size_t data_len, struct HMACSHA256Context *ctx);
+void hmac_sha256_final(uint8_t digest[20], struct HMACSHA256Context *ctx);
+
+#endif /* _HMAC_SHA256_H */
diff --git a/source4/lib/torture/torture.h b/source4/lib/torture/torture.h
index 15b04c2397..f023f319ff 100644
--- a/source4/lib/torture/torture.h
+++ b/source4/lib/torture/torture.h
@@ -257,7 +257,7 @@ void torture_result(struct torture_context *test,
do { const void *__got = (got), *__expected = (expected); \
if (memcmp(__got, __expected, len) != 0) { \
torture_result(torture_ctx, TORTURE_FAIL, \
- __location__": "#got" of len %d did not match"#expected": %s", len, cmt); \
+ __location__": "#got" of len %d did not match"#expected": %s", (int)len, cmt); \
return false; \
} \
} while(0)
diff --git a/source4/libcli/raw/interfaces.h b/source4/libcli/raw/interfaces.h
index 19d51893a6..8e23510f06 100644
--- a/source4/libcli/raw/interfaces.h
+++ b/source4/libcli/raw/interfaces.h
@@ -906,15 +906,24 @@ enum smb_setfileinfo_level {
RAW_SFILEINFO_RENAME_INFORMATION = SMB_SFILEINFO_RENAME_INFORMATION,
RAW_SFILEINFO_DISPOSITION_INFORMATION = SMB_SFILEINFO_DISPOSITION_INFORMATION,
RAW_SFILEINFO_POSITION_INFORMATION = SMB_SFILEINFO_POSITION_INFORMATION,
+ RAW_SFILEINFO_FULL_EA_INFORMATION = SMB_SFILEINFO_FULL_EA_INFORMATION,
RAW_SFILEINFO_MODE_INFORMATION = SMB_SFILEINFO_MODE_INFORMATION,
RAW_SFILEINFO_ALLOCATION_INFORMATION = SMB_SFILEINFO_ALLOCATION_INFORMATION,
RAW_SFILEINFO_END_OF_FILE_INFORMATION = SMB_SFILEINFO_END_OF_FILE_INFORMATION,
- RAW_SFILEINFO_1023 = SMB_SFILEINFO_1023,
+ RAW_SFILEINFO_PIPE_INFORMATION = SMB_SFILEINFO_PIPE_INFORMATION,
+ RAW_SFILEINFO_VALID_DATA_INFORMATION = SMB_SFILEINFO_VALID_DATA_INFORMATION,
+ RAW_SFILEINFO_SHORT_NAME_INFORMATION = SMB_SFILEINFO_SHORT_NAME_INFORMATION,
RAW_SFILEINFO_1025 = SMB_SFILEINFO_1025,
+ RAW_SFILEINFO_1027 = SMB_SFILEINFO_1027,
RAW_SFILEINFO_1029 = SMB_SFILEINFO_1029,
+ RAW_SFILEINFO_1030 = SMB_SFILEINFO_1030,
+ RAW_SFILEINFO_1031 = SMB_SFILEINFO_1031,
RAW_SFILEINFO_1032 = SMB_SFILEINFO_1032,
- RAW_SFILEINFO_1039 = SMB_SFILEINFO_1039,
- RAW_SFILEINFO_1040 = SMB_SFILEINFO_1040,
+ RAW_SFILEINFO_1036 = SMB_SFILEINFO_1036,
+ RAW_SFILEINFO_1041 = SMB_SFILEINFO_1041,
+ RAW_SFILEINFO_1042 = SMB_SFILEINFO_1042,
+ RAW_SFILEINFO_1043 = SMB_SFILEINFO_1043,
+ RAW_SFILEINFO_1044 = SMB_SFILEINFO_1044,
/* cope with breakage in SMB2 */
RAW_SFILEINFO_RENAME_INFORMATION_SMB2 = SMB_SFILEINFO_RENAME_INFORMATION|0x80000000,
@@ -1901,7 +1910,7 @@ union smb_lock {
uint16_t ulock_cnt;
uint16_t lock_cnt;
struct smb_lock_entry {
- uint16_t pid;
+ uint32_t pid; /* 16 bits in SMB1 */
uint64_t offset;
uint64_t count;
} *locks; /* unlocks are first in the arrray */
diff --git a/source4/libcli/raw/rawsetfileinfo.c b/source4/libcli/raw/rawsetfileinfo.c
index 16052e8708..5a4706778a 100644
--- a/source4/libcli/raw/rawsetfileinfo.c
+++ b/source4/libcli/raw/rawsetfileinfo.c
@@ -110,12 +110,20 @@ bool smb_raw_setfileinfo_passthru(TALLOC_CTX *mem_ctx,
}
/* Unhandled levels */
- case RAW_SFILEINFO_1023:
+ case RAW_SFILEINFO_PIPE_INFORMATION:
+ case RAW_SFILEINFO_VALID_DATA_INFORMATION:
+ case RAW_SFILEINFO_SHORT_NAME_INFORMATION:
case RAW_SFILEINFO_1025:
+ case RAW_SFILEINFO_1027:
case RAW_SFILEINFO_1029:
+ case RAW_SFILEINFO_1030:
+ case RAW_SFILEINFO_1031:
case RAW_SFILEINFO_1032:
- case RAW_SFILEINFO_1039:
- case RAW_SFILEINFO_1040:
+ case RAW_SFILEINFO_1036:
+ case RAW_SFILEINFO_1041:
+ case RAW_SFILEINFO_1042:
+ case RAW_SFILEINFO_1043:
+ case RAW_SFILEINFO_1044:
break;
default:
@@ -227,12 +235,21 @@ static bool smb_raw_setinfo_backend(struct smbcli_tree *tree,
parms, blob);
/* Unhandled passthru levels */
- case RAW_SFILEINFO_1023:
+ case RAW_SFILEINFO_PIPE_INFORMATION:
+ case RAW_SFILEINFO_VALID_DATA_INFORMATION:
+ case RAW_SFILEINFO_SHORT_NAME_INFORMATION:
+ case RAW_SFILEINFO_FULL_EA_INFORMATION:
case RAW_SFILEINFO_1025:
+ case RAW_SFILEINFO_1027:
case RAW_SFILEINFO_1029:
+ case RAW_SFILEINFO_1030:
+ case RAW_SFILEINFO_1031:
case RAW_SFILEINFO_1032:
- case RAW_SFILEINFO_1039:
- case RAW_SFILEINFO_1040:
+ case RAW_SFILEINFO_1036:
+ case RAW_SFILEINFO_1041:
+ case RAW_SFILEINFO_1042:
+ case RAW_SFILEINFO_1043:
+ case RAW_SFILEINFO_1044:
return smb_raw_setfileinfo_passthru(mem_ctx, parms->generic.level,
parms, blob);
diff --git a/source4/libcli/raw/trans2.h b/source4/libcli/raw/trans2.h
index 5b7987aa8c..63632eb5ed 100644
--- a/source4/libcli/raw/trans2.h
+++ b/source4/libcli/raw/trans2.h
@@ -217,32 +217,37 @@ Found 13 valid levels
#define SMB_SFILEINFO_UNIX_INFO2 0x20b
#define SMB_SFILEINFO_BASIC_INFORMATION 1004
#define SMB_SFILEINFO_RENAME_INFORMATION 1010
+#define SMB_SFILEINFO_LINK_INFORMATION 1011
#define SMB_SFILEINFO_DISPOSITION_INFORMATION 1013
#define SMB_SFILEINFO_POSITION_INFORMATION 1014
+#define SMB_SFILEINFO_FULL_EA_INFORMATION 1015
#define SMB_SFILEINFO_MODE_INFORMATION 1016
#define SMB_SFILEINFO_ALLOCATION_INFORMATION 1019
#define SMB_SFILEINFO_END_OF_FILE_INFORMATION 1020
-
-/* filemon shows FilePipeInformation */
-#define SMB_SFILEINFO_1023 1023
+#define SMB_SFILEINFO_PIPE_INFORMATION 1023
+#define SMB_SFILEINFO_VALID_DATA_INFORMATION 1039
+#define SMB_SFILEINFO_SHORT_NAME_INFORMATION 1040
/* filemon shows FilePipeRemoteInformation */
#define SMB_SFILEINFO_1025 1025
+/* vista scan responds */
+#define SMB_SFILEINFO_1027 1027
+
/* filemon shows CopyOnWriteInformation */
#define SMB_SFILEINFO_1029 1029
/* filemon shows OleClassIdInformation */
#define SMB_SFILEINFO_1032 1032
-/* seems to be the file size - perhaps valid data size?
- filemon shows 'InheritContentIndexInfo'
-*/
-#define SMB_SFILEINFO_1039 1039
-
-/* OLE_INFORMATION? */
-#define SMB_SFILEINFO_1040 1040
-
+/* vista scan responds to these */
+#define SMB_SFILEINFO_1030 1030
+#define SMB_SFILEINFO_1031 1031
+#define SMB_SFILEINFO_1036 1036
+#define SMB_SFILEINFO_1041 1041
+#define SMB_SFILEINFO_1042 1042
+#define SMB_SFILEINFO_1043 1043
+#define SMB_SFILEINFO_1044 1044
/* trans2 findfirst levels */
/*
diff --git a/source4/libcli/smb2/signing.c b/source4/libcli/smb2/signing.c
index 01f7576134..16c0ff99c1 100644
--- a/source4/libcli/smb2/signing.c
+++ b/source4/libcli/smb2/signing.c
@@ -23,7 +23,7 @@
#include "libcli/raw/libcliraw.h"
#include "libcli/smb2/smb2.h"
#include "libcli/smb2/smb2_calls.h"
-#include "heimdal/lib/hcrypto/sha.h"
+#include "lib/crypto/crypto.h"
/*
NOTE: this code does not yet interoperate with the windows SMB2
@@ -54,7 +54,7 @@ NTSTATUS smb2_sign_message(struct smb2_request *req)
{
struct smb2_request_buffer *buf = &req->out;
uint64_t session_id;
- SHA256_CTX m;
+ struct HMACSHA256Context m;
uint8_t res[32];
if (!req->transport->signing.doing_signing ||
@@ -85,11 +85,9 @@ NTSTATUS smb2_sign_message(struct smb2_request *req)
SIVAL(buf->hdr, SMB2_HDR_FLAGS, IVAL(buf->hdr, SMB2_HDR_FLAGS) | SMB2_HDR_FLAG_SIGNED);
ZERO_STRUCT(m);
- SHA256_Init(&m);
- SHA256_Update(&m, req->transport->signing.session_key.data,
- req->transport->signing.session_key.length);
- SHA256_Update(&m, buf->buffer+NBT_HDR_SIZE, buf->size-NBT_HDR_SIZE);
- SHA256_Final(res, &m);
+ hmac_sha256_init(req->transport->signing.session_key.data, 16, &m);
+ hmac_sha256_update(buf->buffer+NBT_HDR_SIZE, buf->size-NBT_HDR_SIZE, &m);
+ hmac_sha256_final(res, &m);
DEBUG(5,("signed SMB2 message of size %u\n", (unsigned)buf->size - NBT_HDR_SIZE));
@@ -110,7 +108,7 @@ NTSTATUS smb2_check_signature(struct smb2_transport *transport,
uint8_t *buffer, uint_t length)
{
uint64_t session_id;
- SHA256_CTX m;
+ struct HMACSHA256Context m;
uint8_t res[SHA256_DIGEST_LENGTH];
uint8_t sig[16];
@@ -147,10 +145,9 @@ NTSTATUS smb2_check_signature(struct smb2_transport *transport,
memset(buffer + NBT_HDR_SIZE + SMB2_HDR_SIGNATURE, 0, 16);
ZERO_STRUCT(m);
- SHA256_Init(&m);
- SHA256_Update(&m, transport->signing.session_key.data, 16);
- SHA256_Update(&m, buffer+NBT_HDR_SIZE, length-NBT_HDR_SIZE);
- SHA256_Final(res, &m);
+ hmac_sha256_init(transport->signing.session_key.data, 16, &m);
+ hmac_sha256_update(buffer+NBT_HDR_SIZE, length-NBT_HDR_SIZE, &m);
+ hmac_sha256_final(res, &m);
memcpy(buffer+NBT_HDR_SIZE+SMB2_HDR_SIGNATURE, sig, 16);
diff --git a/source4/ntvfs/common/brlock.c b/source4/ntvfs/common/brlock.c
index c87eca8aff..3b34873152 100644
--- a/source4/ntvfs/common/brlock.c
+++ b/source4/ntvfs/common/brlock.c
@@ -109,7 +109,7 @@ NTSTATUS brl_remove_pending(struct brl_context *brl,
*/
NTSTATUS brl_locktest(struct brl_context *brl,
struct brl_handle *brlh,
- uint16_t smbpid,
+ uint32_t smbpid,
uint64_t start, uint64_t size,
enum brl_type lock_type)
{
diff --git a/source4/ntvfs/common/brlock_tdb.c b/source4/ntvfs/common/brlock_tdb.c
index 362a6d01e2..c94b9b446e 100644
--- a/source4/ntvfs/common/brlock_tdb.c
+++ b/source4/ntvfs/common/brlock_tdb.c
@@ -57,7 +57,7 @@ struct brl_context {
*/
struct lock_context {
struct server_id server;
- uint16_t smbpid;
+ uint32_t smbpid;
struct brl_context *ctx;
};
@@ -286,7 +286,7 @@ static NTSTATUS brl_tdb_lock_failed(struct brl_handle *brlh, struct lock_struct
*/
static NTSTATUS brl_tdb_lock(struct brl_context *brl,
struct brl_handle *brlh,
- uint16_t smbpid,
+ uint32_t smbpid,
uint64_t start, uint64_t size,
enum brl_type lock_type,
void *notify_ptr)
@@ -436,7 +436,7 @@ static void brl_tdb_notify_all(struct brl_context *brl,
*/
static NTSTATUS brl_tdb_unlock(struct brl_context *brl,
struct brl_handle *brlh,
- uint16_t smbpid,
+ uint32_t smbpid,
uint64_t start, uint64_t size)
{
TDB_DATA kbuf, dbuf;
@@ -581,7 +581,7 @@ static NTSTATUS brl_tdb_remove_pending(struct brl_context *brl,
*/
static NTSTATUS brl_tdb_locktest(struct brl_context *brl,
struct brl_handle *brlh,
- uint16_t smbpid,
+ uint32_t smbpid,
uint64_t start, uint64_t size,
enum brl_type lock_type)
{
diff --git a/source4/ntvfs/ntvfs.h b/source4/ntvfs/ntvfs.h
index 7a2edc7e2c..5de8a8b649 100644
--- a/source4/ntvfs/ntvfs.h
+++ b/source4/ntvfs/ntvfs.h
@@ -263,7 +263,7 @@ struct ntvfs_request {
struct auth_session_info *session_info;
/* the smb pid is needed for locking contexts */
- uint16_t smbpid;
+ uint32_t smbpid;
/*
* client capabilities
diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c
index d705758475..4f3a7e2198 100644
--- a/source4/ntvfs/ntvfs_generic.c
+++ b/source4/ntvfs/ntvfs_generic.c
@@ -986,8 +986,8 @@ NTSTATUS ntvfs_map_qpathinfo(struct ntvfs_module_context *ntvfs,
NTVFS lock generic to any mapper
*/
NTSTATUS ntvfs_map_lock(struct ntvfs_module_context *ntvfs,
- struct ntvfs_request *req,
- union smb_lock *lck)
+ struct ntvfs_request *req,
+ union smb_lock *lck)
{
union smb_lock *lck2;
struct smb_lock_entry *locks;
@@ -1035,7 +1035,8 @@ NTSTATUS ntvfs_map_lock(struct ntvfs_module_context *ntvfs,
case RAW_LOCK_SMB2: {
/* this is only approximate! We need to change the
generic structure to fix this properly */
- int i, j;
+ int i;
+ bool isunlock;
if (lck->smb2.in.lock_count < 1) {
return NT_STATUS_INVALID_PARAMETER;
}
@@ -1051,32 +1052,28 @@ NTSTATUS ntvfs_map_lock(struct ntvfs_module_context *ntvfs,
if (lck2->generic.in.locks == NULL) {
return NT_STATUS_NO_MEMORY;
}
+ /* only the first lock gives the UNLOCK bit - see
+ MS-SMB2 3.3.5.14 */
+ if (lck->smb2.in.locks[0].flags & SMB2_LOCK_FLAG_UNLOCK) {
+ lck2->generic.in.ulock_cnt = lck->smb2.in.lock_count;
+ isunlock = true;
+ } else {
+ lck2->generic.in.lock_cnt = lck->smb2.in.lock_count;
+ isunlock = false;
+ }
for (i=0;i<lck->smb2.in.lock_count;i++) {
- if (!(lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_UNLOCK)) {
- break;
- }
- j = lck2->generic.in.ulock_cnt;
- if (lck->smb2.in.locks[i].flags &
- (SMB2_LOCK_FLAG_SHARED|SMB2_LOCK_FLAG_EXCLUSIVE)) {
+ if (isunlock &&
+ (lck->smb2.in.locks[i].flags &
+ (SMB2_LOCK_FLAG_SHARED|SMB2_LOCK_FLAG_EXCLUSIVE))) {
return NT_STATUS_INVALID_PARAMETER;
}
- lck2->generic.in.ulock_cnt++;
- lck2->generic.in.locks[j].pid = 0;
- lck2->generic.in.locks[j].offset = lck->smb2.in.locks[i].offset;
- lck2->generic.in.locks[j].count = lck->smb2.in.locks[i].length;
- lck2->generic.in.locks[j].pid = 0;
- }
- for (;i<lck->smb2.in.lock_count;i++) {
- if (lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_UNLOCK) {
- /* w2008 requires unlocks to come first */
+ if (!isunlock &&
+ (lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_UNLOCK)) {
return NT_STATUS_INVALID_PARAMETER;
}
- j = lck2->generic.in.ulock_cnt + lck2->generic.in.lock_cnt;
- lck2->generic.in.lock_cnt++;
- lck2->generic.in.locks[j].pid = 0;
- lck2->generic.in.locks[j].offset = lck->smb2.in.locks[i].offset;
- lck2->generic.in.locks[j].count = lck->smb2.in.locks[i].length;
- lck2->generic.in.locks[j].pid = 0;
+ lck2->generic.in.locks[i].pid = req->smbpid;
+ lck2->generic.in.locks[i].offset = lck->smb2.in.locks[i].offset;
+ lck2->generic.in.locks[i].count = lck->smb2.in.locks[i].length;
if (!(lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_EXCLUSIVE)) {
lck2->generic.in.mode = LOCKING_ANDX_SHARED_LOCK;
}
diff --git a/source4/ntvfs/posix/pvfs_lock.c b/source4/ntvfs/posix/pvfs_lock.c
index 822b28246a..0054455838 100644
--- a/source4/ntvfs/posix/pvfs_lock.c
+++ b/source4/ntvfs/posix/pvfs_lock.c
@@ -31,7 +31,7 @@
*/
NTSTATUS pvfs_check_lock(struct pvfs_state *pvfs,
struct pvfs_file *f,
- uint16_t smbpid,
+ uint32_t smbpid,
uint64_t offset, uint64_t count,
enum brl_type rw)
{
diff --git a/source4/ntvfs/posix/pvfs_oplock.c b/source4/ntvfs/posix/pvfs_oplock.c
index dfa3697af7..71add72987 100644
--- a/source4/ntvfs/posix/pvfs_oplock.c
+++ b/source4/ntvfs/posix/pvfs_oplock.c
@@ -177,7 +177,7 @@ static void pvfs_oplock_break_dispatch(struct messaging_context *msg,
opb = *p;
} else {
DEBUG(0,("%s: ignore oplock break with length[%u]\n",
- __location__, data->length));
+ __location__, (unsigned)data->length));
return;
}
if (opb.file_handle != opl->handle) {
diff --git a/source4/setup/setpassword b/source4/setup/setpassword
index 65770e1f4d..65770e1f4d 100644..100755
--- a/source4/setup/setpassword
+++ b/source4/setup/setpassword
diff --git a/source4/smb_server/smb/trans2.c b/source4/smb_server/smb/trans2.c
index e5ba814cb2..711c86bb74 100644
--- a/source4/smb_server/smb/trans2.c
+++ b/source4/smb_server/smb/trans2.c
@@ -588,12 +588,20 @@ static NTSTATUS trans2_parse_sfileinfo(struct smbsrv_request *req,
case RAW_SFILEINFO_UNIX_BASIC:
case RAW_SFILEINFO_UNIX_LINK:
case RAW_SFILEINFO_UNIX_HLINK:
- case RAW_SFILEINFO_1023:
+ case RAW_SFILEINFO_PIPE_INFORMATION:
+ case RAW_SFILEINFO_VALID_DATA_INFORMATION:
+ case RAW_SFILEINFO_SHORT_NAME_INFORMATION:
case RAW_SFILEINFO_1025:
+ case RAW_SFILEINFO_1027:
case RAW_SFILEINFO_1029:
+ case RAW_SFILEINFO_1030:
+ case RAW_SFILEINFO_1031:
case RAW_SFILEINFO_1032:
- case RAW_SFILEINFO_1039:
- case RAW_SFILEINFO_1040:
+ case RAW_SFILEINFO_1036:
+ case RAW_SFILEINFO_1041:
+ case RAW_SFILEINFO_1042:
+ case RAW_SFILEINFO_1043:
+ case RAW_SFILEINFO_1044:
return NT_STATUS_INVALID_LEVEL;
default:
@@ -784,6 +792,7 @@ static NTSTATUS find_fill_info(struct find_state *state,
SMBSRV_REQ_DEFAULT_STR_FLAGS(req));
case RAW_SEARCH_DATA_UNIX_INFO:
+ case RAW_SEARCH_DATA_UNIX_INFO2:
return NT_STATUS_INVALID_LEVEL;
}
diff --git a/source4/smb_server/smb2/fileinfo.c b/source4/smb_server/smb2/fileinfo.c
index 942000133c..6c4b8f33d5 100644
--- a/source4/smb_server/smb2/fileinfo.c
+++ b/source4/smb_server/smb2/fileinfo.c
@@ -53,6 +53,11 @@ static void smb2srv_getinfo_send(struct ntvfs_request *ntvfs)
SMB2SRV_CHECK(op->send_fn(op));
}
+ if (op->info->in.output_buffer_length < op->info->out.blob.length) {
+ smb2srv_send_error(req, NT_STATUS_INFO_LENGTH_MISMATCH);
+ return;
+ }
+
SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x08, true, op->info->out.blob.length));
SMB2SRV_CHECK(smb2_push_o16s32_blob(&req->out, 0x02, op->info->out.blob));
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) {
diff --git a/source4/torture/basic/delaywrite.c b/source4/torture/basic/delaywrite.c
index c7bccae08f..c03e89d36e 100644
--- a/source4/torture/basic/delaywrite.c
+++ b/source4/torture/basic/delaywrite.c
@@ -673,23 +673,11 @@ static bool test_finfo_after_write(struct torture_context *tctx, struct smbcli_s
} while (0)
#define COMPARE_ACCESS_TIME_EQUAL(given,correct) \
COMPARE_ACCESS_TIME_CMP(given,correct,!=)
-#define COMPARE_ACCESS_TIME_GREATER(given,correct) \
- COMPARE_ACCESS_TIME_CMP(given,correct,<=)
-#define COMPARE_ACCESS_TIME_LESS(given,correct) \
- COMPARE_ACCESS_TIME_CMP(given,correct,>=)
#define COMPARE_BOTH_TIMES_EQUAL(given,correct) do { \
COMPARE_ACCESS_TIME_EQUAL(given,correct); \
COMPARE_WRITE_TIME_EQUAL(given,correct); \
} while (0)
-#define COMPARE_BOTH_TIMES_GEATER(given,correct) do { \
- COMPARE_ACCESS_TIME_GREATER(given,correct); \
- COMPARE_WRITE_TIME_GREATER(given,correct); \
-} while (0)
-#define COMPARE_BOTH_TIMES_LESS(given,correct) do { \
- COMPARE_ACCESS_TIME_LESS(given,correct); \
- COMPARE_WRITE_TIME_LESS(given,correct); \
-} while (0)
#define GET_INFO_FILE(finfo) do { \
NTSTATUS _status; \
diff --git a/source4/torture/gentest.c b/source4/torture/gentest.c
index 07d394fad6..60243a5d1b 100644
--- a/source4/torture/gentest.c
+++ b/source4/torture/gentest.c
@@ -2199,16 +2199,20 @@ static void gen_setfileinfo(int instance, union smb_setfileinfo *info)
LVL(STANDARD), LVL(ALLOCATION_INFO), LVL(END_OF_FILE_INFO),
LVL(SETATTR), LVL(SETATTRE), LVL(BASIC_INFORMATION),
LVL(RENAME_INFORMATION), LVL(DISPOSITION_INFORMATION),
- LVL(POSITION_INFORMATION), LVL(MODE_INFORMATION),
+ LVL(POSITION_INFORMATION), LVL(FULL_EA_INFORMATION), LVL(MODE_INFORMATION),
LVL(ALLOCATION_INFORMATION), LVL(END_OF_FILE_INFORMATION),
- LVL(1023), LVL(1025), LVL(1029), LVL(1032), LVL(1039), LVL(1040),
+ LVL(PIPE_INFORMATION), LVL(VALID_DATA_INFORMATION), LVL(SHORT_NAME_INFORMATION),
+ LVL(1025), LVL(1027), LVL(1029), LVL(1030), LVL(1031), LVL(1032), LVL(1036),
+ LVL(1041), LVL(1042), LVL(1043), LVL(1044),
};
struct levels smb2_levels[] = {
LVL(BASIC_INFORMATION),
LVL(RENAME_INFORMATION), LVL(DISPOSITION_INFORMATION),
- LVL(POSITION_INFORMATION), LVL(MODE_INFORMATION),
+ LVL(POSITION_INFORMATION), LVL(FULL_EA_INFORMATION), LVL(MODE_INFORMATION),
LVL(ALLOCATION_INFORMATION), LVL(END_OF_FILE_INFORMATION),
- LVL(1023), LVL(1025), LVL(1029), LVL(1032), LVL(1039), LVL(1040)
+ LVL(PIPE_INFORMATION), LVL(VALID_DATA_INFORMATION), LVL(SHORT_NAME_INFORMATION),
+ LVL(1025), LVL(1027), LVL(1029), LVL(1030), LVL(1031), LVL(1032), LVL(1036),
+ LVL(1041), LVL(1042), LVL(1043), LVL(1044),
};
struct levels *levels = options.smb2?smb2_levels:smb_levels;
uint32_t num_levels = options.smb2?ARRAY_SIZE(smb2_levels):ARRAY_SIZE(smb_levels);
@@ -2276,12 +2280,9 @@ static void gen_setfileinfo(int instance, union smb_setfileinfo *info)
case RAW_SFILEINFO_GENERIC:
case RAW_SFILEINFO_SEC_DESC:
- case RAW_SFILEINFO_1023:
case RAW_SFILEINFO_1025:
case RAW_SFILEINFO_1029:
case RAW_SFILEINFO_1032:
- case RAW_SFILEINFO_1039:
- case RAW_SFILEINFO_1040:
case RAW_SFILEINFO_UNIX_BASIC:
case RAW_SFILEINFO_UNIX_INFO2:
case RAW_SFILEINFO_UNIX_LINK:
diff --git a/source4/torture/nbench/nbench.c b/source4/torture/nbench/nbench.c
index 96144c4773..5a4037f906 100644
--- a/source4/torture/nbench/nbench.c
+++ b/source4/torture/nbench/nbench.c
@@ -23,7 +23,6 @@
#include "torture/smbtorture.h"
#include "system/filesys.h"
#include "system/locale.h"
-#include "pstring.h"
#include "torture/nbench/proto.h"
@@ -59,7 +58,7 @@ static bool run_netbench(struct torture_context *tctx, struct smbcli_state *cli,
{
int torture_nprocs = torture_setting_int(tctx, "nprocs", 4);
int i;
- pstring line;
+ char line[1024];
char *cname;
FILE *f;
bool correct = true;
diff --git a/source4/torture/smb2/getinfo.c b/source4/torture/smb2/getinfo.c
index 906d6e4f8d..5b35d7e693 100644
--- a/source4/torture/smb2/getinfo.c
+++ b/source4/torture/smb2/getinfo.c
@@ -167,6 +167,40 @@ static bool torture_smb2_fsinfo(struct smb2_tree *tree)
}
+/*
+ test for buffer size handling
+*/
+static bool torture_smb2_buffercheck(struct smb2_tree *tree)
+{
+ NTSTATUS status;
+ struct smb2_handle handle;
+ struct smb2_getinfo b;
+
+ printf("Testing buffer size handling\n");
+ status = smb2_util_roothandle(tree, &handle);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf(__location__ " Unable to create root handle - %s\n", nt_errstr(status));
+ return false;
+ }
+
+ ZERO_STRUCT(b);
+ b.in.info_type = SMB2_GETINFO_FS;
+ b.in.info_class = 1;
+ b.in.output_buffer_length = 0x1;
+ b.in.input_buffer_length = 0;
+ b.in.file.handle = handle;
+
+ status = smb2_getinfo(tree, tree, &b);
+ if (!NT_STATUS_EQUAL(status, NT_STATUS_INFO_LENGTH_MISMATCH)) {
+ printf(__location__ " Wrong error code for small buffer %s\n",
+ nt_errstr(status));
+ return false;
+ }
+
+ return true;
+}
+
+
/* basic testing of all SMB2 getinfo levels
*/
bool torture_smb2_getinfo(struct torture_context *torture)
@@ -196,6 +230,7 @@ bool torture_smb2_getinfo(struct torture_context *torture)
ret &= torture_smb2_fileinfo(torture, tree);
ret &= torture_smb2_fsinfo(tree);
+ ret &= torture_smb2_buffercheck(tree);
talloc_free(mem_ctx);
diff --git a/source4/torture/smb2/scan.c b/source4/torture/smb2/scan.c
index 1ce796be4d..ae51af1882 100644
--- a/source4/torture/smb2/scan.c
+++ b/source4/torture/smb2/scan.c
@@ -77,22 +77,20 @@ bool torture_smb2_getinfo_scan(struct torture_context *torture)
io.in.file.handle = fhandle;
status = smb2_getinfo(tree, torture, &io);
- if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_INFO_CLASS) &&
- !NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER) &&
- !NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) {
- printf("file level 0x%02x:%02x is %ld bytes - %s\n",
+ if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_INFO_CLASS)) {
+ printf("file level 0x%02x:%02x %u is %ld bytes - %s\n",
io.in.info_type, io.in.info_class,
+ (unsigned)io.in.info_class,
(long)io.out.blob.length, nt_errstr(status));
dump_data(1, io.out.blob.data, io.out.blob.length);
}
io.in.file.handle = dhandle;
status = smb2_getinfo(tree, torture, &io);
- if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_INFO_CLASS) &&
- !NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER) &&
- !NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) {
- printf("dir level 0x%02x:%02x is %ld bytes - %s\n",
+ if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_INFO_CLASS)) {
+ printf("dir level 0x%02x:%02x %u is %ld bytes - %s\n",
io.in.info_type, io.in.info_class,
+ (unsigned)io.in.info_class,
(long)io.out.blob.length, nt_errstr(status));
dump_data(1, io.out.blob.data, io.out.blob.length);
}
@@ -134,8 +132,7 @@ bool torture_smb2_setinfo_scan(struct torture_context *torture)
io.in.level = (i<<8) | c;
io.in.file.handle = handle;
status = smb2_setinfo(tree, &io);
- if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_INFO_CLASS) &&
- !NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) {
+ if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_INFO_CLASS)) {
printf("file level 0x%04x - %s\n",
io.in.level, nt_errstr(status));
}