packages: cacti-plugin-rrdclean/cacti-plugin-rrdclean.spec, cacti-plugin-rr...

glen glen at pld-linux.org
Tue Dec 14 09:35:10 CET 2010


Author: glen                         Date: Tue Dec 14 08:35:10 2010 GMT
Module: packages                      Tag: HEAD
---- Log message:
- fix rrdmove, it was totally broken, i.e created only parent dir of parent dir of target rrd, so simplify and make rrdclean_create_path work on dir

---- Files affected:
packages/cacti-plugin-rrdclean:
   cacti-plugin-rrdclean.spec (1.11 -> 1.12) , rrdmove-fixes.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: packages/cacti-plugin-rrdclean/cacti-plugin-rrdclean.spec
diff -u packages/cacti-plugin-rrdclean/cacti-plugin-rrdclean.spec:1.11 packages/cacti-plugin-rrdclean/cacti-plugin-rrdclean.spec:1.12
--- packages/cacti-plugin-rrdclean/cacti-plugin-rrdclean.spec:1.11	Tue Dec 14 08:41:56 2010
+++ packages/cacti-plugin-rrdclean/cacti-plugin-rrdclean.spec	Tue Dec 14 09:35:05 2010
@@ -3,7 +3,7 @@
 Summary:	Cacti RRD File Cleaner
 Name:		cacti-plugin-%{plugin}
 Version:	0.40
-Release:	0.5
+Release:	0.7
 License:	GPL v2
 Group:		Applications/WWW
 Source0:	http://docs.cacti.net/_media/plugin:rrdclean-v%{version}.tgz
@@ -11,6 +11,7 @@
 Patch0:		paths.patch
 Patch1:		fix-paths-handling.patch
 Patch2:		warning-fixes.patch
+Patch3:		rrdmove-fixes.patch
 URL:		http://docs.cacti.net/plugin:rrdclean
 Requires:	cacti >= 0.8.6j
 Requires:	php-common >= 3:4.3.0
@@ -32,6 +33,7 @@
 %patch0 -p1
 %patch1 -p1
 %patch2 -p1
+%patch3 -p1
 
 %install
 rm -rf $RPM_BUILD_ROOT
@@ -55,6 +57,9 @@
 All persons listed below can be reached at <cvs_login>@pld-linux.org
 
 $Log$
+Revision 1.12  2010/12/14 08:35:05  glen
+- fix rrdmove, it was totally broken, i.e created only parent dir of parent dir of target rrd, so simplify and make rrdclean_create_path work on dir
+
 Revision 1.11  2010/12/14 07:41:56  glen
 - use string not undefined constant
 

================================================================
Index: packages/cacti-plugin-rrdclean/rrdmove-fixes.patch
diff -u /dev/null packages/cacti-plugin-rrdclean/rrdmove-fixes.patch:1.1
--- /dev/null	Tue Dec 14 09:35:10 2010
+++ packages/cacti-plugin-rrdclean/rrdmove-fixes.patch	Tue Dec 14 09:35:05 2010
@@ -0,0 +1,81 @@
+--- cacti-plugin-rrdclean-0.40/rrdmove.php~	2010-12-14 10:10:59.431054842 +0200
++++ cacti-plugin-rrdclean-0.40/rrdmove.php	2010-12-14 10:32:23.984260340 +0200
+@@ -137,31 +137,36 @@
+ 
+ 	/* now scan the files */
+ 	foreach ($file_array as $file) {
++		$source_file = $rra_path . "/" . $file["name"];
+ 		switch ($file['action']) {
+ 		case "1" :
+-			if (unlink($rra_path . "/" . $file["name"])) {
++			if (unlink($source_file)) {
+ 				cacti_log("Deleted: " . $file["name"], true, "RRDCLEAN");
+ 			} else {
+ 				cacti_log($file["name"] . " Error: unable to delete from $rra_path!", true, "RRDCLEAN");
+ 			}
+ 			break;
+ 		case "2" :
+-			if (!is_dir(dirname($rrd_backup . "/" . $file["name"]))) {
+-				rrdclean_create_path(dirname($rrd_backup . "/" . $file["name"]));
++			$target_file = $rrd_backup . "/" . $file["name"];
++			$target_dir = dirname($target_file);
++			if (!is_dir($target_dir)) {
++				rrdclean_create_path($target_dir);
+ 			}
+ 
+-			if (copy($rra_path . "/" . $file["name"], $rrd_backup . "/" . $file["name"])) {
++			if (copy($source_file, $target_file)) {
+ 				cacti_log("Copied: " . $file["name"] . " to: " . $rrd_backup, true, "RRDCLEAN");
+ 			} else {
+ 				cacti_log($file["name"] . " Error: unable to save to $rrd_backup!", true, "RRDCLEAN");
+ 			}
+ 			break;
+ 		case "3" :
+-			if (!is_dir(dirname($rrd_archive . "/" . $file["name"]))) {
+-				rrdclean_create_path(dirname($rrd_archive . "/" . $file["name"]));
++			$target_file = $rrd_archive . "/" . $file["name"];
++			$target_dir = dirname($target_file);
++			if (!is_dir($target_dir)) {
++				rrdclean_create_path($target_dir);
+ 			}
+ 
+-			if (rename($rra_path . "/" . $file["name"], $rrd_archive . "/" . $file["name"])) {
++			if (rename($source_file, $target_file)) {
+ 				cacti_log("Moved: " . $file["name"] . " to: " . $rrd_archive, true, "RRDCLEAN");
+ 			} else {
+ 				cacti_log($file["name"] . " Error: unable to move to $rrd_archive!", true, "RRDCLEAN");
+@@ -224,25 +229,24 @@
+ function rrdclean_create_path($path) {
+ 	global $config;
+ 
+-	if (!is_dir(dirname($path))) {
+-		if (mkdir(dirname($path), 0775)) {
++	if (!is_dir($path)) {
++		if (mkdir($path, 0775)) {
+ 			if ($config["cacti_server_os"] != "win32") {
+ 				$owner_id      = fileowner($config["rra_path"]);
+ 				$group_id      = filegroup($config["rra_path"]);
+ 
+-				if ((chown(dirname($path), $owner_id)) &&
+-					(chgrp(dirname($path), $group_id))) {
+-					return TRUE;
+-				}else{
+-					cacti_log("ERROR: Unable to set directory permissions for '" . dirname($path) . "'", FALSE);
+-				}
++				// NOTE: chown/chgrp fails for non-root users, checking their
++				// result is therefore irrevelevant
++				@chown($path, $owner_id);
++				@chgrp($path, $group_id);
+ 			}
+ 		}else{
+-			cacti_log("ERROR: Unable to create directory '" . dirname($path) . "'", FALSE);
++			cacti_log("ERROR: Unable to create directory '" . $path . "'", FALSE);
+ 		}
+ 	}
+ 
+-	return FALSE;
++	// if path existed, we can return true
++	return is_dir($path) && is_writable($path);
+ }
+ 
+ /*
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/cacti-plugin-rrdclean/cacti-plugin-rrdclean.spec?r1=1.11&r2=1.12&f=u



More information about the pld-cvs-commit mailing list