Skip to contentSkip to conversation

cman: Print an error if cluster name is too long

PATCH New Fabio M. Di Nitto 2 participants 3 messages Aug 5, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 cman: Print an error if cluster name is too long

From: Christine Caulfield <[email protected]>

Print an error and exit cman-preconfig if the cluster name exceeeds 15 characters.

Resolvs: rhbz#728230

---
 cman/daemon/cman-preconfig.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
cman/daemon/cman-preconfig.c +4 -0
index aeedf8b..e435484 100644
@@ -1274,6 +1274,10 @@ static int get_cman_globals(struct objdb_iface_ver0 *objdb)
 	char *use_hash;
 
 	objdb_get_string(objdb, cluster_parent_handle, "name", &cluster_name);
+	if (!cluster_name || strlen(cluster_name) > 15) {
+		    sprintf(error_reason, "%s\n", "Invalid cluster name. It must be 15 characters or fewer\n");
+		return -1;
+	}
 
 	if (!cluster_name) {
 		sprintf(error_reason, "Unable to determine cluster name.\n");
Signature · 1 line
1.7.4.4
#1 lore raw

PATCH 2/2 cman: fix printing of error if clustername is too long

Patch 03e9af7db105 did mask an error and was not propagating the error string in the cman pipe, making it impossible to see the error at startup when it is more important, since clustername cannot be changed at runtime.

Resolves: rhbz#728230

---
 cman/daemon/cman-preconfig.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
cman/daemon/cman-preconfig.c +6 -4
index e435484..070761e 100644
@@ -1274,13 +1274,15 @@ static int get_cman_globals(struct objdb_iface_ver0 *objdb)
 	char *use_hash;
 
 	objdb_get_string(objdb, cluster_parent_handle, "name", &cluster_name);
-	if (!cluster_name || strlen(cluster_name) > 15) {
-		    sprintf(error_reason, "%s\n", "Invalid cluster name. It must be 15 characters or fewer\n");
+	if (!cluster_name) {
+		sprintf(error_reason, "Unable to determine cluster name.\n");
+		write_cman_pipe("Unable to determine cluster name.\n");
 		return -1;
 	}
 
-	if (!cluster_name) {
-		sprintf(error_reason, "Unable to determine cluster name.\n");
+	if (strlen(cluster_name) > 15) {
+		sprintf(error_reason, "%s\n", "Invalid cluster name. It must be 15 characters or fewer\n");
+		write_cman_pipe("Invalid cluster name. It must be 15 characters or fewer\n");
 		return -1;
 	}
 
Signature · 1 line
1.7.4.4
#2 lore raw

PATCH 2/2 cman: fix printing of error if clustername is too long

ACK to both

Chrissie

Quoted 36 lines · Fabio M. Di Nitto

Patch 03e9af7db105 did mask an error and was not propagating the error string in the cman pipe, making it impossible to see the error at startup when it is more important, since clustername cannot be changed at runtime.

Resolves: rhbz#728230

---
  cman/daemon/cman-preconfig.c |   10 ++++++----
  1 files changed, 6 insertions(+), 4 deletions(-)
cman/daemon/cman-preconfig.c +6 -4
index e435484..070761e 100644
@@ -1274,13 +1274,15 @@ static int get_cman_globals(struct objdb_iface_ver0 *objdb)
  	char *use_hash;
 
  	objdb_get_string(objdb, cluster_parent_handle, "name",&cluster_name);
-	if (!cluster_name || strlen(cluster_name)>  15) {
-		    sprintf(error_reason, "%s\n", "Invalid cluster name. It must be 15 characters or fewer\n");
+	if (!cluster_name) {
+		sprintf(error_reason, "Unable to determine cluster name.\n");
+		write_cman_pipe("Unable to determine cluster name.\n");
  		return -1;
  	}
 
-	if (!cluster_name) {
-		sprintf(error_reason, "Unable to determine cluster name.\n");
+	if (strlen(cluster_name)>  15) {
+		sprintf(error_reason, "%s\n", "Invalid cluster name. It must be 15 characters or fewer\n");
+		write_cman_pipe("Invalid cluster name. It must be 15 characters or fewer\n");
  		return -1;
  	}