All of lore.kernel.org
 help / color / mirror / Atom feed
* [Cluster-devel] cluster/cman/daemon cmanccs.c
@ 2007-03-15  9:27 pcaulfield
  0 siblings, 0 replies; 20+ messages in thread
From: pcaulfield @ 2007-03-15  9:27 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	pcaulfield at sourceware.org	2007-03-15 09:27:20

Modified files:
	cman/daemon    : cmanccs.c 

Log message:
	Support IP(v4) addresses in cluster.conf
	per bz#232068

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/daemon/cmanccs.c.diff?cvsroot=cluster&r1=1.24&r2=1.25

--- cluster/cman/daemon/cmanccs.c	2007/01/02 15:04:21	1.24
+++ cluster/cman/daemon/cmanccs.c	2007/03/15 09:27:20	1.25
@@ -244,7 +244,6 @@
 	return 0;
 }
 
-
 static int verify_nodename(int cd, char *nodename)
 {
 	char path[MAX_PATH_LEN];
@@ -342,6 +341,23 @@
 			goto out;
 		}
 
+		/* See if it's the IP address that's in cluster.conf */
+		error = getnameinfo(sa, sizeof(*sa), nodename2,
+				    sizeof(nodename2), NULL, 0, NI_NUMERICHOST);
+		if (error)
+			goto out;
+
+		str = NULL;
+		memset(path, 0, 256);
+		sprintf(path, NODE_NAME_PATH_BYNAME, nodename2);
+
+		error = ccs_get(cd, path, &str);
+		if (!error) {
+			free(str);
+			strcpy(nodename, nodename2);
+			goto out;
+		}
+
 		/* truncate this name and try again */
 
 		dot = strstr(nodename2, ".");



^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Cluster-devel] cluster/cman/daemon cmanccs.c
@ 2007-11-05 16:03 pcaulfield
  0 siblings, 0 replies; 20+ messages in thread
From: pcaulfield @ 2007-11-05 16:03 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	pcaulfield at sourceware.org	2007-11-05 16:03:59

Modified files:
	cman/daemon    : cmanccs.c 

Log message:
	Add missing format string.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/daemon/cmanccs.c.diff?cvsroot=cluster&r1=1.36&r2=1.37

--- cluster/cman/daemon/cmanccs.c	2007/10/24 05:58:07	1.36
+++ cluster/cman/daemon/cmanccs.c	2007/11/05 16:03:58	1.37
@@ -170,7 +170,7 @@
 			snprintf(message, sizeof(message),
 				"No node ID for %s, run 'ccs_tool addnodeids' to fix",
 				nodename);
-			log_printf(LOG_ERR, message);
+			log_printf(LOG_ERR, "%s", message);
 			write_cman_pipe(message);
 			error = -EINVAL;
 			goto out_err;



^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Cluster-devel] cluster/cman/daemon cmanccs.c
  2007-10-24  5:55 rmccabe
@ 2007-10-24  7:27 ` Fabio Massimo Di Nitto
  0 siblings, 0 replies; 20+ messages in thread
From: Fabio Massimo Di Nitto @ 2007-10-24  7:27 UTC (permalink / raw)
  To: cluster-devel.redhat.com

rmccabe at sourceware.org wrote:
> -	dot = strstr(nodename2, ".");
> +	dot = strchr(nodename2, '.');

This change introduces a build warning:

warning: passing argument 2 of ?strstr? makes pointer from integer without a cast

Fabio

-- 
I'm going to make him an offer he can't refuse.



^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Cluster-devel] cluster/cman/daemon cmanccs.c
@ 2007-10-24  5:58 rmccabe
  0 siblings, 0 replies; 20+ messages in thread
From: rmccabe @ 2007-10-24  5:58 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	rmccabe at sourceware.org	2007-10-24 05:58:07

Modified files:
	cman/daemon    : cmanccs.c 

Log message:
	Commit msg with the last commit went missing..
	
	- Fix unsafe string handling:
	- replace memset(s,c,n);sprintf(s,...); with snprintf with proper error checking
	- don't overflow the stack if the cluster name specified in the env var is too long
	- don't overflow the stack if the local nodename from uname(2) is too long
	- don't overflow the stack if the local nodename specified in the env var is too long
	
	- Don't leak the ccs descriptor in get_ccs_join_info() on errors
	- Fix a couple of small memory leaks in error paths
	- Handle OOM conditions

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/daemon/cmanccs.c.diff?cvsroot=cluster&r1=1.35&r2=1.36

--- cluster/cman/daemon/cmanccs.c	2007/10/24 05:55:07	1.35
+++ cluster/cman/daemon/cmanccs.c	2007/10/24 05:58:07	1.36
@@ -637,6 +637,8 @@
 	/* optional security key filename */
 	if (getenv("CMAN_KEYFILE")) {
 		key_filename = strdup(getenv("CMAN_KEYFILE"));
+		if (key_filename == NULL)
+			return -ENOMEM;
 	}
 	else {
 		error = ccs_get(cd, KEY_PATH, &str);
@@ -662,13 +664,13 @@
 		error = ccs_get(cd, path, &str);
 		if (!error) {
 			int votestmp = atoi(str);
+			free(str);
 			if (votestmp < 0 || votestmp > 255) {
 				log_printf(LOG_ERR, "invalid votes value %d", votestmp);
 				write_cman_pipe("Found invalid votes for node in CCS");
 				return -EINVAL;
 			}
 			votes = votestmp;
-			free(str);
 		}
 		else {
 			votes = 1;



^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Cluster-devel] cluster/cman/daemon cmanccs.c
@ 2007-10-24  5:55 rmccabe
  2007-10-24  7:27 ` Fabio Massimo Di Nitto
  0 siblings, 1 reply; 20+ messages in thread
From: rmccabe @ 2007-10-24  5:55 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	rmccabe at sourceware.org	2007-10-24 05:55:07

Modified files:
	cman/daemon    : cmanccs.c 

Log message:
	- Fix unsafe string handling:
	- replace memset(s,c,n);sprintf(s,...); with snprintf with proper error checking
	- don't overflow the stack if the cluster name specified in the env var is too long
	- don't overflow the stack if the local nodename from uname(2) is too long
	- don't overflow the stack if the local nodename specified in the env var is too long
	
	- Don't leak the ccs descriptor in get_ccs_join_info() on errors

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/daemon/cmanccs.c.diff?cvsroot=cluster&r1=1.34&r2=1.35

