@@ -, +, @@ logfile issues --- installer/install.pl | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) --- a/installer/install.pl +++ a/installer/install.pl @@ -323,12 +323,9 @@ elsif ( $step && $step == 3 ) { my $now = POSIX::strftime( "%Y-%m-%dT%H:%M:%S", localtime() ); my $logdir = C4::Context->config('logdir'); - unless ( -w $logdir ) { - $logdir = tempdir; - } - my ( $logfilepath, $logfilepath_errors ) = ( $logdir . "/updatedatabase_$now.log", $logdir . "/updatedatabase-error_$now.log" ); + my ( $logfilepath, $logfilepath_errors ) = ( chk_log($logdir, "updatedatabase_$now"), chk_log($logdir, "updatedatabase-error_$now") ); - my $cmd = C4::Context->config("intranetdir") . "/installer/data/$info{dbms}/updatedatabase.pl > $logfilepath 2> $logfilepath_errors"; + my $cmd = C4::Context->config("intranetdir") . "/installer/data/$info{dbms}/updatedatabase.pl >> $logfilepath 2>> $logfilepath_errors"; system($cmd ); @@ -423,3 +420,17 @@ else { } } output_html_with_http_headers $query, $cookie, $template->output; + +sub chk_log { #returns a logfile in $dir or - if that failed - in temp dir + my ($dir, $name) = @_; + $name.= '_XXXX'; + my ($fh, $fn)= eval { + File::Temp::tempfile($name, DIR => $dir, SUFFIX => '.log' ) + }; + if(!$fn) { + ($fh, $fn)= File::Temp::tempfile( $name, TMPDIR => 1, SUFFIX => '.log'); + #if this should not work, let croak take over + } + close $fh if $fh; + return $fn; +} --