[SCM] Samba Shared Repository - branch v4-0-test updated - release-4-0-0alpha3-1645-ge360be0

Andrew Tridgell tridge at samba.org
Tue May 20 05:59:38 GMT 2008


The branch, v4-0-test has been updated
       via  e360be0b99b638afdfa789e217bf08f99d09be7a (commit)
       via  c05ed7bb9ae7211a7001fd0a3403744ba4f6dda0 (commit)
       via  d4f41db964ce82c8889017d0f932d60100b3cd32 (commit)
       via  aa9108374f0dda8510245a6e69a53189f55a81e3 (commit)
       via  e90c7587385598a1dd976c2420798f9bd682b43d (commit)
       via  634a4bbd98e1c281f8339073b90cb7696ac59baa (commit)
       via  b2f1154bc338fb56fc998f40159156cb6859075b (commit)
       via  c05b58940f06b01b9770c218eb0708cb621215ef (commit)
       via  6a3b1cd6698faa460c6258bb41b4936e363f4387 (commit)
       via  7989ca861dcc700b52be3a47ea5ae8b03fbb9330 (commit)
       via  ffbd222d651dcddb19cacdc50cdbfeaefa816940 (commit)
       via  1e0c24b2760f2a632333b51710cd9581f0cee851 (commit)
       via  733937e87a1adcc19492ea2bd138e705701901b6 (commit)
       via  1323aab11fbf346e19c4cef227d727ddfcaa7d60 (commit)
       via  67290e0ad69df2f2fe651249c6550b8e32dd641b (commit)
       via  ac10e3ad15dd17b96424987d1a2b7a0e4dc67cd0 (commit)
       via  5b6f80aba30fc8ade26f73b0a1336c22e40b66a9 (commit)
       via  5240e1e25655af1f9b92da99e85d845bf30c4e9e (commit)
       via  433038f3fea60087bdca07dcc856d0be4a4753f3 (commit)
       via  a5459bd88092863668db199953458fe97162240c (commit)
       via  d5165ed7a77120f42c25c4997be2630f0f1cb98c (commit)
       via  edb4b38ed33b545d8024f45c602d3f5e4a74c511 (commit)
       via  8007342061d77eb711af0652ecd38aec0d3cc9d1 (commit)
       via  0e4b8602dec3ec87676c91a99371e5d77fe78196 (commit)
       via  b7560afd4bab984c0083e9687b69bc42970ad932 (commit)
       via  1acc8077fb86c1e78724b010d149db166d98238d (commit)
       via  6ea8295a64ff5425def11b0d1cd988ef000320be (commit)
      from  5dfa316b3636718ffc6fd26cf7a397a797bd2ac1 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v4-0-test


- Log -----------------------------------------------------------------
commit e360be0b99b638afdfa789e217bf08f99d09be7a
Merge: c05ed7bb9ae7211a7001fd0a3403744ba4f6dda0 5dfa316b3636718ffc6fd26cf7a397a797bd2ac1
Author: Andrew Tridgell <tridge at samba.org>
Date:   Tue May 20 15:35:49 2008 +1000

    Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into v4-0-test

commit c05ed7bb9ae7211a7001fd0a3403744ba4f6dda0
Author: Andrew Tridgell <tridge at samba.org>
Date:   Tue May 20 15:16:53 2008 +1000

    added read and write handlers. Fixed --analyse

commit d4f41db964ce82c8889017d0f932d60100b3cd32
Author: Andrew Tridgell <tridge at samba.org>
Date:   Tue May 20 13:37:51 2008 +1000

    added smb2_util_setatr

commit aa9108374f0dda8510245a6e69a53189f55a81e3
Author: Andrew Tridgell <tridge at samba.org>
Date:   Tue May 20 13:37:40 2008 +1000

    specify which server failed to deltree

commit e90c7587385598a1dd976c2420798f9bd682b43d
Author: Andrew Tridgell <tridge at samba.org>
Date:   Tue May 20 13:37:27 2008 +1000

    added SMB2 setpathinfo composite wrapper

