Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into v4-0-test
authorAndrew Tridgell <tridge@samba.org>
Tue, 3 Jun 2008 22:11:42 +0000 (15:11 -0700)
committerAndrew Tridgell <tridge@samba.org>
Tue, 3 Jun 2008 22:11:42 +0000 (15:11 -0700)
24 files changed:
source/lib/crypto/config.mk
source/lib/crypto/crypto.h
source/lib/crypto/hmacsha256.c [new file with mode: 0644]
source/lib/crypto/hmacsha256.h [new file with mode: 0644]
source/lib/torture/torture.h
source/libcli/raw/interfaces.h
source/libcli/raw/rawsetfileinfo.c
source/libcli/raw/trans2.h
source/libcli/smb2/signing.c
source/ntvfs/common/brlock.c
source/ntvfs/common/brlock_tdb.c
source/ntvfs/ntvfs.h
source/ntvfs/ntvfs_generic.c
source/ntvfs/posix/pvfs_lock.c
source/ntvfs/posix/pvfs_oplock.c
source/setup/setpassword [changed mode: 0644->0755]
source/smb_server/smb/trans2.c
source/smb_server/smb2/fileinfo.c
source/smb_server/smb2/tcon.c
source/torture/basic/delaywrite.c
source/torture/gentest.c
source/torture/nbench/nbench.c
source/torture/smb2/getinfo.c
source/torture/smb2/scan.c

index b9a7f7cb9ec962809fc056a5ca6e9709714455fc..fb1c1bf6ce730a03f2ebbde22fa04c5c2a5728a6 100644 (file)
@@ -6,7 +6,7 @@
 
 LIBCRYPTO_OBJ_FILES = $(addprefix $(libcryptosrcdir)/, \
                                         crc32.o md5.o hmacmd5.o md4.o \
-                                        arcfour.o sha1.o hmacsha1.o)
+                                        arcfour.o sha1.o hmacsha1.o hmacsha256.o)
 
 
 [MODULE::TORTURE_LIBCRYPTO]
index 10e2258fa7d1371f82381d75b782dcf2f93678eb..03a233ec988c02672f7fa24dea77b26550052ec9 100644 (file)
@@ -23,6 +23,8 @@
 #include "lib/crypto/hmacmd5.h"
 #include "lib/crypto/sha1.h"
 #include "lib/crypto/hmacsha1.h"
+#include "heimdal/lib/hcrypto/sha.h"
+#include "lib/crypto/hmacsha256.h"
 
 struct arcfour_state {
        uint8_t sbox[256];
diff --git a/source/lib/crypto/hmacsha256.c b/source/lib/crypto/hmacsha256.c
new file mode 100644 (file)
index 0000000..5503bdd
--- /dev/null
@@ -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/source/lib/crypto/hmacsha256.h b/source/lib/crypto/hmacsha256.h
new file mode 100644 (file)
index 0000000..8960c63
--- /dev/null
@@ -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 */
index 15b04c23974c25edc7a5f4f729fc5ee800233498..f023f319ffe0c3802670e6fce256d27fdb55e101 100644 (file)
@@ -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)
index 19d51893a616411c7f211bb3446cee38d91b9728..8e23510f0691348663ab6f7386a0fd34d6dbb849 100644 (file)
@@ -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 */
index 16052e87086eaa5b9f86b9ecc46d51d4f4c0ab5d..5a4706778a4a0e2b586a634cda87c231f54d0504 100644 (file)
@@ -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);
 
index 5b7987aa8caa8d5d1fe67364a12e46accbf0b1f7..63632eb5edbda403b98afde7696a568fddd6ec76 100644 (file)
@@ -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 */
 /*
index 01f7576134b67b64e16af31d2fe8fcf6b2f7b8ec..16c0ff99c1bab4a243d5fa541ce07038e16c557e 100644 (file)
@@ -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);
 
index c87eca8aff3371da5d389c7188c2ca6719ac19da..3b3487315206bd77ececa84560abac59bb2791f1 100644 (file)
@@ -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)
 {
index 362a6d01e24d6c24af0d5de59a89c2cfcacdca2e..c94b9b446e67c19d54caae2a76b41a8b707f91ef 100644 (file)
@@ -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)
 {
index 7a2edc7e2c2b5570bf3616b3e2120618d2d1141b..5de8a8b6491cd7e0f81915907de5b4fbc8153a47 100644 (file)
@@ -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
index d70575847574f6a6ca361fdf2f32e99b6bb661bd..4f3a7e21983743dc8249770c014a2827dc419488 100644 (file)
@@ -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;
                        }
index 822b28246ad6f5a7a36cb8c490b78db7f0ccd26a..0054455838a98246df26b0410e20bd2666d6bd5f 100644 (file)
@@ -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)
 {
index dfa3697af7b27cc868cfedaee30245e5ad91aaca..71add72987ae67226e5436fd4914ae4022bccdde 100644 (file)
@@ -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) {
old mode 100644 (file)
new mode 100755 (executable)
index e5ba814cb21c9f77253fb18079a2c070165471ed..711c86bb74b88b6903b36728c068b17dfd7d1a83 100644 (file)
@@ -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;
        }
 
index 942000133c3dfe5d378dab0e96fa9dd1a521a4f3..6c4b8f33d5b839ce604880fcc69b9199104136c7 100644 (file)
@@ -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));
index 040947f84f3f7c784be796a6244728b60382d3d5..be64013bb252597b8bd644b925f68fd3e81bcaed 100644 (file)
@@ -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) {
index c7bccae08f8cee2caa16d73f95f740230115f66b..c03e89d36eb72738ea14ed639f597bc1b5ecde6e 100644 (file)
@@ -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; \
index 07d394fad6b79e12aeda17a89259eb1de2d17237..60243a5d1b8f961e07bc2309381016225dbef004 100644 (file)
@@ -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:
index 96144c47735592b5af885c7371ce3e0588e133e5..5a4037f906d1d73dba685ae5b9922ca0ab2100de 100644 (file)
@@ -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;
index 906d6e4f8d57bb4e32d8d7082b1593097323c7de..5b35d7e693a8fc1f8c9bbfdb21204fbdc421c2ff 100644 (file)
@@ -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);
 
index 1ce796be4da63194e0faa94d46ecbbc6a3b7627f..ae51af18820ed0ad97281be2a97814f3321423ef 100644 (file)
@@ -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));
                        }