--- cluster/cman/daemon/cmanccs.c	2007/10/24 03:21:45	1.34
+++ cluster/cman/daemon/cmanccs.c	2007/10/24 05:55:07	1.35
@@ -1,7 +1,7 @@
 /******************************************************************************
 *******************************************************************************
 **
-**  Copyright (C) 2005-2006 Red Hat, Inc.  All rights reserved.
+**  Copyright (C) 2005-2007 Red Hat, Inc.  All rights reserved.
 **
 **  This copyrighted material is made available to anyone wishing to use,
 **  modify, copy, or redistribute it subject to the terms and conditions
@@ -125,49 +125,60 @@
     if (!ccs_get(ctree, TWO_NODE_PATH, &str)) {
 	    two_node = atoi(str);
 	    free(str);
-    }
-    else
-	two_node = 0;
+    } else
+		two_node = 0;
 
     for (i=1;;i++) {
-	char path[MAX_PATH_LEN];
-	int  votes=0, nodeid=0;
+		char path[MAX_PATH_LEN];
+		int votes=0, nodeid=0;
+		int ret;
+
+		ret = snprintf(path, sizeof(path), NODE_NAME_PATH_BYNUM, i);
+		if (ret < 0 || (size_t) ret >= sizeof(path))
+			return -E2BIG;
 
-	memset(path, 0, MAX_PATH_LEN);
-	sprintf(path, NODE_NAME_PATH_BYNUM, i);
-	error = ccs_get(ctree, path, &nodename);
-	if (error)
-	    break;
+		error = ccs_get(ctree, path, &nodename);
+		if (error)
+			break;
 
-	memset(path, 0, MAX_PATH_LEN);
-	sprintf(path, NODE_VOTES_PATH, nodename);
-	if (!ccs_get(ctree, path, &str)) {
-	    votes = atoi(str);
-	    free(str);
-	} else
-	    votes = 1;
+		ret = snprintf(path, sizeof(path), NODE_VOTES_PATH, nodename);
+		if (ret < 0 || ret >= sizeof(path)) {
+			error = -E2BIG;
+			goto out_err;
+		}
 
-	memset(path, 0, MAX_PATH_LEN);
-	sprintf(path, NODE_NODEID_PATH, nodename);
-	if (!ccs_get(ctree, path, &str)) {
-	    nodeid = atoi(str);
-	    free(str);
+		if (!ccs_get(ctree, path, &str)) {
+			votes = atoi(str);
+			free(str);
+		} else
+			votes = 1;
 
-	}
+		ret = snprintf(path, sizeof(path), NODE_NODEID_PATH, nodename);
+		if (ret < 0 || (size_t) ret >= sizeof(path)) {
+			error = -E2BIG;
+			goto out_err;
+		}
 
-	if (check_nodeids && nodeid == 0) {
-		char message[132];
+		if (!ccs_get(ctree, path, &str)) {
+			nodeid = atoi(str);
+			free(str);
+		}
 
-		sprintf(message, "No node ID for %s, run 'ccs_tool addnodeids' to fix", nodename);
-		log_printf(LOG_ERR, message);
-		write_cman_pipe(message);
-		return -1;
-	}
+		if (check_nodeids && nodeid == 0) {
+			char message[132];
 
-	P_MEMB("Got node %s from ccs (id=%d, votes=%d)\n", nodename, nodeid, votes);
-	add_ccs_node(nodename, nodeid, votes, expected);
+			snprintf(message, sizeof(message),
+				"No node ID for %s, run 'ccs_tool addnodeids' to fix",
+				nodename);
+			log_printf(LOG_ERR, message);
+			write_cman_pipe(message);
+			error = -EINVAL;
+			goto out_err;
+		}
 
-	free(nodename);
+		P_MEMB("Got node %s from ccs (id=%d, votes=%d)\n", nodename, nodeid, votes);
+		add_ccs_node(nodename, nodeid, votes, expected);
+		free(nodename);
     }
 
     if (expected)
@@ -177,6 +188,11 @@
     ccs_disconnect(ctree);
 
     return 0;
+
+out_err:
+	free(nodename);
+	ccs_disconnect(ctree);
+	return error;
 }
 
 static char *default_mcast(uint16_t cluster_id)
@@ -260,11 +276,14 @@
 	struct ifaddrs *ifa, *ifa_list;
 	struct sockaddr *sa;
 	int error, i;
+	int ret;
 
 	/* nodename is either from commandline or from uname */
 	str = NULL;
