Tags:
create new tag
, view all tags

Bug: Log and Warning File Permissions give a bad error message

When TWiki can't write to log or warning files, the only error message is "print to closed file handle" in the apache log.

This is bad for a new admin trying to install TWiki: they need helpful messages for likely problems at this critical time for them.

Test case

chmod a log file and visit a wiki page. Look in the apache log.

Environment

TWiki version: TWikiBetaRelease2004x03x20
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS: RH 9.0
Web server: Apache 2.047
Perl version:  
Client OS:  
Web Browser:  

-- MartinGregory - 04 Jul 2004

Follow up

Fix record

Here are a couple of patches to rectify this situation:


*** Store.pm.orig       2004-06-27 17:47:56.000000000 +1000
--- Store.pm    2004-07-04 15:44:40.000000000 +1000
***************
*** 958,964 ****

      my $filename = $TWiki::logFilename;
      $filename =~ s/%DATE%/$yearmonth/go;
!     open( FILE, ">>$filename");
      print FILE "$text\n";
      close( FILE);
  }
--- 958,964 ----

      my $filename = $TWiki::logFilename;
      $filename =~ s/%DATE%/$yearmonth/go;
!     open( FILE, ">>$filename") or print STDERR "Couldn't write \"$text\" to $filename: $!\n";
      print FILE "$text\n";
      close( FILE);
  }


*** TWiki.pm.old        2004-07-04 15:32:03.000000000 +1000
--- TWiki.pm    2004-07-04 15:44:57.000000000 +1000
***************
*** 248,254 ****
          $year = sprintf( "%.4u", $year + 1900 );
          my $time = sprintf( "%.2u ${tmon} %.2u - %.2u:%.2u",
                           $mday, $year, $hour, $min );
!         open( FILE, ">>$warningFilename" );
          print FILE "$time $text\n";
          close( FILE );
      }
--- 248,254 ----
          $year = sprintf( "%.4u", $year + 1900 );
          my $time = sprintf( "%.2u ${tmon} %.2u - %.2u:%.2u",
                           $mday, $year, $hour, $min );
!         open( FILE, ">>$warningFilename" ) or print STDERR "Couldn't write \"$text\" to $warningFilename: $!\n";
          print FILE "$time $text\n";
          close( FILE );
      }

I'll commit this soon (unless i find something wrong with it smile )

-- SvenDowideit - 05 Jul 2004

The proposed code does not avoid the "print to closed file handle" issue. Untested fix:

        my $time = sprintf( "%.2u ${tmon} %.2u - %.2u:%.2u",
                            $mday, $year, $hour, $min );
        if( open( FILE, ">>$warningFilename" ) ) {
            print FILE "$time $text\n";
            close( FILE );
        } else {
            print STDERR "Couldn't write \"$text\" to $warningFilename: $!\n";
        }

-- PeterThoeny - 05 Jul 2004

in svn smile

-- SvenDowideit - 06 Jul 2004

Yeah - fair call. I knew that was the case, but thought to myself: who cares?

I suggested the minimal change to explain the situation to the admin.

But you're right, this is tidier, less lazy smile

Martin

-- MartinGregory - 08 Jul 2004

Edit | Attach | Watch | Print version | History: r7 < r6 < r5 < r4 < r3 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r7 - 2004-07-10 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2015 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.