[SCM] Samba Shared Repository - branch master updated

Volker Lendecke vlendec at samba.org
Sat Nov 14 03:03:54 MST 2009


The branch, master has been updated
       via  f668e41... s3: Convert cli_set_unix_extensions_capabilities_send to async
       via  f38edcd... Introduce tevent_req_poll_ntstatus
       via  c254349... Introduce tevent_req_simple_finish_ntstatus
       via  6133ab6... s3: Tiny logic simplification
      from  a3632f2... s4-drs: DsExecuteKCC() implementation

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


- Log -----------------------------------------------------------------
commit f668e4104f5fc5e3c0a48502e30163b1ffc777ae
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Nov 14 00:40:21 2009 +0100

    s3: Convert cli_set_unix_extensions_capabilities_send to async

commit f38edcd61a556815db2ecfaa265a46e859e980f6
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Nov 14 10:01:44 2009 +0100

    Introduce tevent_req_poll_ntstatus

commit c254349261e0a59e4403c314ec8c17aa6b7dfc37
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Nov 14 09:38:20 2009 +0100

    Introduce tevent_req_simple_finish_ntstatus

commit 6133ab6055f68a11380d384c1d871774139035ea
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Nov 12 20:44:37 2009 +0100

    s3: Tiny logic simplification

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

Summary of changes:
 lib/util/tevent_ntstatus.c |   32 ++++++++++++
 lib/util/tevent_ntstatus.h |   15 ++++++
 source3/client/client.c    |    7 ++-
 source3/include/proto.h    |    9 +++-
 source3/libsmb/clifsinfo.c |  116 ++++++++++++++++++++++++++++++--------------
 source3/libsmb/cliprint.c  |   19 ++++---
 source3/torture/torture.c  |    8 ++-
 7 files changed, 153 insertions(+), 53 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/util/tevent_ntstatus.c b/lib/util/tevent_ntstatus.c
index d6cb0af..e6b37f6 100644
--- a/lib/util/tevent_ntstatus.c
+++ b/lib/util/tevent_ntstatus.c
@@ -59,3 +59,35 @@ NTSTATUS tevent_req_simple_recv_ntstatus(struct tevent_req *req)
 	}
 	return NT_STATUS_OK;
 }
+
+void tevent_req_simple_finish_ntstatus(struct tevent_req *subreq,
+				       NTSTATUS subreq_status)
+{
+	struct tevent_req *req = tevent_req_callback_data(
+		subreq, struct tevent_req);
+
+	TALLOC_FREE(subreq);
+
+	if (!NT_STATUS_IS_OK(subreq_status)) {
+		tevent_req_nterror(req, subreq_status);
+		return;
+	}
+	tevent_req_done(req);
+}
+
+/*
+ * We have to declare map_nt_error_from_unix here, both s3 and s4 have their
+ * (different) implementations of it.
+ */
+NTSTATUS map_nt_error_from_unix(int sys_errno);
+
+bool tevent_req_poll_ntstatus(struct tevent_req *req,
+			      struct tevent_context *ev,
+			      NTSTATUS *status)
+{
+	bool ret = tevent_req_poll(req, ev);
+	if (!ret) {
+		*status = map_nt_error_from_unix(errno);
+	}
+	return ret;
+}
diff --git a/lib/util/tevent_ntstatus.h b/lib/util/tevent_ntstatus.h
index 22fe918..7f312b7 100644
--- a/lib/util/tevent_ntstatus.h
+++ b/lib/util/tevent_ntstatus.h
@@ -29,4 +29,19 @@ bool tevent_req_nterror(struct tevent_req *req, NTSTATUS status);
 bool tevent_req_is_nterror(struct tevent_req *req, NTSTATUS *pstatus);
 NTSTATUS tevent_req_simple_recv_ntstatus(struct tevent_req *req);
 
+/*
+ * Helper routine to pass the subreq_ntstatus to the req embedded in
+ * tevent_req_callback_data(subreq), which will be freed.
+ */
+void tevent_req_simple_finish_ntstatus(struct tevent_req *subreq,
+				       NTSTATUS subreq_status);
+
+/*
+ * Wrapper for tevent_req_poll that grabs NTSTATUS directly in case of a
+ * failure
+ */
+bool tevent_req_poll_ntstatus(struct tevent_req *req,
+			      struct tevent_context *ev,
+			      NTSTATUS *status);
+
 #endif
diff --git a/source3/client/client.c b/source3/client/client.c
index f81762a..6773e6d 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -2531,8 +2531,11 @@ static int cmd_posix(void)
 
 	d_printf("Server supports CIFS capabilities %s\n", caps);
 