-	memset(path, 0, MAX_PATH_LEN);
-	sprintf(path, NODE_NAME_PATH_BYNAME, nodename);
+
+	ret = snprintf(path, sizeof(path), NODE_NAME_PATH_BYNAME, nodename);
+	if (ret < 0 || (size_t) ret >= sizeof(path))
+		return -E2BIG;
 
 	error = ccs_get(cd, path, &str);
 	if (!error) {
@@ -274,13 +293,14 @@
 
 	/* If nodename was from uname, try a domain-less version of it */
 	strcpy(nodename2, nodename);
-	dot = strstr(nodename2, ".");
+	dot = strchr(nodename2, '.');
 	if (dot) {
 		*dot = '\0';
 
 		str = NULL;
-		memset(path, 0, MAX_PATH_LEN);
-		sprintf(path, NODE_NAME_PATH_BYNAME, nodename2);
+		ret = snprintf(path, sizeof(path), NODE_NAME_PATH_BYNAME, nodename2);
+		if (ret < 0 || (size_t) ret >= sizeof(path))
+			return -E2BIG;
 
 		error = ccs_get(cd, path, &str);
 		if (!error) {
@@ -290,21 +310,25 @@
 		}
 	}
 
-
 	/* If nodename (from uname) is domain-less, try to match against
 	   cluster.conf names which may have domainname specified */
 	for (i = 1; ; i++) {
 		int len;
+
 		str = NULL;
-		memset(path, 0, 256);
-		sprintf(path, "/cluster/clusternodes/clusternode[%d]/@name", i);
+		ret = snprintf(path, sizeof(path),
+				"/cluster/clusternodes/clusternode[%d]/@name", i);
+		if (ret < 0 || (size_t) ret >= sizeof(path)) {
+			error = -E2BIG;
+			break;
+		}
 
 		error = ccs_get(cd, path, &str);
 		if (error || !str)
 			break;
 
 		strcpy(nodename3, str);
-		dot = strstr(nodename3, ".");
+		dot = strchr(nodename3, '.');
 		if (dot)
 			len = dot-nodename3;
 		else
@@ -328,7 +352,6 @@
 		return -1;
 
 	for (ifa = ifa_list; ifa; ifa = ifa->ifa_next) {
-
 		/* Restore this */
 		strcpy(nodename2, nodename);
 		sa = ifa->ifa_addr;
@@ -341,8 +364,11 @@
 			goto out;
 
 		str = NULL;
-		memset(path, 0, 256);
-		sprintf(path, NODE_NAME_PATH_BYNAME, nodename2);
+		ret = snprintf(path, sizeof(path), NODE_NAME_PATH_BYNAME, nodename2);
+		if (ret < 0 || (size_t) ret >= sizeof(path)) {
+			error = -E2BIG;
+			goto out;
+		}
 
 		error = ccs_get(cd, path, &str);
 		if (!error) {
@@ -353,14 +379,17 @@
 
 		/* truncate this name and try again */
 
-		dot = strstr(nodename2, ".");
+		dot = strchr(nodename2, '.');
 		if (!dot)
 			continue;
 		*dot = '\0';
 
 		str = NULL;
-		memset(path, 0, 256);
-		sprintf(path, NODE_NAME_PATH_BYNAME, nodename2);
+		ret = snprintf(path, sizeof(path), NODE_NAME_PATH_BYNAME, nodename2);
+		if (ret < 0 || (size_t) ret >= sizeof(path)) {
+			error = -E2BIG;
+			goto out;
+		}
 
 		error = ccs_get(cd, path, &str);
 		if (!error) {
@@ -376,8 +405,11 @@
 			goto out;
 
 		str = NULL;
-		memset(path, 0, 256);
-		sprintf(path, NODE_NAME_PATH_BYNAME, nodename2);
+		ret = snprintf(path, sizeof(path), NODE_NAME_PATH_BYNAME, nodename2);
+		if (ret < 0 || (size_t) ret >= sizeof(path)) {
+			error = -E2BIG;
+			goto out;
+		}
 
 		error = ccs_get(cd, path, &str);
 		if (!error) {
@@ -398,7 +430,7 @@
 {
 	char path[MAX_PATH_LEN];
 	char nodename[MAX_CLUSTER_MEMBER_NAME_LEN+1];
-	char *str, *name, *cname = NULL;
+	char *str, *name, *cname = NULL, *nodename_env;
 	int cd, error, i, vote_sum = 0, node_count = 0;
 	unsigned short port = 0;
 
@@ -420,17 +452,26 @@
 	if (error) {
 		log_printf(LOG_ERR, "cannot find cluster name in config file");
 		write_cman_pipe("Can't find cluster name in CCS");
-		return -ENOENT;
+		error = -ENOENT;
+		goto out;
 	}
 
 	if (cname) {
 		if (strcmp(cname, str)) {
 			log_printf(LOG_ERR, "cluster names not equal %s %s", cname, str);
 			write_cman_pipe("Cluster name in CCS does not match that passed to cman_tool");
-			return -ENOENT;
+			error = -ENOENT;
+			goto out;
 		}
 	}
 
+	if (strlen(str) >= sizeof(cluster_name)) {
+		free(str);
+		write_cman_pipe("Cluster name in CCS is too long");
+		error = -E2BIG;
+		goto out;
+	}
+
 	strcpy(cluster_name, str);
 	free(str);
 
@@ -444,32 +485,55 @@
 	}
 
 	/* our nodename */
-	memset(nodename, 0, sizeof(nodename));
+	nodename_env = getenv("CMAN_NODENAME");
+	if (nodename_env != NULL) {
+		int ret;
+
+		if (strlen(nodename_env) >= sizeof(nodename)) {
+			log_printf(LOG_ERR, "Overridden node name %s is too long", nodename);
+			write_cman_pipe("Overridden node name is too long");
+			error = -E2BIG;
+			goto out;
+		}
 
-	if (getenv("CMAN_NODENAME")) {
-		strcpy(nodename, getenv("CMAN_NODENAME"));
+		strcpy(nodename, nodename_env);
 		log_printf(LOG_INFO, "Using override node name %s\n", nodename);
 
-		sprintf(path, NODE_NAME_PATH_BYNAME, nodename);
+		ret = snprintf(path, sizeof(path), NODE_NAME_PATH_BYNAME, nodename);
+		if (ret < 0 || (size_t) ret >= sizeof(path)) {
+			log_printf(LOG_ERR, "Overridden node name %s is too long", nodename);
+			write_cman_pipe("Overridden node name is too long");
+			error = -E2BIG;
+			goto out;
+		}
 
 		error = ccs_get(cd, path, &str);
 		if (!error) {
 			free(str);
-		}
-		else {
+		} else {
 			log_printf(LOG_ERR, "Overridden node name %s is not in CCS", nodename);
 			write_cman_pipe("Overridden node name is not in CCS");
-			return -ENOENT;
+			error = -ENOENT;
+			goto out;
 		}
-	}
-	else {
+	} else {
 		struct utsname utsname;
+
 		error = uname(&utsname);
 		if (error) {
 			log_printf(LOG_ERR, "cannot get node name, uname failed");
 			write_cman_pipe("Can't determine local node name");
-			return -ENOENT;
+			error = -ENOENT;
+			goto out;
+		}
+
+		if (strlen(utsname.nodename) >= sizeof(nodename)) {
+			log_printf(LOG_ERR, "node name from uname is too long");
+			write_cman_pipe("Can't determine local node name");
+			error = -E2BIG;
+			goto out;
 		}
+
 		strcpy(nodename, utsname.nodename);
 	}
 
@@ -480,9 +544,15 @@
 		log_printf(LOG_ERR, "local node name \"%s\" not found in cluster.conf",
 			nodename);
 		write_cman_pipe("Can't find local node name in cluster.conf");
-		return -ENOENT;
+		error = -ENOENT;
+		goto out;
 	}
+
 	nodenames[0] = strdup(nodename);
+	if (nodenames[0] == NULL) {
+		error = -ENOMEM;
+		goto out;
+	}
 
 	expected_votes = 0;
 	if (getenv("CMAN_EXPECTEDVOTES")) {
@@ -499,9 +569,14 @@
 	/* Sum node votes for expected */
 	if (expected_votes == 0) {
 		for (i = 1; ; i++) {
+			int ret;
+
 			name = NULL;
-			memset(path, 0, MAX_PATH_LEN);
-			sprintf(path, NODE_NAME_PATH_BYNUM, i);
+			ret = snprintf(path, sizeof(path), NODE_NAME_PATH_BYNUM, i);
+			if (ret < 0 || (size_t) ret >= sizeof(path)) {
+				error = -E2BIG;
+				break;
+			}
 
 			error = ccs_get(cd, path, &name);
 			if (error || !name)
@@ -509,10 +584,14 @@
 
 			node_count++;
 
-			memset(path, 0, MAX_PATH_LEN);
-			sprintf(path, NODE_VOTES_PATH, name);
+			ret = snprintf(path, sizeof(path), NODE_VOTES_PATH, name);
 			free(name);
 
+			if (ret < 0 || (size_t) ret >= sizeof(path)) {
+				error = -E2BIG;
+				break;
+			}
+
 			error = ccs_get(cd, path, &str);
 			if (error)
 				vote_sum++;
@@ -520,7 +599,8 @@
 				if (atoi(str) < 0) {
 					log_printf(LOG_ERR, "negative votes not allowed");
 					write_cman_pipe("Found negative votes for this node in CCS");
-					return -EINVAL;
+					error = -EINVAL;
+					goto out;
 				}
 				vote_sum += atoi(str);
 				free(str);
@@ -572,8 +652,12 @@
 	}
 
 	if (!votes) {
-		memset(path, 0, MAX_PATH_LEN);
-		sprintf(path, NODE_VOTES_PATH, nodename);
+		int ret = snprintf(path, sizeof(path), NODE_VOTES_PATH, nodename);
+		if (ret < 0 || (size_t) ret >= sizeof(path)) {
+			log_printf(LOG_ERR, "unable to find votes for %s", nodename);
+			write_cman_pipe("Unable to find votes for node in CCS");
+			return -E2BIG;
+		}
 
 		error = ccs_get(cd, path, &str);
 		if (!error) {
@@ -599,13 +683,14 @@
 	}
 
 	if (!nodeid) {
-		memset(path, 0, MAX_PATH_LEN);
-		sprintf(path, NODE_NODEID_PATH, nodename);
+		int ret = snprintf(path, sizeof(path), NODE_NODEID_PATH, nodename);
 
-		error = ccs_get(cd, path, &str);
-		if (!error) {
-			nodeid = atoi(str);
-			free(str);
+		if (ret >= 0 && (size_t) ret < sizeof(path)) {
+			error = ccs_get(cd, path, &str);
+			if (!error) {
+				nodeid = atoi(str);
+				free(str);
+			}
 		}
 	}
 
@@ -638,35 +723,44 @@
 	/* Get all alternative node names */
 	num_nodenames = 1;
 
-	memset(path, 0, MAX_PATH_LEN);
-
-
 	for (i = 1; ; i++) {
-		str = NULL;
-		sprintf(path, NODE_ALTNAMES_PATH, nodename, i);
+		int ret = snprintf(path, sizeof(path), NODE_ALTNAMES_PATH, nodename, i);
+		if (ret < 0 || (size_t) ret >= sizeof(path)) {
+			error = -E2BIG;
+			break;
+		}
 
+		str = NULL;
 		error = ccs_get(cd, path, &str);
 		if (error || !str)
 			break;
 
 		nodenames[i] = str;
 
-		sprintf(path, NODE_ALTNAMES_PORT, nodename, i);
+		ret = snprintf(path, sizeof(path), NODE_ALTNAMES_PORT, nodename, i);
+		if (ret < 0 || (size_t) ret >= sizeof(path)) {
+			error = -E2BIG;
+			break;
+		}
+
 		error = ccs_get(cd, path, &str);
 		if (error || !str) {
 			portnums[i] = portnums[0];
-		}
-		else {
+		} else {
 			portnums[i] = atoi(str);
 			free(str);
 		}
 
-		sprintf(path, NODE_ALTNAMES_MCAST, nodename, i);
+		ret = snprintf(path, sizeof(path), NODE_ALTNAMES_MCAST, nodename, i);
+		if (ret < 0 || (size_t) ret >= sizeof(path)) {
+			error = -E2BIG;
+			break;
+		}
+
 		error = ccs_get(cd, path, &str);
 		if (error || !str) {
 			mcast[i] = mcast_name;
-		}
-		else {
+		} else {
 			mcast[i] = str;
 		}
 
@@ -686,7 +780,8 @@
 					"votes of 1 (node_count=%d vote_sum=%d)",
 					node_count, vote_sum);
 				write_cman_pipe("two_node set but there are more than 2 nodes");
-				return -EINVAL;
+				error = -EINVAL;
+				goto out;
 			}
 
 			if (votes != 1) {
@@ -694,13 +789,17 @@
 					"nodes with one vote each and expected "
 					"votes of 1 (votes=%d)", votes);
 				write_cman_pipe("two_node set but votes not set to 1");
-				return -EINVAL;
+				error = -EINVAL;
+				goto out;
 			}
 		}
 	}
 
+	error = 0;
+
+out:
 	ccs_disconnect(cd);
-	return 0;
+	return error;
 }
 
 



^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Cluster-devel] cluster/cman/daemon cmanccs.c
@ 2007-10-24  3:21 fabbione
  0 siblings, 0 replies; 20+ messages in thread
From: fabbione @ 2007-10-24  3:21 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	fabbione at sourceware.org	2007-10-24 03:21:45

Modified files:
	cman/daemon    : cmanccs.c 

Log message:
	Use standard path var and memset it before each query

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/daemon/cmanccs.c.diff?cvsroot=cluster&r1=1.33&r2=1.34

--- cluster/cman/daemon/cmanccs.c	2007/10/24 03:21:22	1.33
+++ cluster/cman/daemon/cmanccs.c	2007/10/24 03:21:45	1.34
@@ -130,24 +130,26 @@
 	two_node = 0;
 
     for (i=1;;i++) {
-	char nodekey[256];
-	char key[256];
+	char path[MAX_PATH_LEN];
 	int  votes=0, nodeid=0;
 
-	sprintf(nodekey, NODE_NAME_PATH_BYNUM, i);
-	error = ccs_get(ctree, nodekey, &nodename);
+	memset(path, 0, MAX_PATH_LEN);
+	sprintf(path, NODE_NAME_PATH_BYNUM, i);
+	error = ccs_get(ctree, path, &nodename);
 	if (error)
 	    break;
 
-	sprintf(key, NODE_VOTES_PATH, nodename);
-	if (!ccs_get(ctree, key, &str)) {
+	memset(path, 0, MAX_PATH_LEN);
+	sprintf(path, NODE_VOTES_PATH, nodename);
+	if (!ccs_get(ctree, path, &str)) {
 	    votes = atoi(str);
 	    free(str);
 	} else
 	    votes = 1;
 
-	sprintf(key, NODE_NODEID_PATH, nodename);
-	if (!ccs_get(ctree, key, &str))	{
+	memset(path, 0, MAX_PATH_LEN);
+	sprintf(path, NODE_NODEID_PATH, nodename);
+	if (!ccs_get(ctree, path, &str)) {
 	    nodeid = atoi(str);
 	    free(str);
 



^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Cluster-devel] cluster/cman/daemon cmanccs.c
@ 2007-10-24  3:21 fabbione
  0 siblings, 0 replies; 20+ messages in thread
From: fabbione @ 2007-10-24  3:21 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	fabbione at sourceware.org	2007-10-24 03:21:22

Modified files:
	cman/daemon    : cmanccs.c 

Log message:
	Use right vars to print debugging info

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/daemon/cmanccs.c.diff?cvsroot=cluster&r1=1.32&r2=1.33

--- cluster/cman/daemon/cmanccs.c	2007/10/24 03:20:58	1.32
+++ cluster/cman/daemon/cmanccs.c	2007/10/24 03:21:22	1.33
@@ -577,7 +577,7 @@
 		if (!error) {
 			int votestmp = atoi(str);
 			if (votestmp < 0 || votestmp > 255) {
-				log_printf(LOG_ERR, "invalid votes value %d", votes);
+				log_printf(LOG_ERR, "invalid votes value %d", votestmp);
 				write_cman_pipe("Found invalid votes for node in CCS");
 				return -EINVAL;
 			}



^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Cluster-devel] cluster/cman/daemon cmanccs.c
@ 2007-10-24  3:20 fabbione
  0 siblings, 0 replies; 20+ messages in thread
From: fabbione @ 2007-10-24  3:20 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	fabbione at sourceware.org	2007-10-24 03:20:59

Modified files:
	cman/daemon    : cmanccs.c 

Log message:
	Clean up duplicate ccs query paths

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/daemon/cmanccs.c.diff?cvsroot=cluster&r1=1.31&r2=1.32

--- cluster/cman/daemon/cmanccs.c	2007/10/03 10:06:21	1.31
+++ cluster/cman/daemon/cmanccs.c	2007/10/24 03:20:58	1.32
@@ -45,7 +45,6 @@
 #define PORT_PATH		"/cluster/cman/@port"
 #define KEY_PATH		"/cluster/cman/@keyfile"
 
-#define NODEI_NAME_PATH		"/cluster/clusternodes/clusternode[%d]/@name"
 #define NODE_NAME_PATH_BYNAME	"/cluster/clusternodes/clusternode[@name=\"%s\"]/@name"
 #define NODE_NAME_PATH_BYNUM	"/cluster/clusternodes/clusternode[%d]/@name"
 #define NODE_VOTES_PATH		"/cluster/clusternodes/clusternode[@name=\"%s\"]/@votes"
@@ -500,7 +499,7 @@
 		for (i = 1; ; i++) {
 			name = NULL;
 			memset(path, 0, MAX_PATH_LEN);
-			sprintf(path, NODEI_NAME_PATH, i);
+			sprintf(path, NODE_NAME_PATH_BYNUM, i);
 
 			error = ccs_get(cd, path, &name);
 			if (error || !name)



^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Cluster-devel] cluster/cman/daemon cmanccs.c
@ 2007-08-17  7:51 pcaulfield
  0 siblings, 0 replies; 20+ messages in thread
From: pcaulfield @ 2007-08-17  7:51 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL51
Changes by:	pcaulfield at sourceware.org	2007-08-17 07:51:03

Modified files:
	cman/daemon    : cmanccs.c 

Log message:
	bz#250688
	Don't lose the cluster name if it's specified on the cman_tool command line.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/daemon/cmanccs.c.diff?cvsroot=cluster&only_with_tag=RHEL51&r1=1.21.2.4&r2=1.21.2.4.2.1

--- cluster/cman/daemon/cmanccs.c	2007/05/23 10:31:00	1.21.2.4
+++ cluster/cman/daemon/cmanccs.c	2007/08/17 07:51:03	1.21.2.4.2.1
@@ -424,9 +424,9 @@
 			write_cman_pipe("Cluster name in CCS does not match that passed to cman_tool");
 			return -ENOENT;
 		}
-	} else {
-		strcpy(cluster_name, str);
 	}
+
+	strcpy(cluster_name, str);
 	free(str);
 
 	error = ccs_get(cd, CLUSTER_ID_PATH, &str);



^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Cluster-devel] cluster/cman/daemon cmanccs.c
@ 2007-08-03 10:49 pcaulfield
  0 siblings, 0 replies; 20+ messages in thread
From: pcaulfield @ 2007-08-03 10:49 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL5
Changes by:	pcaulfield at sourceware.org	2007-08-03 10:49:11

Modified files:
	cman/daemon    : cmanccs.c 

Log message:
	Don't lost the cluster name if it is specified on the command line
	probably the cause of bz#250688

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/daemon/cmanccs.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.21.2.4&r2=1.21.2.5

--- cluster/cman/daemon/cmanccs.c	2007/05/23 10:31:00	1.21.2.4
+++ cluster/cman/daemon/cmanccs.c	2007/08/03 10:49:11	1.21.2.5
@@ -424,9 +424,9 @@
 			write_cman_pipe("Cluster name in CCS does not match that passed to cman_tool");
 			return -ENOENT;
 		}
-	} else {
-		strcpy(cluster_name, str);
 	}
+
+	strcpy(cluster_name, str);
 	free(str);
 
 	error = ccs_get(cd, CLUSTER_ID_PATH, &str);



^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Cluster-devel] cluster/cman/daemon cmanccs.c
@ 2007-08-03  7:35 pcaulfield
  0 siblings, 0 replies; 20+ messages in thread
From: pcaulfield @ 2007-08-03  7:35 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	pcaulfield at sourceware.org	2007-08-03 07:35:07

Modified files:
	cman/daemon    : cmanccs.c 

Log message:
	Don't lost the cluster name if it is specified on the command line
	probably the cause of bz#250688

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/daemon/cmanccs.c.diff?cvsroot=cluster&r1=1.28&r2=1.29

--- cluster/cman/daemon/cmanccs.c	2007/05/21 10:48:40	1.28
+++ cluster/cman/daemon/cmanccs.c	2007/08/03 07:35:06	1.29
@@ -426,9 +426,9 @@
 			write_cman_pipe("Cluster name in CCS does not match that passed to cman_tool");
 			return -ENOENT;
 		}