commit 634a4bbd98e1c281f8339073b90cb7696ac59baa
Author: Andrew Tridgell <tridge at samba.org>
Date:   Tue May 20 11:59:43 2008 +1000

    first version of gentest_smb2. Only generates create and close so far.

commit b2f1154bc338fb56fc998f40159156cb6859075b
Author: Andrew Tridgell <tridge at samba.org>
Date:   Tue May 20 11:59:18 2008 +1000

    moved these util functions into libcli

commit c05b58940f06b01b9770c218eb0708cb621215ef
Author: Andrew Tridgell <tridge at samba.org>
Date:   Tue May 20 11:58:47 2008 +1000

    check the creation options where the client can require a path to be a
    file or a directory

commit 6a3b1cd6698faa460c6258bb41b4936e363f4387
Author: Andrew Tridgell <tridge at samba.org>
Date:   Tue May 20 11:58:04 2008 +1000

    added some SMB2 utility functions

commit 7989ca861dcc700b52be3a47ea5ae8b03fbb9330
Author: Andrew Tridgell <tridge at samba.org>
Date:   Tue May 20 11:57:43 2008 +1000

    remember the server time fields on negotiate. Needed for gentest

commit ffbd222d651dcddb19cacdc50cdbfeaefa816940
Merge: 1e0c24b2760f2a632333b51710cd9581f0cee851 b6f91ce75ae401bed515012fa3019a6241e7ff6d
Author: Andrew Tridgell <tridge at samba.org>
Date:   Tue May 20 11:37:23 2008 +1000

    Merge commit 'origin/v4-0-test' into vfs_smb2

commit 1e0c24b2760f2a632333b51710cd9581f0cee851
Author: Andrew Tridgell <tridge at samba.org>
Date:   Mon May 19 13:05:08 2008 +1000

    added SMB2 proxying of rmdir

commit 733937e87a1adcc19492ea2bd138e705701901b6
Merge: 1323aab11fbf346e19c4cef227d727ddfcaa7d60 b4613e81351fa0477d0c76a19fb0474a79f8689f
Author: Andrew Tridgell <tridge at samba.org>
Date:   Mon May 19 11:40:25 2008 +1000

    Merge commit 'origin/v4-0-test' into vfs_smb2

commit 1323aab11fbf346e19c4cef227d727ddfcaa7d60
Author: Andrew Tridgell <tridge at samba.org>
Date:   Mon May 19 11:39:16 2008 +1000

    added mkdir to SMB2 proxy

commit 67290e0ad69df2f2fe651249c6550b8e32dd641b
Author: Andrew Tridgell <tridge at samba.org>
Date:   Fri May 16 15:03:58 2008 +1000

    private -> private_data for struct smb2_request

commit ac10e3ad15dd17b96424987d1a2b7a0e4dc67cd0
Author: Andrew Tridgell <tridge at samba.org>
Date:   Fri May 16 15:03:24 2008 +1000

    build the smb2 composite calls

commit 5b6f80aba30fc8ade26f73b0a1336c22e40b66a9
Author: Andrew Tridgell <tridge at samba.org>
Date:   Fri May 16 15:03:12 2008 +1000

    declare composite_wait_free()

commit 5240e1e25655af1f9b92da99e85d845bf30c4e9e
Author: Andrew Tridgell <tridge at samba.org>
Date:   Fri May 16 15:02:58 2008 +1000

    - added a composite_wait_free() call
    
    - allow composite_error() to take NT_STATUS_OK

commit 433038f3fea60087bdca07dcc856d0be4a4753f3
Author: Andrew Tridgell <tridge at samba.org>
Date:   Fri May 16 15:02:14 2008 +1000

    started adding SMB2 composite functions that emulate common SMB calls
    (such as unlink)

commit a5459bd88092863668db199953458fe97162240c
Author: Andrew Tridgell <tridge at samba.org>
Date:   Fri May 16 15:01:31 2008 +1000

    added SMB2 proxying for unlink

