6 use vars qw($VERSION $SystemUser $Nobody $Handle $Logger);
8 $VERSION = '!!RT_VERSION!!';
16 A fully featured request tracker package
25 #Get a database connection
26 $Handle = new RT::Handle($RT::DatabaseType);
30 #RT's system user is a genuine database user. its id lives here
31 $SystemUser = new RT::CurrentUser();
32 $SystemUser->LoadByName('RT_System');
34 #RT's "nobody user" is a genuine database user. its ID lives here.
35 $Nobody = new RT::CurrentUser();
36 $Nobody->LoadByName('Nobody');
43 Create the RT::Logger object.
48 # We have to set the record seperator ($, man perlvar)
49 # or Log::Dispatch starts getting
50 # really pissy, as some other module we use unsets it.
53 use Log::Dispatch 1.6;
54 use Log::Dispatch::File;
55 use Log::Dispatch::Screen;
57 $Logger=Log::Dispatch->new();
60 my $filename = $RT::LogToFileNamed || "$RT::LogDir/rt.log";
62 $Logger->add(Log::Dispatch::File->new
64 min_level=> $RT::LogToFile,
67 callbacks => sub {my %p=@_; return "[".gmtime(time)."] [".$p{level}."]: $p{message}\n"}
71 if ($RT::LogToScreen) {
72 $Logger->add(Log::Dispatch::Screen->new
74 min_level => $RT::LogToScreen,
80 ## This is the default handling of warnings and die'ings in the code
81 ## (including other used modules - maybe except for errors catched by
82 ## Mason). It will log all problems through the standard logging
83 ## mechanism (see above).
85 $SIG{__WARN__} = sub {$RT::Logger->warning($_[0])};
87 #When we call die, trap it and log->crit with the value of the die.
90 unless ($^S || !defined $^S ) {
91 $RT::Logger->crit("$_[0]");
95 #Get out of here if we're in an eval
116 =head2 DropSetGIDPermissions
118 Drops setgid permissions.
122 sub DropSetGIDPermissions {
123 # Now that we got the config read in, we have the database
124 # password and don't need to be setgid
125 # make the effective group the real group
143 ok (require RT::TestHarness);
145 ok ($RT::Nobody->Name() eq 'Nobody', "Nobody is nobody");
146 ok ($RT::Nobody->Name() ne 'root', "Nobody isn't named root");
147 ok ($RT::SystemUser->Name() eq 'RT_System', "The system user is RT_System");
148 ok ($RT::SystemUser->Name() ne 'noname', "The system user isn't noname");