[Rt-commit] r6363 - in rt/branches/3.6-RELEASE: .

falcone at bestpractical.com falcone at bestpractical.com
Mon Nov 6 14:09:33 EST 2006


Author: falcone
Date: Mon Nov  6 14:09:32 2006
New Revision: 6363

Modified:
   rt/branches/3.6-RELEASE/   (props changed)
   rt/branches/3.6-RELEASE/lib/RT.pm.in

Log:
 r14256 at ketch:  falcone | 2006-11-06 14:08:54 -0500
 Make LoadConfig a lot more vocal about why it can't read your config files
 and offer some hints and warnings about fixing it


Modified: rt/branches/3.6-RELEASE/lib/RT.pm.in
==============================================================================
--- rt/branches/3.6-RELEASE/lib/RT.pm.in	(original)
+++ rt/branches/3.6-RELEASE/lib/RT.pm.in	Mon Nov  6 14:09:32 2006
@@ -127,13 +127,36 @@
 
 sub LoadConfig {
      local *Set = sub { $_[0] = $_[1] unless defined $_[0] }; 
+
+    my $username = getpwuid($>);
+    my $group = getgrgid($();
+    my $message = qq{Couldn't load RT config file %s as user $username / group $group.
+The file is owned by user %s and group %s.
+This usually means that the user/group your webserver is running as cannot read the file.
+Be careful not to make the permissions on this file too liberal, because it contains database
+passwords.  You may need to put the webserver user in the appropriate group (%s) or change
+permissions be able to run succesfully};
+
     if ( -f "$SITE_CONFIG_FILE" ) {
-        require $SITE_CONFIG_FILE
-          || die ("Couldn't load RT config file  '$SITE_CONFIG_FILE'\n$@");
+        eval { require $SITE_CONFIG_FILE };
+        if ($@) {
+            my ($fileuid,$filegid) = (stat($SITE_CONFIG_FILE))[4,5];
+            my $fileusername = getpwuid($fileuid);
+            my $filegroup = getgrgid($filegid);
+            my $errormessage = sprintf($message, $SITE_CONFIG_FILE,
+                                       $fileusername, $filegroup, $filegroup);
+            die ("$errormessage\n$@");
+        }
+    }
+    eval { require $CORE_CONFIG_FILE };
+    if ($@) {
+        my ($fileuid,$filegid) = (stat($SITE_CONFIG_FILE))[4,5];
+        my $fileusername = getpwuid($fileuid);
+        my $filegroup = getgrgid($filegid);
+        my $errormessage = sprintf($message, $SITE_CONFIG_FILE,
+                                   $fileusername, $filegroup, $filegroup);
+        die ("$message '$CORE_CONFIG_FILE'\n$@") 
     }
-    require $CORE_CONFIG_FILE
-      || die ("Couldn't load RT config file '$CORE_CONFIG_FILE'\n$@");
-
 
     # RT::Essentials mistakenly recommends that WebPath be set to '/'.
     # If the user does that, do what they mean.


More information about the Rt-commit mailing list