diff --git a/logrotate/CHANGELOG b/logrotate/CHANGELOG index 8ef4d7652..aea8b05e7 100644 --- a/logrotate/CHANGELOG +++ b/logrotate/CHANGELOG @@ -5,3 +5,5 @@ Added a button on the Edit Log File page for forcing the immediate rotation of j Added a Module Config option for specifying a file to add new logrotate sections to. ---- Changes since 1.270 ---- Added checkboxes and a button for deleting multiple logs at once. +---- Changes since 1.620 ---- +The module config option for the new file to add logrotate sections to can now be a directory, like /etc/logrotate.d diff --git a/logrotate/logrotate-lib.pl b/logrotate/logrotate-lib.pl index cb394839c..5bf3b8d2c 100755 --- a/logrotate/logrotate-lib.pl +++ b/logrotate/logrotate-lib.pl @@ -349,11 +349,16 @@ local $out = &backquote_logged("$config{'logrotate'} -f $temp 2>&1"); return ($?, $out); } -# get_add_file() +# get_add_file([filename]) # Returns the file to which new logrotate sections should be added sub get_add_file { -if ($config{'add_file'}) { +local ($filename) = @_; +if ($config{'add_file'} && -d $config{'add_file'} && $filename) { + # Adding to a new file in a directory + return "$config{'add_file'}/$filename.conf"; + } +elsif ($config{'add_file'} && !-d $config{'add_file'}) { # Make sure file is valid local ($conf, $lnum, $files) = &get_config(); if (&indexof($config{'add_file'}, @$files) >= 0) { diff --git a/logrotate/save_log.cgi b/logrotate/save_log.cgi index afa514367..3acfd71b3 100755 --- a/logrotate/save_log.cgi +++ b/logrotate/save_log.cgi @@ -6,14 +6,16 @@ require './logrotate-lib.pl'; &ReadParse(); $parent = &get_config_parent(); $conf = $parent->{'members'}; +@files = split(/\s+/, $in{'file'}); if ($in{'global'}) { # Editing the global options $log = $parent; } elsif ($in{'new'}) { # Adding a new section + $cfilename = $files[0] =~ /\/([^\/]+)$/ ? $1 : undef; $log = { 'members' => [ ], - 'file' => &get_add_file() }; + 'file' => &get_add_file($cfilename) }; $logfile = $in{'file'}; } else { @@ -50,7 +52,6 @@ else { &lock_file($log->{'file'}); &error_setup($text{'save_err'}); if (!$in{'global'}) { - @files = split(/\s+/, $in{'file'}); foreach $f (@files) { $f =~ /^\/\S+$/ || &error($text{'save_efile'}); }