Table of Contents

Tips

Restoring grub

This will help you to restore your grub boot loader if it has been overwritten by another operating system say M$ windows.

  1. Boot using a live cd or boot into rescue mode
  2. Type grub
  3. Type root(hd0,0) where the first 0 is the disk and the second is the partition substitute to fit your disk layout
  4. Type setup (hd0) where the 0 is your disk substitute to fit your installation.
  5. Type quit
  6. reboot

Thats it you are home and away.

Mailwatch Improved quarantine release

The default methods of releasing messages from the mailscanner quarantine using mailwatch are not user friendly as the message gets modified and appears to come from the postmaster account. Most users will not be comfortable with this as they can no longer just hit reply within their mail client.

This method releases the message in such a way that the envelope address remains the same so when displayed on the client side it looks like a message that was not even quarantined.

Okay with the reason for doing this out of the way lets get down and dirty, To do this you will need the following:

Install mailfeeder

# wget http://www.pldaniels.com/mailfeeder/mailfeeder-0.2.3.tar.gz
# tar xzvf mailfeeder-0.2.3.tar.gz
# cd mailfeeder-0.2.3
# make
# cp mailfeeder /usr/local/bin

Patch Mailwatch

diff -X x -Nur mailscanner/conf.php /var/www/html/conf.php
--- mailscanner/conf.php	2007-03-16 01:10:27.000000000 +0200
+++ /var/www/html/conf.php	2007-12-03 12:30:02.000000000 +0200
@@ -83,8 +83,8 @@
 Postmaster');
 define(QUARANTINE_REPORT_HOSTURL, 'http://'.chop(`hostname`).'/mailscanner/');
 define(QUARANTINE_REPORT_DAYS, 7);
-define(QUARANTINE_USE_SENDMAIL, false);
-define(QUARANTINE_SENDMAIL_PATH, '/usr/sbin/sendmail');
+define(QUARANTINE_USE_SENDMAIL, true);
+define(QUARANTINE_SENDMAIL_PATH, '/usr/local/bin/mailfeeder');
 
 // This turns virus names into links that can be used to get more information
 // about a given virus or virus alias.  Comment out or set to false to disable.
diff -X x -Nur mailscanner/functions.php /var/www/html/functions.php
--- mailscanner/functions.php	2007-05-11 17:34:53.000000000 +0200
+++ /var/www/html/functions.php	2007-12-03 12:30:02.000000000 +0200
@@ -2066,6 +2096,7 @@
   DATE_FORMAT(date,'%Y%m%d') AS date, 
   id,
   to_address,
+  from_address,
   CASE WHEN isspam>0 THEN 'Y' ELSE 'N' END AS isspam, 
   CASE WHEN nameinfected>0 THEN 'Y' ELSE 'N' END AS nameinfected,
   CASE WHEN virusinfected>0 THEN 'Y' ELSE 'N' END AS virusinfected,
@@ -2094,6 +2125,7 @@
    $quarantined[$count]['host']		= $row->hostname;
    $quarantined[$count]['msgid']	= $row->id;
    $quarantined[$count]['to']		= $row->to_address;
+   $quarantined[$count]['from']		= $row->from_address;
    $quarantined[$count]['file'] 	= "message";
    $quarantined[$count]['type'] 	= "message/rfc822";
    $quarantined[$count]['path'] 	= $nonspam;
@@ -2108,6 +2140,7 @@
    $quarantined[$count]['host'] 	= $row->hostname;
    $quarantined[$count]['msgid']	= $row->id;
    $quarantined[$count]['to']		= $row->to_address;
+   $quarantined[$count]['from']		= $row->from_address;
    $quarantined[$count]['file']     	= "message";
    $quarantined[$count]['type']     	= "message/rfc822";
    $quarantined[$count]['path']     	= $spam;
@@ -2122,6 +2155,7 @@
    $quarantined[$count]['host']         = $row->hostname;
    $quarantined[$count]['msgid']        = $row->id;
    $quarantined[$count]['to']           = $row->to_address;
+   $quarantined[$count]['from']		= $row->from_address;
    $quarantined[$count]['file']         = "message";
    $quarantined[$count]['type']         = "message/rfc822";
    $quarantined[$count]['path']         = $mcp;