commit d5165ed7a77120f42c25c4997be2630f0f1cb98c
Author: Andrew Tridgell <tridge at samba.org>
Date:   Fri May 16 12:46:28 2008 +1000

    fixed warning

commit edb4b38ed33b545d8024f45c602d3f5e4a74c511
Author: Andrew Tridgell <tridge at samba.org>
Date:   Fri May 16 12:46:16 2008 +1000

    fixed file_index reference

commit 8007342061d77eb711af0652ecd38aec0d3cc9d1
Author: Andrew Tridgell <tridge at samba.org>
Date:   Thu May 15 20:47:28 2008 +1000

    added handlers for connect, search_first and fsinfo.
    
    Directory listing in smbclient now works

commit 0e4b8602dec3ec87676c91a99371e5d77fe78196
Author: Andrew Tridgell <tridge at samba.org>
Date:   Thu May 15 20:46:43 2008 +1000

    better match WSPP doc name for find flags

commit b7560afd4bab984c0083e9687b69bc42970ad932
Author: Andrew Tridgell <tridge at samba.org>
Date:   Thu May 15 20:46:10 2008 +1000

    update some SMB2 find flags

commit 1acc8077fb86c1e78724b010d149db166d98238d
Author: Andrew Tridgell <tridge at samba.org>
Date:   Thu May 15 20:45:30 2008 +1000

    use a newer fsinfo level in smbclient, to support larger disks

commit 6ea8295a64ff5425def11b0d1cd988ef000320be
Author: Andrew Tridgell <tridge at samba.org>
Date:   Thu May 15 10:57:22 2008 +1000

    started new vfs_smb2 module
    
    This new module is based on the vfs_cifs module. The idea is to create a backend
    which maps SMB requests to a SMB2 server. This will allow existing
    test suites for SMB to be run against our SMB2 client and server code.
    
    It will also help validate our SMB2 client library, probably leading
    to some API changes to make it flexible enough

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

Summary of changes:
 source/client/client.c                      |    9 +-
 source/libcli/clifile.c                     |   11 +-
 source/libcli/composite/composite.c         |   19 +-
 source/libcli/composite/composite.h         |    1 +
 source/libcli/config.mk                     |    3 +-
 source/libcli/raw/interfaces.h              |    7 +-
 source/libcli/smb2/config.mk                |    2 +-
 source/libcli/smb2/connect.c                |   11 +-
 source/libcli/smb2/find.c                   |    2 +-
 source/libcli/smb2/request.c                |   25 +-
 source/libcli/smb2/session.c                |    4 +-
 source/libcli/smb2/smb2.h                   |    9 +-
 source/libcli/smb2/util.c                   |  200 +++
 source/libcli/smb_composite/smb2.c          |  371 +++++
 source/libcli/smb_composite/smb_composite.h |    1 +
 source/librpc/rpc/dcerpc_smb2.c             |   16 +-
 source/ntvfs/config.mk                      |   14 +
 source/ntvfs/ntvfs_base.c                   |    1 +
 source/ntvfs/posix/pvfs_open.c              |   14 +
 source/ntvfs/smb2/vfs_smb2.c                |  844 ++++++++++++
 source/smb_server/smb/receive.c             |    3 +-
 source/smb_server/smb2/find.c               |    4 +-
 source/torture/config.mk                    |   17 +
 source/torture/gentest_smb2.c               | 1952 +++++++++++++++++++++++++++
 source/torture/smb2/oplocks.c               |    2 +-
 source/torture/smb2/util.c                  |   42 +-
 26 files changed, 3501 insertions(+), 83 deletions(-)
 create mode 100644 source/libcli/smb2/util.c
 create mode 100644 source/libcli/smb_composite/smb2.c
 create mode 100644 source/ntvfs/smb2/vfs_smb2.c
 create mode 100644 source/torture/gentest_smb2.c


Changeset truncated at 500 lines:

diff --git a/source/client/client.c b/source/client/client.c
index 120a80c..01197e8 100644
--- a/source/client/client.c
+++ b/source/client/client.c
@@ -214,15 +214,18 @@ check the space on a device
 ****************************************************************************/
 static int do_dskattr(struct smbclient_context *ctx)
 {
-	int total, bsize, avail;
+	uint32_t bsize;
+	uint64_t total, avail;
 
 	if (NT_STATUS_IS_ERR(smbcli_dskattr(ctx->cli->tree, &bsize, &total, &avail))) {
 		d_printf("Error in dskattr: %s\n",smbcli_errstr(ctx->cli->tree)); 
 		return 1;
 	}
 
-	d_printf("\n\t\t%d blocks of size %d. %d blocks available\n",
-		 total, bsize, avail);
+	d_printf("\n\t\t%llu blocks of size %u. %llu blocks available\n",
+		 (unsigned long long)total, 
+		 (unsigned)bsize, 
+		 (unsigned long long)avail);
 
 	return 0;
 }
diff --git a/source/libcli/clifile.c b/source/libcli/clifile.c
index e59b7f9..2cf1740 100644
--- a/source/libcli/clifile.c
+++ b/source/libcli/clifile.c
@@ -650,7 +650,8 @@ NTSTATUS smbcli_chkpath(struct smbcli_tree *tree, const char *path)
 /****************************************************************************
  Query disk space.
 ****************************************************************************/
