[SCM] Samba Shared Repository - branch master updated

Volker Lendecke vlendec at samba.org
Tue Nov 2 09:43:01 MDT 2010


The branch, master has been updated
       via  0e95fca s3: Add "net registry getvaluesraw"
       via  18e3b22 s3: Do not connect to ctdb if it is blocked for some reason
       via  27056d3 cluster_fatal() exit code should not indicate success.
      from  4622f2e s3: Fix a typo in a DEBUG msg

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


- Log -----------------------------------------------------------------
commit 0e95fca747826209edfde79d18b106c69e51cd6b
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Dec 15 20:17:01 2009 +0100

    s3: Add "net registry getvaluesraw"
    
    Autobuild-User: Volker Lendecke <vlendec at samba.org>
    Autobuild-Date: Tue Nov  2 15:42:22 UTC 2010 on sn-devel-104

commit 18e3b223c77b8257966879f5238994642881d147
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Nov 16 12:03:24 2009 +0100

    s3: Do not connect to ctdb if it is blocked for some reason

commit 27056d37e0a7a7f46a4765b7ea45193050caa277
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Oct 22 13:03:20 2009 +0200

    cluster_fatal() exit code should not indicate success.
    
    cluster_fatal() logs a fatal event and then exits with 0.  This seems
    wrong.  Sometimes command like "net" use this code and return
    incorrect empty output but then exit with 0.
    
    This simply changes the exit code to 1.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

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

Summary of changes:
 source3/lib/ctdbd_conn.c     |   60 +++++++++++++++++++++++++++++++++++++++++-
 source3/utils/net_registry.c |   51 +++++++++++++++++++++++++++++++++++
 2 files changed, 110 insertions(+), 1 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index f8d6245..dee477f 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -58,7 +58,7 @@ static void cluster_fatal(const char *why)
 	   a core file. We need to release this process id immediately
 	   so that someone else can take over without getting sharing
 	   violations */
-	_exit(0);
+	_exit(1);
 }
 
 /*
@@ -105,6 +105,59 @@ static NTSTATUS get_cluster_vnn(struct ctdbd_connection *conn, uint32 *vnn)
 	return status;
 }
 
+/*
+ * Are we active (i.e. not banned or stopped?)
+ */
+static bool ctdbd_working(struct ctdbd_connection *conn, uint32_t vnn)
+{
+	int32_t cstatus=-1;
+	NTSTATUS status;
+	TDB_DATA outdata;
+	struct ctdb_node_map *m;
+	uint32_t failure_flags;
+	bool ret = false;
+	int i;
+
+	status = ctdbd_control(conn, CTDB_CURRENT_NODE,
+			       CTDB_CONTROL_GET_NODEMAP, 0, 0,
+			       tdb_null, talloc_tos(), &outdata, &cstatus);
+	if (!NT_STATUS_IS_OK(status)) {
+		cluster_fatal("ctdbd_control failed\n");
+	}
+	if ((cstatus != 0) || (outdata.dptr == NULL)) {
+		DEBUG(2, ("Received invalid ctdb data\n"));
+		return false;
+	}
+
+	m = (struct ctdb_node_map *)outdata.dptr;
+
+	for (i=0; i<m->num; i++) {
+		if (vnn == m->nodes[i].pnn) {
+			break;
+		}
+	}
+
+	if (i == m->num) {
+		DEBUG(2, ("Did not find ourselves (node %d) in nodemap\n",
+			  (int)vnn));
+		goto fail;
+	}
+
+	failure_flags = NODE_FLAGS_BANNED | NODE_FLAGS_DISCONNECTED
+		| NODE_FLAGS_PERMANENTLY_DISABLED | NODE_FLAGS_STOPPED;
+
+	if ((m->nodes[i].flags & failure_flags) != 0) {
+		DEBUG(2, ("Node has status %x, not active\n",
+			  (int)m->nodes[i].flags));
+		goto fail;
+	}
+
+	ret = true;
+fail:
+	TALLOC_FREE(outdata.dptr);
+	return ret;;
+}
+
 uint32 ctdbd_vnn(const struct ctdbd_connection *conn)
 {
 	return conn->our_vnn;
@@ -460,6 +513,11 @@ static NTSTATUS ctdbd_init_connection(TALLOC_CTX *mem_ctx,
 		goto fail;
 	}
 
+	if (!ctdbd_working(conn, conn->our_vnn)) {
+		DEBUG(2, ("Node is not working, can not connect\n"));
+		goto fail;
+	}
+
 	generate_random_buffer((unsigned char *)&conn->rand_srvid,
 			       sizeof(conn->rand_srvid));
 
diff --git a/source3/utils/net_registry.c b/source3/utils/net_registry.c
index 7ea68f1..163d059 100644
--- a/source3/utils/net_registry.c
+++ b/source3/utils/net_registry.c
@@ -352,6 +352,49 @@ static int net_registry_getvalueraw(struct net_context *c, int argc,
 	return net_registry_getvalue_internal(c, argc, argv, true);
 }
 
+static int net_registry_getvaluesraw(struct net_context *c, int argc,
+				     const char **argv)
+{
+	WERROR werr;
+	int ret = -1;
+	struct registry_key *key = NULL;
+	TALLOC_CTX *ctx = talloc_stackframe();
+	uint32_t idx;
+
+	if (argc != 1 || c->display_usage) {
+		d_fprintf(stderr, "usage: net rpc registry getvaluesraw "
+			  "<key>\n");
+		goto done;
+	}
+
+	werr = open_key(ctx, argv[0], REG_KEY_READ, &key);
+	if (!W_ERROR_IS_OK(werr)) {
+		d_fprintf(stderr, "open_key failed: %s\n", win_errstr(werr));
+		goto done;
+	}
+
+	idx = 0;
+	while (true) {
+		struct registry_value *val;
+
+		werr = reg_enumvalue(talloc_tos(), key, idx, NULL, &val);
+
+		if (W_ERROR_EQUAL(werr, WERR_NO_MORE_ITEMS)) {
+			ret = 0;
+			break;
+		}
+		if (!W_ERROR_IS_OK(werr)) {
+			break;
+		}
+		print_registry_value(val, true);
+		TALLOC_FREE(val);
+		idx += 1;
+	}
+done:
+	TALLOC_FREE(ctx);
+	return ret;
+}
+
 static int net_registry_setvalue(struct net_context *c, int argc,
 				 const char **argv)
 {
@@ -1165,6 +1208,14 @@ int net_registry(struct net_context *c, int argc, const char **argv)
 			   "    Print a registry value (raw format)")
 		},
 		{
+			"getvaluesraw",
+			net_registry_getvaluesraw,
+			NET_TRANSPORT_LOCAL,
+			"Print all values of a key in raw format",
+			"net registry getvaluesraw <key>\n"
+			"    Print a registry value (raw format)"
+		},
+		{
 			"setvalue",
 			net_registry_setvalue,
 			NET_TRANSPORT_LOCAL,


-- 
Samba Shared Repository


More information about the samba-cvs mailing list