cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] cluster/rgmanager/src/daemons resrules.c
@ 2006-08-31 12:00 mgrac
  0 siblings, 0 replies; 8+ messages in thread
From: mgrac @ 2006-08-31 12:00 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	mgrac at sourceware.org	2006-08-31 12:00:14

Modified files:
	rgmanager/src/daemons: resrules.c 

Log message:
	Fix #203720. Do not run backup copies (ends with ~) of resource agents.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/resrules.c.diff?cvsroot=cluster&r1=1.13&r2=1.14

--- cluster/rgmanager/src/daemons/resrules.c	2006/07/19 18:43:32	1.13
+++ cluster/rgmanager/src/daemons/resrules.c	2006/08/31 12:00:13	1.14
@@ -22,6 +22,7 @@
 #include <ccs.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include <string.h>
 #include <resgroup.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -954,6 +955,10 @@
 		fn = basename(de->d_name);
 		if (!fn)
 			continue;
+		
+		if ((fn != NULL) && (strlen(fn) > 0) && 
+			(fn[strlen(fn)-1] == '~')) 
+			continue;
 
 		snprintf(path, sizeof(path), "%s/%s",
 			 rpath, de->d_name);



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

* [Cluster-devel] cluster/rgmanager/src/daemons resrules.c
@ 2006-10-20 20:29 lhh
  0 siblings, 0 replies; 8+ messages in thread
From: lhh @ 2006-10-20 20:29 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	lhh at sourceware.org	2006-10-20 20:29:16

Modified files:
	rgmanager/src/daemons: resrules.c 

Log message:
	Compatibility fix for resource agents between linux-cluster and linux-ha

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/resrules.c.diff?cvsroot=cluster&r1=1.14&r2=1.15

--- cluster/rgmanager/src/daemons/resrules.c	2006/08/31 12:00:13	1.14
+++ cluster/rgmanager/src/daemons/resrules.c	2006/10/20 20:29:16	1.15
@@ -394,6 +394,48 @@
 
 
 /**
+  Take the first unique + required attr and call it the 'primary' attr
+  for rgmanager.  If there's no primary, index 0 becomes the primary attr.
+ */
+int
+choose_primary(resource_attr_t *attrs)
+{
+	int x = 0, primary = 0;
+	int flags;
+	char *name, *val;
+
+	if (!attrs)
+		return 0;
+
+	for (x = 0; attrs[x].ra_name; x++) {
+
+		if ((attrs[x].ra_flags & (RA_UNIQUE | RA_REQUIRED)) == 
+		    (RA_UNIQUE | RA_REQUIRED)) {
+			primary = x;
+			break;
+		}
+	}
+
+	if (primary != 0) {
+		flags = attrs[primary].ra_flags | RA_PRIMARY;
+		name = attrs[primary].ra_name;
+		val = attrs[primary].ra_value;
+
+		attrs[primary].ra_flags = attrs[0].ra_flags;
+		attrs[primary].ra_name = attrs[0].ra_name;
+		attrs[primary].ra_value = attrs[0].ra_value;
+
+		attrs[0].ra_flags = flags;
+		attrs[0].ra_name = name;
+		attrs[0].ra_value = val;
+	} else {
+		attrs[0].ra_flags |= RA_PRIMARY;
+	}
+
+	return 0;
+}
+
+/**
    Store a child type in the child array of a resource rule.
    XXX Could be rewritten to use list macros.
 
@@ -662,6 +704,9 @@
 			store_attribute(&rr->rr_attrs, attrname, ret, flags);
 	}
 
+	if (!primary_found)
+		choose_primary(rr->rr_attrs);
+
 	return 0;
 }
 



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

* [Cluster-devel] cluster/rgmanager/src/daemons resrules.c
@ 2006-10-20 20:29 lhh
  0 siblings, 0 replies; 8+ messages in thread
From: lhh @ 2006-10-20 20:29 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL4
Changes by:	lhh at sourceware.org	2006-10-20 20:29:40

Modified files:
	rgmanager/src/daemons: resrules.c 

Log message:
	Compatibility fix for resource agents between linux-cluster and linux-ha

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/resrules.c.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.9.2.2&r2=1.9.2.3

--- cluster/rgmanager/src/daemons/resrules.c	2005/03/21 22:01:30	1.9.2.2
+++ cluster/rgmanager/src/daemons/resrules.c	2006/10/20 20:29:39	1.9.2.3
@@ -19,10 +19,10 @@
 #include <libxml/parser.h>
 #include <libxml/xmlmemory.h>
 #include <libxml/xpath.h>
-#include <magma.h>
 #include <ccs.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include <string.h>
 #include <resgroup.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -53,12 +53,6 @@
 				newrule->rr_type);
 			return -1;
 		}
-		if (newrule->rr_root && curr->rr_root) {
-			fprintf(stderr, "Error storing %s: root "
-				"resource type %s exists already\n",
-				newrule->rr_type, curr->rr_type);
-			return -1;
-		}
 
 	} while (!list_done(rulelist, curr));
 			
@@ -186,30 +180,6 @@
 }
 
 
-/**
-   Get and store the root attribute.
-
-   @param doc		Pre-parsed XML document pointer.
-   @param ctx		Pre-allocated XML XPath context pointer.
-   @param base		XPath prefix to search
-   @param rr		Resource rule to store new information in.
- */
-void
-_get_root(xmlDocPtr doc, xmlXPathContextPtr ctx, char *base,
-	  resource_rule_t *rr)
-{
-	char xpath[256];
-	char *ret = NULL;
-
-	snprintf(xpath, sizeof(xpath), "%s/attributes/@root", base);
-	ret = xpath_get_one(doc, ctx, xpath);
-	if (ret) {
-		rr->rr_root = 1;
-		free(ret);
-	}
-}
-
-
 int
 expand_time(char *val)
 {
@@ -356,8 +326,6 @@
 			free(act);
 		
 	} while (1);
