[SCM] Samba Shared Repository - branch master updated - release-4-0-0alpha6-468-g858116d

Günther Deschner gd at samba.org
Wed Feb 4 21:50:20 GMT 2009


The branch, master has been updated
       via  858116d54e61f2d86757aecce3afba147434c7fc (commit)
       via  64e3a90530e4231fc9725652535a4881b149228a (commit)
       via  c464b5ebc07a27d7ab01629f87fc053dd90882ed (commit)
      from  94d1dbbaf01acff05dc0237470268ec85d02fdbb (commit)

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


- Log -----------------------------------------------------------------
commit 858116d54e61f2d86757aecce3afba147434c7fc
Author: Günther Deschner <gd at samba.org>
Date:   Fri Jan 16 18:04:11 2009 +0100

    s4-smbtorture: in eventlog readlog test, print all records in a buffer.
    
    Guenther

commit 64e3a90530e4231fc9725652535a4881b149228a
Author: Günther Deschner <gd at samba.org>
Date:   Tue Feb 3 20:48:43 2009 +0100

    s3-eventlog: make can_write_to_eventlog static.
    
    Guenther

commit c464b5ebc07a27d7ab01629f87fc053dd90882ed
Author: Günther Deschner <gd at samba.org>
Date:   Fri Jan 16 12:18:21 2009 +0100

    s3-rpcclient: fix eventlog read client to read an array of entries.
    
    Guenther

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

Summary of changes:
 source3/include/proto.h               |    1 -
 source3/rpc_server/srv_eventlog_lib.c |    2 +-
 source3/rpcclient/cmd_eventlog.c      |   67 ++++++++++++++++++++++++--------
 source4/torture/rpc/eventlog.c        |   35 +++++++++++++----
 4 files changed, 77 insertions(+), 28 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/include/proto.h b/source3/include/proto.h
index 68c4c8b..5cef54f 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -6257,7 +6257,6 @@ TDB_CONTEXT *elog_init_tdb( char *tdbfilename );
 char *elog_tdbname(TALLOC_CTX *ctx, const char *name );
 int elog_tdb_size( TDB_CONTEXT * tdb, int *MaxSize, int *Retention );
 bool prune_eventlog( TDB_CONTEXT * tdb );
-bool can_write_to_eventlog( TDB_CONTEXT * tdb, int32 needed );
 ELOG_TDB *elog_open_tdb( const char *logname, bool force_clear, bool read_only );
 int elog_close_tdb( ELOG_TDB *etdb, bool force_close );
 int write_eventlog_tdb( TDB_CONTEXT * the_tdb, Eventlog_entry * ee );
diff --git a/source3/rpc_server/srv_eventlog_lib.c b/source3/rpc_server/srv_eventlog_lib.c
index d894ab0..c5d2ad7 100644
--- a/source3/rpc_server/srv_eventlog_lib.c
+++ b/source3/rpc_server/srv_eventlog_lib.c
@@ -270,7 +270,7 @@ bool prune_eventlog( TDB_CONTEXT * tdb )
 /********************************************************************
 ********************************************************************/
 
