]> git.pld-linux.org Git - packages/cacti-plugin-rrdclean.git/commitdiff
- fix rrdmove, it was totally broken, i.e created only parent dir of parent dir of... cacti-plugin-rrdclean-0_40-0_7
authorElan Ruusamäe <glen@pld-linux.org>
Tue, 14 Dec 2010 08:35:05 +0000 (08:35 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    cacti-plugin-rrdclean.spec -> 1.12
    rrdmove-fixes.patch -> 1.1

cacti-plugin-rrdclean.spec
rrdmove-fixes.patch [new file with mode: 0644]

index ba0cd739db862fb604c997c1da72531581bef6f3..93ce7d5b599de4f6f59881db5805485cffbad726 100644 (file)
@@ -2,7 +2,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
@@ -10,6 +10,7 @@ Source0:      http://docs.cacti.net/_media/plugin:rrdclean-v%{version}.tgz
 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
@@ -31,6 +32,7 @@ mv %{plugin}/* .; rmdir %{plugin}
 %patch0 -p1
 %patch1 -p1
 %patch2 -p1
+%patch3 -p1
 
 %install
 rm -rf $RPM_BUILD_ROOT
diff --git a/rrdmove-fixes.patch b/rrdmove-fixes.patch
new file mode 100644 (file)
index 0000000..cf87b69
--- /dev/null
@@ -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);
+ }
+ /*
This page took 0.093654 seconds and 4 git commands to generate.