Uninformative 'Permission denied' in log & mail

Today I faced problem with mail delivery into RT:
[Thu Nov 29 19:39:14 2007] [debug]: Found a ticket ID. It’s 105503 (/usr/local/rt3/lib/RT/Interface/Email.pm:477)
[Thu Nov 29 19:39:14 2007] [debug]: SpamHeader: Accepting non-spam message. From: was bla-bla. (/usr/local/rt3/lib/RT/Interface/Email/Filter/SpamHeader.pm:78)
[Thu Nov 29 19:39:14 2007] [crit]: Permission Denied (/usr/local/rt3/lib/RT/Interface/Email.pm:243)
[Thu Nov 29 19:39:14 2007] [error]: Could not record email: Message not recorded: Permission Denied (/usr/local/rt3/share/html/REST/1.0/NoAuth/mail-gateway:75)

E-mail returned message was not informative too.

So I created patch, adding some kind of debug, i.e.:

diff -aur RT.old/ACE_Overlay.pm RT/ACE_Overlay.pm
— RT.old/ACE_Overlay.pm Thu May 17 07:11:33 2007
+++ RT/ACE_Overlay.pm Fri Nov 30 17:28:06 2007
@@ -250,13 +250,13 @@
unless ( $self->CurrentUser->HasRight( Object => $args{‘Object’},
Right => ‘AdminGroup’ )
) {

  •        return ( 0, $self->loc('Permission Denied') );
    
  •        return ( 0, __FILE__.'('.__LINE__.'): '.$self->loc('Permission Denied') );
       }
    
    }

    patch is very simple:
    #!/bin/sh
    cd /rt/lib
    grep -lR ‘Permission Denied’ ./| xargs sed -i.bakpd -E “s,([$]self->loc([’”]Permission Denied[’"])),FILE.’(’.LINE.’): '.\1,"
    grep -lR ‘LINE’ ./ |while read tt; do perl -c $tt; done
    find ./ -name *.backpd -delete

It’s just a crutch, and right variant is to supply human-readable reasons.
(In my case it was: “You have no right to reply to this ticket” (/usr/local/rt3/lib/RT/Ticket_Overlay.pm, 2348)

Boris Lytochkin,
JSC e-port, Moscow