This is the mail archive of the cluster-cvs@sourceware.org mailing list for the cluster.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

master - cman: cope better with malformed config files


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;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]