The use of SSHFS

SSHFS is a tool that uses SSH to enable mounting of a remote filesystem on a local machine. This tool can be used for directories sharing. SSHFS is built using FUSE and non-priviliged users can create their own file systems. Only two steps needed to use sshfs.

1) Install sshfs
2) Edit /etc/group and add your login name in the FUSE group

How to share a directory using sshfs

1) Create a local directory for the mountpoint.
mkdir /home/user/TEST
2) Mount any directory from the remote machine
sshfs foo@remote_machine:/home/foo home/user/TEST

Now the directory 'TEST' has all the contents of the remote home directory of foo.
The files in this directory are editable and can move around just as though it were a
local directory.

Posted in Labels: | 0 comments

How to remove mail from postqueue based on email address

To delete a mail from postfix, i will usually run 2 commands below :
1) Postqueue -p (to list the postfix mail queue)
2) Postsuper -d "mail id" (to delete a mail based on id)

This method is easy if just need to delete few mails. How if there are bunch of messages queued in postfix. I was told by my superior to delete hundreds of mails queued in our mail server. Postfix does not have the function for doing that, luckily a search on Google gave a perl script for doing the clean up. All the credit goes to the site where i found the solution.

Here is a simple perl script that i found to delete my mails in postqueue.

1) Create a file (eg:delete_queue.pl) and paste the scripts below
2) chmod a+x delete_queue.pl
3) ./delete_queue.pl "mail id" (Delete mail based on mail id)
4) ./delete_queue.p "email address" (Delete mails from the same email address)

#!/usr/bin/perl -w
#
# pfdel - deletes message containing specified address from
# Postfix queue. Matches either sender or recipient address.
#
# Usage: pfdel
#

use strict;

# Change these paths if necessary.
my $LISTQ = "/usr/sbin/postqueue -p";
my $POSTSUPER = "/usr/sbin/postsuper";

my $email_addr = "";
my $qid = "";
my $euid = $>;

if ( @ARGV != 1 ) {
die "Usage: pfdel \n";
} else {
$email_addr = $ARGV[0];
}

if ( $euid != 0 ) {
die "You must be root to delete queue files.\n";
}


open(QUEUE, "$LISTQ |") ||
die "Can't get pipe to $LISTQ: $!\n";

my $entry = ; # skip single header line
$/ = ""; # Rest of queue entries print on
# multiple lines.
while ( $entry = ) {
if ( $entry =~ / $email_addr$/m ) {
($qid) = split(/\s+/, $entry, 2);
$qid =~ s/[\*\!]//;
next unless ($qid);

#
# Execute postsuper -d with the queue id.
# postsuper provides feedback when it deletes
# messages. Let its output go through.
#
if ( system($POSTSUPER, "-d", $qid) != 0 ) {
# If postsuper has a problem, bail.
die "Error executing $POSTSUPER: error " .
"code " . ($?/256) . "\n";
}
}
}
close(QUEUE);

if (! $qid ) {
die "No messages with the address <$email_addr> " .
"found in queue.\n";
}

exit 0;



Posted in Labels: | 0 comments

Attachment filtering in Postfix

How to configure postfix to filter mail attachments based on file extension? This was one of the question has been lurking in my mind for past few days. Finally i got the solution from my fren "google". Its can be done by 3 simple steps as follow

1) Edit main.cf and add this line > mime_header_checks = regexp:/etc/postfix/mime_header_checks
2) Edit mime_header_checks file and add /name=[^>]*\.(bat|com|exe|dll|vbs|jpg)/ REJECT
It means that, all the file extension listed will be rejected during file attachment.You can add more file extensions by adding this line with |.
3) Postmap mime_header_checks

You are done. Now try to attach the rejected file extension and you will see a pop up message on attachment filtering.

Posted in Labels: | 0 comments

Linux Kernel To Get Microsoft Code

Guyz, i came across something interesting on Linux.com and would like to share here. Microsoft has contributed code to the Linux Kernel. About 20,000 lines of device driver code were contributed to the Linux kernel under the GPL v2 license. The code has been submitted for inclusion to the main Linux kernel source tree. This measure was initiated to enable Linux run as virtual machine on top of Hyper-V.

Is this a initial move by MS to create a MS Linux distro??? Hmmm... More details are still awaited.....

More info can be found on Linux.com

Posted in Labels: | 0 comments

Adding ldap log via syslogd LOCAL4

Log file is created and maintained for the activity performed by server. This file is very important as it plays important role in performing troubleshooting. The first thing one can do when encounter a problem in accessing a service is to read the log file to find the actual issue. Mostly the log file and path will be created automatically but in certain cases the log file need to be created on our own. For an instance, how do we create a log file for LDAP via syslogd LOCAL4.

1) Edit /etc/syslog.conf - add local4.* /var/log/ldap/log
2) Touch /var/log/ldap.log
3) /etc/init.d/syslogd restart @ kilall -HUP syslogd

Now, initiate ldap and view the log by using tail -f /var/log/ldap.log


Posted in Labels: , | 0 comments