-
-
 }
 
 
@@ -426,6 +394,48 @@
 
 
 /**
+  Take the first unique + required attr and call it the 'primary' attr
+  for rgmanager.  If there's no primary, index 0 becomes the primary attr.
+ */
+int
+choose_primary(resource_attr_t *attrs)
+{
+	int x = 0, primary = 0;
+	int flags;
+	char *name, *val;
+
+	if (!attrs)
+		return 0;
+
+	for (x = 0; attrs[x].ra_name; x++) {
+
+		if ((attrs[x].ra_flags & (RA_UNIQUE | RA_REQUIRED)) == 
+		    (RA_UNIQUE | RA_REQUIRED)) {
+			primary = x;
+			break;
+		}
+	}
+
+	if (primary != 0) {
+		flags = attrs[primary].ra_flags | RA_PRIMARY;
+		name = attrs[primary].ra_name;
+		val = attrs[primary].ra_value;
+
+		attrs[primary].ra_flags = attrs[0].ra_flags;
+		attrs[primary].ra_name = attrs[0].ra_name;
+		attrs[primary].ra_value = attrs[0].ra_value;
+
+		attrs[0].ra_flags = flags;
+		attrs[0].ra_name = name;
+		attrs[0].ra_value = val;
+	} else {
+		attrs[0].ra_flags |= RA_PRIMARY;
+	}
+
+	return 0;
+}
+
+/**
    Store a child type in the child array of a resource rule.
    XXX Could be rewritten to use list macros.
 
@@ -487,10 +497,7 @@
 {
 	int x;
 
-	printf("Resource Rules for \"%s\"", rr->rr_type);
-	if (rr->rr_root)
-		printf(" [ROOT]");
-	printf("\n");
+	printf("Resource Rules for \"%s\"\n", rr->rr_type);
 
 	if (rr->rr_version)
 		printf("OCF API Version: %s\n", rr->rr_version);
@@ -551,7 +558,7 @@
 
 
 children:
-	printf("Recognized child resource types:\n");
+	printf("Explicitly defined child resource types:\n");
 	if (!rr->rr_childtypes) {
 		printf("  - None -\n\n");
 		return;
@@ -697,6 +704,9 @@
 			store_attribute(&rr->rr_attrs, attrname, ret, flags);
 	}
 
+	if (!primary_found)
+		choose_primary(rr->rr_attrs);
+
 	return 0;
 }
 
@@ -918,12 +928,11 @@
 		snprintf(base, sizeof(base),
 			 "/resource-agent[%d]/special[@tag=\"rgmanager\"]",
 			 ruleid);
-		_get_root(doc, ctx, base, rr);
 		_get_maxparents(doc, ctx, base, rr);
 		rr->rr_agent = strdup(filename);
 
 		/*
-		   Second, add the allowable-children fields
+		   Second, add the children fields
 		 */
 		_get_childtypes(doc, ctx, base, rr);
 