-	} else {
-		strcpy(cluster_name, str);
 	}
+
+	strcpy(cluster_name, str);
 	free(str);
 
 	error = ccs_get(cd, CLUSTER_ID_PATH, &str);



^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Cluster-devel] cluster/cman/daemon cmanccs.c
@ 2007-05-23 10:31 pcaulfield
  0 siblings, 0 replies; 20+ messages in thread
From: pcaulfield @ 2007-05-23 10:31 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL5
Changes by:	pcaulfield at sourceware.org	2007-05-23 10:31:00

Modified files:
	cman/daemon    : cmanccs.c 

Log message:
	Move fix for bz #232068 (IP addresses in cluster.conf) to RHEL5 branch

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/daemon/cmanccs.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.21.2.3&r2=1.21.2.4

--- cluster/cman/daemon/cmanccs.c	2007/05/18 12:46:30	1.21.2.3
+++ cluster/cman/daemon/cmanccs.c	2007/05/23 10:31:00	1.21.2.4
@@ -246,7 +246,6 @@
 	return 0;
 }
 
-
 static int verify_nodename(int cd, char *nodename)
 {
 	char path[MAX_PATH_LEN];
@@ -316,14 +315,17 @@
 		free(str);
 	}
 
-
 	/* The cluster.conf names may not be related to uname at all,
-	   they may match a hostname on some network interface */
+	   they may match a hostname on some network interface.
+	   NOTE: This is IPv4 only */
 	error = getifaddrs(&ifa_list);
 	if (error)
 		return -1;
 
 	for (ifa = ifa_list; ifa; ifa = ifa->ifa_next) {
+
+		/* Restore this */
+		strcpy(nodename2, nodename);
 		sa = ifa->ifa_addr;
 		if (!sa || sa->sa_family != AF_INET)
 			continue;
@@ -361,6 +363,23 @@
 			strcpy(nodename, nodename2);
 			goto out;
 		}