-NTSTATUS smbcli_dskattr(struct smbcli_tree *tree, int *bsize, int *total, int *avail)
+NTSTATUS smbcli_dskattr(struct smbcli_tree *tree, uint32_t *bsize, 
+			uint64_t *total, uint64_t *avail)
 {
 	union smb_fsinfo fsinfo_parms;
 	TALLOC_CTX *mem_ctx;
@@ -658,12 +659,12 @@ NTSTATUS smbcli_dskattr(struct smbcli_tree *tree, int *bsize, int *total, int *a
 
 	mem_ctx = talloc_init("smbcli_dskattr");
 
-	fsinfo_parms.dskattr.level = RAW_QFS_DSKATTR;
+	fsinfo_parms.dskattr.level = RAW_QFS_SIZE_INFO;
 	status = smb_raw_fsinfo(tree, mem_ctx, &fsinfo_parms);
 	if (NT_STATUS_IS_OK(status)) {
-		*bsize = fsinfo_parms.dskattr.out.block_size;
-		*total = fsinfo_parms.dskattr.out.units_total;
-		*avail = fsinfo_parms.dskattr.out.units_free;
+		*bsize = fsinfo_parms.size_info.out.bytes_per_sector * fsinfo_parms.size_info.out.sectors_per_unit;
+		*total = fsinfo_parms.size_info.out.total_alloc_units;
+		*avail = fsinfo_parms.size_info.out.avail_alloc_units;
 	}
 
 	talloc_free(mem_ctx);
diff --git a/source/libcli/composite/composite.c b/source/libcli/composite/composite.c
index 966f56c..3e3f224 100644
--- a/source/libcli/composite/composite.c
+++ b/source/libcli/composite/composite.c
@@ -69,6 +69,17 @@ _PUBLIC_ NTSTATUS composite_wait(struct composite_context *c)
 	return c->status;
 }
 
+/*
+  block until a composite function has completed, then return the status. 
+  Free the composite context before returning
+*/
+_PUBLIC_ NTSTATUS composite_wait_free(struct composite_context *c)
+{
+	NTSTATUS status = composite_wait(c);
+	talloc_free(c);
+	return status;
+}
+
 /* 
    callback from composite_done() and composite_error()
 
@@ -94,6 +105,12 @@ static void composite_trigger(struct event_context *ev, struct timed_event *te,
 
 _PUBLIC_ void composite_error(struct composite_context *ctx, NTSTATUS status)
 {
+	/* you are allowed to pass NT_STATUS_OK to composite_error(), in which
+	   case it is equivalent to composite_done() */
+	if (NT_STATUS_IS_OK(status)) {
+		composite_done(ctx);
+		return;
+	}
 	if (!ctx->used_wait && !ctx->async.fn) {
 		event_add_timed(ctx->event_ctx, ctx, timeval_zero(), composite_trigger, ctx);
 	}
@@ -187,7 +204,7 @@ _PUBLIC_ void composite_continue_smb2(struct composite_context *ctx,
 {
 	if (composite_nomem(new_req, ctx)) return;
 	new_req->async.fn = continuation;
-	new_req->async.private = private_data;
+	new_req->async.private_data = private_data;
 }
 
 _PUBLIC_ void composite_continue_nbt(struct composite_context *ctx,
diff --git a/source/libcli/composite/composite.h b/source/libcli/composite/composite.h
index f1bed20..28cd6a8 100644
--- a/source/libcli/composite/composite.h
+++ b/source/libcli/composite/composite.h
@@ -101,6 +101,7 @@ bool composite_is_ok(struct composite_context *ctx);
 void composite_done(struct composite_context *ctx);
 void composite_error(struct composite_context *ctx, NTSTATUS status);
 NTSTATUS composite_wait(struct composite_context *c);
+NTSTATUS composite_wait_free(struct composite_context *c);
 
 
 #endif /* __COMPOSITE_H__ */
diff --git a/source/libcli/config.mk b/source/libcli/config.mk
index 0cc97c0..f502091 100644
--- a/source/libcli/config.mk
+++ b/source/libcli/config.mk
@@ -33,7 +33,8 @@ LIBCLI_SMB_COMPOSITE_OBJ_FILES = $(addprefix $(libclisrcdir)/smb_composite/, \
 	sesssetup.o \
 	fetchfile.o \
 	appendacl.o \
-	fsinfo.o)
+	fsinfo.o \
+	smb2.o)
 
 $(eval $(call proto_header_template,$(libclisrcdir)/smb_composite/proto.h,$(LIBCLI_SMB_COMPOSITE_OBJ_FILES:.o=.c)))
 
diff --git a/source/libcli/raw/interfaces.h b/source/libcli/raw/interfaces.h
index bad3743..871bab0 100644
--- a/source/libcli/raw/interfaces.h
+++ b/source/libcli/raw/interfaces.h
@@ -2354,10 +2354,11 @@ union smb_search_first {
 #define SMB2_FIND_ID_BOTH_DIRECTORY_INFO 0x25
 #define SMB2_FIND_ID_FULL_DIRECTORY_INFO 0x26
 
-/* flags for RAW_FILEINFO_SMB2_ALL_EAS */
+/* flags for SMB2 find */
 #define SMB2_CONTINUE_FLAG_RESTART    0x01
 #define SMB2_CONTINUE_FLAG_SINGLE     0x02
-#define SMB2_CONTINUE_FLAG_NEW        0x10
+#define SMB2_CONTINUE_FLAG_INDEX      0x04
+#define SMB2_CONTINUE_FLAG_REOPEN     0x10
 
 	/* SMB2 Find */
 	struct smb2_find {
@@ -2370,7 +2371,7 @@ union smb_search_first {
 			/* uint16_t buffer_code;  0x21 = 0x20 + 1 */
 			uint8_t level;
 			uint8_t continue_flags; /* SMB2_CONTINUE_FLAG_* */
-			uint32_t unknown; /* perhaps a continue token? */
+			uint32_t file_index; 
 			/* struct smb2_handle handle; */
 			/* uint16_t pattern_ofs; */
 			/* uint16_t pattern_size; */
diff --git a/source/libcli/smb2/config.mk b/source/libcli/smb2/config.mk
index e653fba..00b6305 100644
--- a/source/libcli/smb2/config.mk
+++ b/source/libcli/smb2/config.mk
@@ -5,6 +5,6 @@ LIBCLI_SMB2_OBJ_FILES = $(addprefix $(libclisrcdir)/smb2/, \
 	transport.o request.o negprot.o session.o tcon.o \
 	create.o close.o connect.o getinfo.o write.o read.o \
 	setinfo.o find.o ioctl.o logoff.o tdis.o flush.o \
-	lock.o notify.o cancel.o keepalive.o break.o)
+	lock.o notify.o cancel.o keepalive.o break.o util.o)
 
 $(eval $(call proto_header_template,$(libclisrcdir)/smb2/smb2_proto.h,$(LIBCLI_SMB2_OBJ_FILES:.o=.c)))
diff --git a/source/libcli/smb2/connect.c b/source/libcli/smb2/connect.c
index 59d4e6e..eabfa41 100644
--- a/source/libcli/smb2/connect.c
+++ b/source/libcli/smb2/connect.c
@@ -44,7 +44,7 @@ struct smb2_connect_state {
 */
 static void continue_tcon(struct smb2_request *req)
 {
-	struct composite_context *c = talloc_get_type(req->async.private, 
+	struct composite_context *c = talloc_get_type(req->async.private_data, 
 						      struct composite_context);
 	struct smb2_connect_state *state = talloc_get_type(c->private_data, 
 							   struct smb2_connect_state);
@@ -83,7 +83,7 @@ static void continue_session(struct composite_context *creq)
 	if (composite_nomem(req, c)) return;
 
 	req->async.fn = continue_tcon;
-	req->async.private = c;	
+	req->async.private_data = c;	
 }
 
 /*
@@ -91,7 +91,7 @@ static void continue_session(struct composite_context *creq)
 */
 static void continue_negprot(struct smb2_request *req)
 {
-	struct composite_context *c = talloc_get_type(req->async.private, 
+	struct composite_context *c = talloc_get_type(req->async.private_data, 
 						      struct composite_context);
 	struct smb2_connect_state *state = talloc_get_type(c->private_data, 
 							   struct smb2_connect_state);
@@ -101,6 +101,9 @@ static void continue_negprot(struct smb2_request *req)
 	c->status = smb2_negprot_recv(req, c, &state->negprot);
 	if (!composite_is_ok(c)) return;
 
+	transport->negotiate.system_time = state->negprot.out.system_time;
+	transport->negotiate.server_start_time = state->negprot.out.server_start_time;
+
 	state->session = smb2_session_init(transport, global_loadparm, state, true);
 	if (composite_nomem(state->session, c)) return;
 
@@ -142,7 +145,7 @@ static void continue_socket(struct composite_context *creq)
 	if (composite_nomem(req, c)) return;
 
 	req->async.fn = continue_negprot;
-	req->async.private = c;
+	req->async.private_data = c;
 }
 
 
diff --git a/source/libcli/smb2/find.c b/source/libcli/smb2/find.c
index 6b4902a..8ebfd81 100644
--- a/source/libcli/smb2/find.c
+++ b/source/libcli/smb2/find.c
@@ -38,7 +38,7 @@ struct smb2_request *smb2_find_send(struct smb2_tree *tree, struct smb2_find *io
 
 	SCVAL(req->out.body, 0x02, io->in.level);
 	SCVAL(req->out.body, 0x03, io->in.continue_flags);
-	SIVAL(req->out.body, 0x04, io->in.unknown);
+	SIVAL(req->out.body, 0x04, io->in.file_index);
 	smb2_push_handle(req->out.body+0x08, &io->in.file.handle);
 
 	status = smb2_push_o16s16_string(&req->out, 0x18, io->in.pattern);
diff --git a/source/libcli/smb2/request.c b/source/libcli/smb2/request.c
index f52b0ce..64d427f 100644
--- a/source/libcli/smb2/request.c
+++ b/source/libcli/smb2/request.c
@@ -43,6 +43,18 @@ void smb2_setup_bufinfo(struct smb2_request *req)
 	}
 }
 
+
+/* destroy a request structure */
+static int smb2_request_destructor(struct smb2_request *req)
+{
+	if (req->transport) {
+		/* remove it from the list of pending requests (a null op if
+		   its not in the list) */
+		DLIST_REMOVE(req->transport->pending_recv, req);
+	}
+	return 0;
+}
+
 /*
   initialise a smb2 request
 */
@@ -122,6 +134,8 @@ struct smb2_request *smb2_request_init(struct smb2_transport *transport, uint16_
 		SCVAL(req->out.dynamic, 0, 0);
 	}
 
+	talloc_set_destructor(req, smb2_request_destructor);
+
 	return req;
 }
 
@@ -154,18 +168,13 @@ NTSTATUS smb2_request_destroy(struct smb2_request *req)
 	   _send() call fails completely */
 	if (!req) return NT_STATUS_UNSUCCESSFUL;
 
-	if (req->transport) {
-		/* remove it from the list of pending requests (a null op if
-		   its not in the list) */
-		DLIST_REMOVE(req->transport->pending_recv, req);
-	}
-
 	if (req->state == SMB2_REQUEST_ERROR &&
 	    NT_STATUS_IS_OK(req->status)) {
-		req->status = NT_STATUS_INTERNAL_ERROR;
+		status = NT_STATUS_INTERNAL_ERROR;
+	} else {
+		status = req->status;
 	}
 
-	status = req->status;
 	talloc_free(req);
 	return status;
 }
diff --git a/source/libcli/smb2/session.c b/source/libcli/smb2/session.c
index 18fe348..29af665 100644
--- a/source/libcli/smb2/session.c
+++ b/source/libcli/smb2/session.c
@@ -145,7 +145,7 @@ struct smb2_session_state {
 */
 static void session_request_handler(struct smb2_request *req)
 {
-	struct composite_context *c = talloc_get_type(req->async.private, 
+	struct composite_context *c = talloc_get_type(req->async.private_data, 
 						      struct composite_context);
 	struct smb2_session_state *state = talloc_get_type(c->private_data, 
 							   struct smb2_session_state);
@@ -178,7 +178,7 @@ static void session_request_handler(struct smb2_request *req)
 		}
 
 		state->req->async.fn = session_request_handler;
-		state->req->async.private = c;
+		state->req->async.private_data = c;
 		return;
 	}
 
diff --git a/source/libcli/smb2/smb2.h b/source/libcli/smb2/smb2.h
index ae66a6e..b55da05 100644
--- a/source/libcli/smb2/smb2.h
+++ b/source/libcli/smb2/smb2.h
@@ -19,6 +19,9 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#ifndef __LIBCLI_SMB2_SMB2_H__
+#define __LIBCLI_SMB2_SMB2_H__
+
 #include "libcli/raw/request.h"
 
 struct smb2_handle;
@@ -32,6 +35,8 @@ struct smb2_options {
 */
 struct smb2_negotiate {
 	DATA_BLOB secblob;
+	NTTIME system_time;
+	NTTIME server_start_time;
 };
 
 /* this is the context for the smb2 transport layer */
@@ -165,7 +170,7 @@ struct smb2_request {
 	*/
 	struct {
 		void (*fn)(struct smb2_request *);
-		void *private;
+		void *private_data;
 	} async;
 };
 
@@ -282,3 +287,5 @@ struct smb2_request {
 		return NT_STATUS_INVALID_PARAMETER; \
 	} \
 } while (0)
+
+#endif
diff --git a/source/libcli/smb2/util.c b/source/libcli/smb2/util.c
new file mode 100644
index 0000000..9eb344e
--- /dev/null
+++ b/source/libcli/smb2/util.c
@@ -0,0 +1,200 @@
+/* 
+   Unix SMB/CIFS implementation.
+
+   SMB2 client utility functions
+
+   Copyright (C) Andrew Tridgell 2005
+   
+   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/raw/libcliraw.h"
+#include "libcli/raw/raw_proto.h"
+#include "libcli/smb2/smb2.h"
+#include "libcli/smb2/smb2_calls.h"
+#include "libcli/smb_composite/smb_composite.h"
+
+/*
+  simple close wrapper with SMB2
+*/
+NTSTATUS smb2_util_close(struct smb2_tree *tree, struct smb2_handle h)
+{
+	struct smb2_close c;
+
+	ZERO_STRUCT(c);
+	c.in.file.handle = h;
+
+	return smb2_close(tree, &c);
+}
+
+/*
+  unlink a file with SMB2
+*/
+NTSTATUS smb2_util_unlink(struct smb2_tree *tree, const char *fname)
+{
+	union smb_unlink io;
+	
+	ZERO_STRUCT(io);
+	io.unlink.in.pattern = fname;
+
+	return smb2_composite_unlink(tree, &io);
+}
+
+
+/*
+  rmdir with SMB2
+*/
+NTSTATUS smb2_util_rmdir(struct smb2_tree *tree, const char *dname)
+{
+	struct smb_rmdir io;
+	
+	ZERO_STRUCT(io);
+	io.in.path = dname;
+
+	return smb2_composite_rmdir(tree, &io);
+}
+
+
+/*
+  mkdir with SMB2
+*/
+NTSTATUS smb2_util_mkdir(struct smb2_tree *tree, const char *dname)
+{
+	union smb_mkdir io;
+	
+	ZERO_STRUCT(io);
+	io.mkdir.level = RAW_MKDIR_MKDIR;
+	io.mkdir.in.path = dname;
+
+	return smb2_composite_mkdir(tree, &io);
+}
+
+
+/*
+  set file attribute with SMB2
+*/
+NTSTATUS smb2_util_setatr(struct smb2_tree *tree, const char *name, uint32_t attrib)
+{
+	union smb_setfileinfo io;
+	
+	ZERO_STRUCT(io);
+	io.basic_info.level = RAW_SFILEINFO_BASIC_INFORMATION;
+	io.basic_info.in.file.path = name;
+	io.basic_info.in.attrib = attrib;
+
+	return smb2_composite_setpathinfo(tree, &io);
+}
+
+
+
+
+/* 
+   recursively descend a tree deleting all files
+   returns the number of files deleted, or -1 on error
+*/
+int smb2_deltree(struct smb2_tree *tree, const char *dname)
+{
+	NTSTATUS status;
+	uint32_t total_deleted = 0;
+	uint_t count, i;
+	union smb_search_data *list;
+	TALLOC_CTX *tmp_ctx = talloc_new(tree);
+	struct smb2_find f;
+	struct smb2_create create_parm;
+
+	/* it might be a file */
+	status = smb2_util_unlink(tree, dname);
+	if (NT_STATUS_IS_OK(status)) {
+		talloc_free(tmp_ctx);
+		return 1;
+	}
+	if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND) ||
+	    NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_PATH_NOT_FOUND) ||
+	    NT_STATUS_EQUAL(status, NT_STATUS_NO_SUCH_FILE)) {
+		talloc_free(tmp_ctx);
+		return 0;
+	}
+
+	ZERO_STRUCT(create_parm);
+	create_parm.in.desired_access = SEC_FLAG_MAXIMUM_ALLOWED;
+	create_parm.in.share_access = 
+		NTCREATEX_SHARE_ACCESS_READ|
+		NTCREATEX_SHARE_ACCESS_WRITE;
+	create_parm.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
+	create_parm.in.create_disposition = NTCREATEX_DISP_OPEN;
+	create_parm.in.fname = dname;
+
+	status = smb2_create(tree, tmp_ctx, &create_parm);
+	if (NT_STATUS_IS_ERR(status)) {
+		DEBUG(2,("Failed to open %s - %s\n", dname, nt_errstr(status)));
+		talloc_free(tmp_ctx);
+		return -1;
+	}
+	
+
+	ZERO_STRUCT(f);
+	f.in.file.handle       = create_parm.out.file.handle;
+	f.in.max_response_size = 0x10000;
+	f.in.level             = SMB2_FIND_NAME_INFO;
+	f.in.pattern           = "*";


-- 
Samba Shared Repository


More information about the samba-cvs mailing list