@@ -991,6 +1000,10 @@
 		fn = basename(de->d_name);
 		if (!fn)
 			continue;
+		
+		if ((fn != NULL) && (strlen(fn) > 0) && 
+			(fn[strlen(fn)-1] == '~')) 
+			continue;
 
 		snprintf(path, sizeof(path), "%s/%s",
 			 rpath, de->d_name);



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

* [Cluster-devel] cluster/rgmanager/src/daemons resrules.c
@ 2006-10-20 20:57 lhh
  0 siblings, 0 replies; 8+ messages in thread
From: lhh @ 2006-10-20 20:57 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL4
Changes by:	lhh at sourceware.org	2006-10-20 20:57:19

Modified files:
	rgmanager/src/daemons: resrules.c 

Log message:
	Correct incorrectly applied patch to fix compatibility issue

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/resrules.c.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.9.2.3&r2=1.9.2.4

--- cluster/rgmanager/src/daemons/resrules.c	2006/10/20 20:29:39	1.9.2.3
+++ cluster/rgmanager/src/daemons/resrules.c	2006/10/20 20:57:19	1.9.2.4
@@ -19,10 +19,10 @@
 #include <libxml/parser.h>
 #include <libxml/xmlmemory.h>
 #include <libxml/xpath.h>
+#include <magma.h>
 #include <ccs.h>
 #include <stdlib.h>
 #include <stdio.h>
-#include <string.h>
 #include <resgroup.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -53,6 +53,12 @@
 				newrule->rr_type);
 			return -1;
 		}
+		if (newrule->rr_root && curr->rr_root) {
+			fprintf(stderr, "Error storing %s: root "
+				"resource type %s exists already\n",
+				newrule->rr_type, curr->rr_type);
+			return -1;
+		}
 
 	} while (!list_done(rulelist, curr));
 			
@@ -180,6 +186,30 @@
 }
 
 
+/**
+   Get and store the root attribute.
+
+   @param doc		Pre-parsed XML document pointer.
+   @param ctx		Pre-allocated XML XPath context pointer.
+   @param base		XPath prefix to search
+   @param rr		Resource rule to store new information in.
+ */
+void
+_get_root(xmlDocPtr doc, xmlXPathContextPtr ctx, char *base,
+	  resource_rule_t *rr)
+{
+	char xpath[256];
+	char *ret = NULL;
+
+	snprintf(xpath, sizeof(xpath), "%s/attributes/@root", base);
+	ret = xpath_get_one(doc, ctx, xpath);
+	if (ret) {
+		rr->rr_root = 1;
+		free(ret);
+	}
+}
+
+
 int
 expand_time(char *val)
 {
@@ -326,6 +356,8 @@
 			free(act);
 		
 	} while (1);
+
+
 }
 
 
