I am writing this more for future me than anything else. We’d set up our help desk (well, technically our .bash_profiles on our various servers) such that any root access would be logged to RT.
We’d originally set it up to go to our generic help desk queue, but that quickly proved annoying. First of all, we’re in the midst of bringing all sorts of web services online, and this requires a lot of root access. And second, I don’t want root access messages getting lost among the various “Freddy Can’t Print his Email” tickets.
RT makes this oh so easy. With a few caveats that really have nothing to do with RT, it has to do with mail.
The RT Queue
In RT, I created a queue called
rootAccessAlerts. I set its
Comment Address to firstname.lastname@example.org.
/etc/smrsh and rt-mailgate
First, you should familiarize yourself with smrsh, the restricted shell that allows sendmail to execute commands found only in the /etc/smrsh directory. This looks to be a Fedora thing, according to this article, from which I gleaned this information. Take a look at the man page for smrsh to learn more.
In /etc/smrsh, I wrote shell scripts that sendmail would execute. First, I wrote
#!/bin/sh /opt/rt3/bin/rt-mailgate $*
Next, after some gnashing of teeth, I figured out that I needed another script, as one of my queues had a space in its name – and $* was parsing it according to what shell wanted to do, and not what I wanted it to do. So, I wrote second script, called
#/bin/sh /opt/rt3/bin/rt-mailgate --queue 'help desk' --action correspond --url http://my.rtserver.com/rt3
OK, now let’s add the alias for to email@example.com email address. Edit /etc/aliases using your favorite text editor (or mine, which is vim), and add lines for the root.access alias:
root.access: "|rt-mailgate-gen --queue 'rootAccessAlerts' --action correspond --url http://my.rtserver.com/rt3" root.access-comment: "|rt-mailgate-gen --queue 'rootAccessAlerts' --action comment --url http://my.rtserver.com/rt3"
Once saved, run the newaliases command so sendmail knows about the .. uhh … new aliases.