+
+		/* See if it's the IP address that's in cluster.conf */
+		error = getnameinfo(sa, sizeof(*sa), nodename2,
+				    sizeof(nodename2), NULL, 0, NI_NUMERICHOST);
+		if (error)
+			goto out;
+
+		str = NULL;
+		memset(path, 0, 256);
+		sprintf(path, NODE_NAME_PATH_BYNAME, nodename2);
+
+		error = ccs_get(cd, path, &str);
+		if (!error) {
+			free(str);
+			strcpy(nodename, nodename2);
+			goto out;
+		}
 	}
 
 	error = -1;



^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Cluster-devel] cluster/cman/daemon cmanccs.c
@ 2007-03-15 11:12 pcaulfield
  0 siblings, 0 replies; 20+ messages in thread
From: pcaulfield @ 2007-03-15 11:12 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	pcaulfield at sourceware.org	2007-03-15 11:12:33

Modified files:
	cman/daemon    : cmanccs.c 

Log message:
	If the machine is multi-homed, then using a truncated name in uname but not in
	cluster.conf would fail to match them up.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/daemon/cmanccs.c.diff?cvsroot=cluster&r1=1.25&r2=1.26

--- cluster/cman/daemon/cmanccs.c	2007/03/15 09:27:20	1.25
+++ cluster/cman/daemon/cmanccs.c	2007/03/15 11:12:33	1.26
@@ -313,14 +313,17 @@
 		free(str);
 	}
 