@@ -497,7 +529,10 @@
 {
 	int x;
 
-	printf("Resource Rules for \"%s\"\n", rr->rr_type);
+	printf("Resource Rules for \"%s\"", rr->rr_type);
+	if (rr->rr_root)
+		printf(" [ROOT]");
+	printf("\n");
 
 	if (rr->rr_version)
 		printf("OCF API Version: %s\n", rr->rr_version);
@@ -928,11 +963,12 @@
 		snprintf(base, sizeof(base),
 			 "/resource-agent[%d]/special[@tag=\"rgmanager\"]",
 			 ruleid);
+		_get_root(doc, ctx, base, rr);
 		_get_maxparents(doc, ctx, base, rr);
 		rr->rr_agent = strdup(filename);
 
 		/*
-		   Second, add the children fields
+		   Second, add the allowable-children fields
 		 */
 		_get_childtypes(doc, ctx, base, rr);
 



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

* [Cluster-devel] cluster/rgmanager/src/daemons resrules.c
@ 2006-10-20 20:59 lhh
  0 siblings, 0 replies; 8+ messages in thread
From: lhh @ 2006-10-20 20:59 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	lhh at sourceware.org	2006-10-20 20:59:49

Modified files:
	rgmanager/src/daemons: resrules.c 

Log message:
	Roll back patch to resrules.c

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/resrules.c.diff?cvsroot=cluster&r1=1.15&r2=1.16

--- cluster/rgmanager/src/daemons/resrules.c	2006/10/20 20:29:16	1.15
+++ cluster/rgmanager/src/daemons/resrules.c	2006/10/20 20:59:49	1.16
@@ -394,48 +394,6 @@
 
 
 /**
-  Take the first unique + required attr and call it the 'primary' attr
-  for rgmanager.  If there's no primary, index 0 becomes the primary attr.
- */
-int
-choose_primary(resource_attr_t *attrs)
-{
-	int x = 0, primary = 0;
-	int flags;
-	char *name, *val;
-
-	if (!attrs)
-		return 0;
-
-	for (x = 0; attrs[x].ra_name; x++) {
-
-		if ((attrs[x].ra_flags & (RA_UNIQUE | RA_REQUIRED)) == 
-		    (RA_UNIQUE | RA_REQUIRED)) {
-			primary = x;
-			break;
-		}
-	}
-
-	if (primary != 0) {
-		flags = attrs[primary].ra_flags | RA_PRIMARY;
-		name = attrs[primary].ra_name;
-		val = attrs[primary].ra_value;
-
-		attrs[primary].ra_flags = attrs[0].ra_flags;
-		attrs[primary].ra_name = attrs[0].ra_name;
-		attrs[primary].ra_value = attrs[0].ra_value;
-
-		attrs[0].ra_flags = flags;
-		attrs[0].ra_name = name;
-		attrs[0].ra_value = val;
-	} else {
-		attrs[0].ra_flags |= RA_PRIMARY;
-	}
-
-	return 0;
-}
-
-/**
    Store a child type in the child array of a resource rule.
    XXX Could be rewritten to use list macros.
 
@@ -704,9 +662,6 @@
 			store_attribute(&rr->rr_attrs, attrname, ret, flags);
 	}
 
-	if (!primary_found)
-		choose_primary(rr->rr_attrs);
-
 	return 0;
 }
 



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

* [Cluster-devel] cluster/rgmanager/src/daemons resrules.c
@ 2007-05-31 18:37 lhh
  0 siblings, 0 replies; 8+ messages in thread
From: lhh @ 2007-05-31 18:37 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL5
Changes by:	lhh at sourceware.org	2007-05-31 18:37:50

Modified files:
	rgmanager/src/daemons: resrules.c 

Log message:
	Resolves: #234249

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/resrules.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.16.2.3&r2=1.16.2.4

--- cluster/rgmanager/src/daemons/resrules.c	2007/05/10 16:23:43	1.16.2.3
+++ cluster/rgmanager/src/daemons/resrules.c	2007/05/31 18:37:50	1.16.2.4
@@ -1010,8 +1010,9 @@
 {
 	DIR *dir;
 	struct dirent *de;
-	char *fn;//, *dot;
+	char *fn, *dot;
 	char path[2048];
+	struct stat st_buf;
 
 	dir = opendir(rpath);
 	if (!dir)
@@ -1024,14 +1025,40 @@
 		if (!fn)
 			continue;
 		
+		/* Ignore files with common backup extension */
 		if ((fn != NULL) && (strlen(fn) > 0) && 
 			(fn[strlen(fn)-1] == '~')) 
 			continue;
 
+		/* Ignore hidden files */
+		if (*fn == '.')
+			continue;
+
+		dot = strrchr(fn, '.');
+		if (dot) {
+			/* Ignore RPM installed save files, patches,
+			   diffs, etc. */
+			if (!strncasecmp(dot, ".rpm", 4)) {
+				fprintf(stderr, "Warning: "
+					"Ignoring %s/%s: Bad extension %s\n",
+					rpath, de->d_name, dot);
+				continue;
+			}
+		}
+
 		snprintf(path, sizeof(path), "%s/%s",
 			 rpath, de->d_name);
 
-		load_resource_rulefile(path, rules);
+		if (stat(path, &st_buf) < 0)
+			continue;
+
+		if (S_ISDIR(st_buf.st_mode))
+			continue;
+
+ 		if (st_buf.st_mode & (S_IXUSR|S_IXOTH|S_IXGRP)) {
+ 			printf("Loading resource rule from %s\n", path);
+  			load_resource_rulefile(path, rules);
+ 		}
 	}
 	xmlCleanupParser();
 



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