@@ -2139,6 +2173,7 @@
      $quarantined[$count]['host']	= $row->hostname;
      $quarantined[$count]['msgid']	= $row->id;
      $quarantined[$count]['to']		= $row->to_address;
+     $quarantined[$count]['from']	= $row->from_address;
      $quarantined[$count]['file'] 	= $f;
      $file				= escapeshellarg($quarantine.'/'.$f);
      $quarantined[$count]['type'] 	= ltrim(rtrim(`/usr/bin/file -bi $file`));
@@ -2216,7 +2251,9 @@
   } else {
    // Use sendmail to release message
    // We can only release message/rfc822 files in this way.
-   $cmd = QUARANTINE_SENDMAIL_PATH." -i -f ".QUARANTINE_FROM_ADDR." ".escapeshellarg($to)." < ";
+   // we will use mailfeeder to send the message to maintain state
+   //$cmd = QUARANTINE_SENDMAIL_PATH." -i -f ".QUARANTINE_FROM_ADDR." ".escapeshellarg($to)." < ";
+   $cmd = QUARANTINE_SENDMAIL_PATH." -S 127.0.0.1 -s ".escapeshellarg($list['0']['from'])." -r ".escapeshellarg($to)." -i ";
    foreach($num as $key=>$val) {
     if(preg_match('/message\/rfc822/',$list[$val]['type'])) {
      debug($cmd.$list[$val]['path']);

The patch is available for download here http://www.topdog-software.com/files/mailwatch_release.patch.gz

# gunzip mailwatch_release.patch.gz
# cd mailwatch/
# patch --dry-run -i ../mailwatch_release.patch
# patch -i ../mailwatch_release.patch

Finally

If you are running sendmail you don't have to do anything more thats it, enjoy your new release system. If you are running Exim however you need to make some changes to your exim configuration as mailfeeder operates in pipelining mode. Add the following to your exim configuration and restart

 pipelining_advertise_hosts = 127.0.0.1

Migrate dovecot from mbox to maildir

To move to the better maildir format from mbox, there are several converts to do this but i found convert-and-create was the most effective in that it even creates the maildirs for the users who may not have mail in the spool file

 # wget http://www.qmail.org/convert-and-create
 # chmod +x convert-and-create
 # service dovecot stop
 # stop your Mail server as well (exim,postfix,sendmail)
 # ./convert-and-create

Another way to do it on the fly is described here

Su without typing password

Sometimes you need to su frequently, typing the password each time may not be convenient. The pam system allows you to configure su without password. To do this you need to add the user to the wheel group and then configure pam

 # vigr
wheel::10:root,username
auth           sufficient      pam_wheel.so trust use_uid

Convert xvid video divx video

To convert xvid videos to divx format to play on stand alone video players in HDTV mode, you can use memcoder to re-encode the video to divx

mencoder <input> -ovc lavc -oac lavc -ffourcc DX50 -xvidencopts profile=dxnhdtv -o <output>

Join 2 video clips on linux

When you need to join two or more video clips to create one complete video.

  # cat file1.avi file2.avi > file1_file2.avi
  # mencoder -forceidx -oac copy -ovc copy file1_file2.avi -o final_file.avi
  # mencoder -oac copy -ovc copy file1 file2 file3 -o final_movie.mpg
  # avimerge -i b1.avi b2.avi b3.avi b4.avi b5.avi b6.avi b7.avi -o bloodspell.avi

A detailed explanation of this can be found here

Decent Iptables front-end

I have never been a fun of iptables front ends preferring to work with the rules directly as it makes debugging easy, how ever i have come across a really great front end. So if you are in need of a great front end that is more than just an iptables config tool take a look at vuurmuur http://www.vuurmuur.org/trac/wiki/Features.

Postgresql tips

Options available with psql the postgresql client.

Postfix using gmail as a smarthost

Yes, you can use gmail as your smarthost with postfix, this is how you do it.

smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/gmail_passwd
smtp_sasl_type = cyrus
smtp_sasl_security_options = noanonymous
relayhost = [smtp.gmail.com]:587
[smtp.gmail.com]:587            username@gmail.com:password
# postmap /etc/postfix/gmail_passwd
# postfix reload

Thats it you are done postfix will now send mail via gmail's smtp servers

Feedback

Got any comments/bugs drop me a mail my contact info is on the home page.