-
 	/* The cluster.conf names may not be related to uname at all,
-	   they may match a hostname on some network interface */
+	   they may match a hostname on some network interface.
+	   NOTE: This is IPv4 only */
 	error = getifaddrs(&ifa_list);
 	if (error)
 		return -1;
 
 	for (ifa = ifa_list; ifa; ifa = ifa->ifa_next) {
+
+		/* Restore this */
+		strcpy(nodename2, nodename);
 		sa = ifa->ifa_addr;
 		if (!sa || sa->sa_family != AF_INET)
 			continue;
@@ -341,11 +344,12 @@
 			goto out;
 		}
 
-		/* See if it's the IP address that's in cluster.conf */
-		error = getnameinfo(sa, sizeof(*sa), nodename2,
-				    sizeof(nodename2), NULL, 0, NI_NUMERICHOST);
-		if (error)
-			goto out;
+		/* truncate this name and try again */
+
+		dot = strstr(nodename2, ".");
+		if (!dot)
+			continue;
+		*dot = '\0';
 
 		str = NULL;
 		memset(path, 0, 256);
@@ -358,12 +362,11 @@
 			goto out;
 		}
 
-		/* truncate this name and try again */
-
-		dot = strstr(nodename2, ".");
-		if (!dot)
-			continue;
-		*dot = '\0';
+		/* See if it's the IP address that's in cluster.conf */
+		error = getnameinfo(sa, sizeof(*sa), nodename2,
+				    sizeof(nodename2), NULL, 0, NI_NUMERICHOST);
+		if (error)
+			goto out;
 
 		str = NULL;
 		memset(path, 0, 256);



^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Cluster-devel] cluster/cman/daemon cmanccs.c
@ 2007-01-02 15:17 pcaulfield
  0 siblings, 0 replies; 20+ messages in thread
From: pcaulfield @ 2007-01-02 15:17 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL5
Changes by:	pcaulfield at sourceware.org	2007-01-02 15:17:36

Modified files:
	cman/daemon    : cmanccs.c 

