Inaccurate error message when the core config file is missing

When the core config file is missing, currently the error message is plain
wrong:

$ perl -Ilib bin/standalone_httpd 8080
Use of uninitialized value in getpwuid at lib/RT.pm line 154.
Use of uninitialized value in getgrgid at lib/RT.pm line 155.
Couldn’t load RT config file %s as user nick / group nick.
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 '/opt/rt3/etc/RT_Config.pm’
Can’t locate /opt/rt3/etc/RT_Config.pm in @INC (@INC contains: /opt/rt3/local/lib /opt/rt3/lib lib /usr/local/lib/perl5/5.8.8/BSDPAN /usr/local/lib/perl5/site_perl/5.8.8/mach /usr/local/lib/perl5/site_perl/5.8.8 /usr/local/lib/perl5/site_perl /usr/local/lib/perl5/5.8.8/mach /usr/local/lib/perl5/5.8.8 .) at lib/RT.pm line 151.
BEGIN failed–compilation aborted at bin/standalone_httpd line 55.

With this patch, at least it’s now only mildly inaccurate:

$ perl -Ilib bin/standalone_httpd 8080
Use of uninitialized value in getpwuid at lib/RT.pm line 165.
Use of uninitialized value in getgrgid at lib/RT.pm line 166.

RT couldn’t load RT config file /opt/rt3/etc/RT_SiteConfig.pm as:
user: nick
group: nick

The file is owned by user root and group wheel.

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
(wheel) or change permissions be able to run successfully.
’/opt/rt3/etc/RT_Config.pm’
Can’t locate /opt/rt3/etc/RT_Config.pm in @INC (@INC contains: /opt/rt3/local/lib /opt/rt3/lib lib /usr/local/lib/perl5/5.8.8/BSDPAN /usr/local/lib/perl5/site_perl/5.8.8/mach /usr/local/lib/perl5/site_perl/5.8.8 /usr/local/lib/perl5/site_perl /usr/local/lib/perl5/5.8.8/mach /usr/local/lib/perl5/5.8.8 .) at lib/RT.pm line 162.
BEGIN failed–compilation aborted at bin/standalone_httpd line 57.

I’m not sure of the best way to implement the message to also cope with
"file is missing". Suggestions?

Nicholas Clark

Index: lib/RT.pm.in
— lib/RT.pm.in (revision 7852)
+++ lib/RT.pm.in (working copy)
@@ -144,7 +144,7 @@
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.
+(%s) or change permissions be able to run successfully.
EOF

@@ -166,7 +166,7 @@
my $filegroup = getgrgid($filegid);
my $errormessage = sprintf($message, $SITE_CONFIG_FILE,
$fileusername, $filegroup, $filegroup);

  •    die ("$message '$CORE_CONFIG_FILE'\n$@") 
    
  •    die ("$errormessage '$CORE_CONFIG_FILE'\n$@") 
    

    }

    RT::Essentials mistakenly recommends that WebPath be set to ‘/’.

When the core config file is missing, currently the error message
is plain
wrong:

With this patch, at least it’s now only mildly inaccurate:

Thanks. Applied.

I’m not sure of the best way to implement the message to also cope
with
"file is missing". Suggestions?

It might make sense just to have a separate check.

Jesse

PGP.sig (186 Bytes)

I’m not sure of the best way to implement the message to also cope
with
"file is missing". Suggestions?

It might make sense just to have a separate check.

Something like this?

[Sorry, looks like my use of tabs is inconsistent with RT’s code policy]

Nicholas Clark

— lib/RT.pm~ Fri May 18 10:50:48 2007
+++ lib/RT.pm Fri May 18 13:23:29 2007
@@ -162,6 +162,12 @@
eval { require $CORE_CONFIG_FILE };
if ($@) {
my ($fileuid,$filegid) = (stat($SITE_CONFIG_FILE))[4,5];

  • if (!defined $fileuid) {
  • die <<"EOF";
    

+RT core config file $CORE_CONFIG_FILE not found.
+RT can’t run without this. Have you installed RT correctly?
+EOF

  • }
    my $fileusername = getpwuid($fileuid);
    my $filegroup = getgrgid($filegid);
    my $errormessage = sprintf($message, $SITE_CONFIG_FILE,

Nick,

Can you shoot this to rt-bugs@bestpractical.com so it gets logged?

Thanks
jesseOn May 18, 2007, at 9:27 AM, Nicholas Clark wrote:

On Mon, May 14, 2007 at 01:03:17PM -0400, Jesse Vincent wrote:

On May 14, 2007, at 10:14 AM, Nicholas Clark wrote:

I’m not sure of the best way to implement the message to also cope
with
“file is missing”. Suggestions?

It might make sense just to have a separate check.

Something like this?

[Sorry, looks like my use of tabs is inconsistent with RT’s code
policy]

Nicholas Clark

— lib/RT.pm~ Fri May 18 10:50:48 2007
+++ lib/RT.pm Fri May 18 13:23:29 2007
@@ -162,6 +162,12 @@
eval { require $CORE_CONFIG_FILE };
if ($@) {
my ($fileuid,$filegid) = (stat($SITE_CONFIG_FILE))[4,5];

  • if (!defined $fileuid) {
  • die <<“EOF”;
    +RT core config file $CORE_CONFIG_FILE not found.
    +RT can’t run without this. Have you installed RT correctly?
    +EOF
  • }
    my $fileusername = getpwuid($fileuid);
    my $filegroup = getgrgid($filegid);
    my $errormessage = sprintf($message, $SITE_CONFIG_FILE,

PGP.sig (186 Bytes)

Nick,

Can you shoot this to rt-bugs@bestpractical.com so it gets logged?

Done as #8386

Nicholas Clark