* [Cluster-devel] cluster/rgmanager/src/daemons resrules.c
@ 2008-01-30 20:00 lhh
  0 siblings, 0 replies; 8+ messages in thread
From: lhh @ 2008-01-30 20:00 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	lhh at sourceware.org	2008-01-30 20:00:15

Modified files:
	rgmanager/src/daemons: resrules.c 

Log message:
	Fix short read handling in read_pipe

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/resrules.c.diff?cvsroot=cluster&r1=1.24&r2=1.25

--- cluster/rgmanager/src/daemons/resrules.c	2007/11/30 20:36:17	1.24
+++ cluster/rgmanager/src/daemons/resrules.c	2008/01/30 20:00:14	1.25
@@ -919,7 +919,7 @@
 		if (n == 0 && (!*length))
 			return 0;
 
-		if (n != sizeof(buf)) {
+		if (n == 0) {
 			done = 1;
 		}
 



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

* [Cluster-devel] cluster/rgmanager/src/daemons resrules.c
@ 2008-01-30 20:00 lhh
  0 siblings, 0 replies; 8+ messages in thread
From: lhh @ 2008-01-30 20:00 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL5
Changes by:	lhh at sourceware.org	2008-01-30 20:00:26

Modified files:
	rgmanager/src/daemons: resrules.c 

Log message:
	Fix short read handling in read_pipe

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/resrules.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.16.2.9&r2=1.16.2.10

--- cluster/rgmanager/src/daemons/resrules.c	2007/12/18 17:52:56	1.16.2.9
+++ cluster/rgmanager/src/daemons/resrules.c	2008/01/30 20:00:26	1.16.2.10
@@ -906,7 +906,7 @@
 		if (n == 0 && (!*length))
 			return 0;
 
-		if (n != sizeof(buf)) {
+		if (n == 0) {
 			done = 1;
 		}
 



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

end of thread, other threads:[~2008-01-30 20:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-31 12:00 [Cluster-devel] cluster/rgmanager/src/daemons resrules.c mgrac
  -- strict thread matches above, loose matches on Subject: below --
2006-10-20 20:29 lhh
2006-10-20 20:29 lhh
2006-10-20 20:57 lhh
2006-10-20 20:59 lhh
2007-05-31 18:37 lhh
2008-01-30 20:00 lhh
2008-01-30 20:00 lhh

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 NNTP newsgroup(s).