-	if (!cli_set_unix_extensions_capabilities(cli, major, minor, caplow, caphigh)) {
-		d_printf("Can't set UNIX CIFS extensions capabilities. %s.\n", cli_errstr(cli));
+	status = cli_set_unix_extensions_capabilities(cli, major, minor,
+						      caplow, caphigh);
+	if (!NT_STATUS_IS_OK(status)) {
+		d_printf("Can't set UNIX CIFS extensions capabilities. %s.\n",
+			 nt_errstr(status));
 		return 1;
 	}
 
diff --git a/source3/include/proto.h b/source3/include/proto.h
index aeb19d3..8c0a3e3 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -2692,8 +2692,13 @@ NTSTATUS cli_unix_extensions_version_recv(struct tevent_req *req,
 NTSTATUS cli_unix_extensions_version(struct cli_state *cli, uint16 *pmajor,
 				     uint16 *pminor, uint32 *pcaplow,
 				     uint32 *pcaphigh);
-bool cli_set_unix_extensions_capabilities(struct cli_state *cli, uint16 major, uint16 minor,
-                                        uint32 caplow, uint32 caphigh);
+struct tevent_req *cli_set_unix_extensions_capabilities_send(
+	TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct cli_state *cli,
+	uint16_t major, uint16_t minor, uint32_t caplow, uint32_t caphigh);
+NTSTATUS cli_set_unix_extensions_capabilities_recv(struct tevent_req *req);
+NTSTATUS cli_set_unix_extensions_capabilities(struct cli_state *cli,
+					      uint16 major, uint16 minor,
+					      uint32 caplow, uint32 caphigh);
 bool cli_get_fs_attr_info(struct cli_state *cli, uint32 *fs_attr);
 bool cli_get_fs_volume_info_old(struct cli_state *cli, fstring volume_name, uint32 *pserial_number);
 bool cli_get_fs_volume_info(struct cli_state *cli, fstring volume_name, uint32 *pserial_number, time_t *pdate);
diff --git a/source3/libsmb/clifsinfo.c b/source3/libsmb/clifsinfo.c
index 03ec54a..9e2177a 100644
--- a/source3/libsmb/clifsinfo.c
+++ b/source3/libsmb/clifsinfo.c
@@ -161,53 +161,95 @@ NTSTATUS cli_unix_extensions_version(struct cli_state *cli, uint16 *pmajor,
  Set UNIX extensions capabilities.
 ****************************************************************************/
 
-bool cli_set_unix_extensions_capabilities(struct cli_state *cli, uint16 major, uint16 minor,
-                                        uint32 caplow, uint32 caphigh)
+struct cli_set_unix_extensions_capabilities_state {
+	uint16_t setup[1];
+	uint8_t param[4];
+	uint8_t data[12];
+};
+
+static void cli_set_unix_extensions_capabilities_done(
+	struct tevent_req *subreq);
+
+struct tevent_req *cli_set_unix_extensions_capabilities_send(
+	TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct cli_state *cli,
+	uint16_t major, uint16_t minor, uint32_t caplow, uint32_t caphigh)
 {
-	bool ret = False;
-	uint16 setup;
-	char param[4];
-	char data[12];
-	char *rparam=NULL, *rdata=NULL;
-	unsigned int rparam_count=0, rdata_count=0;
+	struct tevent_req *req, *subreq;
+	struct cli_set_unix_extensions_capabilities_state *state;
 
-	setup = TRANSACT2_SETFSINFO;
+	req = tevent_req_create(
+		mem_ctx, &state,
+		struct cli_set_unix_extensions_capabilities_state);
+	if (req == NULL) {
+		return NULL;
+	}
 
-	SSVAL(param,0,0);
-	SSVAL(param,2,SMB_SET_CIFS_UNIX_INFO);
+	SSVAL(state->setup+0, 0, TRANSACT2_SETFSINFO);
 
-	SSVAL(data,0,major);
-	SSVAL(data,2,minor);
-	SIVAL(data,4,caplow);
-	SIVAL(data,8,caphigh);
+	SSVAL(state->param, 0, 0);
+	SSVAL(state->param, 2, SMB_SET_CIFS_UNIX_INFO);
 
-	if (!cli_send_trans(cli, SMBtrans2,
-		    NULL,
-		    0, 0,
-		    &setup, 1, 0,
-		    param, 4, 0,
-		    data, 12, 560)) {
-		goto cleanup;
-	}
+	SSVAL(state->data, 0, major);
+	SSVAL(state->data, 2, minor);
+	SIVAL(state->data, 4, caplow);
+	SIVAL(state->data, 8, caphigh);
 
-	if (!cli_receive_trans(cli, SMBtrans2,
-                              &rparam, &rparam_count,
-                              &rdata, &rdata_count)) {
-		goto cleanup;
+	subreq = cli_trans_send(state, ev, cli, SMBtrans2,
+				NULL, 0, 0, 0,
+				state->setup, 1, 0,
+				state->param, 4, 0,
+				state->data, 12, 560);
+	if (tevent_req_nomem(subreq, req)) {
+		return tevent_req_post(req, ev);
 	}
+	tevent_req_set_callback(
+		subreq, cli_set_unix_extensions_capabilities_done, req);
+	return req;
+}
 
-	if (cli_is_error(cli)) {
-		ret = False;
-		goto cleanup;
-	} else {
-		ret = True;
-	}
+static void cli_set_unix_extensions_capabilities_done(
+	struct tevent_req *subreq)
+{
+	return tevent_req_simple_finish_ntstatus(
+		subreq, cli_trans_recv(subreq, NULL, NULL, NULL, NULL, NULL,
+				       NULL, NULL));
+}
 
-cleanup:
-	SAFE_FREE(rparam);
-	SAFE_FREE(rdata);
+NTSTATUS cli_set_unix_extensions_capabilities_recv(struct tevent_req *req)
+{
+	return tevent_req_simple_recv_ntstatus(req);
+}
 
-	return ret;
+NTSTATUS cli_set_unix_extensions_capabilities(struct cli_state *cli,
+					      uint16 major, uint16 minor,
+					      uint32 caplow, uint32 caphigh)
+{
+	struct tevent_context *ev;
+	struct tevent_req *req;
+	NTSTATUS status = NT_STATUS_NO_MEMORY;
+
+	if (cli_has_async_calls(cli)) {
+		return NT_STATUS_INVALID_PARAMETER;
+	}
+	ev = tevent_context_init(talloc_tos());
+	if (ev == NULL) {
+		goto fail;
+	}
+	req = cli_set_unix_extensions_capabilities_send(
+		ev, ev, cli, major, minor, caplow, caphigh);
+	if (req == NULL) {
+		goto fail;
+	}
+	if (!tevent_req_poll_ntstatus(req, ev, &status)) {
+		goto fail;
+	}
+	status = cli_set_unix_extensions_capabilities_recv(req);
+fail:
+	TALLOC_FREE(ev);
+	if (!NT_STATUS_IS_OK(status)) {
+		cli_set_error(cli, status);
+	}
+	return status;
 }
 
 bool cli_get_fs_attr_info(struct cli_state *cli, uint32 *fs_attr)
diff --git a/source3/libsmb/cliprint.c b/source3/libsmb/cliprint.c
index e78930c..723ae02 100644
--- a/source3/libsmb/cliprint.c
+++ b/source3/libsmb/cliprint.c
@@ -27,20 +27,21 @@
 static const char *fix_char_ptr(unsigned int datap, unsigned int converter,
 			  char *rdata, int rdrcnt)
 {
+	unsigned int offset;
+
 	if (datap == 0)	{
 		/* turn NULL pointers into zero length strings */
 		return "";
-	} else {
-		unsigned int offset = datap - converter;
-
-		if (offset >= rdrcnt) {
-			DEBUG(1,("bad char ptr: datap=%u, converter=%u rdrcnt=%d>",
-				 datap, converter, rdrcnt));
-			return "<ERROR>";
-		} else {
-			return &rdata[offset];
-		}
 	}
+
+	offset = datap - converter;
+
+	if (offset >= rdrcnt) {
+		DEBUG(1,("bad char ptr: datap=%u, converter=%u rdrcnt=%d>",
+			 datap, converter, rdrcnt));
+		return "<ERROR>";
+	}
+	return &rdata[offset];
 }
 
 /****************************************************************************
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 9abcabd..840dc94 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -4392,9 +4392,11 @@ static bool run_simple_posix_open_test(int dummy)
 		return false;
 	}
 
-	if (!cli_set_unix_extensions_capabilities(cli1,
-			major, minor, caplow, caphigh)) {
-		printf("Server doesn't support setting UNIX CIFS extensions.\n");
+	status = cli_set_unix_extensions_capabilities(cli1, major, minor,
+						      caplow, caphigh);
+	if (!NT_STATUS_IS_OK(status)) {
+		printf("Server doesn't support setting UNIX CIFS extensions: "
+		       "%s.\n", nt_errstr(status));
 		return false;
         }
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list