Category Archives: Red Hat/CentOS

Releasing a message from a quarantine with amavisd-relase

amavisd-new is a high-performance and reliable interface between mailer (MTA) and one or more content checkers: virus scanners, and/or Mail::SpamAssassin Perl module. It is written in Perl, ensuring high reliability, portability and maintainability. It talks to MTA via (E)SMTP or LMTP protocols, or by using helper programs. No timing gaps exist in the design, which could cause a mail loss.

In other words, amavisd-new will help you to fight against spam. In this post, I won’t write about installation (coming soon in you theaters)

This post is just a small trick which will help you to release specific message from quarantine (false positive or you simple want to read spam messages)

Fist you need to find message inside the messages log file (usually /var/log/messages)

May 10 10:06:56 ns1 amavis[12774]: (12774-13) Blocked SPAM, [207.46.22.35] [207.46.22.35] <cnfrmpro@microsoft.com> -> <mymail@domain.tld>, quarantine: spam-1lvc624m6MVB.gz, Message-ID: <BY2MSFTVSMTP03Dfn8e0003d305@by2msftvsmtp03.phx.gbl>, mail_id: 1lvc624m6MVB, Hits: 7.743, size: 3013, 4325 ms

As you can see above, it is spam-1lvc624m6MVB.gz

Now you can release specific message with

[root@s1 ~]# amavisd-release spam-1lvc624m6MVB.gz

And you will see something like

250 2.0.0 Ok, id=rel-1lvc624m6MVB, from MTA([127.0.0.1]:10025): 250 2.0.0 Ok: queued as 403206AF07CE

Now you just need to check your inbox and you should see the message.

Config mta – howto

Centos has a neat application for switching between alternative software packages, called alternatives.

Few days ago I noticed that one server doesn’t send logwatch email. I wanted to see what was the reason and here are the few tips you can check before you dig inside logwatch settings.

First, check /etc/aliases and root email inside

# nano /etc/aliases

at the end, check next lines:

# Person who should get root's mail
root:           blabla@domain.tld

After you save aliases, enter command

# newaliases

This command rebuilds the random access data base for the mail aliases file /etc/aliases. It must be run each time this file is changed in order for the change to take effect. This would be enough to receive all email directed to root, but in case you still don’t get root emails, check mta with:

# alternatives --display mta

This will show you something like

[root@s1 ~]# alternatives --display mta
mta - status is manual.
 link currently points to /usr/sbin/sendmail.sendmail
/usr/sbin/sendmail.sendmail - priority 90
 slave mta-pam: /etc/pam.d/smtp.sendmail
 slave mta-mailq: /usr/bin/mailq.sendmail
 slave mta-newaliases: /usr/bin/newaliases.sendmail
 slave mta-rmail: /usr/bin/rmail.sendmail
 slave mta-sendmail: /usr/lib/sendmail.sendmail
 slave mta-mailqman: /usr/share/man/man1/mailq.sendmail.1.gz
 slave mta-newaliasesman: /usr/share/man/man1/newaliases.sendmail.1.gz
 slave mta-aliasesman: /usr/share/man/man5/aliases.sendmail.5.gz
 slave mta-sendmailman: /usr/share/man/man8/sendmail.sendmail.8.gz
/usr/sbin/sendmail.postfix - priority 30
 slave mta-pam: /etc/pam.d/smtp.postfix
 slave mta-mailq: /usr/bin/mailq.postfix
 slave mta-newaliases: /usr/bin/newaliases.postfix
 slave mta-rmail: /usr/bin/rmail.postfix
 slave mta-sendmail: /usr/lib/sendmail.postfix
 slave mta-mailqman: /usr/share/man/man1/mailq.postfix.1.gz
 slave mta-newaliasesman: /usr/share/man/man1/newaliases.postfix.1.gz
 slave mta-aliasesman: /usr/share/man/man5/aliases.postfix.5.gz
 slave mta-sendmailman: /usr/share/man/man1/sendmail.postfix.1.gz
Current `best' version is /usr/sbin/sendmail.sendmail.

We use postfix so we should change this with

[root@s1 ~]# alternatives --config mta
 
There are 2 programs which provide 'mta'.
 
  Selection    Command
-----------------------------------------------
*+ 1           /usr/sbin/sendmail.sendmail
   2           /usr/sbin/sendmail.postfix
 
Enter to keep the current selection[+], or type selection number:

Enter 2 and press Enter. Then check your mta with

[root@s1 ~]# alternatives --display mta
mta - status is manual.
 link currently points to /usr/sbin/sendmail.postfix

That’s it… Now if your logwatch is configured properly you should receive root emails…

RPMforge howto

The RPMforge project is an open source project that provides RPM packages for various distributions (RH, CentOS, Fedora, …). To enable RPMforge you can install the rpmforge-release package for your distribution.

For RHEL5 / CentOS-5:
i386

# wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.1-1.el5.rf.i386.rpm
# rpm -Uvh rpmforge-release-0.5.1-1.el5.rf.i386.rpm

x86_64

# wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.1-1.el5.rf.x86_64.rpm
# rpm -Uvh rpmforge-release-0.5.1-1.el5.rf.x86_64.rpm

For older releases (RHEL 4 / CentOS 4) please follow the instructions available on RPMrepo Wiki

How do I check what version of Centos/Fedora/RH my server is running?

You can run the command below at a command prompt to see what version of Centos/Fedora/RH your server is running.

[root@hydra:~]# cat /etc/redhat-release
CentOS release 5.2 (Final)

Fedora sample:

[root@s2 ~]# cat /etc/redhat-release
Fedora release 7 (Moonshine)

Upgrading to PHP 5.2.5 on RHEL and CentOS

As you probably know, the latest CentOS and RHEL distros are available only with PHP 5.1.6 and if you want to upgrade PHP, you need to install it manually (or to find someone to do it for you 🙂 ). The 5.2.5 release brings several security enhancements, more than 60 bug fixes, and improved performance for those of you that like arrays (and really, who doesn’t?). I wanted to install latest RoundCube webmail application and it won’t work if you don’t have PHP> 5.2. Also, latest Vivvo won’t work without 5.2.x

So, if you don’t want to build rpms or to go through ./configure, make, make install nightmare, you can enable Jason Litka yum repository to your RHEL or CentOS system. To do this please follow next few steps.

First you need to validate that the packages came from Jason Litka and you’ll do it with next command:

#rpm --import http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka

After you added his public GPG key, you’ll need to adjust yum so he can search at his repo. To do this, please follow next steps:

#nano -w /etc/yum.repos.d/utterramblings.repo

Now copy next lines inside this file and save those changes.

[utterramblings]
name=Jason's Utter Ramblings Repo
baseurl=http://www.jasonlitka.com/media/EL$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka

Now you can upgrade your PHP installation with simple:

#yum update php

More information about this can be found HERE.

#php -v

should return

[root@ns1 ~]# php -v
PHP 5.2.6 (cli) (built: May  5 2008 10:32:59)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
[root@ns1 ~]#

I forget to say that you should restart httpd after upgrade.