-bool can_write_to_eventlog( TDB_CONTEXT * tdb, int32_t needed )
+static bool can_write_to_eventlog( TDB_CONTEXT * tdb, int32_t needed )
 {
 	int calcd_size;
 	int MaxSize, Retention;
diff --git a/source3/rpcclient/cmd_eventlog.c b/source3/rpcclient/cmd_eventlog.c
index 905b147..e212452 100644
--- a/source3/rpcclient/cmd_eventlog.c
+++ b/source3/rpcclient/cmd_eventlog.c
@@ -55,7 +55,7 @@ static NTSTATUS cmd_eventlog_readlog(struct rpc_pipe_client *cli,
 				     int argc,
 				     const char **argv)
 {
-	NTSTATUS status;
+	NTSTATUS status = NT_STATUS_OK;
 	struct policy_handle handle;
 
 	uint32_t flags = EVENTLOG_BACKWARDS_READ |
@@ -67,7 +67,7 @@ static NTSTATUS cmd_eventlog_readlog(struct rpc_pipe_client *cli,
 	uint32_t real_size = 0;
 
 	if (argc < 2 || argc > 4) {
-		printf("Usage: %s logname [offset]\n", argv[0]);
+		printf("Usage: %s logname [offset] [number_of_bytes]\n", argv[0]);
 		return NT_STATUS_OK;
 	}
 
@@ -75,12 +75,27 @@ static NTSTATUS cmd_eventlog_readlog(struct rpc_pipe_client *cli,
 		offset = atoi(argv[2]);
 	}
 
+	if (argc >= 4) {
+		number_of_bytes = atoi(argv[3]);
+		data = talloc_array(mem_ctx, uint8_t, number_of_bytes);
+		if (!data) {
+			goto done;
+		}
+	}
+
 	status = get_eventlog_handle(cli, mem_ctx, argv[1], &handle);
 	if (!NT_STATUS_IS_OK(status)) {
 		return status;
 	}
 
-	while (1) {
+	do {
+
+		enum ndr_err_code ndr_err;
+		DATA_BLOB blob;
+		struct EVENTLOGRECORD r;
+		uint32_t size = 0;
+		uint32_t pos = 0;
+
 		status = rpccli_eventlog_ReadEventLogW(cli, mem_ctx,
 						       &handle,
 						       flags,
@@ -93,35 +108,53 @@ static NTSTATUS cmd_eventlog_readlog(struct rpc_pipe_client *cli,
 		    real_size > 0 ) {
 			number_of_bytes = real_size;
 			data = talloc_array(mem_ctx, uint8_t, real_size);
-			continue;
+			if (!data) {
+				goto done;
+			}
+			status = rpccli_eventlog_ReadEventLogW(cli, mem_ctx,
+							       &handle,
+							       flags,
+							       offset,
+							       number_of_bytes,
+							       data,
+							       &sent_size,
+							       &real_size);
 		}
 
-		number_of_bytes = 0;
-
-		if (!NT_STATUS_IS_OK(status)) {
+		if (!NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE) &&
+		    !NT_STATUS_IS_OK(status)) {
 			goto done;
 		}
 
-		{
-			enum ndr_err_code ndr_err;
-			DATA_BLOB blob;
-			struct eventlog_Record rec;
+		number_of_bytes = 0;
+
+		size = IVAL(data, pos);
 
-			blob = data_blob_const(data, sent_size);
+		while (size > 0) {
 
-			ndr_err = ndr_pull_struct_blob_all(&blob, mem_ctx, NULL,
-							   &rec,
-							   (ndr_pull_flags_fn_t)ndr_pull_eventlog_Record);
+			blob = data_blob_const(data + pos, size);
+			/* dump_data(0, blob.data, blob.length); */
+			ndr_err = ndr_pull_struct_blob_all(&blob, mem_ctx, NULL, &r,
+					   (ndr_pull_flags_fn_t)ndr_pull_EVENTLOGRECORD);
 			if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
 				status = ndr_map_error2ntstatus(ndr_err);
 				goto done;
 			}
 
-			NDR_PRINT_DEBUG(eventlog_Record, &rec);
+			NDR_PRINT_DEBUG(EVENTLOGRECORD, &r);
+
+			pos += size;
+
+			if (pos + 4 > sent_size) {
+				break;
+			}
+
+			size = IVAL(data, pos);
 		}
 
 		offset++;
-	}
+
+	} while (NT_STATUS_IS_OK(status));
 
  done:
 	rpccli_eventlog_CloseEventLog(cli, mem_ctx, &handle);
diff --git a/source4/torture/rpc/eventlog.c b/source4/torture/rpc/eventlog.c
index d5bc4e6..2fd9d92 100644
--- a/source4/torture/rpc/eventlog.c
+++ b/source4/torture/rpc/eventlog.c
@@ -125,9 +125,10 @@ static bool test_ReadEventLog(struct torture_context *tctx,
 
 	while (1) {
 		DATA_BLOB blob;
-		struct eventlog_Record rec;
-		struct ndr_pull *ndr;
+		struct EVENTLOGRECORD rec;
 		enum ndr_err_code ndr_err;
+		uint32_t size = 0;
+		uint32_t pos = 0;
 
 		/* Read first for number of bytes in record */
 
@@ -140,6 +141,7 @@ static bool test_ReadEventLog(struct torture_context *tctx,
 		status = dcerpc_eventlog_ReadEventLogW(p, tctx, &r);
 
 		if (NT_STATUS_EQUAL(r.out.result, NT_STATUS_END_OF_FILE)) {
+			/* FIXME: still need to decode then */
 			break;
 		}
 
@@ -156,17 +158,32 @@ static bool test_ReadEventLog(struct torture_context *tctx,
 		torture_assert_ntstatus_ok(tctx, status, "ReadEventLog failed");
 
 		/* Decode a user-marshalled record */
+		size = IVAL(r.out.data, pos);
 
-		blob.length = *r.out.sent_size;
-		blob.data = talloc_steal(tctx, r.out.data);
+		while (size > 0) {
 
-		ndr = ndr_pull_init_blob(&blob, tctx, lp_iconv_convenience(tctx->lp_ctx));
+			blob = data_blob_const(r.out.data + pos, size);
+			dump_data(0, blob.data, blob.length);
 
-		ndr_err = ndr_pull_eventlog_Record(
-			ndr, NDR_SCALARS|NDR_BUFFERS, &rec);
-		status = ndr_map_error2ntstatus(ndr_err);
+			ndr_err = ndr_pull_struct_blob_all(&blob, tctx,
+				lp_iconv_convenience(tctx->lp_ctx), &rec,
+				(ndr_pull_flags_fn_t)ndr_pull_EVENTLOGRECORD);
+			if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+				status = ndr_map_error2ntstatus(ndr_err);
+				torture_assert_ntstatus_ok(tctx, status,
+					"ReadEventLog failed parsing event log record");
+			}
 
-		NDR_PRINT_DEBUG(eventlog_Record, &rec);
+			NDR_PRINT_DEBUG(EVENTLOGRECORD, &rec);
+
+			pos += size;
+
+			if (pos + 4 > *r.out.sent_size) {
+				break;
+			}
+
+			size = IVAL(r.out.data, pos);
+		}
 
 		torture_assert_ntstatus_ok(tctx, status,
 				"ReadEventLog failed parsing event log record");


-- 
Samba Shared Repository


More information about the samba-cvs mailing list