Log message:
	Bring forward the last two changes from HEAD:
	- add cluster_id to cluster.conf
	- improve error message if cluster name is too long.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/daemon/cmanccs.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.21.2.1&r2=1.21.2.2

--- cluster/cman/daemon/cmanccs.c	2006/11/30 10:47:23	1.21.2.1
+++ cluster/cman/daemon/cmanccs.c	2007/01/02 15:17:36	1.21.2.2
@@ -36,6 +36,7 @@
 #define CONFIG_VERSION_PATH	"/cluster/@config_version"
 #define CLUSTER_NAME_PATH	"/cluster/@name"
 
+#define CLUSTER_ID_PATH 	"/cluster/cman/@cluster_id"
 #define EXP_VOTES_PATH		"/cluster/cman/@expected_votes"
 #define TWO_NODE_PATH		"/cluster/cman/@two_node"
 #define MCAST_ADDR_PATH		"/cluster/cman/multicast/@addr"
@@ -217,6 +218,10 @@
 	 */
 	error = cman_join_cluster(cluster_name, cluster_id,
 				  two_node, expected_votes);
+	if (error == -EINVAL) {
+		write_cman_pipe("Cannot start, cluster name is too long or other CCS error");
+		return error;
+	}
 	if (error) {
 		write_cman_pipe("Cannot start, ais may already be running");
 		return error;
@@ -402,7 +407,15 @@
 		strcpy(cluster_name, str);
 	}
 	free(str);
-	cluster_id = generate_cluster_id(cluster_name);
+
+	error = ccs_get(cd, CLUSTER_ID_PATH, &str);
+	if (!error) {
+		cluster_id = atoi(str);
+		free(str);
+	}
+	else {
+		cluster_id = generate_cluster_id(cluster_name);
+	}
 
 	/* our nodename */
 	memset(nodename, 0, sizeof(nodename));



^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Cluster-devel] cluster/cman/daemon cmanccs.c
@ 2007-01-02 15:04 pcaulfield
  0 siblings, 0 replies; 20+ messages in thread
From: pcaulfield @ 2007-01-02 15:04 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	pcaulfield at sourceware.org	2007-01-02 15:04:21

Modified files:
	cman/daemon    : cmanccs.c 

Log message:
	Give a better error if the cluster name is too long.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/daemon/cmanccs.c.diff?cvsroot=cluster&r1=1.23&r2=1.24

--- cluster/cman/daemon/cmanccs.c	2006/12/15 13:43:03	1.23
+++ cluster/cman/daemon/cmanccs.c	2007/01/02 15:04:21	1.24
@@ -218,6 +218,10 @@
 	 */
 	error = cman_join_cluster(cluster_name, cluster_id,
 				  two_node, expected_votes);
+	if (error == -EINVAL) {
+		write_cman_pipe("Cannot start, cluster name is too long or other CCS error");
+		return error;
+	}
 	if (error) {
 		write_cman_pipe("Cannot start, ais may already be running");
 		return error;



^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Cluster-devel] cluster/cman/daemon cmanccs.c
@ 2006-12-15 15:17 pcaulfield
  0 siblings, 0 replies; 20+ messages in thread
From: pcaulfield @ 2006-12-15 15:17 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL50
Changes by:	pcaulfield at sourceware.org	2006-12-15 15:17:13

Modified files:
	cman/daemon    : cmanccs.c 

Log message:
	Don't truncate the node name when we check for it unqualified.
	bz#217724

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/daemon/cmanccs.c.diff?cvsroot=cluster&only_with_tag=RHEL50&r1=1.21&r2=1.21.4.1

--- cluster/cman/daemon/cmanccs.c	2006/10/02 08:50:02	1.21
+++ cluster/cman/daemon/cmanccs.c	2006/12/15 15:17:13	1.21.4.1
@@ -283,6 +283,7 @@
 	/* If nodename (from uname) is domain-less, try to match against
 	   cluster.conf names which may have domainname specified */
 	for (i = 1; ; i++) {
+		int len;
 		str = NULL;
 		memset(path, 0, 256);
 		sprintf(path, "/cluster/clusternodes/clusternode[%d]/@name", i);
@@ -294,10 +295,12 @@
 		strcpy(nodename3, str);
 		dot = strstr(nodename3, ".");
 		if (dot)
-			*dot = '\0';
+			len = dot-nodename3;
+		else
+			len = strlen(nodename3);
 
-		if (strlen(nodename2) == strlen(nodename3) &&
-		    !strncmp(nodename2, nodename3, strlen(nodename3))) {
+		if (strlen(nodename2) == len &&
+		    !strncmp(nodename2, nodename3, len)) {
 			free(str);
 			strcpy(nodename, nodename3);
 			return 0;



^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Cluster-devel] cluster/cman/daemon cmanccs.c
@ 2006-12-15 13:43 pcaulfield
  0 siblings, 0 replies; 20+ messages in thread
From: pcaulfield @ 2006-12-15 13:43 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	pcaulfield at sourceware.org	2006-12-15 13:43:03

Modified files:
	cman/daemon    : cmanccs.c 

Log message:
	Add cluster_id override field to cluster.conf, so that people can manually
	assign cluster IDs where the hash values for similar names clash

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/daemon/cmanccs.c.diff?cvsroot=cluster&r1=1.22&r2=1.23

--- cluster/cman/daemon/cmanccs.c	2006/11/30 10:46:35	1.22
+++ cluster/cman/daemon/cmanccs.c	2006/12/15 13:43:03	1.23
@@ -36,6 +36,7 @@
 #define CONFIG_VERSION_PATH	"/cluster/@config_version"
 #define CLUSTER_NAME_PATH	"/cluster/@name"
 
+#define CLUSTER_ID_PATH 	"/cluster/cman/@cluster_id"
 #define EXP_VOTES_PATH		"/cluster/cman/@expected_votes"
 #define TWO_NODE_PATH		"/cluster/cman/@two_node"
 #define MCAST_ADDR_PATH		"/cluster/cman/multicast/@addr"
@@ -402,7 +403,15 @@
 		strcpy(cluster_name, str);
 	}
 	free(str);
-	cluster_id = generate_cluster_id(cluster_name);
+
+	error = ccs_get(cd, CLUSTER_ID_PATH, &str);
+	if (!error) {
+		cluster_id = atoi(str);
+		free(str);
+	}
+	else {
+		cluster_id = generate_cluster_id(cluster_name);
+	}
 
 	/* our nodename */
 	memset(nodename, 0, sizeof(nodename));



^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Cluster-devel] cluster/cman/daemon cmanccs.c
@ 2006-11-30 10:47 pcaulfield
  0 siblings, 0 replies; 20+ messages in thread
