public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
From: Christine Caulfield <chrissie@fedoraproject.org>
To: cluster-cvs-relay@redhat.com
Subject: master - cman: cope better with malformed config files
Date: Wed, 03 Sep 2008 12:32:00 -0000	[thread overview]
Message-ID: <20080903105932.24F7FC07B7@lists.fedorahosted.org> (raw)

Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=3941e5e4ce38ac3ac49d7dcf4e838dd30b063c62
Commit:        3941e5e4ce38ac3ac49d7dcf4e838dd30b063c62
Parent:        f308bb5e0a3f7dde8340046a92acee8e72c0017c
Author:        Christine Caulfield <ccaulfie@redhat.com>
AuthorDate:    Wed Sep 3 11:56:52 2008 +0100
Committer:     Christine Caulfield <ccaulfie@redhat.com>
CommitterDate: Wed Sep 3 11:56:52 2008 +0100

cman: cope better with malformed config files

A config file with

 <clusternodes>
   <clusternode/
 ... valid nodes entries
 </clusternodes>

would fool cman into not finding the nodename, even though it exists.
This fixes that.

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
---
 cman/daemon/cman-preconfig.c |    8 ++++++--
 cman/daemon/nodelist.h       |    3 ++-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/cman/daemon/cman-preconfig.c b/cman/daemon/cman-preconfig.c
index 6715b3f..4926591 100644
--- a/cman/daemon/cman-preconfig.c
+++ b/cman/daemon/cman-preconfig.c
@@ -360,7 +360,8 @@ static int verify_nodename(struct objdb_iface_ver0 *objdb, char *nodename)
 
 		if (objdb_get_string(objdb, nodes_handle, "name", &str)) {
 			sprintf(error_reason, "Cannot get node name");
-			break;
+			nodes_handle = nodeslist_next(objdb, find_handle);
+			continue;
 		}
 
 		strcpy(nodename3, str);
@@ -494,7 +495,7 @@ static int get_env_overrides()
 
 static int get_nodename(struct objdb_iface_ver0 *objdb)
 {
-	char *nodeid_str;
+	char *nodeid_str = NULL;
 	unsigned int object_handle;
 	unsigned int find_handle;
 	unsigned int node_object_handle;
@@ -552,6 +553,9 @@ static int get_nodename(struct objdb_iface_ver0 *objdb)
 			write_cman_pipe("This node has no nodeid in cluster.conf");
 			return -1;
 		}
+		sprintf(error_reason, "Failed to find node name in cluster.conf");
+		write_cman_pipe("Failed to find node name in cluster.conf");
+		return -1;
 	}
 
 	objdb->object_find_create(cluster_parent_handle, "cman", strlen("cman"), &find_handle);
diff --git a/cman/daemon/nodelist.h b/cman/daemon/nodelist.h
index faf63c1..02dfe17 100644
--- a/cman/daemon/nodelist.h
+++ b/cman/daemon/nodelist.h
@@ -79,7 +79,8 @@ static inline unsigned int nodelist_byname(OBJDB_API *corosync,
 	nodes_handle = nodeslist_init(corosync, cluster_parent_handle, &find_handle);
 	while (nodes_handle) {
 		if (objdb_get_string(corosync, nodes_handle, "name", &nodename)) {
-			break;
+			nodes_handle = nodeslist_next(corosync, find_handle);
+			continue;
 		}
 		if (strcmp(nodename, name) == 0)
 			return nodes_handle;


                 reply	other threads:[~2008-09-03 11:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080903105932.24F7FC07B7@lists.fedorahosted.org \
    --to=chrissie@fedoraproject.org \
    --cc=cluster-cvs-relay@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).