From: pcaulfield @ 2006-11-30 10:47 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL5
Changes by:	pcaulfield at sourceware.org	2006-11-30 10:47:23

Modified files:
	cman/daemon    : cmanccs.c 

Log message:
	Don't truncate the node name when we check for it unqualified.
	bz#217724

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/daemon/cmanccs.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.21&r2=1.21.2.1

--- cluster/cman/daemon/cmanccs.c	2006/10/02 08:50:02	1.21
+++ cluster/cman/daemon/cmanccs.c	2006/11/30 10:47:23	1.21.2.1
@@ -283,6 +283,7 @@
 	/* If nodename (from uname) is domain-less, try to match against
 	   cluster.conf names which may have domainname specified */
 	for (i = 1; ; i++) {
+		int len;
 		str = NULL;
 		memset(path, 0, 256);
 		sprintf(path, "/cluster/clusternodes/clusternode[%d]/@name", i);
@@ -294,10 +295,12 @@
 		strcpy(nodename3, str);
 		dot = strstr(nodename3, ".");
 		if (dot)
-			*dot = '\0';
+			len = dot-nodename3;
+		else
+			len = strlen(nodename3);
 
-		if (strlen(nodename2) == strlen(nodename3) &&
-		    !strncmp(nodename2, nodename3, strlen(nodename3))) {
+		if (strlen(nodename2) == len &&
+		    !strncmp(nodename2, nodename3, len)) {
 			free(str);
 			strcpy(nodename, nodename3);
 			return 0;



^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Cluster-devel] cluster/cman/daemon cmanccs.c
@ 2006-11-30 10:46 pcaulfield
  0 siblings, 0 replies; 20+ messages in thread
From: pcaulfield @ 2006-11-30 10:46 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	pcaulfield at sourceware.org	2006-11-30 10:46:36

Modified files:
	cman/daemon    : cmanccs.c 

Log message:
	Don't truncate the node name when we check for it unqualified.
	bz#217724

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/daemon/cmanccs.c.diff?cvsroot=cluster&r1=1.21&r2=1.22

--- cluster/cman/daemon/cmanccs.c	2006/10/02 08:50:02	1.21
+++ cluster/cman/daemon/cmanccs.c	2006/11/30 10:46:35	1.22
@@ -283,6 +283,7 @@
 	/* If nodename (from uname) is domain-less, try to match against
 	   cluster.conf names which may have domainname specified */
 	for (i = 1; ; i++) {
+		int len;
 		str = NULL;
 		memset(path, 0, 256);
 		sprintf(path, "/cluster/clusternodes/clusternode[%d]/@name", i);
@@ -294,10 +295,12 @@
 		strcpy(nodename3, str);
 		dot = strstr(nodename3, ".");
 		if (dot)
-			*dot = '\0';
+			len = dot-nodename3;
+		else
+			len = strlen(nodename3);
 
-		if (strlen(nodename2) == strlen(nodename3) &&
-		    !strncmp(nodename2, nodename3, strlen(nodename3))) {
+		if (strlen(nodename2) == len &&
+		    !strncmp(nodename2, nodename3, len)) {
 			free(str);
 			strcpy(nodename, nodename3);
 			return 0;



^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Cluster-devel] cluster/cman/daemon cmanccs.c
@ 2006-07-03  8:51 pcaulfield
  0 siblings, 0 replies; 20+ messages in thread
From: pcaulfield @ 2006-07-03  8:51 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	pcaulfield at sourceware.org	2006-07-03 08:51:10

Modified files:
	cman/daemon    : cmanccs.c 

Log message:
	Count votes correctly - buy not shadowing variables, sigh.
	Also fail to start if the nodeid is not set.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/daemon/cmanccs.c.diff?cvsroot=cluster&r1=1.16&r2=1.17

--- cluster/cman/daemon/cmanccs.c	2006/06/30 13:00:27	1.16
+++ cluster/cman/daemon/cmanccs.c	2006/07/03 08:51:10	1.17
@@ -506,12 +506,12 @@
 
 		error = ccs_get(cd, path, &str);
 		if (!error) {
-			int votes = atoi(str);
-			if (votes < 0 || votes > 255) {
+			int votestmp = atoi(str);
+			if (votestmp < 0 || votestmp > 255) {
 				log_msg(LOG_ERR, "invalid votes value %d", votes);
 				return -EINVAL;
 			}
-			votes = votes;
+			votes = votestmp;
 			free(str);
 		}
 		else {
@@ -537,6 +537,11 @@
 		}
 	}
 
+	if (!nodeid) {
+		log_msg(LOG_ERR, "No nodeid specified in cluster.conf");
+		return -EINVAL;
+	}
+
 	if (getenv("CMAN_MCAST_ADDR")) {
 		mcast_name = getenv("CMAN_MCAST_ADDR");
 		log_msg(LOG_INFO, "Using override multicast address %s\n", mcast_name);



^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2007-11-05 16:03 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-15  9:27 [Cluster-devel] cluster/cman/daemon cmanccs.c pcaulfield
  -- strict thread matches above, loose matches on Subject: below --
2007-11-05 16:03 pcaulfield
2007-10-24  5:58 rmccabe
2007-10-24  5:55 rmccabe
2007-10-24  7:27 ` Fabio Massimo Di Nitto
2007-10-24  3:21 fabbione
2007-10-24  3:21 fabbione
2007-10-24  3:20 fabbione
2007-08-17  7:51 pcaulfield
2007-08-03 10:49 pcaulfield
2007-08-03  7:35 pcaulfield
2007-05-23 10:31 pcaulfield
2007-03-15 11:12 pcaulfield
2007-01-02 15:17 pcaulfield
2007-01-02 15:04 pcaulfield
2006-12-15 15:17 pcaulfield
2006-12-15 13:43 pcaulfield
2006-11-30 10:47 pcaulfield
2006-11-30 10:46 pcaulfield
2006-07-03  8:51 pcaulfield

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.